mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-10-07 09:19:19 +00:00
Share Week/Date/Range on inline, board, and slide-over DateCell. A selected range lands on the start day, matching the wizard.
121 lines
3.4 KiB
TypeScript
121 lines
3.4 KiB
TypeScript
import { renderWithProviders } from "@/test/test-utils";
|
|
import { screen } from "@testing-library/react";
|
|
import { describe, expect, it, vi } from "vitest";
|
|
import { WoTableBody } from "@/app/(protected)/workorders/_components/list/table/wo-table-body";
|
|
import { WoTableRowCells } from "@/app/(protected)/workorders/_components/list/table/wo-table-row-cells";
|
|
import type { WoTableRowHandlers } from "@/app/(protected)/workorders/_components/list/table/wo-table-row";
|
|
import type { ReturnTypeOfUseWorkOrdersTableData } from "@/app/(protected)/workorders/_components/list/table/wo-table-types";
|
|
import type { WorkOrderTableRow } from "@/domain/work-orders/types/work-order-table-row";
|
|
|
|
const unscheduledRow: WorkOrderTableRow = {
|
|
id: 42,
|
|
woNumber: "WO-42",
|
|
site: "CHI-1042",
|
|
type: "PM",
|
|
severity: null,
|
|
dispatcherId: "u1",
|
|
dispatcherName: "Test Dispatcher",
|
|
scheduledOn: "",
|
|
completedDate: "",
|
|
targetWeek: "",
|
|
dayGroup: "",
|
|
dayLabel: "",
|
|
location: "Chicago Loop",
|
|
locationId: "mock-loc-1",
|
|
pm: "HVAC — Quarterly PM",
|
|
serviceNotes: "",
|
|
extraServices: [],
|
|
vendorId: "",
|
|
company: "",
|
|
tech: "",
|
|
techPhone: "",
|
|
apptStart: "",
|
|
apptEnd: "",
|
|
apptTime: "",
|
|
status: "Pending",
|
|
docStatus: "No",
|
|
pocName: "",
|
|
pocPhone: "",
|
|
pocNotes: "",
|
|
additionalContacts: [],
|
|
dueDate: "2026-07-15",
|
|
rescheduleCount: 0,
|
|
carriedOver: 0,
|
|
isAddOn: false,
|
|
originalWeek: "",
|
|
originalDate: "",
|
|
isPastDue: false,
|
|
scheduleWeekOnly: false,
|
|
mediaCount: 0,
|
|
title: "",
|
|
priority: "",
|
|
primaryDispatchId: null,
|
|
rowVersion: "",
|
|
dispatchRowVersion: "",
|
|
flagColor: null,
|
|
upliftSummary: { hasUplift: false, pendingCount: 0 },
|
|
};
|
|
|
|
const handlers: WoTableRowHandlers = {
|
|
onRowClick: vi.fn(),
|
|
onView: vi.fn(),
|
|
onEdit: vi.fn(),
|
|
onOpenMedia: vi.fn(),
|
|
onPatch: vi.fn(),
|
|
onScheduleDate: vi.fn(),
|
|
onScheduleWeek: vi.fn(),
|
|
onScheduleRange: vi.fn(),
|
|
onOpenSlideOver: vi.fn(),
|
|
onOpenCompDoc: vi.fn(),
|
|
onOpenUplifts: vi.fn(),
|
|
onReorder: vi.fn(),
|
|
onDragStart: vi.fn(),
|
|
onDragOver: vi.fn(),
|
|
onDrop: vi.fn(),
|
|
onDragEnd: vi.fn(),
|
|
};
|
|
|
|
describe("WoTableBody unscheduled exclusion (SH-240)", () => {
|
|
it("does not render Unscheduled rows in the day-tab board view", () => {
|
|
const tableData = {
|
|
advActive: false,
|
|
unassigned: [],
|
|
unassignedError: null,
|
|
unassignedLoading: false,
|
|
unassignedOpen: true,
|
|
setUnassignedOpen: vi.fn(),
|
|
unscheduled: [unscheduledRow],
|
|
unschedOpen: true,
|
|
draftDayKey: null,
|
|
displayGroups: [],
|
|
todayKey: null,
|
|
startDayDraft: vi.fn(),
|
|
setUnschedOpen: vi.fn(),
|
|
} as unknown as ReturnTypeOfUseWorkOrdersTableData;
|
|
|
|
const renderRow = (row: WorkOrderTableRow, forceScheduleHighlight = false) => (
|
|
<tr key={String(row.id)}>
|
|
<WoTableRowCells
|
|
row={row}
|
|
allRows={[row]}
|
|
users={[]}
|
|
sites={[]}
|
|
forceScheduleHighlight={forceScheduleHighlight}
|
|
forceDueDateHighlight={false}
|
|
handlers={handlers}
|
|
onPatchRow={vi.fn()}
|
|
/>
|
|
</tr>
|
|
);
|
|
|
|
renderWithProviders(
|
|
<table>
|
|
<WoTableBody tableData={tableData} renderRow={renderRow} renderInlineRow={() => null} />
|
|
</table>,
|
|
{ withAuth: false },
|
|
);
|
|
|
|
expect(screen.queryByRole("button", { name: /Unscheduled/ })).not.toBeInTheDocument();
|
|
expect(screen.queryByText("WO-42")).not.toBeInTheDocument();
|
|
});
|
|
});
|