test: 添加回归测试脚本

基于 Playwright 的 UI 回归脚本,覆盖返回导航、数据处理向导、调优创建、模型管理、页面表层级、训练日志布局六个场景。
This commit is contained in:
caoxiaozhu
2026-07-10 16:46:23 +08:00
parent 6f6609dae5
commit e2eabe3525
6 changed files with 816 additions and 0 deletions

View File

@@ -0,0 +1,30 @@
import assert from 'node:assert/strict'
import { readFile } from 'node:fs/promises'
import { fileURLToPath } from 'node:url'
import path from 'node:path'
import { parse as parseSfc } from '@vue/compiler-sfc'
const scriptDir = path.dirname(fileURLToPath(import.meta.url))
const viewPath = path.resolve(scriptDir, '../src/views/model/ModelManageView.vue')
const source = await readFile(viewPath, 'utf8')
const { descriptor, errors } = parseSfc(source, { filename: viewPath })
assert.equal(errors.length, 0, `模型管理页面模板无法解析:${errors[0]}`)
assert.ok(descriptor.template?.content.trim(), '模型管理页面缺少可渲染模板')
assert.equal((source.match(/<template>/g) || []).length, 1, '模型管理页面只能有一个根模板标签')
const configTableStart = source.indexOf('v-if="activeTab === \'config\'"')
const trainedTableStart = source.indexOf('<DataTablePage\n v-else')
assert.ok(configTableStart >= 0 && trainedTableStart > configTableStart, '模型管理页面缺少两个标签对应的列表分支')
assert.doesNotMatch(
source.slice(configTableStart, trainedTableStart),
/activeTab === 'trained'/,
'配置模型分支不应再比较已不可能的训练模型状态',
)
assert.doesNotMatch(
source.slice(trainedTableStart),
/activeTab === 'config'/,
'训练模型分支不应再比较已不可能的配置模型状态',
)
console.log('模型管理页面模板回归检查通过')