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] });