mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-09-30 15:03:12 +00:00
Allow empty Appt Time in wizard, table, and slide-over without blocking create or complete. Omit appointment fields without vendorId so create does not hit DispatchRequired.
96 lines
2.5 KiB
TypeScript
96 lines
2.5 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import {
|
|
draftHasScheduleDate,
|
|
getInlineCreateMissing,
|
|
INLINE_CREATE_REQ_LABELS,
|
|
inlineCreateSaveHint,
|
|
inlineCreateSiteError,
|
|
} from "@/domain/work-orders/utils/get-inline-create-missing";
|
|
|
|
describe("getInlineCreateMissing", () => {
|
|
it("does not require Appt Time for inline create", () => {
|
|
expect(
|
|
getInlineCreateMissing({
|
|
site: "BK5",
|
|
locationId: "12",
|
|
woNumber: "25001",
|
|
pocName: "Jane",
|
|
pocPhone: "555-0100",
|
|
}),
|
|
).toEqual([]);
|
|
expect(Object.keys(INLINE_CREATE_REQ_LABELS)).not.toContain("apptTime");
|
|
});
|
|
|
|
it("returns empty when Site, WO#, and POC are filled even without schedule", () => {
|
|
expect(
|
|
getInlineCreateMissing({
|
|
site: "BK5",
|
|
locationId: "12",
|
|
woNumber: "25001",
|
|
pocName: "Jane",
|
|
pocPhone: "555-0100",
|
|
}),
|
|
).toEqual([]);
|
|
});
|
|
|
|
it("accepts locationId alone as site presence", () => {
|
|
expect(
|
|
getInlineCreateMissing({
|
|
site: "",
|
|
locationId: 42,
|
|
woNumber: "25001",
|
|
pocName: "Jane",
|
|
pocPhone: "555-0100",
|
|
}),
|
|
).toEqual([]);
|
|
});
|
|
|
|
it("lists missing POC fields without requiring schedule", () => {
|
|
expect(
|
|
getInlineCreateMissing({
|
|
site: "BK5",
|
|
woNumber: "25001",
|
|
pocName: "",
|
|
pocPhone: "",
|
|
}),
|
|
).toEqual(["pocName", "pocPhone"]);
|
|
});
|
|
|
|
it("lists site and woNumber when empty", () => {
|
|
expect(getInlineCreateMissing({})).toEqual(["site", "woNumber", "pocName", "pocPhone"]);
|
|
});
|
|
});
|
|
|
|
describe("inlineCreateSaveHint", () => {
|
|
it("returns Save when ready", () => {
|
|
expect(inlineCreateSaveHint([])).toBe("Save");
|
|
});
|
|
|
|
it("lists missing labels", () => {
|
|
expect(inlineCreateSaveHint(["site", "woNumber"])).toBe("Missing: Site, WO #");
|
|
});
|
|
});
|
|
|
|
describe("inlineCreateSiteError", () => {
|
|
it("prefers site-required message when site is missing", () => {
|
|
expect(inlineCreateSiteError(["site", "pocName"])).toBe("Site is required");
|
|
});
|
|
|
|
it("surfaces contact message when only POC is missing", () => {
|
|
expect(inlineCreateSiteError(["pocName", "pocPhone"])).toBe(
|
|
"Contact name and phone are required",
|
|
);
|
|
});
|
|
});
|
|
|
|
describe("draftHasScheduleDate", () => {
|
|
it("is true for a concrete day", () => {
|
|
expect(draftHasScheduleDate({ scheduledOn: "2026-06-25" })).toBe(true);
|
|
});
|
|
|
|
it("is false for week-only", () => {
|
|
expect(
|
|
draftHasScheduleDate({ scheduledOn: "", scheduleWeekOnly: true, schedMode: "week" }),
|
|
).toBe(false);
|
|
});
|
|
});
|