// Generate a self-contained browser regression fixture using the installed Vue/Element Plus. // Open the printed file URL; assertions run without a server, login, or backend requests. const fs = require('node:fs'); const path = require('node:path'); const assert = require('node:assert/strict'); const sass = require('sass'); const { parse } = require('@vue/compiler-sfc'); const root = path.resolve(__dirname, '..'); const read = (file) => fs.readFileSync(path.join(root, file), 'utf8'); const directive = read('src/directive/common/trainingFillHints.js').replace('export default', 'window.trainingFillHints ='); // Every currently routed task page must opt in, including both shared task shells. const router = read('src/router/index.js'); const taskImports = [...router.matchAll(/@\/views\/((?:foundation|demand|product|test|channel|assessment|training)\/[^"']+\.vue)/g)]; for (const [, file] of taskImports) { assert.match(parse(read(`src/views/${file}`)).descriptor.template.content, /v-training-fill-hints/, `${file} is missing fill hints`); } assert.equal(new Set(taskImports.map(([, file]) => file)).size, 30); const taskStyles = parse(read('src/views/demand/business-feasibility.vue')).descriptor.styles.map((style) => style.content).join('\n'); const css = read('node_modules/element-plus/dist/index.css') + sass.compileString( read('src/assets/styles/student-training.scss') + '\n' + taskStyles, { logger: sass.Logger.silent } ).css; const fixture = `
验证中…`; const outputDir = path.join(root, 'tests/e2e/reports'); fs.mkdirSync(outputDir, { recursive: true }); const output = path.join(outputDir, 'training-fill-hints.html'); fs.writeFileSync(output, fixture); console.log(`Task-page coverage passed: 30 routed components. Browser fixture: file:///${output.replaceAll('\\', '/')}`);