Skip to content

Add Playwright E2E coverage + fail-closed auth to web dashboard#48

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

Add Playwright E2E coverage + fail-closed auth to web dashboard#48
posthog[bot] wants to merge 1 commit into
mainfrom
posthog-code/web-e2e-tests-and-fail-closed-auth

Conversation

@posthog

@posthog posthog Bot commented Jul 22, 2026

Copy link
Copy Markdown

Summary

The web/ dashboard had zero E2E coverage, and its auth middleware failed open when the Supabase env vars were missing. This PR adds both a regression safety net and closes the latent auth-bypass.

  • E2E tests (Playwright). Adds @playwright/test + a test:e2e script and a config that boots the Next.js dev server. Tests mock /api/sessions and /api/import at the network layer, so they never touch real Supabase, OAuth, or vendor APIs. Flows covered: dashboard render, New Agent modal, session table, row-click opening the session drawer, and the import error toast.
  • Fail-closed auth. lib/supabase/middleware.ts no longer skips route gating when the Supabase vars are absent. In production it now redirects all non-auth routes to /login; the dev pass-through stays explicit (non-production build, or SUPABASE_AUTH_BYPASS=true).
  • Made the browser Supabase client resilient when unconfigured so the dev bypass actually runs the app, and documented env setup, auth-bypass behavior, and the E2E suite in the README.

Why

If the Supabase env vars ever went missing in a production deploy, the middleware's fail-open behavior would expose the entire dashboard with no auth gate. That, plus the total absence of E2E tests on the dashboard's core flows, motivated this contained, pre-production hardening pass.

Test plan

  • npm run test:e2e in web/ — all 5 dashboard specs pass.
  • Verified fail-closed manually against a production build (next start, no Supabase env): GET / → 307 → /login, /login → 200, and SUPABASE_AUTH_BYPASS=true/ passes through (200).

Note: web/components/session-drawer.tsx has a pre-existing react-hooks/set-state-in-effect lint error on main, unrelated to this change and left untouched.


Created with PostHog Code from this inbox report.

…shboard

Adds end-to-end test coverage for the Next.js dashboard and closes a latent
auth-bypass in the Supabase middleware.

E2E tests (Playwright): wires @playwright/test into web/ with a config that boots
the dev server, plus deterministic tests that mock /api/sessions and /api/import
at the network layer (never touching real Supabase, OAuth, or vendor APIs). Covers
dashboard render, the New Agent modal, the session table, opening the session
drawer on row-select, and the import error toast.

Auth hardening: the middleware previously failed open when the Supabase env vars
were missing — silently skipping route gating. It now fails closed in production
(missing vars gate all routes to /login), while keeping the dev pass-through
explicit via a non-production build or SUPABASE_AUTH_BYPASS=true.

Also makes the browser Supabase client resilient when unconfigured so the dev
bypass genuinely runs the app, and documents env setup, the auth-bypass behavior,
and how to run the E2E suite in the README.

Generated-By: PostHog Code
Task-Id: c1a06c7f-4e49-4d79-8839-60392d4f632d
@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 5:11am

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