|
|
import { describe, expect, it } from "vitest";
|
|
|
import { buildCcDoUploadFormValue } from "@/components/CcDoUploadPanel";
|
|
|
import {
|
|
|
extractContainerFromDoFilename,
|
|
|
isDoAttachmentFilename,
|
|
|
listDoFilenames,
|
|
|
} from "@/services/parse/do-upload-extract";
|
|
|
import { classifyMail } from "@/services/parse/classify";
|
|
|
import { extractMailInstructions } from "@/services/parse/split-instructions";
|
|
|
|
|
|
describe("DO upload extract WHSU8127240-DO.pdf", () => {
|
|
|
const filename = "WHSU8127240-DO.pdf";
|
|
|
|
|
|
it("recognizes filename as DO attachment", () => {
|
|
|
expect(isDoAttachmentFilename(filename)).toBe(true);
|
|
|
expect(listDoFilenames([filename, "其他.xlsx"])).toEqual([filename]);
|
|
|
});
|
|
|
|
|
|
it("extracts container from filename", () => {
|
|
|
expect(extractContainerFromDoFilename(filename)).toBe("WHSU8127240");
|
|
|
});
|
|
|
|
|
|
it("classify → DO_UPLOAD", () => {
|
|
|
const e = classifyMail({
|
|
|
subject: "请查收 DO",
|
|
|
body: "",
|
|
|
filenames: [filename],
|
|
|
});
|
|
|
expect(e.mail_type).toBe("DO_UPLOAD");
|
|
|
});
|
|
|
|
|
|
it("buildCcDoUploadFormValue prefills 柜号 + 附件", () => {
|
|
|
const v = buildCcDoUploadFormValue({
|
|
|
subject: "请查收 DO",
|
|
|
filenames: [filename],
|
|
|
});
|
|
|
expect(v.F_ContainerNo).toBe("WHSU8127240");
|
|
|
expect(v.filenames).toEqual([filename]);
|
|
|
});
|
|
|
|
|
|
it("split instructions → do_upload module", () => {
|
|
|
const units = extractMailInstructions({
|
|
|
subject: "请查收 DO:柜号 WHSU8127240",
|
|
|
body: "请查收附件 DO",
|
|
|
filenames: [filename],
|
|
|
});
|
|
|
expect(units.some((u) => u.uiKind === "do_upload")).toBe(true);
|
|
|
});
|
|
|
});
|