bef6abdd2e
- TimeEntryForm.test.tsx: fills date/project/h:mm, clicks submit, asserts fetch called with correct JSON body (mocked fetch) - WeeklyView.test.tsx: renders with stubbed WeeklyReport fixture, asserts each day's h:mm and the week total display correctly - App.test.tsx: smoke test — renders layout with TopBar and main content Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
32 lines
869 B
TypeScript
32 lines
869 B
TypeScript
import { render, screen } from "@testing-library/react";
|
|
import { MemoryRouter } from "react-router-dom";
|
|
import { describe, expect, it, vi } from "vitest";
|
|
import App from "../src/App";
|
|
|
|
// minimal stub so App renders without network calls
|
|
vi.mock("../src/lib/api", () => ({
|
|
api: {
|
|
users: { list: vi.fn().mockResolvedValue([]) },
|
|
reports: {
|
|
weekly: vi.fn().mockResolvedValue({
|
|
days: [],
|
|
weekTotalMinutes: 0,
|
|
weekTotalCostCents: 0,
|
|
}),
|
|
},
|
|
timeEntries: { list: vi.fn().mockResolvedValue([]) },
|
|
},
|
|
}));
|
|
|
|
describe("App", () => {
|
|
it("renders the top bar and main content area", () => {
|
|
render(
|
|
<MemoryRouter initialEntries={["/weekly"]}>
|
|
<App />
|
|
</MemoryRouter>,
|
|
);
|
|
expect(screen.getByText("TimeTracker")).toBeDefined();
|
|
expect(screen.getByRole("main")).toBeDefined();
|
|
});
|
|
});
|