* test(coverage): bootstrap vitest unit infra and add tests at 90%+ per file (#1245) Establishes the unit-test runtime AGENTS.md mandates: a vitest "unit" project alongside the existing storybook project, RTL + jest-dom + happy-dom, a Mantine-aware render helper, and a 90%-line per-file coverage gate enforced by CI. Adds 66 test files covering all 62 components under elements/groups/screens/views, plus core/mcp and clients/web/src/utils. Total: 577 tests, 98.7% line coverage globally. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * test(coverage): address PR #1269 review feedback - AGENTS.md: correct coverage gate description (lines ≥ 90, statements ≥ 85, functions ≥ 80, branches ≥ 50) with rationale for the relaxed branch threshold - InspectorView.test.tsx: document what the Math.random() mock values (0.1 / 0.99) control vs. STUB_SUCCESS_RATE in InspectorView.tsx - vite.config.ts / tsconfig.test.json: drop unused `globals: true` and the `vitest/globals` type now that every test file imports describe/it/expect/vi explicitly; manual `afterEach(cleanup)` in setup.ts remains required because testing-library auto-cleanup relies on globalThis.afterEach Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
43 lines
1.3 KiB
TypeScript
43 lines
1.3 KiB
TypeScript
import { describe, it, expect, vi } from "vitest";
|
|
import userEvent from "@testing-library/user-event";
|
|
import type { Task } from "@modelcontextprotocol/sdk/types.js";
|
|
import { renderWithMantine, screen } from "../../../test/renderWithMantine";
|
|
import { TasksScreen } from "./TasksScreen";
|
|
|
|
const tasks: Task[] = [
|
|
{
|
|
taskId: "t1",
|
|
status: "working",
|
|
createdAt: new Date().toISOString(),
|
|
lastUpdatedAt: new Date().toISOString(),
|
|
pollInterval: 1000,
|
|
ttl: 60000,
|
|
},
|
|
];
|
|
|
|
const baseProps = {
|
|
tasks,
|
|
onRefresh: vi.fn(),
|
|
onClearCompleted: vi.fn(),
|
|
onCancel: vi.fn(),
|
|
};
|
|
|
|
describe("TasksScreen", () => {
|
|
it("renders the controls and list", () => {
|
|
renderWithMantine(<TasksScreen {...baseProps} />);
|
|
expect(screen.getAllByText("Tasks").length).toBeGreaterThan(0);
|
|
});
|
|
|
|
it("renders an empty list when no tasks are provided", () => {
|
|
renderWithMantine(<TasksScreen {...baseProps} tasks={[]} />);
|
|
expect(screen.getAllByText("Tasks").length).toBeGreaterThan(0);
|
|
});
|
|
|
|
it("invokes onRefresh when refresh is clicked", async () => {
|
|
const user = userEvent.setup();
|
|
const onRefresh = vi.fn();
|
|
renderWithMantine(<TasksScreen {...baseProps} onRefresh={onRefresh} />);
|
|
await user.click(screen.getByRole("button", { name: "Refresh" }));
|
|
expect(onRefresh).toHaveBeenCalledTimes(1);
|
|
});
|
|
});
|