mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-10-07 16:19:01 +00:00
Compare commits
No commits in common. "d8da3a50483f38ee50b1d7d0e5ccdaa7d3c824b1" and "4c9f8b7d81ca26fb9fa8e4d9f9a06aa2fa492f32" have entirely different histories.
d8da3a5048
...
4c9f8b7d81
5 changed files with 2 additions and 166 deletions
|
|
@ -42,7 +42,6 @@ const LOCAL_ONLY_KEYS = new Set<keyof WorkOrderTablePatch>([
|
|||
"originalDate",
|
||||
/** Optimistic overlay only — backend owns isAddOn after schedule ops (SH-184). */
|
||||
"isAddOn",
|
||||
"primaryDispatchStatus",
|
||||
]);
|
||||
|
||||
export function isLocalOnlyTablePatch(patch: WorkOrderTablePatch): boolean {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import type { WorkOrderTableRow } from "@/domain/work-orders/types/work-order-table-row";
|
||||
import type { WorkOrderTablePatch } from "@/domain/work-orders/types/work-order-table-row";
|
||||
|
||||
export type VendorAssignmentFields = {
|
||||
vendorId: string;
|
||||
|
|
@ -7,12 +7,7 @@ export type VendorAssignmentFields = {
|
|||
techPhone: string;
|
||||
};
|
||||
|
||||
export type VendorTablePatch = Pick<
|
||||
WorkOrderTableRow,
|
||||
"vendorId" | "company" | "tech" | "techPhone" | "primaryDispatchStatus"
|
||||
>;
|
||||
|
||||
export function toVendorTablePatch(fields: VendorAssignmentFields): VendorTablePatch {
|
||||
export function toVendorTablePatch(fields: VendorAssignmentFields): WorkOrderTablePatch {
|
||||
return {
|
||||
vendorId: fields.vendorId,
|
||||
company: fields.company,
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ import {
|
|||
isLocalOnlyTablePatch,
|
||||
mapDocStatusToApi,
|
||||
} from "@/domain/work-orders/mappers/work-order-board-patch-mapper";
|
||||
import { toVendorTablePatch } from "@/domain/work-orders/utils/vendor-assignment-patch";
|
||||
|
||||
describe("mapDocStatusToApi", () => {
|
||||
it("maps NN to NotNeeded", () => {
|
||||
|
|
@ -26,10 +25,6 @@ describe("isLocalOnlyTablePatch", () => {
|
|||
it("does not treat site as local-only", () => {
|
||||
expect(isLocalOnlyTablePatch({ site: "BK5" })).toBe(false);
|
||||
});
|
||||
|
||||
it("treats primaryDispatchStatus overlay as local-only", () => {
|
||||
expect(isLocalOnlyTablePatch({ primaryDispatchStatus: "" })).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe("expandTablePatchToBoardFieldOps", () => {
|
||||
|
|
@ -141,17 +136,6 @@ describe("expandTablePatchToBoardFieldOps", () => {
|
|||
}),
|
||||
).toEqual([{ field: "vendorId", value: "7" }]);
|
||||
|
||||
expect(
|
||||
expandTablePatchToBoardFieldOps(
|
||||
toVendorTablePatch({
|
||||
vendorId: "9",
|
||||
company: "New Co",
|
||||
tech: "Pat",
|
||||
techPhone: "555",
|
||||
}),
|
||||
),
|
||||
).toEqual([{ field: "vendorId", value: "9" }]);
|
||||
|
||||
expect(
|
||||
expandTablePatchToBoardFieldOps({
|
||||
site: "BK5",
|
||||
|
|
|
|||
|
|
@ -25,11 +25,6 @@ import {
|
|||
applySchedulePatch,
|
||||
useWorkOrderTableMutations,
|
||||
} from "@/domain/work-orders/use-cases/use-work-order-table-mutations";
|
||||
import { toVendorTablePatch } from "@/domain/work-orders/utils/vendor-assignment-patch";
|
||||
import {
|
||||
getClosabilityGaps,
|
||||
tableRowToClosabilityInput,
|
||||
} from "@/domain/work-orders/utils/wo-closability";
|
||||
|
||||
function delay(ms: number): Promise<void> {
|
||||
return new Promise((resolve) => setTimeout(resolve, ms));
|
||||
|
|
@ -350,116 +345,3 @@ describe("useWorkOrderTableMutations schedule isAddOn from BE", () => {
|
|||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("useWorkOrderTableMutations vendor assignment round-trip", () => {
|
||||
let rowState: WorkOrderTableRow;
|
||||
|
||||
beforeEach(() => {
|
||||
getById.mockReset();
|
||||
update.mockReset();
|
||||
patchBoardField.mockReset();
|
||||
rowState = {
|
||||
...BASE_ROW,
|
||||
vendorId: "1",
|
||||
company: "",
|
||||
tech: "",
|
||||
completedDate: "2026-07-15",
|
||||
docStatus: "Yes",
|
||||
mediaCount: 1,
|
||||
woNumber: "20260623001",
|
||||
primaryDispatchStatus: "Refused",
|
||||
primaryDispatchId: 10,
|
||||
dispatchRowVersion: "disp-v1",
|
||||
};
|
||||
});
|
||||
|
||||
it("keeps Company off the gap list when vendor PATCH returns a Pending assignment", async () => {
|
||||
const returnedRow: WorkOrderTableRow = {
|
||||
...rowState,
|
||||
vendorId: "9",
|
||||
company: "New Co",
|
||||
primaryDispatchStatus: "Pending",
|
||||
primaryDispatchId: 11,
|
||||
};
|
||||
patchBoardField.mockResolvedValue(returnedRow);
|
||||
|
||||
const onPatch = vi.fn();
|
||||
const { result } = renderHook(
|
||||
() =>
|
||||
useWorkOrderTableMutations({
|
||||
onPatch,
|
||||
clearPatch: () => undefined,
|
||||
getRow: () => rowState,
|
||||
}),
|
||||
{ wrapper: makeWrapper() },
|
||||
);
|
||||
|
||||
act(() => {
|
||||
result.current.patchField(
|
||||
42,
|
||||
toVendorTablePatch({
|
||||
vendorId: "9",
|
||||
company: "New Co",
|
||||
tech: "",
|
||||
techPhone: "",
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
await waitFor(() =>
|
||||
expect(onPatch).toHaveBeenCalledWith(
|
||||
42,
|
||||
expect.objectContaining({ primaryDispatchStatus: "Pending" }),
|
||||
),
|
||||
);
|
||||
|
||||
expect(patchBoardField).toHaveBeenCalledWith(
|
||||
42,
|
||||
expect.objectContaining({ field: "vendorId", value: "9" }),
|
||||
);
|
||||
const payload = patchBoardField.mock.calls[0]?.[1] as Record<string, unknown>;
|
||||
expect(payload).not.toHaveProperty("primaryDispatchStatus");
|
||||
expect(getClosabilityGaps(tableRowToClosabilityInput(returnedRow))).not.toContain("Company");
|
||||
});
|
||||
|
||||
it("keeps a Company gap when vendor PATCH still returns Refused", async () => {
|
||||
const returnedRow: WorkOrderTableRow = {
|
||||
...rowState,
|
||||
vendorId: "9",
|
||||
company: "New Co",
|
||||
primaryDispatchStatus: "Refused",
|
||||
};
|
||||
patchBoardField.mockResolvedValue(returnedRow);
|
||||
|
||||
const onPatch = vi.fn();
|
||||
const { result } = renderHook(
|
||||
() =>
|
||||
useWorkOrderTableMutations({
|
||||
onPatch,
|
||||
clearPatch: () => undefined,
|
||||
getRow: () => rowState,
|
||||
}),
|
||||
{ wrapper: makeWrapper() },
|
||||
);
|
||||
|
||||
act(() => {
|
||||
result.current.patchField(
|
||||
42,
|
||||
toVendorTablePatch({
|
||||
vendorId: "9",
|
||||
company: "New Co",
|
||||
tech: "",
|
||||
techPhone: "",
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
await waitFor(() =>
|
||||
expect(onPatch).toHaveBeenCalledWith(
|
||||
42,
|
||||
expect.objectContaining({ primaryDispatchStatus: "Refused" }),
|
||||
),
|
||||
);
|
||||
expect(getClosabilityGaps(tableRowToClosabilityInput(returnedRow))).toContain("Company");
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -449,30 +449,6 @@ describe("tableRowToClosabilityInput", () => {
|
|||
});
|
||||
expect(getClosabilityGaps(input)).toEqual([]);
|
||||
});
|
||||
|
||||
it.each(["Pending", "Sent"] as const)(
|
||||
"keeps company assignment after vendor save when primary dispatch status is %s",
|
||||
(primaryDispatchStatus) => {
|
||||
const input = tableRowToClosabilityInput({
|
||||
...closableRow,
|
||||
company: "New Co",
|
||||
vendorId: "9",
|
||||
primaryDispatchStatus,
|
||||
});
|
||||
expect(input.vendorId).toBe("9");
|
||||
expect(getClosabilityGaps(input)).not.toContain("Company");
|
||||
},
|
||||
);
|
||||
|
||||
it("raises Company when leftover Refused remains on the patched vendor id", () => {
|
||||
const input = tableRowToClosabilityInput({
|
||||
...closableRow,
|
||||
company: "New Co",
|
||||
vendorId: "9",
|
||||
primaryDispatchStatus: "Refused",
|
||||
});
|
||||
expect(getClosabilityGaps(input)).toContain("Company");
|
||||
});
|
||||
});
|
||||
|
||||
describe("readDetailWoType", () => {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue