test: wait for the rules hint's aria-describedby
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
This commit is contained in:
1 parent
8ce9fcf471
commit
82e6ddc3e6
1 file changed
+3
-2
@@ -1,4 +1,4 @@
|
||||
import { render, screen, fireEvent, within } from "@testing-library/react";
|
||||
import { render, screen, fireEvent, within, waitFor } from "@testing-library/react";
|
||||
import { describe, it, expect, vi, beforeEach } from "vitest";
|
||||
|
||||
vi.mock("next/navigation", () => ({ useRouter: () => ({ push: vi.fn() }) }));
|
||||
@@ -33,7 +33,8 @@ describe("ResetPasswordPage rules", () => {
|
||||
render(<ResetPasswordPage />);
|
||||
await screen.findByText("No spaces");
|
||||
const input = screen.getByLabelText("New password");
|
||||
expect(input.getAttribute("aria-describedby")).toBe("newPasswordRules");
|
||||
// onShown reaches the parent one render after the hint appears.
|
||||
await waitFor(() => expect(input.getAttribute("aria-describedby")).toBe("newPasswordRules"));
|
||||
fireEvent.change(input, { target: { value: "Short1" } });
|
||||
fireEvent.change(screen.getByLabelText("Confirm new password"), { target: { value: "Short1" } });
|
||||
fireEvent.submit(screen.getByRole("button", { name: /set password/i }));
|
||||
|
||||
Reference in new issue
Block a user