test(work-orders): assert empty apptTime board PATCH and refetch

EOF
This commit is contained in:
Arthur Bassi 2026-08-31 10:54:28 -03:00
parent 8b745608dc
commit 07c03e99b9
2 changed files with 63 additions and 0 deletions

View file

@ -70,6 +70,9 @@ describe("expandTablePatchToBoardFieldOps", () => {
expect(expandTablePatchToBoardFieldOps({ severity: null })).toEqual([
{ field: "severity", value: "" },
]);
expect(expandTablePatchToBoardFieldOps({ apptTime: "" })).toEqual([
{ field: "apptTime", value: "" },
]);
});
it("emits service notes modal ops in pm → extraServices → serviceNotes order", () => {

View file

@ -537,3 +537,63 @@ describe("useWorkOrderTableMutations patchField success callbacks", () => {
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,
}),
);
});
});