const assert = require("node:assert/strict"); const fs = require("node:fs"); const path = require("node:path"); const test = require("node:test"); const frontendRoot = path.resolve(__dirname, ".."); const pageSource = fs.readFileSync(path.join(frontendRoot, "src/views/training/GenericTrainingPage.vue"), "utf8"); const routerSource = fs.readFileSync(path.join(frontendRoot, "src/router/index.js"), "utf8"); test("综合实训不显示右下角补充步骤", () => { assert.match( routerSource, /pageKey: "comprehensive-case-training", hideSupplementSteps: true/, ); }); test("综合实训操作按钮复用统一工具栏并位于工作台标题右侧", () => { assert.match( pageSource, /
[\s\S]*?]*:show-toolbar="true"/); }); test("综合实训步骤保持单行并支持鼠标或触控左右拖动", () => { assert.match(pageSource, /class="comprehensive-step-strip"/); assert.match(pageSource, /@pointerdown="startComprehensiveNavDrag"/); assert.match(pageSource, /@pointermove="moveComprehensiveNavDrag"/); assert.match(pageSource, /\.comprehensive-step-strip\s*\{[\s\S]*?width: max-content/); assert.match(pageSource, /\.comprehensive-step-strip \.step-name\s*\{[\s\S]*?white-space: nowrap/); assert.doesNotMatch(pageSource, /comprehensive-turn-row|comprehensive-turn-rail/); }); test("综合实训首尾步骤只展示可用的底部导航", () => { assert.match(pageSource, /const isFirstConfiguredStep = computed\(\(\) => currentStep\.value <= 1\);/); assert.match(pageSource, /const isLastConfiguredStep = computed\(\(\) => configuredSteps\.value\.length > 0 && currentStep\.value >= configuredSteps\.value\.length\);/); assert.match(pageSource, /v-if="!isFirstConfiguredStep" plain @click="goPreviousStep">上一步/); assert.match(pageSource, /v-if="!isLastConfiguredStep" plain @click="goNextStep">下一步/); });