Skip to content

Commit

Permalink
Merge pull request #7126 from Sage/prep-react-18
Browse files Browse the repository at this point in the history
Add missing `act` wrappers
  • Loading branch information
Parsium authored Dec 16, 2024
2 parents 844523f + 6685d87 commit d1a7d79
Show file tree
Hide file tree
Showing 46 changed files with 977 additions and 422 deletions.
10 changes: 7 additions & 3 deletions src/__internal__/checkable-input/checkable-input.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import { render, screen } from "@testing-library/react";
import { act, render, screen } from "@testing-library/react";
import CheckableInput from ".";

test("renders `label` with expected id when `id` prop is passed", () => {
Expand Down Expand Up @@ -40,7 +40,9 @@ test("renders input with 'aria-describedby' as the id of the validation tooltip

expect(input).not.toHaveAttribute("aria-describedby");

input.focus();
act(() => {
input.focus();
});

expect(input).toHaveAttribute("aria-describedby", "foo-validation");
});
Expand All @@ -59,7 +61,9 @@ test("appends the id of the validation tooltip to the input's 'aria-describedby'

expect(input).toHaveAttribute("aria-describedby", "foo-field-help");

input.focus();
act(() => {
input.focus();
});

expect(input).toHaveAttribute(
"aria-describedby",
Expand Down
13 changes: 9 additions & 4 deletions src/__internal__/fieldset/fieldset.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import { render, screen, within } from "@testing-library/react";
import { act, render, screen, within } from "@testing-library/react";
import Fieldset from ".";
import { testStyledSystemMargin } from "../../__spec_helper__/__internal__/test-utils";

Expand Down Expand Up @@ -96,11 +96,16 @@ test("sets `aria-describedby` on help icon as tooltip content when focused and r
<input />
</Fieldset>,
);

const help = screen.getByRole("button", { name: "help" });
help.focus();

act(() => {
help.focus();
});
expect(help).toHaveAccessibleDescription("label help");
help.blur();

act(() => {
help.blur();
});
expect(help).not.toHaveAttribute("aria-describedby");
});

Expand Down
Loading

0 comments on commit d1a7d79

Please sign in to comment.