Skip to content

Improve test coverage with Vitest: allowlist, CSV import, and RLS fixes#262

Draft
cyrillical00 wants to merge 1 commit into
outerbase:mainfrom
cyrillical00:improve-test-coverage
Draft

Improve test coverage with Vitest: allowlist, CSV import, and RLS fixes#262
cyrillical00 wants to merge 1 commit into
outerbase:mainfrom
cyrillical00:improve-test-coverage

Conversation

@cyrillical00
Copy link
Copy Markdown

Closes #71

Summary

  • Fix RLS schema-prefix bug: Table names with schema prefix (e.g. public.users) were not matched against bare table names in SQL queries, so WHERE clauses were silently not applied to restricted tables
  • Fix RLS wildcard * action: Wildcard actions were not recognized in the restriction check
  • Fix null-safety for subquery FROM items: fromTable.table is null for subquery refs, causing a TypeError
  • Fix test isolation bug: mockConfig.role mutation in one test suite persisted into subsequent suites
  • Add 7 tests for src/allowlist/index.ts — previously at 0% coverage
  • Add 10 tests for src/import/csv.ts — previously untested
  • Update RLS test expectations to reflect correct implementation behavior
  • All 173 tests pass (previously 151 passing with 4 pre-existing failures)

Test plan

  • pnpm test passes (all 173 tests)
  • Coverage improved: statement 83.65%, function 87.05%, branch 55.65% (from ~47%)
  • New tests cover meaningful scenarios (valid input, invalid input, edge cases) not just line coverage

…a matching

- Fix RLS schema-prefix mismatch: table names with schema prefix (e.g. public.users)
  were not matched against bare table names from SQL queries, so WHERE clauses were
  silently not applied to restricted tables
- Fix RLS wildcard action (*) not recognized in the restriction check
- Fix null-safety for subquery FROM items (table field is null for subquery refs)
- Fix test isolation: mockConfig.role mutation persisted across test suites
- Add 7 meaningful tests for src/allowlist/index.ts (previously 0% coverage)
- Add 10 meaningful tests for src/import/csv.ts (previously untested)
- Update RLS test expectations to reflect correct implementation behavior
- All 173 tests pass (previously 151 passing with 4 pre-existing failures)
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.

Improve test coverage with Vitest

1 participant