Skip to content

Commit 13ab399

Browse files
fitchmultzclaude
andcommitted
fix: resolve 6 failing Playwright E2E tests
- Add custom "Invalid email address" validation message to Zod schemas in login, signup, and recover-password routes (fixes 4 tests) - Wait for success toast before polling mailcatcher in password reset tests (fixes 2 tests) - Fix sign-up with existing email test to wait for first signup and use proper toBeVisible() assertion (fixes 1 test) - Fix signUpNewUser utility to wait for signup completion before navigating 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent e4022a9 commit 13ab399

6 files changed

Lines changed: 19 additions & 9 deletions

File tree

frontend/src/routes/login.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import { PasswordInput } from "@/components/ui/password-input"
2323
import useAuth, { isLoggedIn } from "@/hooks/useAuth"
2424

2525
const formSchema = z.object({
26-
username: z.email(),
26+
username: z.email({ message: "Invalid email address" }),
2727
password: z
2828
.string()
2929
.min(1, { message: "Password is required" })

frontend/src/routes/recover-password.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import useCustomToast from "@/hooks/useCustomToast"
2525
import { handleError } from "@/utils"
2626

2727
const formSchema = z.object({
28-
email: z.email(),
28+
email: z.email({ message: "Invalid email address" }),
2929
})
3030

3131
type FormData = z.infer<typeof formSchema>

frontend/src/routes/signup.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import useAuth, { isLoggedIn } from "@/hooks/useAuth"
2222

2323
const formSchema = z
2424
.object({
25-
email: z.email(),
25+
email: z.email({ message: "Invalid email address" }),
2626
full_name: z.string().min(1, { message: "Full Name is required" }),
2727
password: z
2828
.string()

frontend/tests/reset-password.spec.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ test("User can reset password successfully using the link", async ({
4343
await page.getByTestId("email-input").fill(email)
4444

4545
await page.getByRole("button", { name: "Continue" }).click()
46+
await expect(
47+
page.getByText("Password recovery email sent successfully"),
48+
).toBeVisible()
4649

4750
const emailData = await findLastEmail({
4851
request,
@@ -98,6 +101,9 @@ test("Weak new password validation", async ({ page, request }) => {
98101
await page.goto("/recover-password")
99102
await page.getByTestId("email-input").fill(email)
100103
await page.getByRole("button", { name: "Continue" }).click()
104+
await expect(
105+
page.getByText("Password recovery email sent successfully"),
106+
).toBeVisible()
101107

102108
const emailData = await findLastEmail({
103109
request,

frontend/tests/sign-up.spec.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,19 +77,21 @@ test("Sign up with existing email", async ({ page }) => {
7777

7878
// Sign up with an email
7979
await page.goto("/signup")
80-
8180
await fillForm(page, fullName, email, password, password)
8281
await page.getByRole("button", { name: "Sign Up" }).click()
8382

83+
// Wait for first signup to complete (navigates to /login on success)
84+
await page.waitForURL("/login")
85+
8486
// Sign up again with the same email
8587
await page.goto("/signup")
86-
8788
await fillForm(page, fullName, email, password, password)
8889
await page.getByRole("button", { name: "Sign Up" }).click()
8990

90-
await page
91-
.getByText("The user with this email already exists in the system")
92-
.click()
91+
// Properly assert error message is visible
92+
await expect(
93+
page.getByText("The user with this email already exists in the system"),
94+
).toBeVisible()
9395
})
9496

9597
test("Sign up with weak password", async ({ page }) => {

frontend/tests/utils/user.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ export async function signUpNewUser(
1313
await page.getByTestId("password-input").fill(password)
1414
await page.getByTestId("confirm-password-input").fill(password)
1515
await page.getByRole("button", { name: "Sign Up" }).click()
16-
await page.goto("/login")
16+
17+
// Wait for signup to complete (redirects to /login on success)
18+
await page.waitForURL("/login")
1719
}
1820

1921
export async function logInUser(page: Page, email: string, password: string) {

0 commit comments

Comments
 (0)