Skip to content

Commit 7d615e5

Browse files
committed
test: wrap DocsPage tests in ToastProvider + add #sentinel
DocsPage now calls useToasts() for the copy-link toast, so the existing smoke tests fail with "useToasts must be used within ToastProvider". Wrap every render in a ToastProvider via a small renderDocs() helper so all four tests stay tight. Also: EXPECTED_SECTION_IDS was missing #sentinel, which got added to the docs surface earlier today. Without it the "renders every section the sidebar links to" guard wouldn't catch a regression on the Sentinel section. Added.
1 parent 415be60 commit 7d615e5

1 file changed

Lines changed: 20 additions & 22 deletions

File tree

frontend/tests/pages/DocsPage.test.jsx

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { render } from "@testing-library/react"
2020
import { MemoryRouter } from "react-router-dom"
2121

2222
import DocsPage from "../../src/pages/DocsPage"
23+
import { ToastProvider } from "../../src/hooks/useToasts.jsx"
2324

2425

2526
// Section IDs the sidebar links to. Keep in sync with DocsPage.jsx's
@@ -38,6 +39,7 @@ const EXPECTED_SECTION_IDS = [
3839
"camera-groups",
3940
"notifications",
4041
"mcp",
42+
"sentinel",
4143
"plans",
4244
"security-procedures",
4345
"troubleshooting",
@@ -47,23 +49,27 @@ const EXPECTED_SECTION_IDS = [
4749
]
4850

4951

52+
// DocsPage uses useToasts() (for the copy-link toast) so every render
53+
// has to be wrapped in a ToastProvider. Single helper keeps the four
54+
// test bodies short.
55+
function renderDocs() {
56+
return render(
57+
<MemoryRouter>
58+
<ToastProvider>
59+
<DocsPage />
60+
</ToastProvider>
61+
</MemoryRouter>,
62+
)
63+
}
64+
65+
5066
describe("DocsPage (post-split)", () => {
5167
it("mounts without throwing", () => {
52-
expect(() =>
53-
render(
54-
<MemoryRouter>
55-
<DocsPage />
56-
</MemoryRouter>,
57-
),
58-
).not.toThrow()
68+
expect(() => renderDocs()).not.toThrow()
5969
})
6070

6171
it("renders every section the sidebar links to", () => {
62-
const { container } = render(
63-
<MemoryRouter>
64-
<DocsPage />
65-
</MemoryRouter>,
66-
)
72+
const { container } = renderDocs()
6773

6874
for (const id of EXPECTED_SECTION_IDS) {
6975
const section = container.querySelector(`section#${id}`)
@@ -72,22 +78,14 @@ describe("DocsPage (post-split)", () => {
7278
})
7379

7480
it("renders the resources block (the section without an id)", () => {
75-
const { container } = render(
76-
<MemoryRouter>
77-
<DocsPage />
78-
</MemoryRouter>,
79-
)
81+
const { container } = renderDocs()
8082
// Just check the resource grid is present — that's the only block
8183
// without an id and we don't want to slip its loss past the suite.
8284
expect(container.querySelector(".docs-resources")).not.toBeNull()
8385
})
8486

8587
it("renders the bottom CTA link to /sign-up", () => {
86-
const { container } = render(
87-
<MemoryRouter>
88-
<DocsPage />
89-
</MemoryRouter>,
90-
)
88+
const { container } = renderDocs()
9189
const ctaLinks = Array.from(container.querySelectorAll(".docs-cta-btn"))
9290
expect(ctaLinks.length).toBeGreaterThan(0)
9391
expect(ctaLinks[0].getAttribute("href")).toBe("/sign-up")

0 commit comments

Comments
 (0)