mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-10-07 16:19:01 +00:00
test(work-orders): assert empty apptTime board PATCH and refetch
EOF
This commit is contained in:
parent
8b745608dc
commit
07c03e99b9
2 changed files with 63 additions and 0 deletions
|
|
@ -70,6 +70,9 @@ describe("expandTablePatchToBoardFieldOps", () => {
|
||||||
expect(expandTablePatchToBoardFieldOps({ severity: null })).toEqual([
|
expect(expandTablePatchToBoardFieldOps({ severity: null })).toEqual([
|
||||||
{ field: "severity", value: "" },
|
{ field: "severity", value: "" },
|
||||||
]);
|
]);
|
||||||
|
expect(expandTablePatchToBoardFieldOps({ apptTime: "" })).toEqual([
|
||||||
|
{ field: "apptTime", value: "" },
|
||||||
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("emits service notes modal ops in pm → extraServices → serviceNotes order", () => {
|
it("emits service notes modal ops in pm → extraServices → serviceNotes order", () => {
|
||||||
|
|
|
||||||
|
|
@ -537,3 +537,63 @@ describe("useWorkOrderTableMutations patchField success callbacks", () => {
|
||||||
await waitFor(() => expect(onSuccessFirst).toHaveBeenCalledTimes(1));
|
await waitFor(() => expect(onSuccessFirst).toHaveBeenCalledTimes(1));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("useWorkOrderTableMutations apptTime clear", () => {
|
||||||
|
it("patches empty apptTime and keeps the appointment date on refetch", async () => {
|
||||||
|
const datedRow: WorkOrderTableRow = {
|
||||||
|
...BASE_ROW,
|
||||||
|
scheduledOn: "2026-06-25",
|
||||||
|
apptStart: "09:00",
|
||||||
|
apptEnd: "11:00",
|
||||||
|
apptTime: "09:00 – 11:00",
|
||||||
|
vendorId: "7",
|
||||||
|
primaryDispatchId: 10,
|
||||||
|
dispatchRowVersion: "disp-v1",
|
||||||
|
};
|
||||||
|
const clearedRow: WorkOrderTableRow = {
|
||||||
|
...datedRow,
|
||||||
|
apptStart: "",
|
||||||
|
apptEnd: "",
|
||||||
|
apptTime: "",
|
||||||
|
rowVersion: "wo-v2",
|
||||||
|
};
|
||||||
|
patchBoardField.mockReset();
|
||||||
|
patchBoardField.mockResolvedValue(clearedRow);
|
||||||
|
|
||||||
|
const onPatch = vi.fn();
|
||||||
|
const { result } = renderHook(
|
||||||
|
() =>
|
||||||
|
useWorkOrderTableMutations({
|
||||||
|
onPatch,
|
||||||
|
clearPatch: () => undefined,
|
||||||
|
getRow: () => datedRow,
|
||||||
|
}),
|
||||||
|
{ wrapper: makeWrapper() },
|
||||||
|
);
|
||||||
|
|
||||||
|
act(() => {
|
||||||
|
result.current.patchField(42, { apptTime: "" });
|
||||||
|
});
|
||||||
|
|
||||||
|
await waitFor(() =>
|
||||||
|
expect(onPatch).toHaveBeenCalledWith(
|
||||||
|
42,
|
||||||
|
expect.objectContaining({
|
||||||
|
apptTime: "",
|
||||||
|
scheduledOn: "2026-06-25",
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(patchBoardField).toHaveBeenCalledWith(
|
||||||
|
42,
|
||||||
|
expect.objectContaining({
|
||||||
|
field: "apptTime",
|
||||||
|
value: "",
|
||||||
|
workOrderVersion: "AAAAAAA=",
|
||||||
|
dispatchVersion: "disp-v1",
|
||||||
|
primaryDispatchId: 10,
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue