import { describe, expect, it } from "vitest"; import { freightClassOptionMatches, ltlAccessorialDisplayText, ltlAccessorialIsPickupSection, ltlAccessorialLabelMatches, normalizeOpenDeckSubtypeQuery, OPEN_DECK_TYPE_SELECT_SELECTOR, openDeckSelectionOk, } from "@/workers/rpa/priority1/form-interactions"; describe("priority1 form-interactions", () => { it("Freight Class 选项匹配含 Not Sure", () => { expect(freightClassOptionMatches("70", "70")).toBe(true); expect(freightClassOptionMatches("I'm Not Sure", "Not Sure")).toBe(true); expect(freightClassOptionMatches("400", "70")).toBe(false); }); it("Open Deck 子类型别名归一", () => { expect(normalizeOpenDeckSubtypeQuery("Flatbed")).toBe("Foot Flatbed"); expect(normalizeOpenDeckSubtypeQuery("48 Foot Flatbed")).toBe("48 Foot Flatbed"); expect(normalizeOpenDeckSubtypeQuery("Goose Neck RGN")).toBe("Removable Gooseneck"); }); it("Open Deck 选中判定", () => { expect(openDeckSelectionOk("48 Foot Flatbed", "Flatbed")).toBe(true); expect(openDeckSelectionOk("Removable Gooseneck", "Removable Gooseneck")).toBe(true); expect(openDeckSelectionOk("", "Flatbed")).toBe(false); }); it("Open Deck Type 录制 selector", () => { expect(OPEN_DECK_TYPE_SELECT_SELECTOR).toBe("#PickupLocation3"); }); it("LTL 附加服务 label 匹配", () => { expect(ltlAccessorialLabelMatches("Liftgate at Pickup", "Liftgate at Pickup")).toBe(true); expect(ltlAccessorialLabelMatches(" Inside Pickup ", "Inside Pickup")).toBe(true); expect(ltlAccessorialLabelMatches("Inside Delivery", "Inside Pickup")).toBe(false); expect(ltlAccessorialLabelMatches("Liftgate at Delivery", "Liftgate at Pickup")).toBe(false); }); it("LTL 附加 canonical → 页面文案", () => { expect(ltlAccessorialDisplayText("Limited Access Pickup")).toBe("Limited Access"); expect(ltlAccessorialDisplayText("Inside Pickup")).toBe("Inside Pickup"); expect(ltlAccessorialIsPickupSection("Liftgate at Pickup")).toBe(true); expect(ltlAccessorialIsPickupSection("Hazardous Material")).toBe(false); }); });