From ffbf60d16a7e1bfb2966134a18bf3bc955ef3bcb Mon Sep 17 00:00:00 2001 From: Alexandre Brandizzi Date: Wed, 30 Sep 2026 18:24:24 -0300 Subject: [PATCH] fix(workorders): complete service query wiring --- .../advanced-search/adv-filter-sections.tsx | 28 ++++++++----- .../table/cells/pm-type-picker-popover.tsx | 12 +++--- .../list/table/wo-table-inline-row-cells.tsx | 1 + .../workorders/aveta-service-notes.test.tsx | 1 + .../wo-table-inline-schedule-range.test.tsx | 42 +++++++++++++++++++ ...ork-orders-advanced-search-wiring.test.tsx | 3 ++ 6 files changed, 71 insertions(+), 16 deletions(-) diff --git a/src/app/(protected)/workorders/_components/list/advanced-search/adv-filter-sections.tsx b/src/app/(protected)/workorders/_components/list/advanced-search/adv-filter-sections.tsx index 7fb5f6fd..ebc227ea 100644 --- a/src/app/(protected)/workorders/_components/list/advanced-search/adv-filter-sections.tsx +++ b/src/app/(protected)/workorders/_components/list/advanced-search/adv-filter-sections.tsx @@ -163,21 +163,27 @@ export function AdvancedSearchFilterSections({ {Boolean(serviceQuery?.isLoading && !serviceQuery.hasData) && ( - - Loading services… - +
+ + Loading services… + +
)} {Boolean(serviceQuery?.isFetching && serviceQuery.hasData && !serviceQuery.isError) && ( - - Updating services… - +
+ + Updating services… + +
)} {Boolean(serviceQuery?.isError) && ( - +
+ +
)} {Boolean( serviceRegistryManaged && diff --git a/src/app/(protected)/workorders/_components/list/table/cells/pm-type-picker-popover.tsx b/src/app/(protected)/workorders/_components/list/table/cells/pm-type-picker-popover.tsx index dc32a4c5..e1572842 100644 --- a/src/app/(protected)/workorders/_components/list/table/cells/pm-type-picker-popover.tsx +++ b/src/app/(protected)/workorders/_components/list/table/cells/pm-type-picker-popover.tsx @@ -80,11 +80,13 @@ export function PmTypePickerPopover({ )} {error && ( - +
+ +
)} {Boolean(registryManaged && empty) && (
diff --git a/src/app/(protected)/workorders/_components/list/table/wo-table-inline-row-cells.tsx b/src/app/(protected)/workorders/_components/list/table/wo-table-inline-row-cells.tsx index 58e1340b..319333ac 100644 --- a/src/app/(protected)/workorders/_components/list/table/wo-table-inline-row-cells.tsx +++ b/src/app/(protected)/workorders/_components/list/table/wo-table-inline-row-cells.tsx @@ -194,6 +194,7 @@ export function WoTableInlineRowCells({ vendors, pmTypes, services = [], + serviceQuery, allRows, siteCellRef, woCellRef, diff --git a/src/test/app/(protected)/workorders/aveta-service-notes.test.tsx b/src/test/app/(protected)/workorders/aveta-service-notes.test.tsx index 19678c65..feca7415 100644 --- a/src/test/app/(protected)/workorders/aveta-service-notes.test.tsx +++ b/src/test/app/(protected)/workorders/aveta-service-notes.test.tsx @@ -49,6 +49,7 @@ describe("Aveta Service & Notes", () => { fireEvent.click(screen.getByRole("button", { name: /Saved service/i })); + expect(screen.getByRole("alert", { name: /service options unavailable/i })).toBeInTheDocument(); expect(screen.getByText(/service options couldn't load/i)).toBeInTheDocument(); expect(screen.queryByRole("button", { name: "Leak" })).not.toBeInTheDocument(); fireEvent.click(screen.getByRole("button", { name: "Retry" })); diff --git a/src/test/app/(protected)/workorders/wo-table-inline-schedule-range.test.tsx b/src/test/app/(protected)/workorders/wo-table-inline-schedule-range.test.tsx index e1cc7139..cb366c95 100644 --- a/src/test/app/(protected)/workorders/wo-table-inline-schedule-range.test.tsx +++ b/src/test/app/(protected)/workorders/wo-table-inline-schedule-range.test.tsx @@ -12,6 +12,48 @@ function currentMonthIso(day: number): string { } describe("WoTableInlineRowCells — Schedule On range", () => { + it("keeps registry failure and retry in the inline Add WO service picker", async () => { + const retry = vi.fn(); + renderWithProviders( + + + + + + +
, + ); + + fireEvent.click(screen.getByRole("button", { name: "Select …" })); + + expect(screen.getByRole("alert", { name: /service options unavailable/i })).toBeVisible(); + expect(screen.queryByRole("button", { name: "Leak" })).not.toBeInTheDocument(); + fireEvent.click(screen.getByRole("button", { name: "Retry" })); + expect(retry).toHaveBeenCalledOnce(); + }); + it("reopens a company-only inline assignment without inferring its anchor as technician", async () => { renderWithProviders( diff --git a/src/test/app/(protected)/workorders/work-orders-advanced-search-wiring.test.tsx b/src/test/app/(protected)/workorders/work-orders-advanced-search-wiring.test.tsx index 5f763f0e..4daf50ad 100644 --- a/src/test/app/(protected)/workorders/work-orders-advanced-search-wiring.test.tsx +++ b/src/test/app/(protected)/workorders/work-orders-advanced-search-wiring.test.tsx @@ -277,6 +277,9 @@ describe("WorkOrders Advanced Search page wiring (SH-121)", () => { const sheet = screen.getByRole("dialog", { name: "Advanced Filters" }); fireEvent.click(within(sheet).getByRole("button", { name: /^Service/i })); + expect( + within(sheet).getByRole("alert", { name: /service filters unavailable/i }), + ).toBeInTheDocument(); expect(within(sheet).getByText(/service filters couldn't load/i)).toBeInTheDocument(); expect(within(sheet).queryByText("Leak")).not.toBeInTheDocument(); expect(within(sheet).getByText("Previously selected service")).toBeInTheDocument();