Skip to content

chore(site): Make tests faster #6543

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 8 commits into from
Mar 13, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Improve CreateTemplatePage
  • Loading branch information
BrunoQuaresma committed Mar 9, 2023
commit f3ebd3fb81e889cb20dde099f57a2884484e5102
2 changes: 1 addition & 1 deletion site/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"storybook": "start-storybook -p 6006",
"storybook:build": "build-storybook",
"test": "jest --selectProjects test",
"test:ci": "jest --selectProjects test --silent --verbose",
"test:ci": "jest --selectProjects test --silent",
"test:coverage": "jest --selectProjects test --collectCoverage",
"test:watch": "jest --selectProjects test --watch",
"typegen": "xstate typegen 'src/**/*.ts'",
Expand Down
9 changes: 5 additions & 4 deletions site/src/pages/CreateTemplatePage/CreateTemplatePage.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
renderWithAuth,
} from "testHelpers/renderHelpers"
import CreateTemplatePage from "./CreateTemplatePage"
import { screen, waitFor } from "@testing-library/react"
import { screen, waitFor, within } from "@testing-library/react"
import userEvent from "@testing-library/user-event"
import * as API from "api/api"

Expand Down Expand Up @@ -60,10 +60,11 @@ test("Create template with variables", async () => {
])

// Render page, fill the name and submit
const { router } = await renderPage()
const { router, container } = await renderPage()
const form = container.querySelector("form") as HTMLFormElement
await userEvent.type(screen.getByLabelText(/Name/), "my-template")
await userEvent.click(
screen.getByRole("button", { name: /create template/i }),
within(form).getByRole("button", { name: /create template/i }),
)

// Wait for the variables form to be rendered and fill it
Expand Down Expand Up @@ -98,7 +99,7 @@ test("Create template with variables", async () => {
.mockResolvedValue(MockTemplateVersion)
jest.spyOn(API, "createTemplate").mockResolvedValue(MockTemplate)
await userEvent.click(
screen.getByRole("button", { name: /create template/i }),
within(form).getByRole("button", { name: /create template/i }),
)

await waitFor(() => expect(API.createTemplate).toBeCalledTimes(1))
Expand Down