mirror of
https://github.com/Syngnat/GoNavi.git
synced 2026-08-13 01:54:20 +08:00
- 数据导入工作台新增数据库模式,支持 SQL 文件选择、目标库、进度、取消与重试 - 新增受连接保护约束的 ImportDatabaseSQL 接口并复用流式执行链路 - SQL 导出支持切换数据库上下文,兼顾原库备份和跨库导入 - 调整侧栏与表概览入口,备份先进入工作台确认配置再执行 - 同步 Wails 绑定、Web 运行时限制、六语文案和回归测试
81 lines
2.3 KiB
TypeScript
81 lines
2.3 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
|
|
import {
|
|
buildDataImportWorkbenchTab,
|
|
DATA_IMPORT_WORKBENCH_TAB_ID,
|
|
resolveDataImportWorkbenchLaunchTab,
|
|
} from './dataImportTab';
|
|
|
|
describe('dataImportTab', () => {
|
|
it('builds one stable workbench tab with a normalized target', () => {
|
|
const tab = buildDataImportWorkbenchTab({
|
|
connectionId: ' conn-1 ',
|
|
dbName: ' app ',
|
|
tableName: ' public.users ',
|
|
launchKey: ' launch-table-1 ',
|
|
title: ' 数据导入 ',
|
|
});
|
|
|
|
expect(tab).toMatchObject({
|
|
id: DATA_IMPORT_WORKBENCH_TAB_ID,
|
|
title: '数据导入',
|
|
type: 'data-import',
|
|
connectionId: 'conn-1',
|
|
dbName: 'app',
|
|
tableName: 'public.users',
|
|
dataImportMode: 'table',
|
|
dataImportLaunchKey: 'launch-table-1',
|
|
initialTab: 'target',
|
|
});
|
|
});
|
|
|
|
it('keeps optional target values absent for a global entry', () => {
|
|
const tab = buildDataImportWorkbenchTab({ title: 'Import data' });
|
|
|
|
expect(tab.id).toBe(DATA_IMPORT_WORKBENCH_TAB_ID);
|
|
expect(tab.connectionId).toBe('');
|
|
expect(tab.dbName).toBeUndefined();
|
|
expect(tab.tableName).toBeUndefined();
|
|
expect(tab.dataImportMode).toBe('table');
|
|
expect(tab.dataImportLaunchKey).toMatch(/^data-import-/);
|
|
});
|
|
|
|
it('builds a database import launch that clears a stale table target', () => {
|
|
const tab = buildDataImportWorkbenchTab({
|
|
connectionId: 'conn-1',
|
|
dbName: 'app',
|
|
tableName: 'users',
|
|
mode: 'database',
|
|
launchKey: 'database-launch-1',
|
|
});
|
|
|
|
expect(tab).toMatchObject({
|
|
connectionId: 'conn-1',
|
|
dbName: 'app',
|
|
dataImportMode: 'database',
|
|
dataImportLaunchKey: 'database-launch-1',
|
|
});
|
|
expect(tab).toHaveProperty('tableName', undefined);
|
|
});
|
|
|
|
it('keeps the active target when the stable workbench is reopened during an import', () => {
|
|
const existing = {
|
|
...buildDataImportWorkbenchTab({
|
|
connectionId: 'conn-1',
|
|
dbName: 'app',
|
|
tableName: 'users',
|
|
launchKey: 'running-launch',
|
|
}),
|
|
dataImportRunning: true,
|
|
};
|
|
|
|
expect(resolveDataImportWorkbenchLaunchTab(existing, {
|
|
connectionId: 'conn-2',
|
|
dbName: 'analytics',
|
|
tableName: 'events',
|
|
mode: 'database',
|
|
launchKey: 'ignored-launch',
|
|
})).toBe(existing);
|
|
});
|
|
});
|