mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-09-30 06:53:12 +00:00
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 HIGHLIGHT_BOX_SHADOW = "0 0 0 2px var(--color-accent)";
|
|
|
|
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: "",
|
|
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,
|
|
};
|
|
|
|
const handlers: WoTableRowHandlers = {
|
|
onRowClick: vi.fn(),
|
|
onView: vi.fn(),
|
|
onEdit: vi.fn(),
|
|
onOpenMedia: vi.fn(),
|
|
onPatch: vi.fn(),
|
|
onScheduleDate: vi.fn(),
|
|
onScheduleWeek: vi.fn(),
|
|
onOpenSlideOver: vi.fn(),
|
|
onReorder: vi.fn(),
|
|
onDragStart: vi.fn(),
|
|
onDragOver: vi.fn(),
|
|
onDrop: vi.fn(),
|
|
onDragEnd: vi.fn(),
|
|
};
|
|
|
|
/** Mirrors WoTable.renderRow: body `true` → Schedule On only. */
|
|
function renderUnscheduledHarness() {
|
|
const tableData = {
|
|
advActive: false,
|
|
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>
|
|
);
|
|
|
|
return renderWithProviders(
|
|
<table>
|
|
<WoTableBody tableData={tableData} renderRow={renderRow} renderInlineRow={() => null} />
|
|
</table>,
|
|
{ withAuth: false },
|
|
);
|
|
}
|
|
|
|
describe("WoTableBody unscheduled Schedule On highlight (SH-165)", () => {
|
|
it("force-highlights Schedule On for Unscheduled rows, not Due Date", () => {
|
|
renderUnscheduledHarness();
|
|
|
|
const scheduleOn = screen.getByRole("button", { name: /^—$/ });
|
|
const dueDate = screen.getByRole("button", { name: /07-15/ });
|
|
|
|
expect(scheduleOn).toHaveStyle({ boxShadow: HIGHLIGHT_BOX_SHADOW });
|
|
expect(dueDate).not.toHaveStyle({ boxShadow: HIGHLIGHT_BOX_SHADOW });
|
|
});
|
|
});
|