Task 9b9188b8. Adds a typed client for GET /api/v1/admin/history and the History screen (ADMIN-SPEC §5): All events / Reversals / Missed chips that re-query the API, per-period On time / Completed / Missed stats, rows grouped by local day with event type, actor and on-time flag, the append-only footer strip, an inert CSV button (TODO e5133d0f) and the 92px scroll-column padding. Wires the tab into the shell. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
47 lines
1.6 KiB
TypeScript
47 lines
1.6 KiB
TypeScript
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
import { cleanup, fireEvent, render, screen } from "@testing-library/react";
|
|
import App from "./App";
|
|
|
|
describe("NestQuest Admin shell", () => {
|
|
beforeEach(() => {
|
|
// The Today tab fetches the admin snapshot; keep the shell tests offline.
|
|
vi.stubGlobal("fetch", vi.fn(() => new Promise<Response>(() => {})));
|
|
});
|
|
|
|
afterEach(() => {
|
|
cleanup();
|
|
vi.unstubAllGlobals();
|
|
});
|
|
|
|
it("renders the title and all four tab labels", () => {
|
|
render(<App />);
|
|
|
|
expect(screen.getByRole("heading", { name: "NestQuest Admin" })).toBeTruthy();
|
|
for (const label of ["Today", "Tasks", "Schedule", "History"]) {
|
|
expect(screen.getByRole("tab", { name: label })).toBeTruthy();
|
|
}
|
|
});
|
|
|
|
it("starts on the Today screen and switches on tab click", () => {
|
|
render(<App />);
|
|
|
|
expect(screen.getByRole("heading", { name: "Today" })).toBeTruthy();
|
|
|
|
fireEvent.click(screen.getByRole("tab", { name: "History" }));
|
|
|
|
expect(screen.getByRole("heading", { name: "History" })).toBeTruthy();
|
|
expect(screen.getByRole("tabpanel").textContent).not.toContain("placeholder");
|
|
expect(screen.getByRole("tab", { name: "History" }).getAttribute("aria-selected")).toBe(
|
|
"true",
|
|
);
|
|
});
|
|
|
|
it("the Tasks tab renders the definitions screen", () => {
|
|
render(<App />);
|
|
|
|
fireEvent.click(screen.getByRole("tab", { name: "Tasks" }));
|
|
|
|
expect(screen.getByRole("heading", { name: "Tasks" })).toBeTruthy();
|
|
expect(screen.getByRole("tabpanel").textContent).not.toContain("placeholder");
|
|
});
|
|
}); |