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.

50 lines
1.6 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

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