Files
MyGoNavi/frontend/src/components/TableOverview.context-menu.test.ts
Syngnat 21e0921b3b feat(data-sync/export): 支持同步与备份后台工作台
- 将数据同步及各级 SQL 备份统一迁入稳定工作区
- 全局保留任务状态、进度和结构化日志,关闭后可重新接回
- 支持从当前任务及历史记录打开 SQL 恢复工作台
- 锁定运行中配置并禁止后台任务分离到独立窗口
2026-07-20 13:43:58 +08:00

46 lines
2.5 KiB
TypeScript

import { readFileSync } from 'node:fs';
import { describe, expect, it } from 'vitest';
describe('TableOverview v2 context menu', () => {
it('renders card and list table context menus through a measured portal', () => {
const source = readFileSync(new URL('./TableOverview.tsx', import.meta.url), 'utf8');
const cardSource = source.slice(
source.indexOf('const renderCardTableContent = (table: TableStatRow) => ('),
source.indexOf('const renderListTable = (table: TableStatRow) => {'),
);
const listSource = source.slice(
source.indexOf('const renderListTable = (table: TableStatRow) => {'),
source.indexOf('if (loading) {'),
);
expect(source).toContain("import { createPortal } from 'react-dom';");
expect(source).toContain('resolveOverviewContextMenuPosition(event.clientX, event.clientY)');
expect(source).toContain('v2ContextMenuPortalRef');
expect(source).toContain('content?.scrollHeight');
expect(source).toContain('gn-v2-table-overview-context-menu-portal');
expect(source).toContain("['--gn-v2-context-menu-max-height' as any]");
expect(source).toContain('renderV2OverviewTableContextMenu(v2ContextMenuTable)');
expect(cardSource).toContain('onContextMenu={isV2Ui ? (event) => openV2OverviewContextMenu(event, table) : undefined}');
expect(listSource).toContain('onContextMenu={isV2Ui ? (event) => openV2OverviewContextMenu(event, table) : undefined}');
expect(cardSource).not.toContain('popupRender');
expect(listSource).not.toContain('popupRender');
});
it('routes table backup and INSERT export entries through the retained export workbench', () => {
const source = readFileSync(new URL('./TableOverview.tsx', import.meta.url), 'utf8');
expect(source).toContain('buildBatchTableExportWorkbenchTab({');
expect(source).toContain("const resolvedOptions = mode === 'backup'");
expect(source).toContain('await showSQLExportOptionsDialog()');
expect(source).toContain('initialObjectNames: [normalizedTableName]');
expect(source).toContain('contentMode: mode');
expect(source).toContain('...resolvedOptions');
expect(source).toContain("await openTableSQLExportWorkbench(tableName, 'dataOnly')");
expect(source).toContain("void openTableSQLExportWorkbench(tableName, 'backup')");
expect(source).toContain("onClick: () => openTableSQLExportWorkbench(table.name, 'backup')");
expect(source).not.toContain('ExportTableWithOptions');
expect(source).not.toContain('useExportProgressDialog');
expect(source).not.toContain('{exportProgressModal}');
});
});