mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-10-04 17:12:06 +00:00
Board Clear uses empty-week patch; slide-over Save derives Pending via mergeAutoSchedulePatch.
73 lines
2.5 KiB
TypeScript
73 lines
2.5 KiB
TypeScript
import { fireEvent, screen } from "@testing-library/react";
|
|
import { describe, expect, it, vi } from "vitest";
|
|
import { WoTableInlineRow } from "@/app/(protected)/workorders/_components/list/table/wo-table-inline-row";
|
|
import { EMPTY_TABLE_DRAFT } from "@/domain/work-orders/types/work-order-table-row";
|
|
import { renderWithProviders } from "@/test/test-utils";
|
|
|
|
vi.mock("@/app/(protected)/workorders/_components/list/table/cells/site-cell", () => ({
|
|
SiteCell: () => null,
|
|
}));
|
|
vi.mock(
|
|
"@/app/(protected)/workorders/_components/list/table/cells/editable-wo-number-cell",
|
|
() => ({
|
|
EditableWONumberCell: () => null,
|
|
}),
|
|
);
|
|
vi.mock("@/app/(protected)/workorders/_components/list/table/cells/type-cell", () => ({
|
|
TypeCell: () => null,
|
|
}));
|
|
vi.mock("@/app/(protected)/workorders/_components/list/table/cells/assigned-to-cell", () => ({
|
|
AssignedToCell: () => null,
|
|
}));
|
|
vi.mock("@/app/(protected)/workorders/_components/list/table/cells/date-cell", () => ({
|
|
DateCell: () => null,
|
|
}));
|
|
vi.mock("@/app/(protected)/workorders/_components/list/table/cells/due-date-cell", () => ({
|
|
DueDateCell: () => null,
|
|
}));
|
|
vi.mock("@/app/(protected)/workorders/_components/list/table/cells/pm-type-cell", () => ({
|
|
PMTypeCell: () => null,
|
|
}));
|
|
vi.mock("@/app/(protected)/workorders/_components/list/table/cells/vendor-cell", () => ({
|
|
VendorCell: () => null,
|
|
}));
|
|
vi.mock("@/app/(protected)/workorders/_components/list/table/cells/appt-time-cell", () => ({
|
|
ApptTimeCell: () => null,
|
|
}));
|
|
|
|
describe("WoTableInlineRow StatusCell with a concrete schedule", () => {
|
|
it("keeps Scheduled when Incomplete is picked on a dated draft", () => {
|
|
const onChange = vi.fn();
|
|
const draft = {
|
|
...EMPTY_TABLE_DRAFT,
|
|
status: "Incomplete" as const,
|
|
scheduledOn: "2026-06-01",
|
|
scheduleWeekOnly: false,
|
|
};
|
|
|
|
renderWithProviders(
|
|
<table>
|
|
<tbody>
|
|
<WoTableInlineRow
|
|
draft={draft}
|
|
draftDayKey="2026-06-01"
|
|
users={[]}
|
|
sites={[]}
|
|
vendors={[]}
|
|
pmTypes={[]}
|
|
allRows={[]}
|
|
onChange={onChange}
|
|
onSave={vi.fn()}
|
|
onCancel={vi.fn()}
|
|
/>
|
|
</tbody>
|
|
</table>,
|
|
{ withAuth: false },
|
|
);
|
|
|
|
fireEvent.click(screen.getByRole("button", { name: /incomplete/i }));
|
|
fireEvent.click(screen.getByRole("button", { name: /^pending$/i }));
|
|
|
|
expect(onChange).toHaveBeenCalledWith(expect.objectContaining({ status: "Scheduled" }));
|
|
});
|
|
});
|