Skip to content

Commit 3fbc3ff

Browse files
committed
Merge branch 'prefer-is-visible' into error-page
2 parents 9707289 + 8a1a12a commit 3fbc3ff

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

CLAUDE.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,10 @@ pnpm generate-client:nofetch # Regenerate without fetching
202202
- Loading states and skeleton screens
203203
- Accessibility (keyboard navigation, screen readers)
204204

205+
### Testing Best Practices
206+
207+
- **Prefer `toBeVisible()` over `toBeInTheDocument()`** - `toBeVisible()` checks that an element is actually visible to the user (not hidden via CSS, `aria-hidden`, etc.), while `toBeInTheDocument()` only checks DOM presence. Use `toBeVisible()` for positive assertions and `.not.toBeInTheDocument()` for absence checks.
208+
205209
### Mocking & Testing
206210

207211
- **MSW Auto-Mocker**
@@ -230,13 +234,13 @@ describe("ServerList", () => {
230234
render(<ServerList />);
231235

232236
await waitFor(() => {
233-
expect(screen.getByText("Server 1")).toBeInTheDocument();
237+
expect(screen.getByText("Server 1")).toBeVisible();
234238
});
235239

236240
const copyButton = screen.getByRole("button", { name: /copy url/i });
237241
await userEvent.click(copyButton);
238242

239-
expect(screen.getByText(/copied/i)).toBeInTheDocument();
243+
expect(screen.getByText(/copied/i)).toBeVisible();
240244
});
241245
});
242246
```

helm/Chart.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ apiVersion: v2
22
name: toolhive-cloud-ui
33
description: A Helm chart for ToolHive Cloud UI - Next.js application
44
type: application
5-
version: 0.1.0
6-
appVersion: "0.1.0"
5+
version: 0.0.4
6+
appVersion: "0.0.4"
77
keywords:
88
- nextjs
99
- react

src/components/error-page/error-page.test.tsx

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ describe("ErrorPageLayout", () => {
88
<ErrorPageLayout title="Test Error">Error description</ErrorPageLayout>,
99
);
1010

11-
expect(
12-
screen.getByRole("heading", { name: /test error/i }),
13-
).toBeInTheDocument();
11+
expect(screen.getByRole("heading", { name: /test error/i })).toBeVisible();
1412
});
1513

1614
it("displays children as description", () => {
@@ -20,7 +18,7 @@ describe("ErrorPageLayout", () => {
2018
</ErrorPageLayout>,
2119
);
2220

23-
expect(screen.getByText(/this is the error message/i)).toBeInTheDocument();
21+
expect(screen.getByText(/this is the error message/i)).toBeVisible();
2422
});
2523

2624
it("displays action buttons when provided", () => {
@@ -33,9 +31,7 @@ describe("ErrorPageLayout", () => {
3331
</ErrorPageLayout>,
3432
);
3533

36-
expect(
37-
screen.getByRole("button", { name: /click me/i }),
38-
).toBeInTheDocument();
34+
expect(screen.getByRole("button", { name: /click me/i })).toBeVisible();
3935
});
4036

4137
it("displays a decorative illustration", () => {
@@ -44,6 +40,6 @@ describe("ErrorPageLayout", () => {
4440
);
4541

4642
const svg = container.querySelector("svg[aria-hidden='true']");
47-
expect(svg).toBeInTheDocument();
43+
expect(svg).toBeVisible();
4844
});
4945
});

0 commit comments

Comments
 (0)