优化
This commit is contained in:
@@ -22,6 +22,16 @@ function state(a = '2', b = '2', c = '2') {
|
||||
return value
|
||||
}
|
||||
|
||||
test('resume card is redundant only when the same receipt task is on the current page', () => {
|
||||
const activeTask = { receiptNo: 'RR-ACTIVE', palletCode: 'PLT-SHARED' }
|
||||
const listed = tasks => scope.page.computed.activeTaskListed.call({ activeTask, tasks })
|
||||
assert.equal(listed([{ ...activeTask }]), true)
|
||||
assert.equal(listed([{ receiptNo: 'RR-OTHER', palletCode: 'PLT-SHARED' }]), false)
|
||||
assert.equal(listed([]), false, 'keep resume access when paging away from the active task')
|
||||
assert.equal(scope.page.computed.activeTaskListed.call({ activeTask: null, tasks: [activeTask] }), false)
|
||||
assert.equal(scope.page.computed.activeTaskListed.call({ activeTask: {}, tasks: [{}] }), false)
|
||||
})
|
||||
|
||||
test('list entry can confirm without scanning when string wire quantities reconcile', () => {
|
||||
const value = state()
|
||||
assert.equal(value.totals[0].quantity, 4)
|
||||
@@ -40,7 +50,7 @@ test('counting still rejects mismatched totals and invalid box quantities', () =
|
||||
})
|
||||
|
||||
function scanState() {
|
||||
const value = { task: state().task, tasks: [], error: null, scanCode: '', scanResult: '', selectedMark: '', busy: false,
|
||||
const value = { task: state().task, tasks: [], error: null, scanCode: '', scanResult: '', selectedMark: '', busy: false, listLoading: false, openingReceiptNo: '',
|
||||
open(row) { this.task = row }, $nextTick(callback) { callback() } }
|
||||
value.run = scope.page.methods.run.bind(value)
|
||||
value.enterTask = scope.page.methods.enterTask.bind(value)
|
||||
@@ -48,6 +58,61 @@ function scanState() {
|
||||
return value
|
||||
}
|
||||
|
||||
test('opening a task keeps list counts stable and uses only that task loading state until cancellation', async () => {
|
||||
const value = scanState()
|
||||
const row = { receiptNo: 'RR-SELECTED', returnNo: 'RT-SELECTED' }
|
||||
value.task = null; value.tasks = [row]; value.total = 1
|
||||
let release, currentReads = 0
|
||||
const pending = new Promise(resolve => { release = resolve })
|
||||
scope.getCurrentReturnCountTask = async () => { currentReads++; await pending; return null }
|
||||
scope.beginReturnCountTask = async () => assert.fail('cancelled selection cannot begin a task')
|
||||
value.fetchTasks = async () => assert.fail('opening a card cannot refresh the list')
|
||||
value.ask = async () => ({ confirm: false })
|
||||
const opening = scope.page.methods.choose.call(value, row)
|
||||
assert.equal(value.busy, true)
|
||||
assert.equal(value.listLoading, false)
|
||||
assert.equal(value.openingReceiptNo, row.receiptNo)
|
||||
assert.equal(value.total, 1)
|
||||
assert.equal(value.tasks[0], row)
|
||||
await scope.page.methods.choose.call(value, { receiptNo: 'RR-SECOND' })
|
||||
assert.equal(currentReads, 1)
|
||||
release(); await opening
|
||||
assert.equal(value.busy, false)
|
||||
assert.equal(value.openingReceiptNo, '')
|
||||
assert.equal(value.task, null)
|
||||
assert.equal(value.tasks[0], row)
|
||||
})
|
||||
|
||||
test('failed task opening releases its indicator and retains list and diagnostic evidence', async () => {
|
||||
const value = scanState(), row = { receiptNo: 'RR-SELECTED' }
|
||||
value.task = null; value.tasks = [row]
|
||||
scope.getCurrentReturnCountTask = async () => { throw Object.assign(new Error('读取任务失败'), { code: 'A0409', requestId: 'REQ', traceId: 'TRACE' }) }
|
||||
await scope.page.methods.choose.call(value, row)
|
||||
assert.equal(value.busy, false)
|
||||
assert.equal(value.listLoading, false)
|
||||
assert.equal(value.openingReceiptNo, '')
|
||||
assert.equal(value.tasks[0], row)
|
||||
assert.equal(value.error.code, 'A0409')
|
||||
assert.equal(value.error.requestId, 'REQ')
|
||||
assert.equal(value.error.traceId, 'TRACE')
|
||||
})
|
||||
|
||||
test('explicit list loading owns the refresh indicator and always releases it', async () => {
|
||||
for (const fails of [false, true]) {
|
||||
const value = scanState()
|
||||
let release
|
||||
const pending = new Promise(resolve => { release = resolve })
|
||||
value.fetchTasks = async () => { await pending; if (fails) throw new Error('加载失败') }
|
||||
const loading = scope.page.methods.load.call(value)
|
||||
assert.equal(value.listLoading, true)
|
||||
assert.equal(value.openingReceiptNo, '')
|
||||
release(); await loading
|
||||
assert.equal(value.busy, false)
|
||||
assert.equal(value.listLoading, false)
|
||||
assert.equal(Boolean(value.error), fails)
|
||||
}
|
||||
})
|
||||
|
||||
test('box and single-batch pallet scans claim and open counting directly without start dialog', async () => {
|
||||
for (const mark of ['RC#2-1', 'PLT-1']) {
|
||||
const value = scanState()
|
||||
|
||||
Reference in New Issue
Block a user