Skip to content

Add Playwright E2E coverage and close the auth fail-open bypass#46

Draft
posthog[bot] wants to merge 1 commit into
mainfrom
posthog-code/web-playwright-and-auth-fail-closed
Draft

Add Playwright E2E coverage and close the auth fail-open bypass#46
posthog[bot] wants to merge 1 commit into
mainfrom
posthog-code/web-playwright-and-auth-fail-closed

Conversation

@posthog

@posthog posthog Bot commented Jul 22, 2026

Copy link
Copy Markdown

Why

The web/ dashboard had zero end-to-end tests, and the Supabase auth middleware failed open: when NEXT_PUBLIC_SUPABASE_URL / NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY were missing it returned NextResponse.next() and skipped all route gating — so a production deploy with those vars unset would quietly expose the dashboard instead of locking it down. The app is early-stage, which makes now the cheap time to lock in coverage and close the bypass.

What changed

  • Playwright added to web/ — config boots next dev, plus test:e2e / test:e2e:ui scripts. First-phase specs in e2e/ cover the core dashboard flows: shell + empty state, mocked sessions rendering, row-click opening the drawer, the new-agent modal, and the import success/error toasts. Every /api/* route is mocked (see e2e/helpers.ts), so nothing touches real Supabase, OAuth, or the Claude/Jules/Cursor/Gemini vendor APIs.
  • Middleware fails closed — with Supabase unconfigured it now redirects everything to /login instead of passing through. An explicit, opt-in local-dev bypass (AUTH_DEV_BYPASS=true) is honored only when NODE_ENV !== "production", so it can never re-open the gate in a real deploy.
  • Client Supabase usage guardedUserMenu no longer crashes the app when Supabase is unconfigured (the exact bypass scenario), so the UI still renders.
  • README documents the env setup, the fail-closed auth behavior + dev bypass, and the E2E workflow.

Verification

  • All 6 Playwright specs pass against a server where hydration runs.
  • Middleware behavior confirmed: prod (no Supabase) → / redirects to /login; dev with AUTH_DEV_BYPASS=true/ serves 200; dev without the bypass → / redirects to /login. /login stays reachable in every case.

Created with PostHog Code from this inbox report.

The web dashboard had zero end-to-end tests, and the Supabase auth
middleware failed open: with the env vars missing it returned
NextResponse.next() and skipped all route gating, so a prod deploy
without those vars would quietly expose the dashboard.

- Add Playwright to web/ (config boots `next dev`, `test:e2e` script) with
  first-phase specs covering the core dashboard flows: shell + empty state,
  mocked sessions rendering, row-click opening the drawer, the new-agent
  modal, and the import success/error toasts. Every /api/* route is mocked
  so nothing touches real Supabase, OAuth, or the vendor APIs.
- Middleware now fails CLOSED when Supabase is unconfigured (redirect to
  /login), with an explicit, opt-in local-dev bypass (AUTH_DEV_BYPASS=true,
  honored only when NODE_ENV !== "production").
- Guard the client Supabase usage (UserMenu) so the UI still renders in the
  bypass/unconfigured state instead of crashing.
- Document the env setup, auth behavior, and E2E workflow in the README.

Generated-By: PostHog Code
Task-Id: ebe3ffe9-61a2-4909-a679-755bf0f5d7ed
@vercel

vercel Bot commented Jul 22, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
polyagent Ready Ready Preview, Comment Jul 22, 2026 4:56am

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants