fix(pda): guard duplicate submission and invalidate hidden task requests
This commit is contained in:
@@ -36,12 +36,14 @@ test('duplicate onShow shares one load chain while background return refreshes a
|
||||
const page = await read('../pages/picking/picking.vue')
|
||||
const show = page.match(/async onShow\(\) \{[\s\S]*?\r?\n\t\t\},/)?.[0]
|
||||
const hide = page.match(/onHide\(\) \{[\s\S]*?\r?\n\t\t\},/)?.[0]
|
||||
assert.ok(show && hide)
|
||||
const hooks = new Function('requireSession', 'session', `return ({${show}${hide}})`)(() => true, { currentUser: { id: '7' } })
|
||||
const invalidate = page.match(/invalidateTaskSync\(\) \{[^\r\n]+\},/)?.[0]
|
||||
assert.ok(show && hide && invalidate)
|
||||
const hooks = new Function('requireSession', 'session', `return ({${show}${hide}${invalidate}})`)(() => true, { currentUser: { id: '7' } })
|
||||
const calls = []
|
||||
let release
|
||||
const pending = new Promise((resolve) => { release = resolve })
|
||||
const context = { startHardwareScanner() {}, stopHardwareScanner() {}, async refreshAvailableBoxes() { calls.push('pending'); await pending }, async syncRemoteTask() { calls.push('detail+evidence') } }
|
||||
const context = { taskRequestId: 0, invalidateTaskSync: hooks.invalidateTaskSync,
|
||||
startHardwareScanner() {}, stopHardwareScanner() {}, async refreshAvailableBoxes() { calls.push('pending'); await pending }, async syncRemoteTask() { calls.push('detail+evidence') } }
|
||||
const first = hooks.onShow.call(context)
|
||||
const duplicate = hooks.onShow.call(context)
|
||||
assert.deepEqual(calls, ['pending'])
|
||||
@@ -51,6 +53,9 @@ test('duplicate onShow shares one load chain while background return refreshes a
|
||||
await hooks.onShow.call(context)
|
||||
assert.equal(calls.length, 2)
|
||||
hooks.onHide.call(context)
|
||||
assert.equal(context.taskRequestId, 1)
|
||||
assert.equal(context.remoteLoading, false)
|
||||
assert.equal(context._showRefreshPromise, null)
|
||||
await hooks.onShow.call(context)
|
||||
assert.deepEqual(calls, ['pending', 'detail+evidence', 'pending', 'detail+evidence'])
|
||||
const onLoad = page.match(/onLoad\(options = \{\}\) \{[\s\S]*?\r?\n\t\t\},/)?.[0]
|
||||
|
||||
Reference in New Issue
Block a user