contract-draft.test.ts 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439
  1. // @vitest-environment jsdom
  2. import { describe, expect, it } from "vitest";
  3. import { buildContractWrite, businessToday, changedWriteFields, contractEndFromMonths, emptyDraft, emptyItem, frozenChanges, renewalPrefill, renewalStartOf, resolveReplacementSelection } from "../contract-draft";
  4. import type { ContractEditScope, ReplacementCandidate } from "../../lib/api/types";
  5. /** 基线:一份可正常保存的未开通合同草稿。 */
  6. const baseline = () => {
  7. const draft = emptyDraft();
  8. return {
  9. ...draft,
  10. amount: "10800.00",
  11. contractType: "new",
  12. serviceMonths: "12",
  13. start: "2026-01-01",
  14. end: "2026-12-31",
  15. agent: "张三",
  16. agentPhone: "13800000000",
  17. /** 交接日期=签署日期(2026-11-19):草稿只留 signDate,写口按 agent_handover_on 同值落库。 */
  18. signDate: "2026-01-05",
  19. items: [{ ...emptyItem(), planId: "CP-000001", planName: "标准套餐", quantity: 1, exits: ["香港"] }],
  20. };
  21. };
  22. /** 两轴全冻(已开通/已到期且超出更正期)。 */
  23. const allLocked: ContractEditScope = {
  24. state: "opened",
  25. billing: { editable: false, reason: "opened" },
  26. archive: { editable: false, reason: "opened" },
  27. grace_until: null,
  28. };
  29. /** 只冻计费轴(已生效未开通)。 */
  30. const billingOnlyLocked: ContractEditScope = {
  31. state: "effective_unopened",
  32. billing: { editable: false, reason: "grace_expired" },
  33. archive: { editable: true, reason: null },
  34. grace_until: null,
  35. };
  36. /** 两轴全开(未生效/录后 72h 内)。 */
  37. const allOpen: ContractEditScope = {
  38. state: "pending",
  39. billing: { editable: true, reason: null },
  40. archive: { editable: true, reason: null },
  41. grace_until: "2026-11-18T21:00:00+08:00",
  42. };
  43. describe("frozenChanges · 编辑口径守卫(两轴独立判定)", () => {
  44. it("草稿与基线一致 ⇒ 不算越界(其余字段照样可改)", () => {
  45. const base = baseline();
  46. expect(frozenChanges(base, base, allLocked)).toEqual([]);
  47. expect(frozenChanges({ ...base, agent: "张三" }, base, allLocked)).toEqual([]);
  48. });
  49. it("金额/服务期/期间各自命中,且一次列出全部越界项", () => {
  50. const base = baseline();
  51. expect(frozenChanges({ ...base, amount: "12000.00" }, base, allLocked)).toEqual(["合同金额"]);
  52. expect(frozenChanges({ ...base, serviceMonths: "3" }, base, allLocked)).toEqual(["服务期(月)"]);
  53. expect(frozenChanges({ ...base, start: "2026-02-01" }, base, allLocked)).toEqual(["合同生效日"]);
  54. expect(frozenChanges({ ...base, end: "2027-12-31" }, base, allLocked)).toEqual(["合同结束日"]);
  55. expect(frozenChanges({ ...base, amount: "1", start: "2026-02-01", end: "2027-01-01" }, base, allLocked)).toEqual([
  56. "合同金额",
  57. "合同生效日",
  58. "合同结束日",
  59. ]);
  60. });
  61. it("服务构成按条目内容比较:改档位/数量/年价被拦", () => {
  62. const base = baseline();
  63. expect(frozenChanges({ ...base, items: [{ ...base.items[0], quantity: 2 }] }, base, allLocked)).toEqual(["服务构成"]);
  64. expect(frozenChanges({ ...base, items: [{ ...base.items[0], planFamily: "addon" }] }, base, allLocked)).toEqual(["服务构成"]);
  65. // 2026-11-17:IP 条目不属草稿(配置已下线)⇒ 只按服务构成判计费轴。
  66. });
  67. it("档案轴:已冻结时外部单号/签署日期/运营商经办人被拦", () => {
  68. const base = baseline();
  69. expect(frozenChanges({ ...base, externalNo: "WB-NEW" }, base, allLocked)).toEqual(["外部单号"]);
  70. expect(frozenChanges({ ...base, contractType: "renew" }, base, allLocked)).toEqual(["合同类型"]);
  71. expect(frozenChanges({ ...base, signDate: "2026-02-02" }, base, allLocked)).toEqual(["签署日期"]);
  72. // 运营商经办人三件套=交接单上的商务档案,与签署日期同轴;⛔ 与「录入账号」混用。
  73. expect(frozenChanges({ ...base, agent: "李四" }, base, allLocked)).toEqual(["运营商经办人姓名"]);
  74. expect(frozenChanges({ ...base, agentPhone: "13900000000" }, base, allLocked)).toEqual(["运营商经办人电话"]);
  75. expect(frozenChanges({ ...base, agentOrg: "华东运营中心" }, base, allLocked)).toEqual(["运营商经办人机构"]);
  76. });
  77. it("已生效未开通:只冻计费轴,外部单号与运营商经办人仍可改", () => {
  78. const base = baseline();
  79. expect(frozenChanges({ ...base, amount: "1" }, base, billingOnlyLocked)).toEqual(["合同金额"]);
  80. expect(frozenChanges({ ...base, items: [{ ...base.items[0], quantity: 2 }] }, base, billingOnlyLocked)).toEqual(["服务构成"]);
  81. expect(frozenChanges({ ...base, externalNo: "WB-NEW" }, base, billingOnlyLocked)).toEqual([]);
  82. expect(frozenChanges({ ...base, agent: "李四" }, base, billingOnlyLocked)).toEqual([]);
  83. });
  84. it("两轴全开:任何改动都不拦", () => {
  85. const base = baseline();
  86. expect(frozenChanges({ ...base, amount: "1", externalNo: "WB-NEW" }, base, allOpen)).toEqual([]);
  87. });
  88. it("口径缺席(旧后端未下发 edit_scope)⇒ 不在前端臆断冻结", () => {
  89. const base = baseline();
  90. expect(frozenChanges({ ...base, amount: "1" }, base, null)).toEqual([]);
  91. });
  92. });
  93. describe("changedWriteFields · 只提交变了的字段", () => {
  94. it("整份未改 ⇒ 空载荷(后端按键缺席=保持现值)", () => {
  95. const base = baseline();
  96. expect(changedWriteFields(base, base)).toEqual({});
  97. });
  98. it("只改外部单号 ⇒ 载荷只带 external_no", () => {
  99. const base = baseline();
  100. expect(changedWriteFields({ ...base, externalNo: "WB-NEW" }, base)).toEqual({ externalNo: "WB-NEW" });
  101. });
  102. it("只有条目变了才带 service_items", () => {
  103. const base = baseline();
  104. const items = changedWriteFields({ ...base, items: [{ ...base.items[0], quantity: 2 }] }, base);
  105. expect(Object.keys(items)).toEqual(["serviceItems"]);
  106. });
  107. });
  108. /** 候选行(只填与选择矩阵相关的两列,其余置空)。 */
  109. const candidate = (id: string, customized = false): ReplacementCandidate => ({
  110. subscription_id: id,
  111. status: "active",
  112. customized,
  113. });
  114. describe("resolveReplacementSelection · 候选选择矩阵(2026-11-17)", () => {
  115. it("0 个候选 ⇒ 不替换(按新订阅开通)", () => {
  116. expect(resolveReplacementSelection([], "SUB-1", false)).toEqual({ id: "", customized: false });
  117. });
  118. it("1 个候选 ⇒ 自动选中;显式退出后保持不替换", () => {
  119. expect(resolveReplacementSelection([candidate("SUB-1")], "", false)).toEqual({ id: "SUB-1", customized: false });
  120. expect(resolveReplacementSelection([candidate("SUB-1")], "SUB-1", false)).toEqual({ id: "SUB-1", customized: false });
  121. expect(resolveReplacementSelection([candidate("SUB-1")], "SUB-1", true)).toEqual({ id: "", customized: false });
  122. });
  123. it("多个候选 ⇒ 不预选,只沿用仍有效的已选", () => {
  124. const list = [candidate("SUB-1"), candidate("SUB-2", true)];
  125. expect(resolveReplacementSelection(list, "", false)).toEqual({ id: "", customized: false });
  126. expect(resolveReplacementSelection(list, "SUB-2", false)).toEqual({ id: "SUB-2", customized: true });
  127. /** 已选掉出候选(换了档位/出口/客户)⇒ 归零,⛔ 带一个不存在的订阅号提交。 */
  128. expect(resolveReplacementSelection(list, "SUB-9", false)).toEqual({ id: "", customized: false });
  129. });
  130. });
  131. describe("contractEndFromMonths · 合同结束日推算(2026-11-19:生效日+服务期月数−1 天)", () => {
  132. it("结束日=生效日+服务期(月)−1 天", () => {
  133. expect(contractEndFromMonths("2026-11-17", 12)).toBe("2027-11-16");
  134. expect(contractEndFromMonths("2026-11-17", "12")).toBe("2027-11-16");
  135. expect(contractEndFromMonths("2026-11-17", 3)).toBe("2027-02-16");
  136. expect(contractEndFromMonths("2026-11-17", 1)).toBe("2026-12-16");
  137. expect(contractEndFromMonths("2026-11-17", 36)).toBe("2029-11-16");
  138. expect(contractEndFromMonths("2026-11-17", 60)).toBe("2031-11-16");
  139. });
  140. it("该月无对应日先取月末再减一天(与后端 add_months_clamped 同式)", () => {
  141. expect(contractEndFromMonths("2026-01-31", 1)).toBe("2026-02-27");
  142. expect(contractEndFromMonths("2028-02-29", 12)).toBe("2029-02-27");
  143. expect(contractEndFromMonths("2026-12-01", 3)).toBe("2027-02-28");
  144. });
  145. it("服务期非法(0/601/小数/空)或生效日缺失 ⇒ 空串(⛔ 留陈旧值)", () => {
  146. expect(contractEndFromMonths("2026-11-17", 0)).toBe("");
  147. expect(contractEndFromMonths("2026-11-17", 601)).toBe("");
  148. expect(contractEndFromMonths("2026-11-17", 1.5)).toBe("");
  149. expect(contractEndFromMonths("2026-11-17", "")).toBe("");
  150. expect(contractEndFromMonths("", 12)).toBe("");
  151. expect(contractEndFromMonths("2026/11/17", 12)).toBe("");
  152. });
  153. });
  154. describe("businessToday · 业务当天按 Asia/Shanghai", () => {
  155. it("UTC 晚间仍按北京时间取日(⛔ 用 toISOString 跳日)", () => {
  156. expect(businessToday(new Date("2026-11-17T15:59:00Z"))).toBe("2026-11-17");
  157. expect(businessToday(new Date("2026-11-17T16:30:00Z"))).toBe("2026-11-18");
  158. });
  159. });
  160. describe("renewalPrefill · 续签带入(2026-11-17)", () => {
  161. const oldRow = {
  162. contract_id: "CT-000003",
  163. customer_id: "KL-0001-000001",
  164. contract_no: "KL-0001-000001-C1",
  165. external_no: "EXT-9",
  166. status: "effective",
  167. contract_amount_cents: 1_080_000,
  168. contract_type: "renew",
  169. sign_date: "2024-12-28",
  170. service_months: 12,
  171. start_date: "2025-01-01",
  172. end_date: "2025-12-31",
  173. agent_name: "李四",
  174. agent_mobile: "13900000000",
  175. agent_handover_on: "2025-01-03",
  176. agent_org: "省公司",
  177. attachment_url: "klt/contract/attachment/old.pdf",
  178. row_version: "3",
  179. created_at: "2025-01-01T00:00:00Z",
  180. service_items: [
  181. { item_id: "SI-000009", plan_id: "CP-000001", plan_name: "标准套餐", item_family: "link", quantity: 1, line_exits: ["香港"] },
  182. { item_id: "SI-000010", plan_id: "CP-000009", plan_name: "单独境外 IP", item_family: "addon", quantity: 2, line_exits: ["新加坡"] },
  183. ],
  184. };
  185. it("带出金额/服务期/条目/经办人;合同类型置为续签;条目主键清空(新建态由服务端发号)", () => {
  186. const p = renewalPrefill(oldRow as never);
  187. expect(p).not.toBeNull();
  188. if (!p) return;
  189. expect(p.amount).toBe("10800.00");
  190. expect(p.serviceMonths).toBe("12");
  191. expect(p.contractType).toBe("renew");
  192. expect(p.agent).toBe("李四");
  193. expect(p.agentPhone).toBe("13900000000");
  194. expect(p.agentOrg).toBe("省公司");
  195. expect(p.items).toHaveLength(2);
  196. expect(p.items.every((item) => item.itemId === null)).toBe(true);
  197. expect(p.items.map((item) => item.planFamily)).toEqual(["link", "addon"]);
  198. expect(p.items[1].quantity).toBe(2);
  199. });
  200. it("⛔ 带编号/外部单号/结束日/附件/签署日期;生效日取旧止期次日(不早于业务当天)", () => {
  201. const p = renewalPrefill(oldRow as never) as unknown as Record<string, unknown>;
  202. expect(p).not.toBeNull();
  203. for (const key of ["contractNo", "externalNo", "end", "attachmentUrl", "signDate"]) {
  204. expect(p[key]).toBeUndefined();
  205. }
  206. /** 2026-11-17 四轮:新合同接在旧期间之后,旧合同已过期 ⇒ 取业务当天(⛔ 倒签)。 */
  207. expect(renewalStartOf("2025-12-31", "2026-11-17")).toBe("2026-11-17");
  208. expect(renewalStartOf("2026-11-30", "2026-11-17")).toBe("2026-12-01");
  209. expect(typeof p.start).toBe("string");
  210. });
  211. it("旧合同读不到 ⇒ 返回 null,由页面退回手工录入", () => {
  212. expect(renewalPrefill(null)).toBeNull();
  213. });
  214. });
  215. describe("buildContractWrite · 合同期间(2026-11-17:结束日锁定为推算值)", () => {
  216. it("缺生效日 ⇒ 红显生效日并给原话(⛔ 报一句「生效日与结束日」)", () => {
  217. const built = buildContractWrite({ ...baseline(), start: "", end: "" });
  218. expect(built.ok).toBe(false);
  219. if (built.ok) return;
  220. expect(built.error).toBe("请选择生效日");
  221. expect(built.fieldError?.key).toBe("start");
  222. });
  223. it("结束日按草稿原样提交(页面只在生效日/服务期变化时重算)", () => {
  224. const draft = { ...baseline(), start: "2026-11-17", serviceMonths: "12", end: contractEndFromMonths("2026-11-17", 12) };
  225. const built = buildContractWrite(draft);
  226. expect(built.ok).toBe(true);
  227. if (!built.ok) return;
  228. expect(built.write.endDate).toBe("2027-11-16");
  229. });
  230. });
  231. describe("buildContractWrite · 逐条替换 succession 载荷", () => {
  232. const withReplacement = (patch: Partial<ReturnType<typeof emptyItem>> = {}) => {
  233. const base = baseline();
  234. return {
  235. ...base,
  236. items: [{ ...base.items[0], replacesSubscriptionId: "SUB-000041", ...patch }],
  237. };
  238. };
  239. it("选中原订阅 ⇒ 条目带 succession(只带订阅号,起止日由后端派生)", () => {
  240. const built = buildContractWrite(withReplacement());
  241. expect(built.ok).toBe(true);
  242. if (!built.ok) return;
  243. expect(built.write.serviceItems[0].succession).toEqual({ replaces_subscription_id: "SUB-000041" });
  244. });
  245. it("未选中 ⇒ 条目不带 succession(按新订阅开通)", () => {
  246. const built = buildContractWrite(baseline());
  247. expect(built.ok).toBe(true);
  248. if (!built.ok) return;
  249. expect(built.write.serviceItems[0].succession).toBeUndefined();
  250. });
  251. it("定制档须显式确认;确认后放行", () => {
  252. const blocked = buildContractWrite(withReplacement({ replacementCustomized: true }));
  253. expect(blocked.ok).toBe(false);
  254. if (!blocked.ok) expect(blocked.error).toContain("定制档");
  255. const ok = buildContractWrite(withReplacement({ replacementCustomized: true, replacementConfirmed: true }));
  256. expect(ok.ok).toBe(true);
  257. });
  258. it("替换时一条条目只生一份订阅:档位数量须为 1", () => {
  259. const blocked = buildContractWrite(withReplacement({ quantity: 2 }));
  260. expect(blocked.ok).toBe(false);
  261. if (!blocked.ok) expect(blocked.error).toContain("数量须为 1");
  262. });
  263. });
  264. describe("checkItemExits · 出口单选(2026-11-17)", () => {
  265. it("多出口 ⇒ 点名条目并提示只保留 1 个", () => {
  266. const base = baseline();
  267. const built = buildContractWrite({ ...base, items: [{ ...base.items[0], exits: ["香港", "德国"] }] });
  268. expect(built.ok).toBe(false);
  269. if (!built.ok) {
  270. expect(built.error).toContain("条目 1");
  271. expect(built.error).toContain("单选");
  272. }
  273. });
  274. });
  275. describe("buildContractWrite · 交付形态只决定份数(D-15/D-18)", () => {
  276. /**
  277. * P1 起附加项必须挂在跨境链路条目下(D-7)⇒ 造「父链路 + 子附加」两行。
  278. * `parentKey` 是草稿的本地身份,不是数组下标。
  279. */
  280. const withAddon = (quantity: number) => {
  281. const base = baseline();
  282. const parent = { ...base.items[0], planFamily: "link" };
  283. const child = { ...emptyItem(parent.key), planFamily: "addon", planId: "CP-ADDON", quantity, exits: ["香港"] };
  284. return { ...base, items: [parent, child] };
  285. };
  286. const withFamily = (family: string, quantity: number) => {
  287. const base = baseline();
  288. return { ...base, items: [{ ...base.items[0], planFamily: family, quantity }] };
  289. };
  290. it("link 档份数恒 1:填 2 即拦下并点名跨境链路", () => {
  291. const blocked = buildContractWrite(withFamily("link", 2));
  292. expect(blocked.ok).toBe(false);
  293. if (!blocked.ok) expect(blocked.error).toContain("跨境链路档:份数恒为 1");
  294. });
  295. it("addon 档份数可 > 1:3 份放行,等于 3 个 IP 权益", () => {
  296. const built = buildContractWrite(withAddon(3));
  297. expect(built.ok).toBe(true);
  298. if (built.ok) expect(built.write.serviceItems[1].quantity).toBe(3);
  299. });
  300. it("份数 0/小数一律拦(两种形态同一句)", () => {
  301. for (const quantity of [0, 1.5]) {
  302. const blocked = buildContractWrite(withAddon(quantity));
  303. expect(blocked.ok).toBe(false);
  304. if (!blocked.ok) expect(blocked.error).toContain("正整数");
  305. }
  306. });
  307. it("条目载荷只有 item_id/plan_id/quantity/line_exits:⛔ 带价格、带宽、账号数、item_kind", () => {
  308. const base = baseline();
  309. const built = buildContractWrite({
  310. ...base,
  311. items: [{ ...base.items[0], planFamily: "link", quantity: 1, exits: ["美国"] }],
  312. });
  313. expect(built.ok).toBe(true);
  314. if (!built.ok) return;
  315. const item = built.write.serviceItems[0] as Record<string, unknown>;
  316. expect(Object.keys(item).sort()).toEqual(["item_id", "line_exits", "plan_id", "quantity"]);
  317. for (const banned of [
  318. "item_kind",
  319. "item_family",
  320. "annual_price_cents",
  321. "monthly_settle_cents",
  322. "account_count",
  323. "bandwidth_up_mbps",
  324. "bandwidth_down_mbps",
  325. ]) {
  326. expect(item[banned]).toBeUndefined();
  327. }
  328. });
  329. });
  330. describe("buildContractWrite · P1 树形与增量(D-7/D-9)", () => {
  331. it("附加项未挂父 ⇒ 拦下并点名 D-7", () => {
  332. const base = baseline();
  333. const built = buildContractWrite({ ...base, items: [{ ...base.items[0], planFamily: "addon", exits: ["香港"] }] });
  334. expect(built.ok).toBe(false);
  335. if (!built.ok) expect(built.error).toContain("必须挂在某条跨境链路条目下");
  336. });
  337. it("父不是链路(附加挂附加)⇒ 拦下", () => {
  338. const base = baseline();
  339. const link = { ...base.items[0], planFamily: "link", exits: ["香港"] };
  340. const addon = { ...emptyItem(link.key), planFamily: "addon", planId: "CP-A", exits: ["香港"] };
  341. const child = { ...emptyItem(addon.key), planFamily: "addon", planId: "CP-B", exits: ["香港"] };
  342. const built = buildContractWrite({ ...base, items: [link, addon, child] });
  343. expect(built.ok).toBe(false);
  344. if (!built.ok) expect(built.error).toContain("必须是跨境链路");
  345. });
  346. it("子行出口不在父行出口内 ⇒ 拦下", () => {
  347. const base = baseline();
  348. const parent = { ...base.items[0], planFamily: "link", exits: ["香港"] };
  349. const child = { ...emptyItem(parent.key), planFamily: "addon", planId: "CP-A", exits: ["美国"] };
  350. const built = buildContractWrite({ ...base, items: [parent, child] });
  351. expect(built.ok).toBe(false);
  352. if (!built.ok) expect(built.error).toContain("不在父条目");
  353. });
  354. it("父是本次新建 ⇒ 用 0 基 serves_item_index(父已落库才用 serves_item_id)", () => {
  355. const base = baseline();
  356. const parent = { ...base.items[0], planFamily: "link", itemId: null };
  357. const child = { ...emptyItem(parent.key), planFamily: "addon", planId: "CP-A", exits: ["香港"] };
  358. const built = buildContractWrite({ ...base, items: [parent, child] });
  359. expect(built.ok).toBe(true);
  360. if (!built.ok) return;
  361. expect(built.write.serviceItems[1].serves_item_index).toBe(0);
  362. expect(built.write.serviceItems[1].serves_item_id).toBeUndefined();
  363. const saved = buildContractWrite({ ...base, items: [{ ...parent, itemId: "SI-000001" }, child] });
  364. expect(saved.ok).toBe(true);
  365. if (saved.ok) expect(saved.write.serviceItems[1].serves_item_id).toBe("SI-000001");
  366. });
  367. it("增量条目:带 item_mode/ref_subscription_id,且 ⛔ 挂 serves_item_id", () => {
  368. const base = baseline();
  369. const item = { ...emptyItem(null, "increment"), planFamily: "addon", planId: "CP-A", quantity: 3, exits: ["香港"], refSubscriptionId: "SUB-1" };
  370. const built = buildContractWrite({ ...base, increment: true, contractType: "expand", items: [item] });
  371. expect(built.ok).toBe(true);
  372. if (!built.ok) return;
  373. const payload = built.write.serviceItems[0];
  374. expect(payload.item_mode).toBe("increment");
  375. expect(payload.ref_subscription_id).toBe("SUB-1");
  376. expect(payload.serves_item_id).toBeUndefined();
  377. expect(payload.serves_item_index).toBeUndefined();
  378. });
  379. it("增量条目缺引用订阅 ⇒ 拦下(D-9)", () => {
  380. const base = baseline();
  381. const item = { ...emptyItem(null, "increment"), planFamily: "addon", planId: "CP-A", exits: ["香港"] };
  382. const built = buildContractWrite({ ...base, increment: true, contractType: "expand", items: [item] });
  383. expect(built.ok).toBe(false);
  384. if (!built.ok) expect(built.error).toContain("须引用本客户一条在期跨境链路订阅");
  385. });
  386. it("增量合同 ⛔ 把链路条目改成 increment(D-9:增量只补附加项)", () => {
  387. const base = baseline();
  388. const bad = buildContractWrite({ ...base, increment: true, contractType: "expand", items: [{ ...base.items[0], planFamily: "link", itemMode: "increment", refSubscriptionId: "SUB-1" }] });
  389. expect(bad.ok).toBe(false);
  390. if (!bad.ok) expect(bad.error).toContain("只能补附加项");
  391. });
  392. });