import test from 'node:test' import assert from 'node:assert/strict' import { readFile } from 'node:fs/promises' import { parse, compileTemplate } from 'vue/compiler-sfc' const page = await readFile(new URL('../src/pages/dispatch/dispatch.vue', import.meta.url), 'utf8') const photos = await readFile(new URL('../src/components/DispatchLoadingDocuments.vue', import.meta.url), 'utf8') for (const [filename, source] of [['dispatch.vue', page], ['DispatchLoadingDocuments.vue', photos]]) { test(`${filename} compiles its actual presentation template`, () => { const { descriptor, errors } = parse(source, { filename }) assert.deepEqual(errors, []) const compiled = compileTemplate({ source: descriptor.template.content, filename, id: 'dispatch-presentation' }) assert.deepEqual(compiled.errors, []) }) } test('picking separates source facts, current quantity and completion while retaining scanner and action guards', () => { const { descriptor } = parse(page) const template = descriptor.template.content for (const title of ['扫码拣货', '任务摘要', '拣货进度', '托盘与货物来源', '当前拣货', '确认装车完成']) assert.ok(template.includes(title), title) assert.match(template, /class="picking-fact-label">客户<\/text>/) assert.match(template, /class="picking-fact-label">目的地<\/text>/) assert.match(template, /aria-label="本次拣货箱数"[^>]+:disabled="busy"[^>]+@input="updatePackages"/) assert.match(template, /name="dispatch"[^>]+:active="activeTab === 'picking'"[^>]+@submit="handleScan"/) assert.match(template, /:disabled="!canPick \|\| busy" @tap="submitPick"/) assert.match(template, /:disabled="!canComplete \|\| busy" @tap="prepareLoading"/) assert.match(template, /@tap="selectPallet\(item\)"/) assert.match(page, /\.picking-fact > text:last-child \{[^}]*overflow-wrap: anywhere/) })