Skip to content

fix: resolve Supabase database test failures#1330

Merged
riderx merged 1 commit into
mainfrom
riderx/fix-supabase-test-db
Dec 29, 2025
Merged

fix: resolve Supabase database test failures#1330
riderx merged 1 commit into
mainfrom
riderx/fix-supabase-test-db

Conversation

@riderx
Copy link
Copy Markdown
Member

@riderx riderx commented Dec 29, 2025

Summary

Fixed two failing Supabase database tests that were preventing the test suite from passing.

Test plan

Run bun test:all or npx supabase test db to verify all 790 tests pass.

Changes

  • 40_test_email_preferences.sql: Create user in auth.users before inserting into public.users to satisfy foreign key constraint
  • 40_test_password_policy_enforcement.sql: Resolve ambiguous column reference and use proper existence check instead of invalid ON CONFLICT

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Tests
    • Improved email preferences test setup with deterministic user identities for enhanced test reproducibility and reliability.
    • Refined password policy enforcement tests with more robust duplicate prevention logic to ensure data consistency.

✏️ Tip: You can customize this high-level summary in your review settings.

Fixed two test issues:
- 40_test_email_preferences.sql: Create user in auth.users before inserting into public.users to satisfy foreign key constraint
- 40_test_password_policy_enforcement.sql: Resolve ambiguous column reference and use proper existence check instead of invalid ON CONFLICT

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Dec 29, 2025

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

Two SQL test files updated to improve test reproducibility and prevent duplicate data. Test 13 in email preferences now uses deterministic user creation via a DO block. Password policy enforcement test replaces ON CONFLICT logic with conditional IF NOT EXISTS insertion to guard against duplicates.

Changes

Cohort / File(s) Summary
Deterministic Test User Setup
supabase/tests/40_test_email_preferences.sql
Added DO block to create test user via tests.create_supabase_user and obtain deterministic UID from tests.get_supabase_uid('new_email_pref_user') instead of gen_random_uuid(), ensuring reproducible Test 13 execution.
Duplicate Prevention Logic
supabase/tests/40_test_password_policy_enforcement.sql
Replaced direct INSERT with ON CONFLICT DO NOTHING with conditional IF NOT EXISTS check before inserting test_admin into public.org_users. Renamed org_id to target_org_id for clarity. Prevents duplicate org/user entries through guarded insertion.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A rabbit hops through test suites with glee,
Planting deterministic seeds—no more randomness spree!
One guards duplicates with wisdom divine,
While the other ensures reproducible time.
Tests now leap with confidence, organized and clean!

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch riderx/fix-supabase-test-db

📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b70163f and 7781c26.

📒 Files selected for processing (2)
  • supabase/tests/40_test_email_preferences.sql
  • supabase/tests/40_test_password_policy_enforcement.sql

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 SQLFluff (3.5.0)
supabase/tests/40_test_email_preferences.sql

User Error: No dialect was specified. You must configure a dialect or specify one on the command line using --dialect after the command. Available dialects:
ansi, athena, bigquery, clickhouse, databricks, db2, doris, duckdb, exasol, flink, greenplum, hive, impala, mariadb, materialize, mysql, oracle, postgres, redshift, snowflake, soql, sparksql, sqlite, starrocks, teradata, trino, tsql, vertica

supabase/tests/40_test_password_policy_enforcement.sql

User Error: No dialect was specified. You must configure a dialect or specify one on the command line using --dialect after the command. Available dialects:
ansi, athena, bigquery, clickhouse, databricks, db2, doris, duckdb, exasol, flink, greenplum, hive, impala, mariadb, materialize, mysql, oracle, postgres, redshift, snowflake, soql, sparksql, sqlite, starrocks, teradata, trino, tsql, vertica


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@riderx riderx merged commit 8954e70 into main Dec 29, 2025
6 of 8 checks passed
@riderx riderx deleted the riderx/fix-supabase-test-db branch December 29, 2025 13:23
@sonarqubecloud
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot mentioned this pull request Jan 5, 2026
38 tasks
Dalanir pushed a commit that referenced this pull request Jan 12, 2026
Fixed two test issues:
- 40_test_email_preferences.sql: Create user in auth.users before inserting into public.users to satisfy foreign key constraint
- 40_test_password_policy_enforcement.sql: Resolve ambiguous column reference and use proper existence check instead of invalid ON CONFLICT

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Haiku 4.5 <noreply@anthropic.com>
@coderabbitai coderabbitai Bot mentioned this pull request Mar 25, 2026
4 tasks
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