From 1c8d058d71a216076a010567b7257b3e5c347562 Mon Sep 17 00:00:00 2001 From: ouyangxq <775153912@qq.com> Date: Fri, 4 Sep 2026 15:18:57 +0800 Subject: [PATCH] test: avoid duplicate overseas PDA lock assertion --- .../phase4-overseas-pda-lock-contract.test.mjs | 11 +++++++++++ .../admin-test-env-modules/phase4-overseas-pda.mjs | 12 +++++++----- 2 files changed, 18 insertions(+), 5 deletions(-) create mode 100644 scripts/admin-test-env-modules/phase4-overseas-pda-lock-contract.test.mjs diff --git a/scripts/admin-test-env-modules/phase4-overseas-pda-lock-contract.test.mjs b/scripts/admin-test-env-modules/phase4-overseas-pda-lock-contract.test.mjs new file mode 100644 index 000000000..b50d43b56 --- /dev/null +++ b/scripts/admin-test-env-modules/phase4-overseas-pda-lock-contract.test.mjs @@ -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\)/) +}) diff --git a/scripts/admin-test-env-modules/phase4-overseas-pda.mjs b/scripts/admin-test-env-modules/phase4-overseas-pda.mjs index e7267863d..241efb2b2 100644 --- a/scripts/admin-test-env-modules/phase4-overseas-pda.mjs +++ b/scripts/admin-test-env-modules/phase4-overseas-pda.mjs @@ -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') }