Skip to content

Commit

Permalink
fix: reserve range error state (#5357)
Browse files Browse the repository at this point in the history
  • Loading branch information
petermakowski authored Mar 19, 2024
1 parent 83c7eb3 commit 44467ed
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,13 @@ import {
ipRange as ipRangeFactory,
ipRangeState as ipRangeStateFactory,
} from "@/testing/factories";
import { userEvent, render, screen, waitFor } from "@/testing/utils";
import {
userEvent,
render,
screen,
waitFor,
renderWithBrowserRouter,
} from "@/testing/utils";

const mockStore = configureStore();

Expand Down Expand Up @@ -246,4 +252,22 @@ describe("ReservedRangeForm", () => {
screen.queryByRole("textbox", { name: Labels.Comment })
).not.toBeInTheDocument();
});

it("displays an error when start and end IP addresses are not provided", async () => {
renderWithBrowserRouter(<ReservedRangeForm setActiveForm={vi.fn()} />, {
state,
route: "/machines",
});
await userEvent.click(
screen.getByRole("textbox", { name: Labels.StartIp })
);
await userEvent.click(screen.getByRole("textbox", { name: Labels.EndIp }));
await userEvent.click(screen.getByRole("button", { name: "Reserve" }));
expect(
await screen.findByLabelText(Labels.StartIp)
).toHaveAccessibleErrorMessage(/Start IP is required/);
expect(
await screen.findByLabelText(Labels.EndIp)
).toHaveAccessibleErrorMessage(/End IP is required/);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ export enum Labels {

const Schema = Yup.object().shape({
comment: Yup.string(),
end_ip: Yup.string().required("Start IP is required"),
start_ip: Yup.string().required("End IP is required"),
start_ip: Yup.string().required("Start IP is required"),
end_ip: Yup.string().required("End IP is required"),
});

const ReservedRangeForm = ({
Expand Down

0 comments on commit 44467ed

Please sign in to comment.