diff --git a/frontend/src/routes/login.tsx b/frontend/src/routes/login.tsx index 78e3d52798..3e4511ae6f 100644 --- a/frontend/src/routes/login.tsx +++ b/frontend/src/routes/login.tsx @@ -23,7 +23,7 @@ import { PasswordInput } from "@/components/ui/password-input" import useAuth, { isLoggedIn } from "@/hooks/useAuth" const formSchema = z.object({ - username: z.email(), + username: z.email({ message: "Invalid email address" }), password: z .string() .min(1, { message: "Password is required" }) diff --git a/frontend/src/routes/recover-password.tsx b/frontend/src/routes/recover-password.tsx index 3f6420dc40..cfdd04b585 100644 --- a/frontend/src/routes/recover-password.tsx +++ b/frontend/src/routes/recover-password.tsx @@ -25,7 +25,7 @@ import useCustomToast from "@/hooks/useCustomToast" import { handleError } from "@/utils" const formSchema = z.object({ - email: z.email(), + email: z.email({ message: "Invalid email address" }), }) type FormData = z.infer diff --git a/frontend/src/routes/signup.tsx b/frontend/src/routes/signup.tsx index ff4f24e028..252c159767 100644 --- a/frontend/src/routes/signup.tsx +++ b/frontend/src/routes/signup.tsx @@ -22,7 +22,7 @@ import useAuth, { isLoggedIn } from "@/hooks/useAuth" const formSchema = z .object({ - email: z.email(), + email: z.email({ message: "Invalid email address" }), full_name: z.string().min(1, { message: "Full Name is required" }), password: z .string() diff --git a/frontend/tests/reset-password.spec.ts b/frontend/tests/reset-password.spec.ts index 88a2fc277c..4de80b1b65 100644 --- a/frontend/tests/reset-password.spec.ts +++ b/frontend/tests/reset-password.spec.ts @@ -43,6 +43,9 @@ test("User can reset password successfully using the link", async ({ await page.getByTestId("email-input").fill(email) await page.getByRole("button", { name: "Continue" }).click() + await expect( + page.getByText("Password recovery email sent successfully"), + ).toBeVisible() const emailData = await findLastEmail({ request, @@ -98,6 +101,9 @@ test("Weak new password validation", async ({ page, request }) => { await page.goto("/recover-password") await page.getByTestId("email-input").fill(email) await page.getByRole("button", { name: "Continue" }).click() + await expect( + page.getByText("Password recovery email sent successfully"), + ).toBeVisible() const emailData = await findLastEmail({ request, diff --git a/frontend/tests/sign-up.spec.ts b/frontend/tests/sign-up.spec.ts index 82f47b11d5..00517ba510 100644 --- a/frontend/tests/sign-up.spec.ts +++ b/frontend/tests/sign-up.spec.ts @@ -77,19 +77,21 @@ test("Sign up with existing email", async ({ page }) => { // Sign up with an email await page.goto("/signup") - await fillForm(page, fullName, email, password, password) await page.getByRole("button", { name: "Sign Up" }).click() + // Wait for first signup to complete (navigates to /login on success) + await page.waitForURL("/login") + // Sign up again with the same email await page.goto("/signup") - await fillForm(page, fullName, email, password, password) await page.getByRole("button", { name: "Sign Up" }).click() - await page - .getByText("The user with this email already exists in the system") - .click() + // Properly assert error message is visible + await expect( + page.getByText("The user with this email already exists in the system"), + ).toBeVisible() }) test("Sign up with weak password", async ({ page }) => { diff --git a/frontend/tests/utils/user.ts b/frontend/tests/utils/user.ts index 33f86e3255..ef534f4405 100644 --- a/frontend/tests/utils/user.ts +++ b/frontend/tests/utils/user.ts @@ -13,7 +13,9 @@ export async function signUpNewUser( await page.getByTestId("password-input").fill(password) await page.getByTestId("confirm-password-input").fill(password) await page.getByRole("button", { name: "Sign Up" }).click() - await page.goto("/login") + + // Wait for signup to complete (redirects to /login on success) + await page.waitForURL("/login") } export async function logInUser(page: Page, email: string, password: string) {