test: 新增统一回归运行器

新增 run-regressions.mjs 一键执行全部回归脚本,package.json 注册 npm test 入口与 test:fine-tune-create,page-surface 脚本适配统一运行。
This commit is contained in:
caoxiaozhu
2026-07-13 15:31:01 +08:00
parent 3fabd0c0eb
commit aea0d51b44
3 changed files with 26 additions and 4 deletions

View File

@@ -8,6 +8,7 @@
"build": "vue-tsc -b && vite build", "build": "vue-tsc -b && vite build",
"preview": "vite preview", "preview": "vite preview",
"type-check": "vue-tsc -b --noEmit", "type-check": "vue-tsc -b --noEmit",
"test": "node scripts/run-regressions.mjs",
"test:default-dashboard": "node scripts/regression-default-dashboard.mjs", "test:default-dashboard": "node scripts/regression-default-dashboard.mjs",
"test:dashboard": "node scripts/regression-dashboard.mjs", "test:dashboard": "node scripts/regression-dashboard.mjs",
"test:data-process-list": "node scripts/regression-data-process-list.mjs", "test:data-process-list": "node scripts/regression-data-process-list.mjs",
@@ -21,6 +22,7 @@
"test:model-manage": "node scripts/regression-model-manage.mjs", "test:model-manage": "node scripts/regression-model-manage.mjs",
"test:hardware": "node scripts/regression-hardware-dashboard.mjs", "test:hardware": "node scripts/regression-hardware-dashboard.mjs",
"test:training-log-layout": "node scripts/regression-training-log-layout.mjs", "test:training-log-layout": "node scripts/regression-training-log-layout.mjs",
"test:fine-tune-create": "node scripts/regression-fine-tune-create-ui.mjs",
"test:page-surface": "node scripts/regression-page-surface.mjs" "test:page-surface": "node scripts/regression-page-surface.mjs"
}, },
"dependencies": { "dependencies": {

View File

@@ -6,11 +6,12 @@ import { parse as parseTemplate } from '@vue/compiler-dom'
import { parse as parseSfc } from '@vue/compiler-sfc' import { parse as parseSfc } from '@vue/compiler-sfc'
const scriptDir = path.dirname(fileURLToPath(import.meta.url)) const scriptDir = path.dirname(fileURLToPath(import.meta.url))
const [globalStyles, routerSource, mainLayoutSource, trainingLogSource, fineTuneCreateSource] = await Promise.all([ const [globalStyles, routerSource, mainLayoutSource, trainingLogSource, trainingOverviewSource, fineTuneCreateSource] = await Promise.all([
readFile(path.resolve(scriptDir, '../src/styles/index.scss'), 'utf8'), readFile(path.resolve(scriptDir, '../src/styles/index.scss'), 'utf8'),
readFile(path.resolve(scriptDir, '../src/router/index.ts'), 'utf8'), readFile(path.resolve(scriptDir, '../src/router/index.ts'), 'utf8'),
readFile(path.resolve(scriptDir, '../src/layouts/MainLayout.vue'), 'utf8'), readFile(path.resolve(scriptDir, '../src/layouts/MainLayout.vue'), 'utf8'),
readFile(path.resolve(scriptDir, '../src/views/system/TrainingLogView.vue'), 'utf8'), readFile(path.resolve(scriptDir, '../src/views/system/TrainingLogView.vue'), 'utf8'),
readFile(path.resolve(scriptDir, '../src/views/system/training-log/TrainingTaskOverview.vue'), 'utf8'),
readFile(path.resolve(scriptDir, '../src/views/fine-tune/FineTuneCreateView.vue'), 'utf8'), readFile(path.resolve(scriptDir, '../src/views/fine-tune/FineTuneCreateView.vue'), 'utf8'),
]) ])
@@ -70,8 +71,10 @@ const selfSurfaceRoutes = [
'fine-tune', 'fine-tune',
'model-eval', 'model-eval',
'model-inference', 'model-inference',
'model-inference/chat/:id',
'model-manage', 'model-manage',
'data-process', 'data-process',
'data-process/create',
'dataset', 'dataset',
] ]
for (const routePath of selfSurfaceRoutes) { for (const routePath of selfSurfaceRoutes) {
@@ -138,8 +141,8 @@ assert.doesNotMatch(
const layoutContentBlock = extractCssBlock(mainLayoutStyle, '.layout-content') const layoutContentBlock = extractCssBlock(mainLayoutStyle, '.layout-content')
assert.match(layoutContentBlock, /background-color:\s*var\(--app-shell-bg\);/, '主内容区未使用灰色外层背景') assert.match(layoutContentBlock, /background-color:\s*var\(--app-shell-bg\);/, '主内容区未使用灰色外层背景')
const pageCanvasBlock = extractCssBlock(mainLayoutStyle, '.page-canvas') const pageCanvasBlock = extractCssBlock(mainLayoutStyle, '\n.page-canvas {')
assert.match(pageCanvasBlock, /min-height:\s*100%;/, '白色页面画布没有铺满可用高度') assert.match(pageCanvasBlock, /flex:\s*1 0 auto;/, '白色页面画布没有铺满可用高度')
assert.match(pageCanvasBlock, /padding:\s*24px;/, '白色页面画布缺少统一内容内边距') assert.match(pageCanvasBlock, /padding:\s*24px;/, '白色页面画布缺少统一内容内边距')
assert.match(pageCanvasBlock, /border-radius:\s*16px;/, '白色页面画布圆角与参考不一致') assert.match(pageCanvasBlock, /border-radius:\s*16px;/, '白色页面画布圆角与参考不一致')
assert.match(pageCanvasBlock, /background-color:\s*var\(--app-page-bg\);/, '全局页面画布未使用白色背景') assert.match(pageCanvasBlock, /background-color:\s*var\(--app-page-bg\);/, '全局页面画布未使用白色背景')
@@ -174,7 +177,9 @@ assert.match(rootPageCardBlock, /background-color:\s*transparent;/, '页面根
assert.match(rootPageCardBlock, /border-radius:\s*0\s*!important;/, '页面根卡片仍形成第二层圆角边界') assert.match(rootPageCardBlock, /border-radius:\s*0\s*!important;/, '页面根卡片仍形成第二层圆角边界')
assert.match(rootPageCardBlock, /box-shadow:\s*none\s*!important;/, '页面根卡片仍形成重复卡片层级') assert.match(rootPageCardBlock, /box-shadow:\s*none\s*!important;/, '页面根卡片仍形成重复卡片层级')
const trainingLogStyle = parseSfc(trainingLogSource).descriptor.styles.map((item) => item.content).join('\n') const trainingLogStyle = [trainingLogSource, trainingOverviewSource]
.flatMap((source) => parseSfc(source).descriptor.styles.map((item) => item.content))
.join('\n')
const businessSurfaceBlock = extractCssBlock(trainingLogStyle, '.profile-section,\n.runtime-panel') const businessSurfaceBlock = extractCssBlock(trainingLogStyle, '.profile-section,\n.runtime-panel')
assert.match( assert.match(
businessSurfaceBlock, businessSurfaceBlock,

View File

@@ -0,0 +1,15 @@
import { readdir } from 'node:fs/promises'
import { pathToFileURL } from 'node:url'
import path from 'node:path'
const scriptsDir = path.resolve(process.cwd(), 'scripts')
const regressionScripts = (await readdir(scriptsDir))
.filter((file) => file.startsWith('regression-') && file.endsWith('.mjs'))
.sort()
for (const script of regressionScripts) {
console.log(`\n${script}`)
await import(pathToFileURL(path.join(scriptsDir, script)).href)
}
console.log(`\n${regressionScripts.length} 个前端回归脚本全部通过`)