22 lines
1.1 KiB
JavaScript
22 lines
1.1 KiB
JavaScript
import test from 'node:test'
|
|
import assert from 'node:assert/strict'
|
|
import { readFile } from 'node:fs/promises'
|
|
|
|
const page = await readFile(new URL('../pages/picking/picking.vue', import.meta.url), 'utf8')
|
|
|
|
test('saving a seal is single-flight and reuses a stable photo-bound operation', () => {
|
|
assert.match(page, /:disabled="sealSaving \|\| !sealReadyToSave"/)
|
|
assert.match(page, /sealSaving \? '保存中…' : '保存封签'/)
|
|
assert.match(page, /async saveSealNo\(\) \{[\s\S]*?if \(this\.sealSaving\) return/)
|
|
assert.match(page, /find\(\(item\) => item\.fileId && !item\.id\)/)
|
|
assert.match(page, /stableOperationId\('seal',[\s\S]*?fileId: String\(current\.fileId\)[\s\S]*?sealNo: String\(this\.sealNo\)\.trim\(\)/)
|
|
assert.doesNotMatch(page, /seal-no-[^\n]*Date\.now\(\)/)
|
|
assert.match(page, /this\.sealSaving = true[\s\S]*?finally \{[\s\S]*?this\.sealSaving = false/)
|
|
})
|
|
|
|
test('server-returned evidence is deduplicated by type and file id', () => {
|
|
assert.match(page, /const seen = new Set\(\)/)
|
|
assert.match(page, /item\.evidenceType[\s\S]*?item\.fileId/)
|
|
assert.match(page, /if \(seen\.has\(key\)\) return false/)
|
|
})
|