Skip to content

fix: e2e seed timestamps and production safety guard#72

Merged
thomasblaymire merged 1 commit into
mainfrom
fix/e2e-seed-timestamps
Apr 29, 2026
Merged

fix: e2e seed timestamps and production safety guard#72
thomasblaymire merged 1 commit into
mainfrom
fix/e2e-seed-timestamps

Conversation

@thomasblaymire
Copy link
Copy Markdown
Owner

Summary

  • Fix seed timestamp bug: seed-db.ts used Unix seconds but Better Auth expects timestamp_ms (milliseconds), causing all seeded dates to land in 1970 and rejecting login on ephemeral preview environments
  • Add assertSafeToSeed() guard to CLI entry point — blocks VERCEL_ENV=production and only allows file: and libsql://switchflag-pr-{N}-* URLs
  • Update global-setup.ts to also seed ephemeral PR databases (passing auth token through)

Test plan

  • pnpm --filter dashboard exec vitest run — all 984 tests pass
  • pnpm --filter dashboard test:e2e locally — seed runs with file: DB, all personas login
  • Verify TURSO_DATABASE_URL=libsql://switchflag-myorg.turso.io tsx e2e/seed-db.ts throws FATAL
  • Verify VERCEL_ENV=production TURSO_DATABASE_URL=file:test.db tsx e2e/seed-db.ts throws FATAL
  • PR opens → preview-db.yml seeds switchflag-pr-{N} → member user can login on preview

… guard

seed-db.ts used Unix seconds but Better Auth expects timestamp_ms
(milliseconds), causing all seeded dates to land in 1970 and rejecting
login on ephemeral preview environments.

Also adds assertSafeToSeed() to block seeding against production and
updates global-setup.ts to allow seeding ephemeral PR databases.
@vercel
Copy link
Copy Markdown

vercel Bot commented Mar 16, 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 16, 2026 10:32pm
switchflag-web Ready Ready Preview, Comment Mar 16, 2026 10:32pm
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
switchflag-docs Skipped Skipped Mar 16, 2026 10:32pm

@github-actions
Copy link
Copy Markdown

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-qdkkcjiny-tom-blaymires-projects-d8765916.vercel.app

Database: switchflag-pr-72

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 16, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@thomasblaymire thomasblaymire merged commit af62a81 into main Apr 29, 2026
18 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