fix(plex): the rail says once that its facets failed, with Retry
A failed facets load put the same muted line in up to five sections with nothing to press (the query never retries by itself), and only the Year section announced it, so a reader who hid that section heard nothing. The rail now shows one StateMessage with Retry, in the Year section or in its foot when Year is hidden; the facet sections wait for their data as before.
This commit is contained in:
@@ -17,7 +17,7 @@ vi.mock("./plexContext", () => ({
|
||||
usePlexActions: () => ({ setPlaylistOpen: vi.fn() }),
|
||||
}));
|
||||
|
||||
import { PlexYearFilter } from "./PlexSidebar";
|
||||
import { FacetsStatus, PlexYearFilter } from "./PlexSidebar";
|
||||
import { EMPTY_PLEX_FILTERS, type PlexFacets } from "../../lib/api";
|
||||
|
||||
afterEach(cleanup);
|
||||
@@ -64,25 +64,14 @@ describe("the Plex rail's Year section", () => {
|
||||
expect(screen.queryByRole("button", { pressed: true })).toBeNull();
|
||||
});
|
||||
|
||||
it("says the years are loading, or failed to load, rather than showing none", () => {
|
||||
const { rerender } = render(
|
||||
<PlexYearFilter
|
||||
filters={EMPTY_PLEX_FILTERS}
|
||||
facets={undefined}
|
||||
facetsState="loading"
|
||||
patch={() => {}}
|
||||
/>,
|
||||
);
|
||||
it("says the facets are loading, or failed with a way to try again, rather than showing none", () => {
|
||||
const retry = vi.fn();
|
||||
const { rerender } = render(<FacetsStatus failed={false} onRetry={retry} />);
|
||||
expect(screen.getByRole("status").textContent).toBe("common.loading");
|
||||
rerender(
|
||||
<PlexYearFilter
|
||||
filters={EMPTY_PLEX_FILTERS}
|
||||
facets={undefined}
|
||||
facetsState="error"
|
||||
patch={() => {}}
|
||||
/>,
|
||||
);
|
||||
expect(screen.getByRole("alert").textContent).toBe("common.loadError");
|
||||
rerender(<FacetsStatus failed onRetry={retry} />);
|
||||
expect(screen.getByRole("alert").textContent).toContain("common.loadError");
|
||||
fireEvent.click(screen.getByRole("button", { name: "common.retry" }));
|
||||
expect(retry).toHaveBeenCalledOnce();
|
||||
});
|
||||
|
||||
it("names the range fields", () => {
|
||||
|
||||
Reference in New Issue
Block a user