Skip to content

Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.

✅ Fix hydration race in registration test that broke full-suite runs (#2823)

Luke Vella82775ba288ea
diff --git a/apps/web/tests/authentication.spec.ts b/apps/web/tests/authentication.spec.ts
index 8a7f17ace..f427f92af 100644
--- a/apps/web/tests/authentication.spec.ts
+++ b/apps/web/tests/authentication.spec.ts
@@ -29,7 +29,7 @@ test.describe.serial(() => {
test.describe("new user", () => {
test("user registration", async ({ page }) => {
const registerPage = new RegisterPage(page);
- registerPage.goto();
+ await registerPage.goto();
await registerPage.register({
name: "Test User",
email: testUserEmail,
diff --git a/apps/web/tests/register-page.ts b/apps/web/tests/register-page.ts
index 2048f9a19..6dcaf66ed 100644
--- a/apps/web/tests/register-page.ts
+++ b/apps/web/tests/register-page.ts
@@ -17,17 +17,29 @@ export class RegisterPage {
}
async register({ name, email }: { name: string; email: string }) {
- // Request a verification code
- await this.page.getByPlaceholder("[email protected]").fill(email);
- await this.page
- .getByRole("button", { name: "Continue with email" })
- .click();
+ // The login form is visible before React has hydrated it, so input that
+ // lands too early can be silently lost. Retry until the next screen
+ // appears. The OTP is reused across resends (resendStrategy: "reuse"),
+ // so submitting more than once is safe.
+ await expect(async () => {
+ const verifyHeading = this.page.getByRole("heading", {
+ name: "Verify Your Email",
+ });
+ // A previous attempt may have submitted successfully with the
+ // navigation landing only after its wait expired — the login form is
+ // gone at that point, so don't try to fill it again.
+ if (await verifyHeading.isVisible()) {
+ return;
+ }
+ await this.page.getByPlaceholder("[email protected]").fill(email);
+ await this.page
+ .getByRole("button", { name: "Continue with email" })
+ .click();
+ await verifyHeading.waitFor({ timeout: 5000 });
+ }).toPass();
// Handle verification code
const code = await getCode(email);
- await this.page
- .getByRole("heading", { name: "Verify Your Email" })
- .waitFor();
await this.page.getByLabel("Enter your 6-digit code").fill(code);
// New accounts have no name and go through onboarding. The space name