fix: return completed loading tasks to the task list
This commit is contained in:
@@ -7,12 +7,13 @@ const page = await readFile(new URL('../pages/picking/picking.vue', import.meta.
|
||||
const method = page.match(/async completeLoadingTask\(\) \{[\s\S]*?\n\t\t\t\},/)[0]
|
||||
function completion(overrides = {}, savedAttempt = null) {
|
||||
let attempt = savedAttempt
|
||||
const calls = [], cleared = [], messages = []
|
||||
const calls = [], cleared = [], messages = [], destinations = []
|
||||
const bindings = {
|
||||
COMPLETION_PHASE, resolveCompletionPhase, shouldReconcileCompletion,
|
||||
isRemoteReady: () => true, stableTaskOperationIdentity: () => 'task', stableOperationId: (_action, _identity, payload) => `complete-v${payload.expectedTaskVersion}`,
|
||||
restoreLoadingCompletionAttempt: () => attempt, saveLoadingCompletionAttempt: (_identity, value) => { attempt = value },
|
||||
clearLoadingCompletionAttempt: identity => { cleared.push(identity); attempt = null },
|
||||
navigateBackOr: url => destinations.push(url),
|
||||
completeContainerPickingTask: async (_task, payload) => { calls.push(payload); return { taskStatus: 'COMPLETED' } },
|
||||
normalizePickingTask: task => task, observeLoadingCompletion: async options => options.initialTask,
|
||||
sanitizeUserMessage: value => value, ...overrides
|
||||
@@ -27,15 +28,16 @@ function completion(overrides = {}, savedAttempt = null) {
|
||||
remoteFailureMessage: error => error.message, showToast: message => messages.push(message)
|
||||
}
|
||||
state.complete = behavior.completeLoadingTask.bind(state)
|
||||
return { state, calls, cleared, messages, attempt: () => attempt }
|
||||
return { state, calls, cleared, messages, destinations, attempt: () => attempt }
|
||||
}
|
||||
|
||||
test('completion in flight blocks a second click and releases busy after the task context changes', async () => {
|
||||
let resolve
|
||||
const { state, calls } = completion({ completeContainerPickingTask: (...args) => { calls.push(args); return new Promise(done => { resolve = done }) } })
|
||||
const { state, calls, destinations } = completion({ completeContainerPickingTask: (...args) => { calls.push(args); return new Promise(done => { resolve = done }) } })
|
||||
const first = state.complete(); await state.complete(); assert.equal(calls.length, 1)
|
||||
state.evidenceContextId++; resolve({ taskStatus: 'COMPLETED' }); await first
|
||||
assert.equal(state.submitting, false); assert.equal(state.remotePick.taskStatus, undefined)
|
||||
assert.deepEqual(destinations, [])
|
||||
})
|
||||
|
||||
test('an old completion response cannot release a newer picking submission', async () => {
|
||||
|
||||
Reference in New Issue
Block a user