From f8efebdf11052d37a40c318aa28e71861270fec2 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Mon, 12 Oct 2026 13:09:50 +0800 Subject: [PATCH] =?UTF-8?q?test(=E4=B8=BB=E7=B3=BB=E7=BB=9F=E5=AF=B9?= =?UTF-8?q?=E6=8E=A5):=20=E5=A4=8D=E5=88=BB=E7=9C=9F=E5=BA=93=E4=BA=8B?= =?UTF-8?q?=E6=95=85=E7=8E=B0=E5=9C=BA=20=E2=80=94=E2=80=94=2045=20?= =?UTF-8?q?=E5=BE=85=E5=88=86=E6=8B=A3=E8=BF=BD=E5=8A=A0=E5=BF=85=E9=A1=BB?= =?UTF-8?q?=E5=B8=A6=20canForceEdit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 补一条显式用例:把租户连接读回的订单状态锁在 45(待分拣),断言系统追加路径带的 operatorRoles='main_system_import' 且 canForceEdit=true。 配合 orderManageItemsLock.test.ts 的闸门口径(45 无强制位=拒绝、有=放行), 这组用例能在 CI 里直接拦住「主系统新增商品在子系统静默丢失」的复发。 --- server/tests/mainSystemAppendNewRows.test.ts | 24 ++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/server/tests/mainSystemAppendNewRows.test.ts b/server/tests/mainSystemAppendNewRows.test.ts index c75f4cd..d747082 100644 --- a/server/tests/mainSystemAppendNewRows.test.ts +++ b/server/tests/mainSystemAppendNewRows.test.ts @@ -255,6 +255,30 @@ describe('已导入订单的新分配行 → 行级增量追加', () => { expect(String(appended.category_code || '')).not.toBe(''); }); + it('待分拣(45)追加:系统身份必须带 canForceEdit(真库事故的现场复刻)', async () => { + /** + * 2026-10-12 真库事故:我方单 `order_status = 45`(待分拣)+ 主系统新增一行 ⇒ + * 追加走的改明细链路在 `>= 40` 时要求 `order_force_edit`;导入侧先前没传 `canForceEdit` + * ⇒「当前状态不可修改商品明细(履约中须持「强制改单」权限)」⇒ 新分配商品静默丢失。 + * 本用例把**订单状态锁在 45**,断言系统路径确实带上了这个强制位 + * (配合 `orderManageItemsLock.test.ts` 的闸门口径:45 无强制位 = 拒绝、有 = 放行)。 + */ + // 复刻真库现场:该单处于 45(待分拣)——租户连接读回的订单状态就是它 + withTenant.mockImplementation(async (_b: string, fn: (c: unknown) => Promise) => + fn(tenantClient(45)) + ); + const outcome = await importMainSystemGroups({ + supplierCode: 'SUP001', + branchCode: 'SUP001', + userId: null, + groups: [GROUP], + }); + expect(outcome.appended).toBe(1); + const params = syncItems.mock.calls[0][0] as { canForceEdit?: boolean; operatorRoles?: string }; + expect(params.canForceEdit).toBe(true); + expect(params.operatorRoles).toBe('main_system_import'); + }); + it('追加成功后把新行的行级对照写进台账(含 our_order_item_id)', async () => { await importMainSystemGroups({ supplierCode: 'SUP001', branchCode: 'SUP001', userId: null, groups: [GROUP] });