fix: fix flaky PlanningModeModal test — use findByText for async rendering

The test clicked 'Medium' and 'Continue' synchronously without waiting
for the scope question options to fully render. Use findByText/findByRole
to wait for elements to appear before interacting, and add a timeout to
the final waitFor for the second question.
This commit is contained in:
Timothy Laurent
2026-05-05 13:32:59 -07:00
parent 2d107ea01c
commit a126b893d1
2 changed files with 7 additions and 4 deletions

View File

@@ -1167,8 +1167,11 @@ describe("PlanningModeModal", () => {
expect(screen.getByText("What is the scope?")).toBeDefined();
});
fireEvent.click(screen.getByText("Medium"));
fireEvent.click(screen.getByRole("button", { name: "Continue" }));
const mediumOption = await screen.findByText("Medium");
fireEvent.click(mediumOption);
const continueBtn = await screen.findByRole("button", { name: "Continue" });
fireEvent.click(continueBtn);
await waitFor(() => {
expect(screen.getByText("What are the key requirements?")).toBeDefined();