fix(first-leg): show cancelled orders as terminal details
This commit is contained in:
@@ -28,7 +28,10 @@ function harness(t) {
|
||||
const module = compile('./firstLegOrders.ts', {
|
||||
vue, pinia,
|
||||
'@/modules/first-leg/api/firstLeg': api,
|
||||
'@/modules/first-leg/api/unifiedOrders': {},
|
||||
'@/modules/first-leg/api/unifiedOrders': {
|
||||
getMerchantUnifiedOrder: async () => ({ summary: { orderId: 'one', mainStatus: null }, order: { order: { id: 'one', status: behavior.status, version: behavior.version, receivingWarehouseId: 'warehouse' } }, timeline: [] }),
|
||||
isUnifiedOrderQueryUnavailable: () => false,
|
||||
},
|
||||
'@/modules/first-leg/utils/firstLegOrder': { canClientEditFirstLegOrder: status => status === 'DRAFT', getFirstLegStatusLabel: value => value },
|
||||
'@/modules/first-leg/utils/warehousePagination': {},
|
||||
})
|
||||
@@ -38,6 +41,28 @@ function harness(t) {
|
||||
return { store, api, calls, behavior, draft }
|
||||
}
|
||||
|
||||
test('raw and unified cancelled detail remain CANCELLED even when unified mainStatus is null', async t => {
|
||||
const h = harness(t)
|
||||
h.behavior.status = 'CANCELLED'
|
||||
const raw = await h.store.loadDraftDetail('one')
|
||||
assert.equal(raw.status, 'CANCELLED')
|
||||
const unified = await h.store.loadDetail('one')
|
||||
assert.equal(unified.status, 'CANCELLED')
|
||||
h.behavior.status = 'APPROVED'
|
||||
const unknown = await h.store.loadDetail('one')
|
||||
assert.notEqual(unknown.status, 'CANCELLED', 'unknown summary must not be reclassified as cancellation')
|
||||
})
|
||||
|
||||
test('cancelled detail summary has no pending overseas synchronization entries', () => {
|
||||
const source = readFileSync(new URL('../views/FirstLegOrdersView.vue', import.meta.url), 'utf8')
|
||||
const script = source.match(/<script setup lang="ts">([\s\S]*?)<\/script>/)[1]
|
||||
const ast = ts.createSourceFile('view.ts', script, ts.ScriptTarget.Latest, true, ts.ScriptKind.TS)
|
||||
const declaration = ast.statements.flatMap(node => ts.isVariableStatement(node) ? [...node.declarationList.declarations] : []).find(node => node.name.getText(ast) === 'progressSummaryItems')
|
||||
const code = ts.transpileModule('const progressSummaryItems = ' + declaration.initializer.getText(ast), { compilerOptions: { target: ts.ScriptTarget.ES2022 } }).outputText
|
||||
const summary = new Function('computed', 'detailOrder', code + '; return progressSummaryItems.value')(vue.computed, { value: { status: 'CANCELLED' } })
|
||||
assert.deepEqual(summary, [])
|
||||
})
|
||||
|
||||
test('edit freezes detail version rather than cached list version and replays same key/body after uncertain result', async t => {
|
||||
const h = harness(t)
|
||||
const original = await h.store.loadDraftDetail('one')
|
||||
|
||||
Reference in New Issue
Block a user