适配PDA稳定柜次身份契约
This commit is contained in:
@@ -3,19 +3,29 @@ import assert from 'node:assert/strict'
|
||||
import { readFile } from 'node:fs/promises'
|
||||
|
||||
const source = await readFile(new URL('../stores/picking.js', import.meta.url), 'utf8')
|
||||
const taskIdentitySource = await readFile(new URL('../utils/task-identity.js', import.meta.url), 'utf8')
|
||||
|
||||
test('picking drafts are persisted under operator, task and cabinet identity', () => {
|
||||
test('picking drafts are persisted under stable operator, task and loading plan identity', () => {
|
||||
assert.match(source, /pda-picking-draft/)
|
||||
assert.match(source, /operatorId/)
|
||||
assert.match(source, /taskId/)
|
||||
assert.match(source, /containerNo/)
|
||||
assert.match(source, /loadingPlanId/)
|
||||
assert.match(source, /containerBookingId/)
|
||||
assert.match(source, /uni\.setStorageSync\(key/)
|
||||
assert.match(source, /uni\.getStorageSync\(key/)
|
||||
assert.match(source, /uni\.removeStorageSync\(key/)
|
||||
})
|
||||
|
||||
test('draft restore rejects a different operator or task', () => {
|
||||
assert.match(source, /saved\.operatorId !== identityValue\(identity\)\.operatorId/)
|
||||
assert.match(source, /saved\.taskId !== identityValue\(identity\)\.taskId/)
|
||||
assert.match(source, /saved\.containerNo !== identityValue\(identity\)\.containerNo/)
|
||||
assert.match(source, /saved\.operatorId !== expected\.operatorId/)
|
||||
assert.match(source, /saved\.taskId !== expected\.taskId/)
|
||||
assert.match(source, /saved\.loadingPlanId !== expected\.loadingPlanId/)
|
||||
assert.match(source, /saved\.containerBookingId !== expected\.containerBookingId/)
|
||||
assert.doesNotMatch(taskIdentitySource, /containerNo|currentContainerNo|boxNo/)
|
||||
})
|
||||
|
||||
test('mutable real container number is not part of draft identity or restore validation', () => {
|
||||
const restoreGuard = source.match(/const expected = stableTaskIdentity[\s\S]*?return null/)?.[0] || ''
|
||||
assert.doesNotMatch(taskIdentitySource, /containerNo|currentContainerNo|boxNo/)
|
||||
assert.doesNotMatch(restoreGuard, /containerNo|currentContainerNo|boxNo/)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user