mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-10-05 06:02:08 +00:00
89 lines
2.5 KiB
TypeScript
89 lines
2.5 KiB
TypeScript
|
|
import { describe, expect, it } from "vitest";
|
||
|
|
import {
|
||
|
|
effectiveCompany,
|
||
|
|
effectivePoc,
|
||
|
|
effectiveSite,
|
||
|
|
effectiveSitePlace,
|
||
|
|
} from "@/domain/work-orders/utils/effective-completion-snapshot";
|
||
|
|
|
||
|
|
describe("effective completion snapshot", () => {
|
||
|
|
it("prefers frozen values for a completed work order", () => {
|
||
|
|
const frozenSite = { code: "BK5", city: "Chicago", state: "IL" };
|
||
|
|
expect(effectiveSite({ status: "Completed", frozenSite })).toEqual(frozenSite);
|
||
|
|
expect(effectiveSitePlace({ status: "Completed", frozenSite })).toEqual({
|
||
|
|
city: "Chicago",
|
||
|
|
state: "IL",
|
||
|
|
});
|
||
|
|
|
||
|
|
expect(
|
||
|
|
effectiveCompany({
|
||
|
|
status: "Completed",
|
||
|
|
company: "Live Co",
|
||
|
|
tech: "Live Tech",
|
||
|
|
techPhone: "222",
|
||
|
|
frozenCompany: { name: "Frozen Co", contactName: "Frozen Tech", phone: "111" },
|
||
|
|
}),
|
||
|
|
).toMatchObject({ name: "Frozen Co", contactName: "Frozen Tech", phone: "111" });
|
||
|
|
|
||
|
|
expect(
|
||
|
|
effectivePoc({
|
||
|
|
status: "Completed",
|
||
|
|
pocName: "Live POC",
|
||
|
|
pocPhone: "222",
|
||
|
|
pocNotes: "live",
|
||
|
|
additionalContacts: [],
|
||
|
|
frozenPoc: {
|
||
|
|
contacts: [{ name: "Frozen POC", phone: "111" }],
|
||
|
|
notes: "frozen",
|
||
|
|
},
|
||
|
|
}),
|
||
|
|
).toEqual({
|
||
|
|
contacts: [{ name: "Frozen POC", phone: "111" }],
|
||
|
|
notes: "frozen",
|
||
|
|
});
|
||
|
|
});
|
||
|
|
|
||
|
|
it("uses live values while open or when a completed snapshot is missing", () => {
|
||
|
|
expect(effectiveSite({ status: "Scheduled", frozenSite: { city: "Old" } })).toBeUndefined();
|
||
|
|
expect(effectiveSitePlace({ status: "Completed" })).toBeNull();
|
||
|
|
expect(
|
||
|
|
effectiveCompany({
|
||
|
|
status: "Scheduled",
|
||
|
|
company: "Live Co",
|
||
|
|
tech: "Live Tech",
|
||
|
|
techPhone: "222",
|
||
|
|
frozenCompany: { name: "Old Co" },
|
||
|
|
}),
|
||
|
|
).toMatchObject({ name: "Live Co", contactName: "Live Tech", phone: "222" });
|
||
|
|
expect(
|
||
|
|
effectivePoc({
|
||
|
|
status: "Completed",
|
||
|
|
pocName: "Live POC",
|
||
|
|
pocPhone: "222",
|
||
|
|
pocNotes: "live",
|
||
|
|
additionalContacts: [{ name: "Backup", phone: "333" }],
|
||
|
|
}),
|
||
|
|
).toEqual({
|
||
|
|
contacts: [
|
||
|
|
{ name: "Live POC", phone: "222" },
|
||
|
|
{ name: "Backup", phone: "333" },
|
||
|
|
],
|
||
|
|
notes: "live",
|
||
|
|
});
|
||
|
|
});
|
||
|
|
|
||
|
|
it("treats missing additional contacts as an empty live contact list", () => {
|
||
|
|
expect(
|
||
|
|
effectivePoc({
|
||
|
|
status: "Scheduled",
|
||
|
|
pocName: "Primary",
|
||
|
|
pocPhone: "111",
|
||
|
|
pocNotes: "",
|
||
|
|
}),
|
||
|
|
).toEqual({
|
||
|
|
contacts: [{ name: "Primary", phone: "111" }],
|
||
|
|
notes: "",
|
||
|
|
});
|
||
|
|
});
|
||
|
|
});
|