-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(machines): update DHCP and discovery forms to use the new API #1116
(#4389)
- Loading branch information
1 parent
7aec6cd
commit 409fc0b
Showing
32 changed files
with
701 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { generateMAASURL, generateName } from "../../utils"; | ||
|
||
context("Settings - DHCP Snippets", () => { | ||
beforeEach(() => { | ||
cy.login(); | ||
cy.addMachine(); | ||
cy.visit(generateMAASURL("/settings/dhcp/add")); | ||
}); | ||
|
||
it("can add a DHCP snippet to a machine", () => { | ||
const snippetName = generateName("dhcp-snippet"); | ||
cy.get("[data-testid='section-header-title']").contains("Settings"); | ||
cy.findByLabelText("Snippet name").type(snippetName); | ||
cy.findByLabelText("Type").select("Machine"); | ||
cy.findByRole("button", { name: /Choose machine/ }).click(); | ||
// ensure the data has loaded | ||
cy.findByRole("grid").should("have.attr", "aria-busy", "false"); | ||
cy.get("tbody").within(() => { | ||
cy.findAllByRole("row").first().click(); | ||
}); | ||
cy.findByLabelText("DHCP snippet").type("ddns-update-style none;"); | ||
cy.findByRole("button", { name: "Save snippet" }).click(); | ||
// expect to be redirected to the list page | ||
cy.findByLabelText("Search DHCP snippets").type(snippetName); | ||
cy.findByRole("grid").within(() => { | ||
cy.findByText(snippetName).should("be.visible"); | ||
cy.findByRole("button", { name: /Delete/ }).click(); | ||
cy.get("[data-testid='action-confirm']").click(); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
src/app/base/components/DhcpFormFields/MachineSelect/MachineSelect.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { screen } from "@testing-library/react"; | ||
import userEvent from "@testing-library/user-event"; | ||
import { Formik } from "formik"; | ||
|
||
import MachineSelect, { Labels } from "./MachineSelect"; | ||
|
||
import { renderWithMockStore } from "testing/utils"; | ||
|
||
it("can open select box on click", async () => { | ||
renderWithMockStore( | ||
<Formik initialValues={{ machine: "" }} onSubmit={jest.fn()}> | ||
<MachineSelect name="machine" /> | ||
</Formik> | ||
); | ||
|
||
expect(screen.queryByRole("listbox")).not.toBeInTheDocument(); | ||
await userEvent.click( | ||
screen.getByRole("button", { name: new RegExp(Labels.ChooseMachine, "i") }) | ||
); | ||
expect(screen.getByRole("listbox")).toBeInTheDocument(); | ||
}); | ||
|
||
it("sets focus on the input field on open", async () => { | ||
renderWithMockStore( | ||
<Formik initialValues={{ machine: "" }} onSubmit={jest.fn()}> | ||
<MachineSelect name="machine" /> | ||
</Formik> | ||
); | ||
|
||
await userEvent.click( | ||
screen.getByRole("button", { name: new RegExp(Labels.ChooseMachine, "i") }) | ||
); | ||
expect( | ||
screen.getByPlaceholderText("Search by hostname, system ID or tags") | ||
).toHaveFocus(); | ||
}); |
Oops, something went wrong.