Files
kandev/apps/web/src/spa-routes.loading.test.tsx
T
José Almeida eab70052d2 fix(web): prevent blank screens during SPA recovery (#2024)
* fix(web): prevent blank screens during SPA recovery

* fix(web): address SPA recovery review feedback
2026-07-30 10:46:35 +01:00

27 lines
844 B
TypeScript

import { cleanup, render, screen } from "@testing-library/react";
import { afterEach, describe, expect, it, vi } from "vitest";
import { SpaRoutes } from "./spa-routes";
vi.mock("./settings-routes", () => new Promise(() => undefined));
vi.mock("./office-routes", () => new Promise(() => undefined));
afterEach(() => {
cleanup();
window.history.replaceState({}, "", "/");
});
describe("lazy SPA route loading", () => {
it.each([
["/settings", "settings"],
["/office", "office"],
])("shows one accessible status while %s is loading", (pathname, routeName) => {
window.history.replaceState({}, "", pathname);
render(<SpaRoutes />);
const statuses = screen.getAllByRole("status");
expect(statuses).toHaveLength(1);
expect(statuses[0].textContent?.toLowerCase()).toContain(`loading ${routeName}`);
});
});