diff --git a/frontend/src/components/SidebarDatabaseMenu.order.test.ts b/frontend/src/components/SidebarDatabaseMenu.order.test.ts new file mode 100644 index 00000000..4bcf6419 --- /dev/null +++ b/frontend/src/components/SidebarDatabaseMenu.order.test.ts @@ -0,0 +1,25 @@ +import { readFileSync } from 'node:fs'; +import { describe, expect, it } from 'vitest'; + +const source = readFileSync(new URL('./sidebar/sidebarLegacyNodeMenu.tsx', import.meta.url), 'utf8'); + +describe('Sidebar legacy database menu order', () => { + it('keeps new query and run-sql ahead of close database', () => { + const databaseMenuStart = source.indexOf("} else if (node.type === 'database') {"); + const databaseMenuEnd = source.indexOf("} else if (node.type === 'view') {", databaseMenuStart); + + expect(databaseMenuStart).toBeGreaterThanOrEqual(0); + expect(databaseMenuEnd).toBeGreaterThan(databaseMenuStart); + + const databaseMenuSource = source.slice(databaseMenuStart, databaseMenuEnd); + const newQueryIndex = databaseMenuSource.indexOf("key: 'new-query'"); + const runSqlIndex = databaseMenuSource.indexOf("key: 'run-sql'"); + const disconnectIndex = databaseMenuSource.indexOf("key: 'disconnect-db'"); + + expect(newQueryIndex).toBeGreaterThanOrEqual(0); + expect(runSqlIndex).toBeGreaterThanOrEqual(0); + expect(disconnectIndex).toBeGreaterThanOrEqual(0); + expect(newQueryIndex).toBeLessThan(disconnectIndex); + expect(runSqlIndex).toBeLessThan(disconnectIndex); + }); +}); diff --git a/frontend/src/components/TableOverview.i18n.test.ts b/frontend/src/components/TableOverview.i18n.test.ts index 9d1f3a7d..7e0421ce 100644 --- a/frontend/src/components/TableOverview.i18n.test.ts +++ b/frontend/src/components/TableOverview.i18n.test.ts @@ -37,6 +37,10 @@ const normalizedVisibleTableSectionsSource = visibleTableSectionsSource.replace( const renderOverviewSectionTitleSource = source.slice( source.indexOf('const renderOverviewSectionTitle = (section: OverviewTableSection) => {'), + source.indexOf('const renderTableOverviewMetaBadges = useCallback((table: TableStatRow, compact = false) => {'), +); +const metaBadgesSource = source.slice( + source.indexOf('const renderTableOverviewMetaBadges = useCallback((table: TableStatRow, compact = false) => {'), source.indexOf('const renderCardTableContent = (table: TableStatRow) => ('), ); const normalizedRenderOverviewSectionTitleSource = renderOverviewSectionTitleSource.replace(/\s+/g, ' ').trim(); @@ -59,6 +63,8 @@ const aiPromptSource = source.slice( ); const requiredTableOperationKeys = [ + 'table_overview.metric.created_at', + 'table_overview.metric.updated_at', 'table_overview.tab.design_table_title', 'table_overview.tab.table_structure_title', 'table_overview.message.load_tables_failed', @@ -121,18 +127,26 @@ describe('TableOverview i18n', () => { expect(cardSource).not.toContain('title="行数"'); expect(cardSource).not.toContain('title="数据大小"'); expect(cardSource).not.toContain('title="引擎"'); + expect(cardSource).not.toContain('最近修改'); + expect(cardSource).not.toContain('创建时间'); expect(cardSource).toContain("title={t('table_overview.sort.rows')}"); expect(cardSource).toContain("title={t('table_overview.metric.data_size')}"); expect(cardSource).toContain("title={t('table_overview.metric.engine')}"); + expect(cardSource).toContain('{renderTableOverviewMetaBadges(table)}'); + expect(metaBadgesSource).toContain("t('table_overview.metric.updated_at')"); + expect(metaBadgesSource).toContain("t('table_overview.metric.created_at')"); expect(listSource).not.toContain('`${table.engine} 表`'); expect(listSource).not.toContain("'双击打开数据,右键查看更多操作'"); + expect(listSource).not.toContain('最近修改'); + expect(listSource).not.toContain('创建时间'); expect(listSource).not.toContain("