Skip to content

Commit

Permalink
Remove act around @testing-library user events (#2892)
Browse files Browse the repository at this point in the history
  • Loading branch information
imnasnainaec authored Jan 22, 2024
1 parent ef75bcd commit fff32e9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 24 deletions.
12 changes: 3 additions & 9 deletions src/components/ProjectSettings/tests/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
});
Expand All @@ -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)
);
Expand All @@ -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)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
});
});
Expand Down
12 changes: 3 additions & 9 deletions src/components/SiteSettings/tests/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});

0 comments on commit fff32e9

Please sign in to comment.