Skip to content

test: raise Vitest coverage above 75% for worker, allowlist, and imports - #289

Open
Doom-pixel wants to merge 1 commit into
outerbase:mainfrom
Doom-pixel:cursor/improve-vitest-coverage-da73
Open

Doom-pixel wants to merge 1 commit into
outerbase:mainfrom
Doom-pixel:cursor/improve-vitest-coverage-da73

Conversation

@Doom-pixel

Copy link
Copy Markdown

Summary

Improves Vitest coverage for outerbase/starbasedb#71 with behavior-focused tests rather than line-count padding. The suite exercises real, fake, omitted, and invalid inputs on paths previously at 0%.

Also includes two small production fixes found while writing the tests:

  • RLS matching: schema-qualified policies such as public.users apply to unqualified SQL tables like users without leaking across schemas; nested FROM (SELECT …) subqueries are traversed.
  • JWT context: verified JWT claims are copied onto dataSource.context so plugins and RLS can read sub after authentication.

Coverage config excludes src/**/*.test.ts so Istanbul measures production code instead of test files.

Coverage summary

Measured with pnpm vitest run --coverage.enabled true on production src/**/*.ts (test files excluded):

Metric Before (main) After
Statements 76.82% 92.78%
Branches 47.68% 81.92%
Functions 82.10% 92.57%
Lines 77.17% 93.36%

All four thresholds are above the 75% goal. 23 test files and 254 tests passed. New/expanded suites cover the worker, allowlist, CSV/JSON imports, auth/source selection, Durable Object RPC, LiteREST, RLS, and HTTP routes.

Demo / verification notes

Run pnpm test or pnpm vitest run; the new files execute through the existing GitHub Action command. Production coverage can be reproduced with pnpm vitest run --coverage.enabled true.

Remaining gaps: plugins/** is outside the coverage include; LiteREST and src/plugin.ts retain a few uncovered branches; /status/trace still uses the live Cloudflare trace URL.

Bounty

Algora bounty: outerbase/starbasedb#71

/claim #71

Raise production coverage above the 75% goal with behavior-focused
suites for the worker fetch handler, SQL allowlist, CSV import, HTTP
routes, Durable Object RPC, and SDK/hyperdrive query paths.

Also fix RLS so schema-qualified policies match unqualified tables and
nested FROM subqueries, and copy JWT claims onto the request data source
context after authentication.
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.

2 participants