Skip to content

Commit 85233ae

Browse files
f0sselclaude
andcommitted
test: add registry link tests for template pages
Add simple tests to verify the Coder registry links are present and properly configured on both the starter templates page and template editor: - Tests link text, href, target, and rel attributes - Uses existing test patterns with MSW and React Testing Library - Verifies external link behavior and accessibility 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 3d1c952 commit 85233ae

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

site/src/pages/CreateTemplateGalleryPage/CreateTemplateGalleryPage.test.tsx

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,39 @@ test("displays the scratch template", async () => {
5151
screen.getByText(MockTemplateExample2.name);
5252
expect(screen.queryByText("Scratch")).toBeInTheDocument();
5353
});
54+
55+
test("displays registry link in page header", async () => {
56+
server.use(
57+
http.get("api/v2/templates/examples", () => {
58+
return HttpResponse.json([MockTemplateExample]);
59+
}),
60+
);
61+
62+
render(
63+
<AppProviders>
64+
<RouterProvider
65+
router={createMemoryRouter(
66+
[
67+
{
68+
element: <RequireAuth />,
69+
children: [
70+
{
71+
path: "/starter-templates",
72+
element: <CreateTemplateGalleryPage />,
73+
},
74+
],
75+
},
76+
],
77+
{ initialEntries: ["/starter-templates"] },
78+
)}
79+
/>
80+
</AppProviders>,
81+
);
82+
83+
const registryLink = await screen.findByRole("link", {
84+
name: /browse the coder registry/i,
85+
});
86+
expect(registryLink).toHaveAttribute("href", "https://registry.coder.com");
87+
expect(registryLink).toHaveAttribute("target", "_blank");
88+
expect(registryLink).toHaveAttribute("rel", "noopener noreferrer");
89+
});

site/src/pages/TemplateVersionEditorPage/TemplateVersionEditorPage.test.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,18 @@ describe.each([
334334
},
335335
);
336336

337+
test("displays registry link in template editor topbar", async () => {
338+
renderEditorPage();
339+
await waitForLoaderToBeRemoved();
340+
341+
const registryLink = screen.getByRole("link", {
342+
name: /browse the coder registry/i,
343+
});
344+
expect(registryLink).toHaveAttribute("href", "https://registry.coder.com");
345+
expect(registryLink).toHaveAttribute("target", "_blank");
346+
expect(registryLink).toHaveAttribute("rel", "noopener noreferrer");
347+
});
348+
337349
test("display pending badge and update it to running when status changes", async () => {
338350
const MockPendingTemplateVersion = {
339351
...MockTemplateVersion,

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy