Skip to content

Commit 24e08c6

Browse files
Nickatakclaude
andcommitted
docs: Add docstrings to frontend tests
Applies the JSDoc convention to vitest test files under frontend/tests/. Module headers state which component or page the test file covers; per-test docstrings switch from "renders X" / "does Y" framings to BNC-style behavioral statements that say what's actually asserted. Two skipped tests get fuller explanations: - TextField.test.tsx: skipped pending rewrite for the new RHF-generic API. - LandingPage.test.tsx: skipped pending rewrite against the ported component graph. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 34cc06f commit 24e08c6

6 files changed

Lines changed: 49 additions & 17 deletions

File tree

frontend/tests/components/Button.test.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,27 @@
1+
/** Component tests for `Button` from `shared/components/Buttons.tsx`. */
2+
13
import { render, screen } from "@testing-library/react";
24
import React from "react";
35
import { describe, expect, test } from "vitest";
46

57
import { Button } from "@/shared/components/Buttons";
68

79
describe("Button", () => {
10+
/** Children text passes through to the rendered element. */
811
test("renders children text", () => {
912
render(<Button>Log in</Button>);
1013
expect(screen.getByText("Log in")).toBeInTheDocument();
1114
expect(screen.queryByText("Log out")).not.toBeInTheDocument();
1215
});
1316

17+
/** Without href, renders a native `<button>` (no link role). */
1418
test("renders as button when href is omitted", () => {
1519
render(<Button />);
1620
expect(screen.getByRole("button")).toBeInTheDocument();
1721
expect(screen.queryByRole("link")).not.toBeInTheDocument();
1822
});
1923

24+
/** With href, renders an `<a>` (no button role). */
2025
test("renders as link when href is provided", () => {
2126
render(<Button href="www.google.com" />);
2227
expect(screen.getByRole("link")).toBeInTheDocument();

frontend/tests/components/Calendar.test.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
1+
/** Component tests for `Calendar` from `shared/components/Inputs/Calendar.tsx`. */
2+
13
import { render, screen, fireEvent, waitFor } from "@testing-library/react";
24
import React from "react";
35
import { describe, expect, test } from "vitest";
46

57
import { Calendar } from "@/shared/components/Inputs/Calendar";
68

79
describe("Calendar", () => {
10+
/** Calendar root mounts with the test-id wrapper. */
811
test("renders the calendar root", () => {
912
render(<Calendar onChange={() => {}} />);
1013
expect(screen.getByTestId("calendar-root")).toBeInTheDocument();
1114
});
1215

16+
/** Mouse-drag flips aria-checked across the dragged cells, both directions. */
1317
test("drag selects and unselects availability cells", async () => {
1418
render(<Calendar onChange={() => {}} />);
1519
const checkboxes = screen.getAllByRole("checkbox");
@@ -33,6 +37,7 @@ describe("Calendar", () => {
3337
});
3438
});
3539

40+
/** Each cell exposes an aria-label encoding its row and column. */
3641
test("applies aria-label per cell", () => {
3742
render(<Calendar onChange={() => {}} />);
3843
const cells = screen.getAllByRole("checkbox");

frontend/tests/components/Checkbox.test.tsx

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/** Component tests for `Checkbox` from `shared/components/Checkbox.tsx`. */
2+
13
import { render, screen } from "@testing-library/react";
24
import userEvent from "@testing-library/user-event";
35
import React from "react";
@@ -6,6 +8,7 @@ import { describe, expect, test } from "vitest";
68
import { Checkbox } from "@/shared/components/Checkbox";
79

810
describe("Checkbox", () => {
11+
/** Click and Space-key both toggle the checked state. */
912
test("toggles via mouse and keyboard", async () => {
1013
const user = userEvent.setup();
1114
render(<Checkbox label="Full Stack Developer" />);
@@ -23,6 +26,7 @@ describe("Checkbox", () => {
2326
expect(screen.queryByRole("checkbox")).toBeChecked();
2427
});
2528

29+
/** Disabled checkbox doesn't accept click toggles. */
2630
test("disabled cannot be toggled", async () => {
2731
const user = userEvent.setup();
2832
render(<Checkbox label="disabled checkbox" disabled />);
@@ -34,6 +38,7 @@ describe("Checkbox", () => {
3438
expect(screen.queryByRole("checkbox")).not.toBeChecked();
3539
});
3640

41+
/** With `defaultChecked`, initial render is checked; clicking unchecks. */
3742
test("defaultChecked starts checked", async () => {
3843
const user = userEvent.setup();
3944
render(<Checkbox label="defaultChecked checkbox" defaultChecked />);
@@ -45,10 +50,12 @@ describe("Checkbox", () => {
4550
expect(screen.queryByRole("checkbox")).not.toBeChecked();
4651
});
4752

48-
test.skip("labelHidden visually hides the label text", () => {
49-
// The hiding is purely CSS (clip/position/overflow on a hashed
50-
// .module.css class). jsdom doesn't apply stylesheet declarations
51-
// to getComputedStyle output, so there's nothing meaningful to
52-
// assert from the test runtime. Verified by hand in the browser.
53-
});
53+
/**
54+
* `labelHidden` visually hides the label text - skipped because
55+
* the hiding is purely CSS (clip/position/overflow on a hashed
56+
* `.module.css` class). jsdom doesn't apply stylesheet declarations
57+
* to `getComputedStyle` output, so there's nothing meaningful to
58+
* assert from the test runtime. Verified by hand in the browser.
59+
*/
60+
test.skip("labelHidden visually hides the label text", () => {});
5461
});

frontend/tests/components/Notification.test.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/** Component tests for `Notification` from `shared/components/Notification/`. */
2+
13
import { render, screen } from "@testing-library/react";
24
import userEvent from "@testing-library/user-event";
35
import React from "react";
@@ -6,13 +8,15 @@ import { describe, expect, test } from "vitest";
68
import { Notification } from "@/shared/components/Notification/Notification";
79

810
describe("Notification", () => {
11+
/** Default role is "status" (polite) and children render inside the bar. */
912
test("renders children with status role by default", () => {
1013
render(<Notification>This is a warning</Notification>);
1114
expect(screen.getByText("This is a warning")).toBeInTheDocument();
1215
expect(screen.getByRole("status")).toBeInTheDocument();
1316
expect(screen.queryByRole("alert")).not.toBeInTheDocument();
1417
});
1518

19+
/** Close button sets aria-hidden=true on the notification bar. */
1620
test("close button hides the notification", async () => {
1721
const user = userEvent.setup();
1822
render(
Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
1+
/**
2+
* Component tests for `TextField` - currently skipped pending rewrite.
3+
*
4+
* The TextField component changed shape during the Next.js port:
5+
* it is now generic over a react-hook-form value schema and
6+
* requires `register`, `id`, and `type` props. The legacy
7+
* standalone-input test no longer applies; rewriting it requires
8+
* wrapping each render in a `useForm` harness, which is deferred
9+
* to a future PR alongside the form-stack finalization.
10+
*/
11+
112
import { describe, test } from "vitest";
213

3-
// The TextField component changed shape during the Next port: it is now
4-
// generic over a react-hook-form value schema and requires `register`,
5-
// `id`, and `type` props. The legacy standalone-input test no longer
6-
// applies; rewriting it requires wrapping each render in a useForm
7-
// harness, which is deferred to the next PR alongside the form-stack
8-
// finalization.
914
describe.skip("TextField (rewrite needed for new generic API)", () => {
1015
test("placeholder", () => {});
1116
});
Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
1+
/**
2+
* Page tests for LandingPage - currently skipped pending rewrite.
3+
*
4+
* The legacy `LandingPage` test relied on `MemoryRouter` and
5+
* selector classes (`.landing-cop-circle-title`) that are not
6+
* part of the ported feature surface. Re-authoring the assertions
7+
* against the new component graph is deferred; the dialog
8+
* open/close behavior should pick up coverage when the qualifier
9+
* flow's e2e harness lands.
10+
*/
11+
112
import { describe, test } from "vitest";
213

3-
// The legacy LandingPage test relied on `MemoryRouter` and selector
4-
// classes (`.landing-cop-circle-title`) that are not part of the
5-
// ported feature surface. Re-authoring the assertions against the new
6-
// component graph is deferred; the dialog open/close behavior should
7-
// pick up coverage when the qualifier flow's e2e harness lands.
814
describe.skip("LandingPage (rewrite needed post-port)", () => {
915
test("placeholder", () => {});
1016
});

0 commit comments

Comments
 (0)