mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-10-06 15:52:04 +00:00
fix(workorders): retain completed service snapshot labels
This commit is contained in:
parent
18fefef9a3
commit
e35bd2983e
3 changed files with 62 additions and 4 deletions
|
|
@ -61,7 +61,7 @@ export function PMTypeCell({
|
||||||
? serviceNames.filter((p) => p.toLowerCase().includes(search.toLowerCase()))
|
? serviceNames.filter((p) => p.toLowerCase().includes(search.toLowerCase()))
|
||||||
: serviceNames;
|
: serviceNames;
|
||||||
const linkedService = services?.find((service) => String(service.id) === String(serviceId));
|
const linkedService = services?.find((service) => String(service.id) === String(serviceId));
|
||||||
const displayValue = linkedService?.isActive ? linkedService.name : value;
|
const displayValue = !viewOnly && linkedService?.isActive ? linkedService.name : value;
|
||||||
|
|
||||||
const extras = extraServices ?? [];
|
const extras = extraServices ?? [];
|
||||||
const hasDetails = hasServiceNotesDetails(serviceNotes, extras, avetaRequired);
|
const hasDetails = hasServiceNotesDetails(serviceNotes, extras, avetaRequired);
|
||||||
|
|
|
||||||
|
|
@ -77,6 +77,34 @@ describe("Aveta Service & Notes", () => {
|
||||||
expect(screen.queryByRole("button", { name: /Renamed Service/i })).not.toBeInTheDocument();
|
expect(screen.queryByRole("button", { name: /Renamed Service/i })).not.toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("keeps the completed work-order label when its active service is renamed", () => {
|
||||||
|
renderWithProviders(
|
||||||
|
<PMTypeCell
|
||||||
|
value="Saved Completed Label"
|
||||||
|
serviceId={701}
|
||||||
|
pmTypes={[]}
|
||||||
|
services={[
|
||||||
|
{
|
||||||
|
id: 701,
|
||||||
|
name: "Current Active Name",
|
||||||
|
trade: "Electrical",
|
||||||
|
iconKey: "wrench",
|
||||||
|
requiresCompletionDocument: false,
|
||||||
|
completionDocTemplate: null,
|
||||||
|
isActive: true,
|
||||||
|
supportedWorkOrderTypes: ["PM"],
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
workOrderType="PM"
|
||||||
|
viewOnly
|
||||||
|
onSave={vi.fn()}
|
||||||
|
/>,
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(screen.getByRole("button", { name: /Saved Completed Label/i })).toBeInTheDocument();
|
||||||
|
expect(screen.queryByRole("button", { name: /Current Active Name/i })).not.toBeInTheDocument();
|
||||||
|
});
|
||||||
|
|
||||||
it("preserves the historic identity when only service notes change", () => {
|
it("preserves the historic identity when only service notes change", () => {
|
||||||
const onSaveDetails = vi.fn();
|
const onSaveDetails = vi.fn();
|
||||||
renderWithProviders(
|
renderWithProviders(
|
||||||
|
|
|
||||||
|
|
@ -65,9 +65,6 @@ vi.mock("@/app/(protected)/workorders/_components/list/table/cells/date-cell", (
|
||||||
vi.mock("@/app/(protected)/workorders/_components/list/table/cells/appt-time-cell", () => ({
|
vi.mock("@/app/(protected)/workorders/_components/list/table/cells/appt-time-cell", () => ({
|
||||||
ApptTimeCell: () => null,
|
ApptTimeCell: () => 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", () => ({
|
vi.mock("@/app/(protected)/workorders/_components/list/table/cells/vendor-cell", () => ({
|
||||||
VendorCell: () => null,
|
VendorCell: () => null,
|
||||||
}));
|
}));
|
||||||
|
|
@ -155,6 +152,39 @@ describe("SlideOverInfoTabEditView additional contacts", () => {
|
||||||
expect(screen.queryByText("Renamed Service")).not.toBeInTheDocument();
|
expect(screen.queryByText("Renamed Service")).not.toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("keeps a completed slide-over's saved label after its active service is renamed", () => {
|
||||||
|
renderWithProviders(
|
||||||
|
<SlideOverInfoTabDisplayView
|
||||||
|
source={baseRow({
|
||||||
|
status: "Completed",
|
||||||
|
pm: "Saved Completed Label",
|
||||||
|
serviceId: 701,
|
||||||
|
})}
|
||||||
|
isCancelled={false}
|
||||||
|
isCompleted
|
||||||
|
sites={[]}
|
||||||
|
vendors={[]}
|
||||||
|
pmTypes={[]}
|
||||||
|
services={[
|
||||||
|
{
|
||||||
|
id: 701,
|
||||||
|
name: "Current Active Name",
|
||||||
|
trade: "Electrical",
|
||||||
|
iconKey: "wrench",
|
||||||
|
requiresCompletionDocument: false,
|
||||||
|
completionDocTemplate: null,
|
||||||
|
isActive: true,
|
||||||
|
supportedWorkOrderTypes: ["PM"],
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
/>,
|
||||||
|
{ withAuth: false },
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(screen.getByText("Saved Completed Label")).toBeInTheDocument();
|
||||||
|
expect(screen.queryByText("Current Active Name")).not.toBeInTheDocument();
|
||||||
|
});
|
||||||
|
|
||||||
it("saves an incompatible type change only after clearing the registry service", () => {
|
it("saves an incompatible type change only after clearing the registry service", () => {
|
||||||
const baseline = baseRow({ type: "PM", pm: "PM only", serviceId: 701 });
|
const baseline = baseRow({ type: "PM", pm: "PM only", serviceId: 701 });
|
||||||
const onSave = vi.fn();
|
const onSave = vi.fn();
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue