Files
MyGoNavi/frontend/src/components/QueryEditor.sql-analysis-workbench.test.ts
Syngnat c8c8497a2f feat(query-editor): 收敛 SQL 分析工作台与结果区日志体验
- 新增 SQL 分析工作台,统一承载慢 SQL 和 SQL 诊断视图
- 将 SQL 执行日志收进结果区首个日志标签并在失败时展示错误摘要
- 调整侧边栏入口、标签展示、多语言文案与定向前端测试覆盖
2026-06-20 14:09:58 +08:00

41 lines
1.8 KiB
TypeScript

import { readFileSync } from 'node:fs'
import { describe, expect, it } from 'vitest'
describe('SQL analysis workbench wiring', () => {
it('routes QueryEditor diagnose and slow-query actions to the sql-analysis workbench tab', () => {
const source = readFileSync(new URL('./QueryEditor.tsx', import.meta.url), 'utf8')
expect(source).toContain("buildSqlAnalysisWorkbenchTab")
expect(source).toContain("openSqlAnalysisWorkbench('diagnose', getCurrentQuery())")
expect(source).toContain("openSqlAnalysisWorkbench('slow-query')")
expect(source).not.toContain('const [explainOpen, setExplainOpen]')
expect(source).not.toContain('const [slowQueryOpen, setSlowQueryOpen]')
expect(source).not.toContain('<ExplainWorkbench')
expect(source).not.toContain('<SlowQueryPanel')
})
it('opens the same sql-analysis workbench from the sidebar slow-query button', () => {
const source = readFileSync(new URL('./sidebar/SlowQueryRailButton.tsx', import.meta.url), 'utf8')
expect(source).toContain('buildSqlAnalysisWorkbenchTab')
expect(source).toContain("view: 'slow-query'")
expect(source).not.toContain('SlowQueryPanel')
})
it('uses a compact segmented switcher in the sql-analysis workbench header', () => {
const source = readFileSync(new URL('./explain/SqlAnalysisWorkbench.tsx', import.meta.url), 'utf8')
expect(source).toContain('Segmented')
expect(source).toContain('gn-sql-analysis-view-switcher')
expect(source).not.toContain('<Tabs')
})
it('uses a compact segmented switcher inside the explain report view', () => {
const source = readFileSync(new URL('./explain/ExplainWorkbench.tsx', import.meta.url), 'utf8')
expect(source).toContain('Segmented')
expect(source).toContain('gn-explain-report-switcher')
expect(source).not.toContain('<Tabs')
})
})