import { describe, expect, it } from "vitest"; import { buildMailIntent } from "@/services/parse/mail-intent"; describe("mail-intent structured facts", () => { it("label mail → short narrative + discrete facts, no body dump", () => { const intent = buildMailIntent({ mailType: "INSTRUCTION_LABEL", subject: "原箱号YT2604021091=FBA199R49LD6-MDW2=76件换标操作指令", body: `【样例还原】 发件人:a@b.com ${"超长正文".repeat(40)} 柜号 WHSU6227512 仓库 HIA1`, filenames: ["换标清单.xlsx", "覆盖贴.pdf"], shipments: [ { row_index: 1, row_status: "VALID", F_ShipmentID: "YT2604021091", F_FBAID: "FBA199R49LD6", F_FBACode: "MDW2", F_CTNS: 76, F_Remark: "304PCS", }, ], containerNo: "WHSU6227512", }); expect(intent.narrative.length).toBeLessThan(80); expect(intent.content_hint.length).toBeLessThanOrEqual(48); expect(intent.facts.some((f) => f.label === "柜号")).toBe(true); expect(intent.facts.some((f) => f.label === "派送仓" && f.value === "MDW2")).toBe( true, ); expect(intent.attachment_role).not.toMatch(/换标清单\.xlsx/); expect(intent.operation).not.toMatch(/【样例还原】/); }); });