feat(e2e): migrate from MSW to real local Supabase database#45
feat(e2e): migrate from MSW to real local Supabase database#45ryota-murakami merged 3 commits intomainfrom
Conversation
Replace MSW mock handlers with real local Supabase instance for higher test confidence. GitHub API mocking retained for external API stability. - Add global-setup.ts to reset database before tests - Add global-teardown.ts for test completion handling - Add db-query.ts helper with UUID constants for CRUD verification - Expand seed.sql with comprehensive fixture data matching MSW mocks - Update playwright.config.ts with globalSetup/globalTeardown hooks - Update auth.setup.ts with UUID user ID for local Supabase - Update CI workflow to start local Supabase in each shard Closes #42
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthroughSwitches E2E from MSW mocks to a local Supabase-based flow: CI starts Supabase, seeds the DB, Playwright uses globalSetup/globalTeardown, new DB query helpers and deterministic seed data added, many tests gain skipped DB-verification cases and MSW per-test resets removed. Changes
Sequence Diagram(s)sequenceDiagram
participant CI as GitHub Actions CI
participant SupabaseCLI as Supabase CLI
participant DB as Local Supabase (Postgres / PostgREST)
participant WebApp as Next.js web server
participant Playwright as Playwright runner
participant Tests as E2E tests (helpers)
CI->>SupabaseCLI: install & supabase start
SupabaseCLI-->>DB: launch Postgres & PostgREST
CI->>SupabaseCLI: pnpm db:reset (apply `seed.sql`)
SupabaseCLI->>DB: seed fixtures (deterministic UUIDs)
CI->>WebApp: start web server with LOCAL_SUPABASE_* env
WebApp->>DB: serve requests using local Supabase
CI->>Playwright: run tests (globalSetup already reset DB)
Playwright->>WebApp: drive UI flows
Playwright->>Tests: call `e2e/helpers/db-query` for direct DB assertions
Tests->>DB: run SELECT queries for verification
CI->>SupabaseCLI: stop (cleanup)
SupabaseCLI-->>DB: terminate containers
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🤖 Morph Preview TestPreview URL: https://gitbox-3gdjzlddc-laststance.vercel.app AI SummaryIssues:
Verified:
Notes:
RecordingAutomated testing by Morph |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #45 +/- ##
=======================================
Coverage 75.03% 75.03%
=======================================
Files 119 119
Lines 3821 3821
Branches 991 991
=======================================
Hits 2867 2867
Misses 938 938
Partials 16 16 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
🧪 E2E Coverage Report (Sharded: 12 parallel jobs)
📊 Full report available in workflow artifacts |
🤖 Morph Preview TestPreview URL: https://gitbox-ph75bsdy4-laststance.vercel.app AI SummaryIssues:
Verified:
Notes:
RecordingAutomated testing by Morph |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In `@e2e/logged-in/kanban-dnd/card-dnd.spec.ts`:
- Around line 292-337: The test 'should verify card status_id is persisted in
database after move `@slow`' currently uses a conditional that allows the test to
silently pass if the DB value never changes; update the assertions to fail fast
by (1) asserting cardBefore and cardAfter are not null, (2) asserting
cardAfter.status_id !== initialStatusId, and (3) asserting cardAfter.status_id
=== STATUS_IDS.productionRelease (use the existing CARD_IDS.card4, querySingle,
cdpCardToColumnDragAndDrop symbols to locate the flow); optionally implement a
short retry/poll loop around querySingle to wait for the server action to
persist before asserting so the test is robust but still fails when the DB never
updates.
In `@e2e/logged-in/kanban-dnd/column-dnd.spec.ts`:
- Around line 1606-1664: The test currently bypasses assertions when the drag
didn't change grid_row, allowing false positives; update the 'should verify
column grid position is persisted in database `@slow`' test to explicitly fail if
the drag didn't move the column (e.g., assert statusAfter.grid_row !==
initialRow or throw an explicit error) immediately after fetching statusAfter
(before checking expected values), then assert the exact expected values
(grid_row === 2 and grid_col === 1); locate this logic around the
variables/status calls statusBefore, initialRow, cdpColumnToNewRowDragAndDrop,
and statusAfter to implement the early-fail assertion.
🧹 Nitpick comments (1)
e2e/logged-in/board-settings.spec.ts (1)
301-341: Align auth-state path with repo convention before re-enabling this suite.
Line 22 usese2e/.auth/user.json, but the project convention expectstests/e2e/.auth/user.json. Please update the storageState path to avoid auth-state drift when this test is unskipped.Suggested update
- test.use({ storageState: 'e2e/.auth/user.json' }) + test.use({ storageState: 'tests/e2e/.auth/user.json' })Based on learnings: Store authentication state in
tests/e2e/.auth/user.json(gitignored) for E2E tests.
Remove conditional `if (changed) { expect }` assertions that could
silently pass when database updates fail. Use explicit `.not.toBe()`
followed by `.toBe()` to ensure tests fail fast when drag operations
don't persist to database.
Addresses CodeRabbit review feedback on PR #45.
🤖 Morph Preview TestPreview URL: https://gitbox-qww9hlaaq-laststance.vercel.app AI SummaryIssues:
Verified:
Notes:
RecordingAutomated testing by Morph |



Summary
Changes
global-setup.ts,global-teardown.ts, anddb-query.tshelperseed.sqlwith 2 boards, 5 status columns, 5 repo cards, 4 project info entries, 2 maintenance itemsplaywright.config.tswith globalSetup/globalTeardown hooksauth.setup.tswith UUID user ID for local SupabaseTest plan
Technical Notes
pnpm db:resetmay show container restart warnings (handled gracefully)Closes #42
Summary by CodeRabbit
Tests
Chores
✏️ Tip: You can customize this high-level summary in your review settings.