You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
64 lines
2.0 KiB
64 lines
2.0 KiB
import { describe, expect, it } from "vitest";
|
|
import { buildCcWorkOrderFormValue } from "@/components/CcWorkOrderForm";
|
|
import { extractMailInstructions } from "@/services/parse/split-instructions";
|
|
|
|
const INTERCEPT_BODY = [
|
|
"拆柜清单更新 以此为准",
|
|
"注意:",
|
|
"1.WL103516",
|
|
"WL103616",
|
|
"以上几票需要拦截 清单中已备注",
|
|
"2.",
|
|
"WL101167",
|
|
"WL92334",
|
|
"这2票改自提",
|
|
].join("\n");
|
|
|
|
function wrapRound(ccWrap: string, body: string): string {
|
|
return [
|
|
`发件人: clx@cnwally.com.cn`,
|
|
`发送时间: 2026-06-29 ${ccWrap}`,
|
|
`收件人: date; hui`,
|
|
`抄送: ${ccWrap}`,
|
|
`主题: 拆柜清单更新:拦截-209件+拆柜清单`,
|
|
body,
|
|
].join("\n");
|
|
}
|
|
|
|
describe("work-order duplicate rounds + remarks", () => {
|
|
it("same 拦截+改自提 forwarded 3 times → one historical card", () => {
|
|
const body = [
|
|
"Dear,",
|
|
"开箱拍下里面的产品并回传照片",
|
|
"以上货物需要卡转海 麻烦贴标交付",
|
|
wrapRound("18:29 朱甜甜", INTERCEPT_BODY),
|
|
wrapRound("18:22 杨慧元; 朱甜甜", INTERCEPT_BODY),
|
|
wrapRound("18:20 王小悦; 杨慧元; 朱甜甜", INTERCEPT_BODY),
|
|
].join("\n");
|
|
|
|
const units = extractMailInstructions({
|
|
subject: "派送要求更新: 拆柜清单更新:拦截-209件+拆柜清单",
|
|
body,
|
|
filenames: [],
|
|
});
|
|
const wo = units.filter((u) => u.uiKind === "work_order");
|
|
const interceptish = wo.filter((u) => u.keywords.includes("拦截"));
|
|
expect(interceptish.length).toBe(1);
|
|
expect(interceptish[0].keywords).toEqual(
|
|
expect.arrayContaining(["拦截", "改自提"]),
|
|
);
|
|
});
|
|
|
|
it("remarks include 拦截 and 改自提 together", () => {
|
|
const v = buildCcWorkOrderFormValue({
|
|
subject: "拆柜清单更新",
|
|
body: INTERCEPT_BODY,
|
|
filenames: [],
|
|
});
|
|
expect(v.F_Remark).toMatch(/拦截/);
|
|
expect(v.F_Remark).toMatch(/改自提/);
|
|
expect(v.F_MessageContent).toMatch(/拦截/);
|
|
expect(v.F_MessageContent).toMatch(/改自提/);
|
|
});
|
|
});
|