Skip to content
Merged
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
Do less things
  • Loading branch information
BrunoQuaresma committed Mar 9, 2023
commit 70e80c087ec352a02e4b1af0563f7fb21aca0d94
20 changes: 1 addition & 19 deletions site/src/pages/CreateTemplatePage/CreateTemplatePage.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import {
MockTemplateVersionVariable1,
MockTemplateVersionVariable2,
MockTemplateVersionVariable3,
MockTemplateVersionVariable4,
MockTemplateVersionVariable5,
renderWithAuth,
} from "testHelpers/renderHelpers"
import CreateTemplatePage from "./CreateTemplatePage"
Expand Down Expand Up @@ -55,8 +53,6 @@ test("Create template with variables", async () => {
MockTemplateVersionVariable1,
MockTemplateVersionVariable2,
MockTemplateVersionVariable3,
MockTemplateVersionVariable4,
MockTemplateVersionVariable5,
])

// Render page, fill the name and submit
Expand All @@ -69,6 +65,7 @@ test("Create template with variables", async () => {

// Wait for the variables form to be rendered and fill it
await screen.findByText(/Variables/)

// Type first variable
await userEvent.clear(screen.getByLabelText(/var.first_variable/))
await userEvent.type(
Expand All @@ -80,18 +77,6 @@ test("Create template with variables", async () => {
await userEvent.type(screen.getByLabelText(/var.second_variable/), "2")
// Select third variable on radio
await userEvent.click(screen.getByLabelText(/True/))
// Type fourth variable
await userEvent.clear(screen.getByLabelText(/var.fourth_variable/))
await userEvent.type(
screen.getByLabelText(/var.fourth_variable/),
"Fourth value",
)
// Type fifth variable
await userEvent.clear(screen.getByLabelText(/var.fifth_variable/))
await userEvent.type(
screen.getByLabelText(/var.fifth_variable/),
"Fifth value",
)
// Setup the mock for the second template version creation before submit the form
jest.clearAllMocks()
jest
Expand All @@ -101,7 +86,6 @@ test("Create template with variables", async () => {
await userEvent.click(
within(form).getByRole("button", { name: /create template/i }),
)

await waitFor(() => expect(API.createTemplate).toBeCalledTimes(1))
expect(router.state.location.pathname).toEqual(
`/templates/${MockTemplate.name}`,
Expand All @@ -116,8 +100,6 @@ test("Create template with variables", async () => {
{ name: "first_variable", value: "First value" },
{ name: "second_variable", value: "2" },
{ name: "third_variable", value: "true" },
{ name: "fourth_variable", value: "Fourth value" },
{ name: "fifth_variable", value: "Fifth value" },
],
})
})