mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-09-30 05:43:12 +00:00
* fix(work-orders): allow blank WO number in wizard create path
[recover] remove malicious eslint payload (was d0d08508)
* fix(work-orders): emit severity before type in board scalar PATCH ops
Co-authored-by: Cursor <cursoragent@cursor.com>
* chore(work-orders): drop vendor collateral from SH-192 lane
* fix(work-orders): add severity to unscheduled highlight fixture after dev merge
* refactor(work-orders): extract inline type/severity cell under function line cap
* fix(work-orders): add severity to comp-doc and media fixtures after dev merge
PR #45 introduced completion-doc, media and table-mutation fixtures that predate the required severity field, so the integrated head failed tsc. Fill severity on those row builders (null for PM, SEV 1 for the Emergency fixture) and type the mutation BASE_ROW instead of asserting it.
* test(work-orders): align merge fixes with severity field and WO# placeholder
---------
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Arthur Bassi <bassi-arthurr@users.noreply.github.com>
Co-authored-by: Alexandre Brandizzi <alex_brandizzi@hotmail.com>
112 lines
3.3 KiB
TypeScript
112 lines
3.3 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import {
|
|
buildSlideOverPatch,
|
|
isSlideOverDraftDirty,
|
|
SLIDE_OVER_EDIT_KEYS,
|
|
} from "@/domain/work-orders/utils/slide-over-draft";
|
|
import type { WorkOrderTableRow } from "@/domain/work-orders/types/work-order-table-row";
|
|
|
|
function baseRow(overrides: Partial<WorkOrderTableRow> = {}): WorkOrderTableRow {
|
|
return {
|
|
id: 1,
|
|
woNumber: "1001",
|
|
site: "SITE-A",
|
|
type: "PM",
|
|
severity: null,
|
|
dispatcherId: "10",
|
|
dispatcherName: "Alex",
|
|
scheduledOn: "2026-07-16",
|
|
completedDate: "",
|
|
targetWeek: "",
|
|
dayGroup: "2026-07-16",
|
|
dayLabel: "Thu",
|
|
location: "Main",
|
|
locationId: 5,
|
|
pm: "Plumbing",
|
|
serviceNotes: "",
|
|
extraServices: [],
|
|
vendorId: "v1",
|
|
company: "Acme",
|
|
tech: "Sam",
|
|
techPhone: "",
|
|
apptStart: "",
|
|
apptEnd: "",
|
|
apptTime: "09:00",
|
|
status: "Incomplete",
|
|
docStatus: "",
|
|
pocName: "",
|
|
pocPhone: "",
|
|
pocNotes: "",
|
|
dueDate: "2026-07-20",
|
|
rescheduleCount: 0,
|
|
carriedOver: 0,
|
|
originalWeek: "",
|
|
originalDate: "",
|
|
isPastDue: false,
|
|
scheduleWeekOnly: false,
|
|
mediaCount: 0,
|
|
title: "",
|
|
priority: "",
|
|
primaryDispatchId: null,
|
|
rowVersion: "1",
|
|
dispatchRowVersion: "",
|
|
flagColor: null,
|
|
...overrides,
|
|
};
|
|
}
|
|
|
|
describe("slide-over-draft", () => {
|
|
it("exposes only board-persistable edit keys", () => {
|
|
expect(SLIDE_OVER_EDIT_KEYS).toContain("woNumber");
|
|
expect(SLIDE_OVER_EDIT_KEYS).toContain("status");
|
|
expect(SLIDE_OVER_EDIT_KEYS).toContain("vendorId");
|
|
expect(SLIDE_OVER_EDIT_KEYS).not.toContain("pocName");
|
|
expect(SLIDE_OVER_EDIT_KEYS).not.toContain("locationId");
|
|
expect(SLIDE_OVER_EDIT_KEYS).not.toContain("techPhone");
|
|
expect(SLIDE_OVER_EDIT_KEYS).not.toContain("company");
|
|
expect(SLIDE_OVER_EDIT_KEYS).not.toContain("tech");
|
|
});
|
|
|
|
it("tracks vendor via vendorId only (company/tech are display companions)", () => {
|
|
const row = baseRow();
|
|
const draft = baseRow({ company: "Other Co", tech: "Pat" });
|
|
expect(isSlideOverDraftDirty(draft, row)).toBe(false);
|
|
expect(buildSlideOverPatch(draft, row)).toEqual({});
|
|
|
|
const vendorDraft = baseRow({ vendorId: "v2", company: "Other Co", tech: "Pat" });
|
|
expect(isSlideOverDraftDirty(vendorDraft, row)).toBe(true);
|
|
expect(buildSlideOverPatch(vendorDraft, row)).toEqual({ vendorId: "v2" });
|
|
});
|
|
|
|
it("ignores POC-only edits for dirty state", () => {
|
|
const row = baseRow();
|
|
const draft = baseRow({ pocName: "Jordan", pocPhone: "555-0100" });
|
|
expect(isSlideOverDraftDirty(draft, row)).toBe(false);
|
|
expect(buildSlideOverPatch(draft, row)).toEqual({});
|
|
});
|
|
|
|
it("detects dirty draft when a tracked field changes", () => {
|
|
const row = baseRow();
|
|
const draft = baseRow({ scheduledOn: "2026-07-17" });
|
|
expect(isSlideOverDraftDirty(draft, row)).toBe(true);
|
|
});
|
|
|
|
it("is not dirty when values match", () => {
|
|
const row = baseRow();
|
|
expect(isSlideOverDraftDirty(row, row)).toBe(false);
|
|
});
|
|
|
|
it("builds a patch with only changed fields", () => {
|
|
const row = baseRow();
|
|
const draft = baseRow({
|
|
woNumber: "1002",
|
|
status: "Completed",
|
|
extraServices: ["HVAC"],
|
|
});
|
|
expect(buildSlideOverPatch(draft, row)).toEqual({
|
|
woNumber: "1002",
|
|
status: "Completed",
|
|
extraServices: ["HVAC"],
|
|
});
|
|
});
|
|
});
|