Files
pda-overseas-uniapp/tests/receiving-adapter.test.mjs
T

26 lines
1.5 KiB
JavaScript
Raw Normal View History

2026-08-24 19:29:41 +08:00
import test from 'node:test'
import assert from 'node:assert/strict'
import { isNoCurrentReceiving, isReceivingConflict, normalizeReceivingCandidate, normalizeReceivingSession, RECEIVING_PHOTO_ROLES } from '../src/api/receiving-adapter.js'
test('receiving adapter preserves the three signed photo roles in workflow order', () => {
2026-08-26 15:24:51 +08:00
const snowflakeFileId = '2092476334483931138'
2026-08-24 19:29:41 +08:00
const session = normalizeReceivingSession({
status: 'WAIT_SIGN', totalPackages: 8, receivedPackages: 2, pendingPackages: 6,
2026-08-26 15:59:08 +08:00
photos: [{ role: 'DOOR_OPEN', fileId: '3' }, { role: 'LICENSE_PLATE', fileId: snowflakeFileId }, { role: 'CONTAINER_SEAL', fileId: '2' }, { role: 'DOOR_OPEN', fileId: '4' }],
2026-08-24 19:29:41 +08:00
inbounds: [{ inboundCode: 'IN-1', plannedPalletCount: 2, totalPackages: 8, receivedPackages: 2, pendingPackages: 6 }]
})
assert.deepEqual(session.photos.map(({ role }) => role), RECEIVING_PHOTO_ROLES)
2026-08-26 15:24:51 +08:00
assert.equal(session.photos[0].fileId, snowflakeFileId)
2026-08-26 15:59:08 +08:00
assert.equal(session.photos.length, 3)
2026-08-24 19:29:41 +08:00
assert.equal(session.inbounds[0].plannedPalletCount, 2)
})
test('receiving adapter exposes calculable candidate facts and workflow errors', () => {
const candidate = normalizeReceivingCandidate({ destinationCodes: ['ONT8', 'LAX'], plannedPalletCount: 4, currentAccount: true })
assert.deepEqual(candidate.destinationCodes, ['ONT8', 'LAX'])
assert.equal(candidate.plannedPalletCount, 4)
assert.equal(candidate.currentAccount, true)
assert.equal(isNoCurrentReceiving({ code: 404 }), true)
assert.equal(isReceivingConflict({ code: 'B0409' }), true)
})