From 0828fa0eadc304f0789140db800d8d1150e67241 Mon Sep 17 00:00:00 2001 From: "cartsnitch-engineer[bot]" <269717931+cartsnitch-engineer[bot]@users.noreply.github.com> Date: Mon, 4 May 2026 19:07:56 +0000 Subject: [PATCH] fix(register): replace check-your-email success state with inline message (#2) * fix(register): replace check-your-email success state with inline message Ports PR #181 intent from cartsnitch/cartsnitch to cartsnitch/app. Removes registrationComplete, resendLoading, resendMessage state and the handleResendVerification function. After successful signUp.email, now sets setError('Account created! Please sign in.') instead of showing the separate "Check your email" page. Refs: CAR-822, CAR-818 * fix(e2e): update registration test to match new inline success message Renames 'can register a new account and see check your email screen' to 'shows success message after registration' and asserts .bg-red-50 contains 'Account created! Please sign in.' instead of checking for a heading. Updates 'can sign in with credentials' test to first register a fresh account and assert the success message, then proceed with login. Refs: CAR-822, PR cartsnitch/cartsnitch#181 --------- Co-authored-by: Chris Farhood --- e2e/journeys/j1-registration-login.spec.ts | 15 +++++-- src/pages/Register.tsx | 48 +--------------------- 2 files changed, 13 insertions(+), 50 deletions(-) diff --git a/e2e/journeys/j1-registration-login.spec.ts b/e2e/journeys/j1-registration-login.spec.ts index a811cc8..f9eb937 100644 --- a/e2e/journeys/j1-registration-login.spec.ts +++ b/e2e/journeys/j1-registration-login.spec.ts @@ -4,7 +4,7 @@ import { mockAuthRoutes } from '../fixtures'; const uniqueEmail = () => `betty+e2e-${Date.now()}@cartsnitch.test`; test.describe('J1: Registration and Login', () => { - test('can register a new account and see check your email screen', async ({ page }) => { + test('shows success message after registration', async ({ page }) => { await mockAuthRoutes(page, false); await page.goto('/register'); await page.fill('[placeholder="Full Name"]', 'Betty Tester'); @@ -12,7 +12,7 @@ test.describe('J1: Registration and Login', () => { await page.fill('[placeholder="Password (min. 8 characters)"]', 'TestPass123!'); await page.click('button[type="submit"]'); - await expect(page.getByRole('heading', { name: /check your email/i })).toBeVisible(); + await expect(page.locator('.bg-red-50')).toContainText('Account created! Please sign in.'); }); test('shows validation error when registration fields are empty', async ({ page }) => { @@ -31,9 +31,18 @@ test.describe('J1: Registration and Login', () => { }); test('can sign in with credentials and land on dashboard', async ({ page }) => { + await mockAuthRoutes(page, false); + const email = uniqueEmail(); + await page.goto('/register'); + await page.fill('[placeholder="Full Name"]', 'Betty Tester'); + await page.fill('[placeholder="Email"]', email); + await page.fill('[placeholder="Password (min. 8 characters)"]', 'TestPass123!'); + await page.click('button[type="submit"]'); + await expect(page.locator('.bg-red-50')).toContainText('Account created! Please sign in.'); + await mockAuthRoutes(page, true); await page.goto('/login'); - await page.fill('[placeholder="Email"]', 'test@cartsnitch.test'); + await page.fill('[placeholder="Email"]', email); await page.fill('[placeholder="Password"]', 'TestPass123!'); await page.click('button[type="submit"]'); diff --git a/src/pages/Register.tsx b/src/pages/Register.tsx index a36e7c5..2c298ac 100644 --- a/src/pages/Register.tsx +++ b/src/pages/Register.tsx @@ -8,9 +8,6 @@ export function Register() { const [password, setPassword] = useState('') const [error, setError] = useState('') const [loading, setLoading] = useState(false) - const [registrationComplete, setRegistrationComplete] = useState(false) - const [resendLoading, setResendLoading] = useState(false) - const [resendMessage, setResendMessage] = useState('') async function handleSubmit(e: React.FormEvent) { e.preventDefault() @@ -38,7 +35,7 @@ export function Register() { throw new Error(authError.message ?? 'Registration failed') } - setRegistrationComplete(true) + setError('Account created! Please sign in.') } catch { setError('Registration failed. Please try again.') } finally { @@ -46,49 +43,6 @@ export function Register() { } } - async function handleResendVerification() { - setResendLoading(true) - setResendMessage('') - try { - const { error } = await authClient.sendVerificationEmail({ email }) - if (error) { - setResendMessage('Failed to resend. Please try again.') - } else { - setResendMessage('Verification email sent!') - } - } finally { - setResendLoading(false) - } - } - - if (registrationComplete) { - return ( -
-

Check your email

-

- We sent a verification link to {email}. Click it to activate your account. -

- - {resendMessage && ( -

{resendMessage}

- )} -

- Already have an account?{' '} - - Sign in - -

-
- ) - } - return (

Create Account