2026-09-23 20:13:52 -04:00
|
|
|
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
2026-09-23 16:39:36 -04:00
|
|
|
import { cleanup, fireEvent, render, screen } from "@testing-library/react";
|
|
|
|
|
import App from "./App";
|
|
|
|
|
|
|
|
|
|
describe("NestQuest Admin shell", () => {
|
2026-09-23 20:13:52 -04:00
|
|
|
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();
|
|
|
|
|
});
|
2026-09-23 16:39:36 -04:00
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2026-09-23 20:13:52 -04:00
|
|
|
it("starts on the Today screen and switches on tab click", () => {
|
2026-09-23 16:39:36 -04:00
|
|
|
render(<App />);
|
|
|
|
|
|
2026-09-23 20:13:52 -04:00
|
|
|
expect(screen.getByRole("heading", { name: "Today" })).toBeTruthy();
|
2026-09-23 16:39:36 -04:00
|
|
|
|
|
|
|
|
fireEvent.click(screen.getByRole("tab", { name: "History" }));
|
|
|
|
|
|
|
|
|
|
expect(screen.getByRole("tabpanel").textContent).toContain(
|
|
|
|
|
"History placeholder",
|
|
|
|
|
);
|
|
|
|
|
expect(screen.getByRole("tab", { name: "History" }).getAttribute("aria-selected")).toBe(
|
|
|
|
|
"true",
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
});
|