Skip to content

Conversation

@marcodejongh
Copy link
Owner

…raint

The session-persistence tests use 'user-123' as the userId for createDiscoverableSession, but the board_sessions.created_by_user_id column has a foreign key constraint referencing the users table.

This fix:

  • Truncates the users table in beforeEach to ensure clean state
  • Creates the 'user-123' test user before each test

…raint

The session-persistence tests use 'user-123' as the userId for
createDiscoverableSession, but the board_sessions.created_by_user_id
column has a foreign key constraint referencing the users table.

This fix:
- Truncates the users table in beforeEach to ensure clean state
- Creates the 'user-123' test user before each test
@vercel
Copy link

vercel bot commented Dec 31, 2025

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

Project Deployment Review Updated (UTC)
boardsesh Ready Ready Preview, Comment Dec 31, 2025 10:26am

@claude
Copy link

claude bot commented Dec 31, 2025

Claude Review

No issues found.

The fix correctly addresses the foreign key constraint issue by:

  1. Truncating the users table in the proper order (after dependent tables)
  2. Creating the required test user before tests that reference it

The ON CONFLICT DO NOTHING is appropriate for test setup idempotency.

The test setup was creating its own database connection, while
roomManager uses the singleton db from @boardsesh/db/client. This
caused the test user insertion to not be visible to roomManager
when it tried to create discoverable sessions.

Changes:
- Import and use sharedDb (same instance as roomManager) for all
  data operations in beforeEach
- Remove unused local db connection and related imports
- Keep raw postgres client only for initial schema creation
@claude
Copy link

claude bot commented Dec 31, 2025

Claude Review

No significant issues found.

The fix correctly addresses the foreign key constraint violation by:

  1. Truncating the users table in beforeEach
  2. Creating the 'user-123' test user before tests run
  3. Using sharedDb for consistency with roomManager

Minor note: The ON CONFLICT (id) DO NOTHING clause is unnecessary since the table is truncated immediately before, but it's harmless.

Changes:
- Add kilter_climbs, kilter_climb_stats, kilter_difficulty_grades tables
  to test setup (required for climb query tests)
- Add equivalent tension tables for tension board tests
- Fix test parameters to use valid size_id values:
  - kilter: size_id 7 (12x14 Commercial) instead of 1
  - tension: size_id 1 (Full Wall) is already valid

The climb-queries tests require these tables to exist even if empty,
as the queries need to execute against actual database tables.
@claude
Copy link

claude bot commented Dec 31, 2025

Claude Review

Issues Found

  1. Schema drift in test table definitions (packages/backend/src/__tests__/setup.ts:75-155): The kilter_climbs and tension_climbs test tables are missing columns present in the actual schema:

    • Missing angle column
    • Missing synced column

    This may cause tests to pass against an incomplete schema while failing against the real database.

  2. Weak test assertions (packages/backend/src/__tests__/climb-queries.test.ts): Several tests have assertions that always pass:

    • Line 73-78: The expect(climb).toBeDefined() inside the grade filter test doesn't actually validate the grade range
    • Line 264-265: expect(kilterResult === null || typeof kilterResult === 'object').toBe(true) - this will always be true since the result is either null or an object
  3. Tests don't verify core functionality (packages/backend/src/__tests__/climb-queries.test.ts): The climb query tests rely on external database state (synced production-like data) rather than setting up known test fixtures. If the database is empty, tests like minAscents filter (line 81-95) will pass vacuously with 0 results.

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.

3 participants