Skip to content

feat: ephemeral e2e preview environments#68

Merged
thomasblaymire merged 11 commits into
mainfrom
feat/ephemeral-preview-environments
Mar 16, 2026
Merged

feat: ephemeral e2e preview environments#68
thomasblaymire merged 11 commits into
mainfrom
feat/ephemeral-preview-environments

Conversation

@thomasblaymire
Copy link
Copy Markdown
Owner

Summary

  • Add per-PR isolated Turso databases for preview environments with seeded test accounts (owner, member, admin)
  • Replace single-user signup-based E2E auth with multi-persona login flow using pre-seeded accounts
  • New GitHub Action creates/destroys preview databases on PR open/close and posts credentials as a PR comment
  • Add role-specific onboarding E2E tests that were previously blocked

What changed

New files:

  • e2e/helpers/seed.constants.ts — shared persona definitions (owner/member/admin)
  • e2e/seed-db.ts — database seed script using better-auth/crypto for password hashing
  • e2e/global-setup.ts — Playwright globalSetup that seeds local SQLite DBs in CI
  • .github/workflows/preview-db.yml — preview DB lifecycle (create → seed → Vercel env vars → PR comment → cleanup)

Modified files:

  • e2e/auth.setup.ts — simplified to login-only loop for 3 personas
  • e2e/fixtures/auth.fixture.ts — added ownerPage, memberPage, adminPage fixtures
  • e2e/helpers/auth.constants.ts — derives from seed constants
  • e2e/onboarding.spec.ts — added member/admin role-specific tests
  • playwright.config.ts — added globalSetup
  • .github/workflows/e2e.yml — removed unused E2E_TEST_EMAIL/PASSWORD

Required secrets

The preview-db workflow requires these GitHub Actions secrets (already added):

  • TURSO_API_TOKEN, TURSO_GROUP
  • VERCEL_TOKEN, VERCEL_PROJECT_ID, VERCEL_ORG_ID

Test plan

  • CI E2E tests pass with the new globalSetup seeding
  • Preview-db workflow creates Turso DB and posts PR comment on this PR
  • Preview deploy uses the PR-specific database
  • Login with e2e-owner@test.local / TestPassword123! on the preview URL
  • Closing the PR destroys the Turso database

Shared seed script that creates test users (owner, member, admin),
organization, and memberships in any Turso/SQLite database. Used by
both Playwright globalSetup (CI) and the preview-db workflow (preview).
Replace signup-based auth setup with login-only flow for three personas
(owner, member, admin). Add ownerPage, memberPage, adminPage fixtures.
authenticatedPage remains as backward-compatible owner alias.
Member and admin personas should not see the onboarding wizard.
This was previously blocked by the lack of pre-seeded accounts.
New workflow creates an isolated Turso database per PR, seeds test
accounts, sets Vercel branch-scoped env vars, and posts a PR comment
with login credentials. Cleans up on PR close.

Also removes unused E2E_TEST_EMAIL/PASSWORD from the e2e workflow
since auth now uses the seeded personas.
@vercel
Copy link
Copy Markdown

vercel Bot commented Mar 15, 2026

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

Project Deployment Actions Updated (UTC)
switchflag-app Ready Ready Preview, Comment Mar 15, 2026 10:50pm
switchflag-web Ready Ready Preview, Comment Mar 15, 2026 10:50pm
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
switchflag-docs Skipped Skipped Mar 15, 2026 10:50pm

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 15, 2026

Preview Environment

Role Email Password
Owner e2e-owner@test.local TestPassword123!
Member e2e-member@test.local TestPassword123!
Admin e2e-admin@test.local TestPassword123!

Preview URL: https://switchflag-k8wvvv7v0-tom-blaymires-projects-d8765916.vercel.app

Database: switchflag-pr-68

Auto-derive BETTER_AUTH_URL from VERCEL_URL in preview environments
so auth API calls go to the correct origin. Also allow vercel.live
scripts and connections in CSP.
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 15, 2026

Codecov Report

❌ Patch coverage is 44.44444% with 5 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
apps/dashboard/src/env.ts 44.44% 5 Missing ⚠️

📢 Thoughts on this report? Let us know!

@thomasblaymire thomasblaymire merged commit 19cbcf6 into main Mar 16, 2026
16 of 17 checks passed
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.

1 participant