36 lines
1.3 KiB
TypeScript
36 lines
1.3 KiB
TypeScript
import { render, screen } from "@testing-library/react";
|
|||
|
|
import { MemoryRouter } from "react-router";
|
||
|
|
import { describe, expect, it } from "vitest";
|
||
|
|
import { mockFetch } from "./test/fetchMock";
|
||
|
|
import { AppRoutes } from "./App";
|
||
|
|
|
||
|
|
function renderAt(path: string) {
|
||
|
|
return render(
|
||
|
|
<MemoryRouter initialEntries={[path]}>
|
||
|
|
<AppRoutes />
|
||
|
|
</MemoryRouter>,
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
describe("routes", () => {
|
||
|
|
it("home shows the top bar and the version", async () => {
|
||
|
|
mockFetch({ "/api/version": { body: { version: "0.0.1" } }, "/healthz": { body: "ok" } });
|
||
|
|
renderAt("/");
|
||
|
|
expect(screen.getByRole("img", { name: "PESCO" })).toBeInTheDocument();
|
||
|
|
expect(await screen.findByText("0.0.1")).toBeInTheDocument();
|
||
|
|
});
|
||
|
|
|
||
|
|
it("sign-in shows both tabs with disabled inputs", () => {
|
||
|
|
renderAt("/signin");
|
||
|
|
expect(screen.getByRole("tab", { name: "Domain password" })).toHaveAttribute("aria-selected", "true");
|
||
|
|
expect(screen.getByRole("tab", { name: "PIN" })).toBeInTheDocument();
|
||
|
|
expect(screen.getByLabelText("Password")).toBeDisabled();
|
||
|
|
expect(screen.getByText(/phase 1/)).toBeInTheDocument();
|
||
|
|
});
|
||
|
|
|
||
|
|
it("unknown paths show the 404 page", () => {
|
||
|
|
renderAt("/no/such/page");
|
||
|
|
expect(screen.getByRole("heading", { name: "Page not found" })).toBeInTheDocument();
|
||
|
|
});
|
||
|
|
});
|