Skip to content

E2E Testing

Last1 ID uses Playwright for end-to-end tests.

Setup

Install Playwright browsers (required once per machine):

npm run test:e2e:install

Or install all browsers:

npx playwright install

If you see "Executable doesn't exist" errors, install to your user cache:

PLAYWRIGHT_BROWSERS_PATH=$HOME/.cache/ms-playwright npx playwright install chromium

The test:e2e script uses this path by default. E2E runs the dev server with SITE_URL and CORS_ORIGINS set to the test port so onboarding and API requests succeed.

Running Tests

npm run test:e2e

For interactive UI mode:

npm run test:e2e:ui

Test Coverage

Unauthenticated Access (always runs)

  • Visiting /dashboard, /profile, /credentials, /settings redirects to /login
  • Redirect param is preserved (e.g. /profile → /login?redirect=%2Fprofile)
  • Visiting /onboarding without auth redirects to /login?redirect=%2Fonboarding

Login & Redirect (requires credentials)

Add these to .env to run auth-dependent tests:

  • E2E_TEST_EMAIL – test user email
  • E2E_TEST_PASSWORD – test user password (use double quotes if it contains #: E2E_TEST_PASSWORD="pass#word")
  • VITE_SUPABASE_URL and VITE_SUPABASE_ANON_KEY – required; auth tests are skipped when Supabase is not configured

The test script loads .env via dotenv-cli. In .env, # starts a comment—wrap values in double quotes to preserve it.

Tests covered:

  • Redirect to intended path after login (/login?redirect=%2Fprofile → /profile)
  • Redirect to dashboard after login when no redirect param

Signup

  • Form validation (passwords match, min length)
  • After signup: redirects to /onboarding or shows "Check your email" (depends on Supabase email confirmation)

The signup flow test is skipped by default (creates real accounts, can hit Supabase limits). To run the full suite including signup:

npm run test:e2e:full

Onboarding (requires credentials)

  • Completes onboarding flow and redirects to dashboard

Note: The onboarding test passes in isolation. The Linked providers block may intermittently fail when run in the full suite—likely due to a race between auth state and navigation. If the beforeEach completes (user on /dashboard), the subsequent page navigation may not render correctly. Consider running the onboarding test first, then the Linked providers tests.

  • Linked providers page loads and shows sign-in methods
  • Unlink button not shown when only one provider (safety guard)
  • Connected apps page loads
  • Consent page loads
  • Revoke confirmation appears when revoking app access (if app is connected)

CI

Run with CI=1 to disable reusing an existing server and enable retries:

CI=1 npm run test:e2e