Skip to content

test(coverage): expand Vitest test suites across core modules and fix RLS table matching - #312

Open
Saik2789 wants to merge 1 commit into
outerbase:mainfrom
Saik2789:feat/test-coverage-vitest-71
Open

Saik2789 wants to merge 1 commit into
outerbase:mainfrom
Saik2789:feat/test-coverage-vitest-71

Conversation

@Saik2789

Copy link
Copy Markdown

Purpose

Resolves #71: resolves the 4 pre-existing failing RLS tests and brings Vitest test coverage across all metrics (lines, statements, branches, and functions) well above the 75% threshold with meaningful unit and integration tests.

Changes

  • RLS Policy Table Matching: Fixed schema-qualified table matching (schema.table vs table), table aliasing in queries with JOIN ... AS, and traversal of subqueries in src/rls/index.ts.
  • RLS Test Suite: Repaired failing tests and added coverage for aliases, multi-table joins, and nested WHERE clauses in src/rls/index.test.ts.
  • Allowlist Tests: Added complete test suite covering allowlist validation, pattern matching, admin bypass, and query interception in src/allowlist/index.test.ts.
  • CSV Import Tests: Added tests for src/import/csv.ts covering unsupported content types, empty payloads, raw CSV, JSON-wrapped CSV column mapping, multipart parsing, and partial row failure reporting.
  • Worker Fetch & Routing Tests: Added comprehensive test suite for src/index.ts covering CORS preflight, JWT verification, Durable Object selection, client/admin route authorization, interface route handling, and top-level errors.
  • Operation & Handler Coverage: Cleaned up and expanded unit tests in src/operation.test.ts, src/handler.test.ts, and src/do.test.ts to exercise raw query returns, Hyperdrive fallbacks, transaction failures, and feature toggles.
  • pnpm Build Scripts: Added pnpm-workspace.yaml allowing builds for esbuild and workerd under modern pnpm.

Verification

Ran pnpm test -- --run and pnpm exec vitest run --coverage:

  • Test Files: 22 passed (22)
  • Tests: 245 passed, 0 failed (245)
  • Statements: 94.13% (threshold: 75%)
  • Branches: 79.60% (threshold: 75%)
  • Functions: 93.98% (threshold: 75%)
  • Lines: 94.49% (threshold: 75%)

Prettier check and git diff --check both pass cleanly.

Bounty Claim

@algora-pbc /claim #71

Payout Information

  • Wallet (USDC on Base network): 0x20A0525b47f087f1Cc498cda257A0feB78D2320B

…table matching

- Fix schema-qualified policy table matching and alias support in src/rls/index.ts
- Repair existing RLS test suite and add edge cases in src/rls/index.test.ts
- Add unit test suite for allowlist module in src/allowlist/index.test.ts
- Add unit test suite for CSV import route in src/import/csv.test.ts
- Add unit test suite for worker fetch handler and middleware in src/index.test.ts
- Expand test coverage in src/operation.test.ts, src/handler.test.ts, and src/do.test.ts
- Add pnpm-workspace.yaml to permit required build scripts under pnpm 10/12
- Exceed 75% Vitest threshold across all metrics (lines 94.49%, stmts 94.13%, funcs 93.98%, branches 79.60%)

Fixes outerbase#71
@Saik2789
Saik2789 force-pushed the feat/test-coverage-vitest-71 branch from c24d62d to 8dfd5a3 Compare October 25, 2026 05:38
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