优化
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
import assert from 'node:assert/strict'
|
||||
import { readFileSync } from 'node:fs'
|
||||
import { dirname, resolve } from 'node:path'
|
||||
import test from 'node:test'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
|
||||
import { buildPendingActions } from './phase3-pda-convergence.mjs'
|
||||
|
||||
const here = dirname(fileURLToPath(import.meta.url))
|
||||
const read = (path) => readFileSync(resolve(here, path), 'utf8')
|
||||
const convergence = read('./phase3-pda-convergence.mjs')
|
||||
const mapper = read('../../firstleg/src/main/java/com/baiyue/firstleg/mapper/LoadingPickTaskMapper.java')
|
||||
const openApi = read('../../firstleg/src/main/resources/openapi/phase3-pda-convergence-v1.yaml')
|
||||
|
||||
test('AWAITING_REVIEW derives zero client actions and never needs a repeated batch', () => {
|
||||
assert.deepEqual(buildPendingActions({
|
||||
workflowStatus: 'AWAITING_REVIEW',
|
||||
items: [{ id: 1, itemStatus: 'PICKED', pickedPackageCount: 1 }],
|
||||
}), [])
|
||||
assert.deepEqual(buildPendingActions({
|
||||
workflowStatus: 'IN_PROGRESS',
|
||||
items: [{ id: 1, itemStatus: 'PICKED' }, { id: 2, itemStatus: 'PENDING' }],
|
||||
}), [{ itemId: '2', action: 'PICK' }])
|
||||
assert.match(convergence, /pending 与 detail 使用同一 workflowStatus 和未完成数量事实/)
|
||||
assert.match(convergence, /AWAITING_REVIEW 已全拣任务 actions 为空且不再提交 batch/)
|
||||
assert.match(convergence, /AWAITING_REVIEW 可进入装柜取证只读入口/)
|
||||
assert.match(convergence, /filter\(\(item\) => item\.actionType === 'BATCH'/)
|
||||
assert.doesNotMatch(convergence, /pendingActions[\s\S]{0,240}request\(context, 'POST'/)
|
||||
})
|
||||
|
||||
test('pending backend contract derives workflow from task items instead of assignment alone', () => {
|
||||
assert.match(openApi,
|
||||
/PendingTask:[\s\S]*workflowStatus: \{type: string, enum: \[UNASSIGNED, IN_PROGRESS, AWAITING_REVIEW\][^\r\n]*}/)
|
||||
assert.match(mapper,
|
||||
/WHEN SUM\(CASE WHEN pick_item\.item_status IN \('PENDING', 'PICKING'\)[\s\S]*= 0[\s\S]*THEN 'AWAITING_REVIEW'/)
|
||||
assert.doesNotMatch(mapper,
|
||||
/CASE WHEN assignment\.pick_task_id IS NULL THEN 'UNASSIGNED' ELSE 'IN_PROGRESS' END AS workflowStatus/)
|
||||
})
|
||||
Reference in New Issue
Block a user