优化
This commit is contained in:
@@ -2,7 +2,7 @@ import test from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import { readFileSync } from 'node:fs'
|
||||
import * as store from '../src/stores/receiving.js'
|
||||
import { normalizeReceivingSession, toReceivingError } from '../src/api/receiving-adapter.js'
|
||||
import { normalizeReceivingSession, toReceivingError, RECEIVING_PHOTO_ROLES } from '../src/api/receiving-adapter.js'
|
||||
|
||||
const source = readFileSync(new URL('../src/pages/operation/operation.vue', import.meta.url), 'utf8').match(/<script>([\s\S]*?)<\/script>/)[1]
|
||||
const defer = () => { let resolve, reject; const promise = new Promise((a, b) => { resolve = a; reject = b }); return { promise, resolve, reject } }
|
||||
@@ -13,7 +13,7 @@ const sessionValue = (patch = {}) => normalizeReceivingSession({ containerNo: 'C
|
||||
|
||||
function page(overrides = {}) {
|
||||
const deps = { ...store, session: { tenantId: '100', currentUser: { id: 'operator', warehouseId: '900' } },
|
||||
PortalHeader: {}, ReceivingSessionSummary: {}, ScanTargetInput: {}, requireSession: () => true,
|
||||
PortalHeader: {}, ReceivingSessionSummary: {}, ScanTargetInput: {}, RECEIVING_PHOTO_ROLES, requireSession: () => true,
|
||||
startScanBroadcast: () => () => {}, playErrorSound() {}, playSuccessSound() {},
|
||||
receivingPhase: store.receivingPhase, toReceivingError: error => error, ...overrides }
|
||||
const definition = new Function(...Object.keys(deps), source.replace(/^\s*import .*$/gm, '').replace('export default', 'return'))(...Object.values(deps))
|
||||
@@ -25,6 +25,35 @@ function page(overrides = {}) {
|
||||
return { vm, definition, deps }
|
||||
}
|
||||
|
||||
test('camera resume retains all unsigned uploads by role and clears them across session or identity changes', async () => {
|
||||
store.resetReceivingSession()
|
||||
const unsigned = sessionValue({ status: 'WAIT_SIGN', photos: [], domesticLoadingPhotos: [] })
|
||||
let nextFile = 10
|
||||
const { vm, deps } = page({ uploadCurrentUnloadPhoto: async () => ({ fileId: String(++nextFile) }) })
|
||||
await vm.applyCurrentReceiving(unsigned)
|
||||
await vm.replacePhoto(0, 'camera:plate')
|
||||
vm.suspendReceiving(); vm._pageActive = true
|
||||
await vm.applyCurrentReceiving(structuredClone(unsigned))
|
||||
await vm.replacePhoto(1, 'camera:seal')
|
||||
vm.suspendReceiving(); vm._pageActive = true
|
||||
await vm.applyCurrentReceiving(structuredClone(unsigned))
|
||||
await vm.replacePhoto(2, 'camera:door')
|
||||
assert.deepEqual(vm.photoSlots.map(photo => photo.fileId), ['11', '12', '13'])
|
||||
assert.equal(vm.photosReady, true)
|
||||
await vm.replacePhoto(1, 'camera:seal-again')
|
||||
assert.deepEqual(vm.photoSlots.map(photo => photo.fileId), ['11', '14', '13'])
|
||||
deps.session.currentUser = { ...deps.session.currentUser, id: 'other-operator' }; vm.user = deps.session.currentUser
|
||||
await vm.applyCurrentReceiving(structuredClone(unsigned))
|
||||
assert.deepEqual(vm.photoSlots, [null, null, null])
|
||||
await vm.replacePhoto(0, 'camera:new-owner')
|
||||
await vm.applyCurrentReceiving({ ...unsigned, preparedAt: '2026-11-05T10:00:00' })
|
||||
assert.deepEqual(vm.photoSlots, [null, null, null])
|
||||
await vm.replacePhoto(0, 'camera:new-session')
|
||||
await vm.applyCurrentReceiving({ ...unsigned, preparedAt: '2026-11-05T10:00:00', status: 'SIGNED' })
|
||||
assert.deepEqual(vm.photoSlots, [null, null, null])
|
||||
vm.suspendReceiving()
|
||||
})
|
||||
|
||||
test('same current readback retains three signed previews; collapsed unversioned domestic images issue no downloads', async () => {
|
||||
store.resetReceivingSession(); const calls = []
|
||||
const download = async path => { calls.push(path); return `local:${path}` }
|
||||
|
||||
@@ -90,10 +90,11 @@ test('domestic cabinet photos are read-only, previewable and non-blocking in sig
|
||||
assert.doesNotMatch(page, /domesticLoadingPhotos[\s\S]{0,120}customer/)
|
||||
})
|
||||
|
||||
test('fixed receiving action leaves enough scroll-safe space above the PDA bottom bar', () => {
|
||||
test('receiving finish action remains in document flow after the scan and save controls', () => {
|
||||
assert.match(page, /v-if="canFinishOnsite" class="sticky-action-dock"><view class="sticky-action one"/)
|
||||
assert.match(page, /allInboundsReconciled \? '完成整柜入库' : '现场收货结束(标记差异)'/)
|
||||
assert.match(page, /receiving-content-with-action\{[^}]*padding-bottom:calc\(152px \+ env\(safe-area-inset-bottom,0px\)\)/)
|
||||
assert.match(page, /sticky-action-dock\{position:static;max-width:none/)
|
||||
assert.match(page, /receiving-content-with-action\{[^}]*padding-bottom:calc\(24px \+ env\(safe-area-inset-bottom,0px\)\)/)
|
||||
assert.match(page, /primary-button,\.secondary-button,\.ghost-button\{[^}]*align-items:center;justify-content:center[^}]*line-height:normal;text-align:center/)
|
||||
assert.match(page, /sticky-action button\{[^}]*align-items:center;justify-content:center;line-height:normal;text-align:center/)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user