Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Cover lib/availability; bump global ratchet#144

Merged
twschiller merged 1 commit into
mainfrom
coverage/availability-tests
Jun 5, 2026
Merged

Cover lib/availability; bump global ratchet#144
twschiller merged 1 commit into
mainfrom
coverage/availability-tests

Conversation

@twschiller

Copy link
Copy Markdown
Contributor

Summary

Brings `src/lib/availability.ts` from 26.47% → 100% statements (10% → 100% functions, 0% → 100% branches). The file lost most of its incidental coverage when #142 mocked it out of the rule-engine tests; this PR repays that debt with direct tests against each export.

What the tests cover

  • `resolveAvailability` — all four shapes: `undefined` (default-available), `true`, `false` without reason, `false` with `unavailableReason`, and reactive object delegating to `accessor.get()`.
  • `getRuleAvailabilityStates` — produces a snapshot keyed by rule id across a mixed catalog.
  • `subscribeRuleAvailability` — only subscribes to rules with reactive availability; listener fires with a fresh snapshot when an upstream source emits; the returned cleanup tears down each underlying subscription.
  • `availabilitySource` — is frozen and wired to the module's `get` / `subscribe`.
  • `createApiKeyAvailability` — built-in key short-circuits without consulting user storage; user-key-present → available; user-key-absent → unavailable with reason; `subscribe` wires to `subscribeUserApiKey`.

Ratchet

Global thresholds 65/60/61/65 → 68/63/67/68 to lock in the gain (`src/lib` overall: 90.38% → 95% statements).

Test plan

  • `bun run preflight` passes
  • `availability.ts` shows 100/100/100/100 in the coverage report
  • Global threshold check passes at the new 68/63/67/68 floor

🤖 Generated with Claude Code

Brings src/lib/availability.ts from 26.47% to 100% statements (10% to
100% functions, 0% to 100% branches). The file lost most of its
incidental coverage when #142 mocked it out of the rule-engine tests;
this repays that debt with direct tests against each export.

Tests cover the four `resolveAvailability` shapes (undefined / true /
false-no-reason / false-with-reason / reactive object), the
`getRuleAvailabilityStates` snapshot map across mixed rule types, the
`subscribeRuleAvailability` lifecycle (only reactive rules get
subscribed, listener fires with a fresh snapshot when a source emits,
returned cleanup tears down each source), `availabilitySource` shape
(frozen, wired to the right functions), and all four
`createApiKeyAvailability` branches (built-in key short-circuits, user
key present, user key absent, subscribe wiring).

Ratchet global thresholds 65/60/61/65 → 68/63/67/68.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@vercel

vercel Bot commented Jun 5, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
agent-browser-shield-demo-site Ready Ready Preview, Comment Jun 5, 2026 2:28am

Request Review

@twschiller twschiller merged commit 92610e1 into main Jun 5, 2026
7 checks passed
@twschiller twschiller deleted the coverage/availability-tests branch June 5, 2026 02:35
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.

1 participant