8000 feat(site): add create template from scratch by BrunoQuaresma · Pull Request #12082 · coder/coder · GitHub
[go: up one dir, main page]

Skip to content

feat(site): add create template from scratch #12082

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Feb 9, 2024
Prev Previous commit
Next Next commit
Test if scratch template is not displayed
  • Loading branch information
BrunoQuaresma committed Feb 9, 2024
commit 060951119a5ca3f23b3b31e587cd519b318fb745
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import { render, screen } from "@testing-library/react";
import StarterTemplatesPage from "./StarterTemplatesPage";
import { AppProviders } from "App";
import { RouterProvider, createMemoryRouter } from "react-router-dom";
import { RequireAuth } from "contexts/auth/RequireAuth";
import { rest } from "msw";
import {
MockTemplateExample,
MockTemplateExample2,
} from "testHelpers/entities";
import { server } from "testHelpers/server";

test("does not display the scratch template", async () => {
server.use(
rest.get(
"api/v2/organizations/:organizationId/templates/examples",
(req, res, ctx) => {
return res(
ctx.status(200),
ctx.json([
MockTemplateExample,
MockTemplateExample2,
{
...MockTemplateExample,
id: "scratch",
name: "Scratch",
description: "Create a template from scratch",
},
]),
);
},
),
);

render(
<AppProviders>
<RouterProvider
router={createMemoryRouter(
[
{
element: <RequireAuth />,
children: [
{
path: "/starter-templates",
element: <StarterTemplatesPage />,
},
],
},
],
{ initialEntries: ["/starter-templates"] },
)}
/>
</AppProviders>,
);

await screen.findByText(MockTemplateExample.name);
screen.getByText(MockTemplateExample2.name);
expect(screen.queryByText("Scratch")).not.toBeInTheDocument();
});
0