mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-10-05 21:12:07 +00:00
fix(workorders): complete service query wiring
This commit is contained in:
parent
64246db1f0
commit
ffbf60d16a
6 changed files with 71 additions and 16 deletions
|
|
@ -163,21 +163,27 @@ export function AdvancedSearchFilterSections({
|
||||||
|
|
||||||
<AdvSection icon={Flame} label="Service" count={draft.pmTypes.size}>
|
<AdvSection icon={Flame} label="Service" count={draft.pmTypes.size}>
|
||||||
{Boolean(serviceQuery?.isLoading && !serviceQuery.hasData) && (
|
{Boolean(serviceQuery?.isLoading && !serviceQuery.hasData) && (
|
||||||
<Text as="div" variant="description" role="status" aria-label="Loading services">
|
<div role="status" aria-label="Loading services">
|
||||||
Loading services…
|
<Text as="span" variant="description">
|
||||||
</Text>
|
Loading services…
|
||||||
|
</Text>
|
||||||
|
</div>
|
||||||
)}
|
)}
|
||||||
{Boolean(serviceQuery?.isFetching && serviceQuery.hasData && !serviceQuery.isError) && (
|
{Boolean(serviceQuery?.isFetching && serviceQuery.hasData && !serviceQuery.isError) && (
|
||||||
<Text as="div" variant="description" role="status" aria-label="Updating services">
|
<div role="status" aria-label="Updating services">
|
||||||
Updating services…
|
<Text as="span" variant="description">
|
||||||
</Text>
|
Updating services…
|
||||||
|
</Text>
|
||||||
|
</div>
|
||||||
)}
|
)}
|
||||||
{Boolean(serviceQuery?.isError) && (
|
{Boolean(serviceQuery?.isError) && (
|
||||||
<QueryErrorPanel
|
<div role="alert" aria-label="Service filters unavailable">
|
||||||
compact
|
<QueryErrorPanel
|
||||||
message="Service filters couldn't load. Retry to load registry services."
|
compact
|
||||||
onRetry={serviceQuery?.retry}
|
message="Service filters couldn't load. Retry to load registry services."
|
||||||
/>
|
onRetry={serviceQuery?.retry}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
)}
|
)}
|
||||||
{Boolean(
|
{Boolean(
|
||||||
serviceRegistryManaged &&
|
serviceRegistryManaged &&
|
||||||
|
|
|
||||||
|
|
@ -80,11 +80,13 @@ export function PmTypePickerPopover({
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{error && (
|
{error && (
|
||||||
<QueryErrorPanel
|
<div role="alert" aria-label="Service options unavailable">
|
||||||
compact
|
<QueryErrorPanel
|
||||||
message="Service options couldn't load. Retry to load registry services."
|
compact
|
||||||
onRetry={onRetry}
|
message="Service options couldn't load. Retry to load registry services."
|
||||||
/>
|
onRetry={onRetry}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
)}
|
)}
|
||||||
{Boolean(registryManaged && empty) && (
|
{Boolean(registryManaged && empty) && (
|
||||||
<div className="px-2 py-3 text-center text-xs text-muted-foreground">
|
<div className="px-2 py-3 text-center text-xs text-muted-foreground">
|
||||||
|
|
|
||||||
|
|
@ -194,6 +194,7 @@ export function WoTableInlineRowCells({
|
||||||
vendors,
|
vendors,
|
||||||
pmTypes,
|
pmTypes,
|
||||||
services = [],
|
services = [],
|
||||||
|
serviceQuery,
|
||||||
allRows,
|
allRows,
|
||||||
siteCellRef,
|
siteCellRef,
|
||||||
woCellRef,
|
woCellRef,
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,7 @@ describe("Aveta Service & Notes", () => {
|
||||||
|
|
||||||
fireEvent.click(screen.getByRole("button", { name: /Saved service/i }));
|
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.getByText(/service options couldn't load/i)).toBeInTheDocument();
|
||||||
expect(screen.queryByRole("button", { name: "Leak" })).not.toBeInTheDocument();
|
expect(screen.queryByRole("button", { name: "Leak" })).not.toBeInTheDocument();
|
||||||
fireEvent.click(screen.getByRole("button", { name: "Retry" }));
|
fireEvent.click(screen.getByRole("button", { name: "Retry" }));
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,48 @@ function currentMonthIso(day: number): string {
|
||||||
}
|
}
|
||||||
|
|
||||||
describe("WoTableInlineRowCells — Schedule On range", () => {
|
describe("WoTableInlineRowCells — Schedule On range", () => {
|
||||||
|
it("keeps registry failure and retry in the inline Add WO service picker", async () => {
|
||||||
|
const retry = vi.fn();
|
||||||
|
renderWithProviders(
|
||||||
|
<table>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<WoTableInlineRowCells
|
||||||
|
draft={EMPTY_TABLE_DRAFT}
|
||||||
|
weekDefault={false}
|
||||||
|
users={[]}
|
||||||
|
sites={[]}
|
||||||
|
vendors={[]}
|
||||||
|
pmTypes={["Leak"]}
|
||||||
|
services={[]}
|
||||||
|
serviceQuery={{
|
||||||
|
isLoading: false,
|
||||||
|
isError: true,
|
||||||
|
isFetching: false,
|
||||||
|
hasData: false,
|
||||||
|
retry,
|
||||||
|
}}
|
||||||
|
allRows={[]}
|
||||||
|
siteCellRef={createRef()}
|
||||||
|
woCellRef={createRef()}
|
||||||
|
siteShowError={false}
|
||||||
|
siteError=""
|
||||||
|
woShowError={false}
|
||||||
|
onPatch={vi.fn()}
|
||||||
|
/>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>,
|
||||||
|
);
|
||||||
|
|
||||||
|
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 () => {
|
it("reopens a company-only inline assignment without inferring its anchor as technician", async () => {
|
||||||
renderWithProviders(
|
renderWithProviders(
|
||||||
<table>
|
<table>
|
||||||
|
|
|
||||||
|
|
@ -277,6 +277,9 @@ describe("WorkOrders Advanced Search page wiring (SH-121)", () => {
|
||||||
const sheet = screen.getByRole("dialog", { name: "Advanced Filters" });
|
const sheet = screen.getByRole("dialog", { name: "Advanced Filters" });
|
||||||
fireEvent.click(within(sheet).getByRole("button", { name: /^Service/i }));
|
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).getByText(/service filters couldn't load/i)).toBeInTheDocument();
|
||||||
expect(within(sheet).queryByText("Leak")).not.toBeInTheDocument();
|
expect(within(sheet).queryByText("Leak")).not.toBeInTheDocument();
|
||||||
expect(within(sheet).getByText("Previously selected service")).toBeInTheDocument();
|
expect(within(sheet).getByText("Previously selected service")).toBeInTheDocument();
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue