Files
beacon-web/tests/components/LoadingPill.test.tsx
T
MrAlders0n 8e2696b95a feat: loading pill for map and tables
- LoadingPill shows loading/error state in MapView, NodeTable and ObserverTable
- new useInfinitePages hook shares the pagination logic between them
- patchNodeSummary/patchObserverSummary now keep references stable
- tests for loading states, observer updates and infinite paging
2026-06-05 22:59:52 -04:00

26 lines
1.1 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { render, screen } from "@testing-library/react";
import { LoadingPill } from "../../src/components/LoadingPill";
describe("LoadingPill", () => {
it("shows a loading label with a live region", () => {
render(<LoadingPill loading count={42} noun="nodes" />);
expect(screen.getByRole("status")).toHaveTextContent("Loading nodes… (42)");
});
it("shows a total-failure label when nothing loaded", () => {
render(<LoadingPill loading={false} error count={0} noun="observers" />);
expect(screen.getByRole("status")).toHaveTextContent("Failed to load observers");
});
it("shows a partial-failure label when some rows loaded", () => {
render(<LoadingPill loading={false} error count={7} noun="nodes" />);
expect(screen.getByRole("status")).toHaveTextContent("Some nodes failed to load (7 shown)");
});
it("renders nothing when idle (not loading, no error)", () => {
const { container } = render(<LoadingPill loading={false} count={0} noun="nodes" />);
expect(container).toBeEmptyDOMElement();
});
});