fix(pda): make completed loading evidence read-only

This commit is contained in:
2026-09-30 14:21:29 +08:00
parent 764017cfe2
commit 707711b3bd
3 changed files with 49 additions and 7 deletions
+26
View File
@@ -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' },
+1 -1
View File
@@ -5,7 +5,7 @@ import { readFile } from 'node:fs/promises'
const page = await readFile(new URL('../pages/picking/picking.vue', import.meta.url), 'utf8')
test('saving a seal is single-flight and submits the pending photo through the atomic evidence command', () => {
assert.match(page, /:disabled="sealSaving \|\| !sealReadyToSave"/)
assert.match(page, /:disabled="evidenceReadOnly \|\| sealSaving \|\| !sealReadyToSave"/)
assert.match(page, /sealSaving \? '上传中…' : '保存并上传'/)
assert.match(page, /async saveSealNo\(\) \{[\s\S]*?if \(this\.sealSaving\) return/)
assert.match(page, /find\(\(item\) => item\.localPath && !item\.id\)/)