fix(e2e): mock Discord OAuth via DB manipulation (PP-e20)#1293
Open
timothyfroehlich wants to merge 6 commits intomainfrom
Open
fix(e2e): mock Discord OAuth via DB manipulation (PP-e20)#1293timothyfroehlich wants to merge 6 commits intomainfrom
timothyfroehlich wants to merge 6 commits intomainfrom
Conversation
…ion (PP-e20)
The previous attempt at Playwright route interception couldn't work:
linkIdentity fails server-side ("Unsupported provider: missing redirect
URI") with CI's dummy Discord credentials, so no browser navigation
happens to intercept.
This redesign verifies the testable UI surface instead:
- Anonymous /login shows "Continue with Discord" button
- Authenticated user without Discord linked sees "Connect Discord" button
- After direct linkUserDiscordIdentity() (simulating successful OAuth),
UI shows "Disconnect Discord" on reload
- Clicking Disconnect (which hits the server unlink action, not external
OAuth) reverts the UI to "Connect Discord"
Adds linkUserDiscordIdentity() and unlinkUserDiscordIdentity() helpers to
e2e/support/supabase-admin.ts; these insert/delete rows in auth.identities
via a direct postgres connection and sync the user_profiles mirror column.
The OAuth handshake itself (browser → Discord → callback → DB row) is
integration territory and is explicitly out of scope per PP-e20's
mock-only policy.
Removes the two test.fixme(true, "PP-e20") calls added by skip-PR #1290
— these tests are the fix.
Tracking: PP-e20.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR replaces the previous Playwright-based Discord OAuth interception approach with a DB-backed E2E strategy for Connected Accounts, so CI can still validate the settings/login UI surfaces without depending on a real Discord OAuth round-trip.
Changes:
- Added direct Postgres helpers to create/remove a simulated Discord identity for a test user.
- Reworked the Connected Accounts E2E spec to cover anonymous login button visibility, authenticated connect-state visibility, simulated linked-state rendering, and server-side unlink flow.
- Removed the prior
test.fixmecoverage gap for PP-e20 by replacing it with runnable mock-only tests.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
e2e/support/supabase-admin.ts |
Adds direct DB helpers for simulating Discord link/unlink state in Supabase auth + mirrored profile data. |
e2e/full/oauth-connected-accounts.spec.ts |
Replaces skipped OAuth redirect tests with UI-state assertions driven by dynamic users and DB state setup. |
GoTrue reads all identities for a user during sign-in and throws "Database
error querying schema" when any identity row's identity_data is missing the
`email` field. The linkUserDiscordIdentity helper omitted `email`, causing
the test user's subsequent login to fail after the DB insert.
Fix: add a synthetic email (`${discordId}@discord.test`) to identity_data.
Also: wrap both writes (auth.identities + user_profiles) in a transaction in
both link and unlink helpers; switch ON CONFLICT to DO NOTHING to prevent
accidental identity theft if a discordId is reused; use worker-specific prefix
(getTestPrefix) instead of Date.now() for the fake Discord ID to eliminate
millisecond-collision risk across parallel workers; tighten the skip guard to
check both DISCORD_CLIENT_ID and DISCORD_CLIENT_SECRET (matching what
providers.discord.isAvailable() actually requires).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
3 tasks
GoTrue reads all identities for a user during sign-in and throws "Database
error querying schema" when any identity row's identity_data is missing the
`email` field. The linkUserDiscordIdentity helper omitted `email`, causing
the test user's subsequent login to fail after the DB insert.
Fix: add a synthetic email (`${discordId}@discord.test`) to identity_data.
Also: wrap both writes (auth.identities + user_profiles) in a transaction in
both link and unlink helpers; switch ON CONFLICT to DO NOTHING to prevent
accidental identity theft if a discordId is reused; use worker-specific prefix
(getTestPrefix) instead of Date.now() for the fake Discord ID to eliminate
millisecond-collision risk across parallel workers; tighten the skip guard to
check both DISCORD_CLIENT_ID and DISCORD_CLIENT_SECRET (matching what
providers.discord.isAvailable() actually requires).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
5 tasks
…chema error (PP-e20) GoTrue's signInWithPassword validates ALL of a user's identities during authentication. When we insert a synthetic identity row directly into auth.identities and then call signInWithPassword, GoTrue throws "Database error querying schema" (HTTP 500) because the synthetic row doesn't fully satisfy its internal validation path. Fix: log in first (while the user has no Discord identity), then insert the Discord identity, then reload /settings. The settings page reads identities via getUserIdentities() which is a lighter read-only call that doesn't re-run authentication validation logic. This pattern avoids the GoTrue schema error entirely while still testing the full Disconnect → Connect round-trip. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…' into worktree-agent-a90e634ce9f217727
… invalidation (PP-e20) Raw SQL inserts into auth.identities invalidate the GoTrue session during middleware updateSession on every Next.js request. The test cannot pass until a GoTrue-native admin identity linking API is available. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
What the new tests verify
New helpers in e2e/support/supabase-admin.ts
Removes previous test.fixme calls
Removes the 2 test.fixme(true, "PP-e20 ...") calls added by skip-PR #1290 — the two passing tests ARE the fix for those. The DB-link+unlink test is marked fixme separately with a detailed root cause explanation.
Test plan
🤖 Generated with Claude Code