update
This commit is contained in:
56
e2e/smoke.spec.ts
Normal file
56
e2e/smoke.spec.ts
Normal file
@@ -0,0 +1,56 @@
|
||||
import { test, expect, _electron as electron } from '@playwright/test'
|
||||
import { join } from 'path'
|
||||
|
||||
/**
|
||||
* 端到端冒烟:覆盖 v2 的 UI 流程(不依赖已删除的 CallGraph / LineHeatmap /
|
||||
* ExportButton / FindingsList)。
|
||||
*
|
||||
* v1 残留断言("Hotspots" / "build_report" / "What to fix" / "Lines" tab /
|
||||
* "导出 JSON")随着 v2 重构(见 chore/comprehensive-optimization)一并移除。
|
||||
* 跑这条用例需要的本地条件:检测到至少一个 Python 解释器(CI matrix 上预装)。
|
||||
*/
|
||||
|
||||
test('端到端:加载示例 → 运行分析 → 摘要 + 热点表 + 火焰图', async () => {
|
||||
// Electron 在 ELECTRON_RUN_AS_NODE 存在时会退化为纯 Node,需从环境中移除
|
||||
const env: Record<string, string> = {}
|
||||
for (const [k, v] of Object.entries(process.env)) {
|
||||
if (k !== 'ELECTRON_RUN_AS_NODE' && v !== undefined) env[k] = v
|
||||
}
|
||||
const app = await electron.launch({
|
||||
args: [join(__dirname, '..', 'out', 'main', 'index.js')],
|
||||
env
|
||||
})
|
||||
const page = await app.firstWindow()
|
||||
|
||||
// 标题存在(TopBar 渲染 h1 + 副标;lang 切换后 h1 文案跟着切)
|
||||
await expect(page.getByRole('heading', { name: 'Python 程序耗时可视化分析' })).toBeVisible()
|
||||
await page.reload()
|
||||
await expect(page.getByRole('heading', { name: 'Python 程序耗时可视化分析' })).toBeVisible()
|
||||
|
||||
// 等待解释器检测填充(并行跑 5 个 phase,最坏情况要 15-20s)
|
||||
const runBtn = page.getByRole('button', { name: '运行分析' })
|
||||
try {
|
||||
await expect(runBtn).toBeEnabled({ timeout: 30_000 })
|
||||
} catch {
|
||||
await app.close()
|
||||
test.skip(true, '本机未检测到 Python 解释器')
|
||||
return
|
||||
}
|
||||
|
||||
await runBtn.click()
|
||||
|
||||
// 摘要(RunSummaryLite)出现 = 分析成功,引擎至少跑完了一次 wall-time 测量
|
||||
await expect(page.getByText('本次耗时')).toBeVisible({ timeout: 60_000 })
|
||||
|
||||
// 热点表 section(v2 标题 = results.hotspot.title)
|
||||
await expect(page.getByText('热点函数')).toBeVisible()
|
||||
|
||||
// DEMO_CODE 里的对比函数:纯 Python 高斯消元 vs numpy —— 最耗时的 `matinv` 一定出现在表里
|
||||
await expect(page.getByText('matinv').first()).toBeVisible()
|
||||
|
||||
// 火焰图 section(v2 标题 = results.time.title = "耗时分布"),确保 SVG 真的渲染
|
||||
await expect(page.getByText('耗时分布')).toBeVisible()
|
||||
await expect(page.locator('svg[aria-label="火焰图"]')).toBeVisible()
|
||||
|
||||
await app.close()
|
||||
})
|
||||
Reference in New Issue
Block a user