Repository navigation
test(frontend): enforce 60% coverage floor + cover sdk-core/runtime.ts (#13) - #54
Merged
Merged
Conversation
#13) bunfig.toml now sets `coverage = true` + `coverageThreshold = 0.6` so a regression that drops aggregate coverage below #13's 60% acceptance bar fails `bun test` locally and in CI. `coverageReporter` emits the existing `text` summary; `coverageSkipTestFiles` keeps test files out of the floor calculation. To prove the gate works against real surface area, runtime.test.ts now exhaustively covers `invokeOp` — the HTTP transport every generated extension client depends on: - request shaping: default-null body, baseUrl override, URL-encoded path segments, missing-token branch - error mapping per HTTP status: 400/401/403/404/409/503 and a 500 fallback to `internal` - fetch rejection (Error and non-Error throwable) → `unavailable` - unparseable JSON error body falls back to text/statusText - server-supplied `code` wins over status mapping - server-supplied `path` is surfaced on the error envelope Coverage post-change: 89/89 tests pass, aggregate **90.28% funcs / 93.43% lines** across the tested surface. runtime.ts goes from 37.80% → 100%. Bun's coverage gate exits non-zero if either drops below 0.6, so CI catches future drift. #13 acceptance bullets met - [x] Minimum 60% line coverage on the tested surface — gate now enforced in bunfig. - [x] Routing test covering /r/:groups+/:repo/... — PR #33. - [x] CI fails when a touched page lacks a corresponding test update — page-test-coverage-gate.yml (PR #41). Out of scope (separate follow-ups) - Vue SFC component tests (Inbox, RepoHome, CommandPalette). happy- dom's Window doesn't ship Vue's SVG-namespace primitives, so a jsdom switch or @vue/test-utils integration is the next step. - Extension UI smoke tests (ext_issues, ext_pull_requests). Same blocker as above.
There was a problem hiding this comment.
Pull request overview
This PR adds a Bun test coverage gate for the frontend workspace and expands the @comtrya/sdk-core transport tests to fully exercise invokeOp (request shaping + error mapping), helping ensure coverage regressions fail CI and strengthening the SDK’s core HTTP contract.
Changes:
- Enable Bun coverage collection and enforce an aggregate 60% coverage threshold in
frontend/bunfig.toml. - Add a comprehensive
invokeOptest suite covering status→error-code mapping, envelope precedence, transport failures, and URL/body/header shaping. - Reset SDK session state between tests to keep transport tests isolated.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| frontend/packages/sdk-core/src/runtime.test.ts | Adds broad test coverage for invokeOp behavior (errors + request shaping) and resets session state between tests. |
| frontend/bunfig.toml | Turns on Bun coverage and enforces a 60% aggregate coverage threshold for bun test. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+205
to
+211
| test("missing token omits the Authorization header", async () => { | ||
| let headers: Record<string, string> | undefined; | ||
| globalThis.fetch = (async (_u, init?: RequestInit) => { | ||
| headers = init?.headers as Record<string, string>; | ||
| return new Response("null", { status: 200 }); | ||
| }) as unknown as typeof fetch; | ||
| await invokeOp("ext", "i", "x"); |
This was referenced May 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Final acceptance bullet on #13 ("Frontend tests"): enforce the 60% coverage floor so a regression that drops aggregate coverage fails CI.
Changes
`bunfig.toml` — `coverage = true` + `coverageThreshold = 0.6`. `bun test` exits non-zero if either lines or functions drop below 60% across the tested surface.
`packages/sdk-core/src/runtime.test.ts` — exhaustive coverage of `invokeOp`, the HTTP transport every generated extension client depends on:
Coverage
#13 acceptance state after this PR
The two unchecked items genuinely depend on a DOM-layer swap (~2-3 hr of plumbing); ratcheting that into this PR would smuggle a test-infra refactor into a single-concern coverage-gate change.
Closes #13 partial; the SFC-rendering follow-up gets its own issue.