test: avoid duplicate overseas PDA lock assertion
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
import assert from 'node:assert/strict'
|
||||
import { readFileSync } from 'node:fs'
|
||||
import test from 'node:test'
|
||||
|
||||
const source = readFileSync(new URL('./phase4-overseas-pda.mjs', import.meta.url), 'utf8')
|
||||
|
||||
test('cross-container lock is asserted once while both current-run containers are candidates', () => {
|
||||
assert.match(source, /if \(runAuthorizationProbes\) \{\s+const other = candidates\.data\.find/s)
|
||||
assert.match(source, /当前账号跨柜切换锁返回409/)
|
||||
assert.match(source, /runReceiving\(context, primary\.token, secondary\.token,[\s\S]*index === 0\)/)
|
||||
})
|
||||
@@ -563,11 +563,13 @@ async function runReceiving(context, token, secondaryToken, merchantToken, prefe
|
||||
`/api/pda/v1/last-leg/receiving-containers/${encodeURIComponent(containerNo)}/prepare`,
|
||||
{ idempotencyKey: key(context, 'secondary-prepare') }, conflict)
|
||||
}
|
||||
const other = candidates.data.find((item) => item.containerNo !== containerNo
|
||||
&& item.operable === true && item.allPlansReady === true && Number(item.totalPackages) > 0)
|
||||
if (other) await expected(context, token, 'GET', '当前账号跨柜切换锁返回409',
|
||||
`/api/pda/v1/last-leg/receiving-containers/${encodeURIComponent(other.containerNo)}`, undefined, conflict)
|
||||
else blockerGap(context, '跨柜锁409', '当前客户只有一个待收柜,无法在不伪造柜数据的前提下验证跨柜锁')
|
||||
if (runAuthorizationProbes) {
|
||||
const other = candidates.data.find((item) => item.containerNo !== containerNo
|
||||
&& item.operable === true && item.allPlansReady === true && Number(item.totalPackages) > 0)
|
||||
if (other) await expected(context, token, 'GET', '当前账号跨柜切换锁返回409',
|
||||
`/api/pda/v1/last-leg/receiving-containers/${encodeURIComponent(other.containerNo)}`, undefined, conflict)
|
||||
else blockerGap(context, '跨柜锁409', '本轮首柜作业前只有一个可收柜,无法在不伪造柜数据的前提下验证跨柜锁')
|
||||
}
|
||||
const photos = await uploadPhotos(context, token)
|
||||
if (!photos) return
|
||||
const signBody = { photos, idempotencyKey: key(context, 'sign') }
|
||||
|
||||
Reference in New Issue
Block a user