test: 新增统一回归运行器
新增 run-regressions.mjs 一键执行全部回归脚本,package.json 注册 npm test 入口与 test:fine-tune-create,page-surface 脚本适配统一运行。
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
"build": "vue-tsc -b && vite build",
|
||||
"preview": "vite preview",
|
||||
"type-check": "vue-tsc -b --noEmit",
|
||||
"test": "node scripts/run-regressions.mjs",
|
||||
"test:default-dashboard": "node scripts/regression-default-dashboard.mjs",
|
||||
"test:dashboard": "node scripts/regression-dashboard.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:hardware": "node scripts/regression-hardware-dashboard.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"
|
||||
},
|
||||
"dependencies": {
|
||||
|
||||
@@ -6,11 +6,12 @@ import { parse as parseTemplate } from '@vue/compiler-dom'
|
||||
import { parse as parseSfc } from '@vue/compiler-sfc'
|
||||
|
||||
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/router/index.ts'), '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/training-log/TrainingTaskOverview.vue'), 'utf8'),
|
||||
readFile(path.resolve(scriptDir, '../src/views/fine-tune/FineTuneCreateView.vue'), 'utf8'),
|
||||
])
|
||||
|
||||
@@ -70,8 +71,10 @@ const selfSurfaceRoutes = [
|
||||
'fine-tune',
|
||||
'model-eval',
|
||||
'model-inference',
|
||||
'model-inference/chat/:id',
|
||||
'model-manage',
|
||||
'data-process',
|
||||
'data-process/create',
|
||||
'dataset',
|
||||
]
|
||||
for (const routePath of selfSurfaceRoutes) {
|
||||
@@ -138,8 +141,8 @@ assert.doesNotMatch(
|
||||
const layoutContentBlock = extractCssBlock(mainLayoutStyle, '.layout-content')
|
||||
assert.match(layoutContentBlock, /background-color:\s*var\(--app-shell-bg\);/, '主内容区未使用灰色外层背景')
|
||||
|
||||
const pageCanvasBlock = extractCssBlock(mainLayoutStyle, '.page-canvas')
|
||||
assert.match(pageCanvasBlock, /min-height:\s*100%;/, '白色页面画布没有铺满可用高度')
|
||||
const pageCanvasBlock = extractCssBlock(mainLayoutStyle, '\n.page-canvas {')
|
||||
assert.match(pageCanvasBlock, /flex:\s*1 0 auto;/, '白色页面画布没有铺满可用高度')
|
||||
assert.match(pageCanvasBlock, /padding:\s*24px;/, '白色页面画布缺少统一内容内边距')
|
||||
assert.match(pageCanvasBlock, /border-radius:\s*16px;/, '白色页面画布圆角与参考不一致')
|
||||
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, /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')
|
||||
assert.match(
|
||||
businessSurfaceBlock,
|
||||
|
||||
15
frontend/scripts/run-regressions.mjs
Normal file
15
frontend/scripts/run-regressions.mjs
Normal 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} 个前端回归脚本全部通过`)
|
||||
Reference in New Issue
Block a user