From aea0d51b4468add0be3b842801f6efffc810caa2 Mon Sep 17 00:00:00 2001 From: caoxiaozhu Date: Mon, 13 Jul 2026 15:31:01 +0800 Subject: [PATCH] =?UTF-8?q?test:=20=E6=96=B0=E5=A2=9E=E7=BB=9F=E4=B8=80?= =?UTF-8?q?=E5=9B=9E=E5=BD=92=E8=BF=90=E8=A1=8C=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增 run-regressions.mjs 一键执行全部回归脚本,package.json 注册 npm test 入口与 test:fine-tune-create,page-surface 脚本适配统一运行。 --- frontend/package.json | 2 ++ frontend/scripts/regression-page-surface.mjs | 13 +++++++++---- frontend/scripts/run-regressions.mjs | 15 +++++++++++++++ 3 files changed, 26 insertions(+), 4 deletions(-) create mode 100644 frontend/scripts/run-regressions.mjs diff --git a/frontend/package.json b/frontend/package.json index 07913b5..fb2b390 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -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": { diff --git a/frontend/scripts/regression-page-surface.mjs b/frontend/scripts/regression-page-surface.mjs index c7d1a14..81822e5 100644 --- a/frontend/scripts/regression-page-surface.mjs +++ b/frontend/scripts/regression-page-surface.mjs @@ -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, diff --git a/frontend/scripts/run-regressions.mjs b/frontend/scripts/run-regressions.mjs new file mode 100644 index 0000000..ada6c57 --- /dev/null +++ b/frontend/scripts/run-regressions.mjs @@ -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} 个前端回归脚本全部通过`)