From fff32e9148f8546fa7d2259045f6847417656922 Mon Sep 17 00:00:00 2001 From: "D. Ror" Date: Mon, 22 Jan 2024 12:56:47 -0500 Subject: [PATCH] Remove act around @testing-library user events (#2892) --- src/components/ProjectSettings/tests/index.test.tsx | 12 +++--------- .../tests/SpeakerConsentListItemIcon.test.tsx | 8 ++------ src/components/SiteSettings/tests/index.test.tsx | 12 +++--------- 3 files changed, 8 insertions(+), 24 deletions(-) diff --git a/src/components/ProjectSettings/tests/index.test.tsx b/src/components/ProjectSettings/tests/index.test.tsx index c4e9d3d23e..c3b9ad80f8 100644 --- a/src/components/ProjectSettings/tests/index.test.tsx +++ b/src/components/ProjectSettings/tests/index.test.tsx @@ -126,9 +126,7 @@ describe("ProjectSettings", () => { const tabs = Object.values(ProjectSettingsTab); expect(screen.queryAllByRole("tab")).toHaveLength(tabs.length); for (const tab of tabs) { - await act(async () => { - await agent.click(screen.getByTestId(tab)); - }); + await agent.click(screen.getByTestId(tab)); isPanelVisible(tab); } }); @@ -143,9 +141,7 @@ describe("ProjectSettings", () => { const tabs = whichTabs(perm, hasSchedule); expect(screen.queryAllByRole("tab")).toHaveLength(tabs.length); for (const tab of tabs) { - await act(async () => { - await agent.click(screen.getByTestId(tab)); - }); + await agent.click(screen.getByTestId(tab)); whichSettings(perm, hasSchedule, tab).forEach((s) => screen.getByTestId(s) ); @@ -164,9 +160,7 @@ describe("ProjectSettings", () => { const tabs = whichTabs(perm, hasSchedule); expect(screen.queryAllByRole("tab")).toHaveLength(tabs.length); for (const tab of tabs) { - await act(async () => { - await agent.click(screen.getByTestId(tab)); - }); + await agent.click(screen.getByTestId(tab)); whichSettings(perm, hasSchedule, tab).forEach((s) => screen.getByTestId(s) ); diff --git a/src/components/ProjectUsers/tests/SpeakerConsentListItemIcon.test.tsx b/src/components/ProjectUsers/tests/SpeakerConsentListItemIcon.test.tsx index 7295f5c166..64ab376633 100644 --- a/src/components/ProjectUsers/tests/SpeakerConsentListItemIcon.test.tsx +++ b/src/components/ProjectUsers/tests/SpeakerConsentListItemIcon.test.tsx @@ -81,9 +81,7 @@ describe("SpeakerConsentListItemIcon", () => { expect(screen.queryByTestId(ListItemIconId.RecordAudio)).toBeNull; expect(screen.queryByTestId(ListItemIconId.UploadAudio)).toBeNull; - await act(async () => { - await agent.click(screen.getByRole("button")); - }); + await agent.click(screen.getByRole("button")); expect(screen.queryByRole("menu")).not.toBeNull; expect(screen.queryByTestId(ListItemIconId.RecordAudio)).not.toBeNull; expect(screen.queryByTestId(ListItemIconId.UploadAudio)).not.toBeNull; @@ -121,9 +119,7 @@ describe("SpeakerConsentListItemIcon", () => { }); expect(screen.queryAllByRole("dialog")).toBeNull; - await act(async () => { - await agent.click(screen.getByRole("button")); - }); + await agent.click(screen.getByRole("button")); expect(screen.queryAllByRole("dialog")).not.toBeNull; }); }); diff --git a/src/components/SiteSettings/tests/index.test.tsx b/src/components/SiteSettings/tests/index.test.tsx index 5c1d01c263..42199d14d2 100644 --- a/src/components/SiteSettings/tests/index.test.tsx +++ b/src/components/SiteSettings/tests/index.test.tsx @@ -53,21 +53,15 @@ describe("SiteSettings", () => { await renderSiteSettings(); // Banners tab - await act(async () => { - await agent.click(screen.getByTestId(SiteSettingsTab.Banners)); - }); + await agent.click(screen.getByTestId(SiteSettingsTab.Banners)); isPanelVisible(SiteSettingsTab.Banners); // Projects tab - await act(async () => { - await agent.click(screen.getByTestId(SiteSettingsTab.Projects)); - }); + await agent.click(screen.getByTestId(SiteSettingsTab.Projects)); isPanelVisible(SiteSettingsTab.Projects); // Users tab - await act(async () => { - await agent.click(screen.getByTestId(SiteSettingsTab.Users)); - }); + await agent.click(screen.getByTestId(SiteSettingsTab.Users)); isPanelVisible(SiteSettingsTab.Users); }); });