fix(pda): make completed loading evidence read-only
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import test from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import { readFile } from 'node:fs/promises'
|
||||
import {
|
||||
COMPLETION_PHASE,
|
||||
completionPresentation,
|
||||
@@ -8,6 +9,31 @@ import {
|
||||
shouldReconcileCompletion
|
||||
} from '../utils/loading-completion-state.js'
|
||||
|
||||
test('reopened processing and completed tasks keep evidence and completion read-only', async () => {
|
||||
const page = await readFile(new URL('../pages/picking/picking.vue', import.meta.url), 'utf8')
|
||||
const methods = ['loadingCompletionState', 'evidenceReadOnly', 'requireEvidenceStage'].map(name => {
|
||||
const method = page.match(new RegExp(`${name}\\(\\) \\{[\\s\\S]*?\\n\\t\\t\\t\\},`))?.[0]
|
||||
assert.ok(method, name)
|
||||
return method
|
||||
})
|
||||
const behavior = new Function('resolveCompletionPhase', 'completionPresentation', `return ({${methods.join('\n')}})`)(resolveCompletionPhase, completionPresentation)
|
||||
for (const workflowStatus of ['PROCESSING', 'COMPLETED']) {
|
||||
const messages = []
|
||||
const context = { remotePick: { workflowStatus, completionCommand: { status: workflowStatus } }, submitting: false, pickingCompleted: true, loadingStageReady: true, showToast(message) { messages.push(message) } }
|
||||
context.loadingCompletionState = behavior.loadingCompletionState.call(context)
|
||||
context.evidenceReadOnly = behavior.evidenceReadOnly.call(context)
|
||||
assert.equal(context.evidenceReadOnly, true)
|
||||
assert.equal(behavior.requireEvidenceStage.call(context), false)
|
||||
assert.deepEqual(messages, [workflowStatus === 'COMPLETED' ? '装柜已完成' : '完成处理中'])
|
||||
}
|
||||
const retry = { remotePick: { workflowStatus: 'COMPLETION_FAILED' }, submitting: false }
|
||||
retry.loadingCompletionState = behavior.loadingCompletionState.call(retry)
|
||||
assert.equal(behavior.evidenceReadOnly.call(retry), false)
|
||||
assert.match(page, /v-if="evidenceReadOnly"[^>]*role="status"/)
|
||||
assert.match(page, /v-else class="loading-complete-btn"/)
|
||||
assert.match(page, /class="evidence-btn evidence-add-btn" :disabled="evidenceReadOnly"/)
|
||||
})
|
||||
|
||||
test('accepted completion is processing and blocks every repeated mutation', () => {
|
||||
for (const facts of [
|
||||
{ taskStatus: 'COMPLETING' },
|
||||
|
||||
Reference in New Issue
Block a user