import assert from 'node:assert/strict' import { readFileSync } from 'node:fs' import test from 'node:test' import { fileURLToPath } from 'node:url' const detailViewTemplate = readFileSync( fileURLToPath(new URL('../src/views/TravelRequestDetailView.vue', import.meta.url)), 'utf8' ) const detailViewScript = readFileSync( fileURLToPath(new URL('../src/views/scripts/TravelRequestDetailView.js', import.meta.url)), 'utf8' ) function extractFunction(source, name) { const signatureIndex = source.indexOf(`function ${name}(`) assert.notEqual(signatureIndex, -1, `${name} should exist`) const bodyStart = source.indexOf('{', signatureIndex) assert.notEqual(bodyStart, -1, `${name} should have a body`) let depth = 0 for (let index = bodyStart; index < source.length; index += 1) { const char = source[index] if (char === '{') { depth += 1 } else if (char === '}') { depth -= 1 if (depth === 0) { return source.slice(signatureIndex, index + 1) } } } assert.fail(`${name} body should be closed`) } test('detail submit opens a confirmation dialog before calling submit API', () => { assert.match(detailViewTemplate, / { assert.match(detailViewScript, /label:\s*'单据申请日期'/) assert.match(detailViewScript, /label:\s*'创建单据'/) assert.doesNotMatch(detailViewScript, /label:\s*'保存草稿'/) })