Fix AvailableParticipantsSection test: use fireEvent to avoid Radix UI timer hang
Replace async userEvent.click with fireEvent.click for the sport filter dropdown test when hasTeam=true. The extra Checkbox components rendered in that path stall userEvent's act() settlement loop inside Radix UI, causing the test to hang. fireEvent bypasses the async machinery while still exercising the open/close behavior. https://claude.ai/code/session_012ACmUs2vAwEF9jZu7Guos2
This commit is contained in:
parent
da0e118886
commit
52277ab864
1 changed files with 7 additions and 4 deletions
|
|
@ -1,5 +1,5 @@
|
||||||
import { describe, it, expect, vi, beforeEach } from "vitest";
|
import { describe, it, expect, vi, beforeEach } from "vitest";
|
||||||
import { render, screen, within } from "@testing-library/react";
|
import { render, screen, within, fireEvent } from "@testing-library/react";
|
||||||
import userEvent from "@testing-library/user-event";
|
import userEvent from "@testing-library/user-event";
|
||||||
import { AvailableParticipantsSection } from "~/components/draft/AvailableParticipantsSection";
|
import { AvailableParticipantsSection } from "~/components/draft/AvailableParticipantsSection";
|
||||||
import type { DraftIneligibilityReason } from "~/lib/draft-eligibility";
|
import type { DraftIneligibilityReason } from "~/lib/draft-eligibility";
|
||||||
|
|
@ -106,7 +106,7 @@ describe("AvailableParticipantsSection", () => {
|
||||||
expect(screen.getByText("Show Drafted")).toBeInTheDocument();
|
expect(screen.getByText("Show Drafted")).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("renders Show Ineligible and Show drafted sports toggles when hasTeam=true", async () => {
|
it("renders Show Ineligible and Show drafted sports toggles when hasTeam=true", () => {
|
||||||
render(
|
render(
|
||||||
<AvailableParticipantsSection
|
<AvailableParticipantsSection
|
||||||
{...defaultProps}
|
{...defaultProps}
|
||||||
|
|
@ -115,8 +115,11 @@ describe("AvailableParticipantsSection", () => {
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
expect(screen.getByText("Show Ineligible")).toBeInTheDocument();
|
expect(screen.getByText("Show Ineligible")).toBeInTheDocument();
|
||||||
// Show drafted sports lives inside the sport filter dropdown
|
// Show drafted sports lives inside the sport filter dropdown.
|
||||||
await clickFirstSportFilterTrigger("Filter by sport: All Sports");
|
// Use fireEvent instead of user.click to avoid Radix UI timer hang when
|
||||||
|
// hasTeam=true renders extra Checkbox components that stall userEvent's
|
||||||
|
// act() settlement loop.
|
||||||
|
fireEvent.click(screen.getAllByRole("button", { name: "Filter by sport: All Sports" })[0]);
|
||||||
const dialog = screen.getByRole("dialog");
|
const dialog = screen.getByRole("dialog");
|
||||||
expect(within(dialog).getByText("Show drafted sports")).toBeInTheDocument();
|
expect(within(dialog).getByText("Show drafted sports")).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue