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

Skip to content

Cover storage setRuleEnabled / setAllRuleStates / normalize paths#148

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

Cover storage setRuleEnabled / setAllRuleStates / normalize paths#148
twschiller merged 1 commit into
mainfrom
coverage/storage-tests

Conversation

@twschiller

Copy link
Copy Markdown
Contributor

Summary

Brings `src/lib/storage.ts` from 86.48% → 100% statements (66.66% → 100% functions, 82.35% → 94.11% branches). The existing tests covered `DEFAULT_STATES` composition and `parseOverrides` env-var paths; this PR extends with the missing mutators and the stored-value normalize paths.

What the new tests cover

  • `parseOverrides` null / array / primitive guard — covers the `!parsed || typeof parsed !== "object" || Array.isArray(parsed)` short-circuit that none of the existing cases exercised.
  • `normalize` via `getRuleStates` — corrupt stored values (non-boolean for a rule id) fall back to defaults; missing rule ids fill from defaults.
  • `setRuleEnabled` — flips one rule while preserving the others; notifies subscribers on change.
  • `setAllRuleStates` — normalizes partial input and drops non-boolean values before writing.
  • `subscribe` — returned cleanup stops further notifications.

Ratchet

Global thresholds 69/64/67/68 → 69/65/70/69. `src/lib` overall: 96.11% → 97.41% statements, 94.97% → 95.89% branches.

Test plan

  • `bun run preflight` passes
  • `storage.ts` shows 100/94/100/100 in the coverage report
  • Global threshold check passes at the new 69/65/70/69 floor

🤖 Generated with Claude Code

Brings src/lib/storage.ts from 86.48% to 100% statements (66.66% to
100% functions, 82.35% to 94.11% branches). The existing tests covered
DEFAULT_STATES + parseOverrides env-var paths; this PR extends with
the missing mutators and the stored-value normalize paths:

- parseOverrides null / array / primitive guard (covers the
  `!parsed || typeof parsed !== "object" || Array.isArray(parsed)`
  short-circuit that none of the existing cases exercised)
- normalize via getRuleStates: corrupt stored values (non-boolean for
  a rule id) fall back to defaults; missing rule ids fill from
  defaults
- setRuleEnabled: flips one rule, preserves the rest, notifies
  subscribers
- setAllRuleStates: normalizes partial input + drops non-boolean
  values before writing
- subscribe cleanup stops further notifications

Ratchet global thresholds 69/64/67/68 → 69/65/70/69. The statements
and lines ratchets stay at 69 because src/lib went from 96.11/95.09 to
97.41/97.35 — meaningful but not enough to bump the cross-stratum
global past 70%.

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 3:09am

Request Review

@twschiller twschiller merged commit 2f65faf into main Jun 5, 2026
7 checks passed
@twschiller twschiller deleted the coverage/storage-tests branch June 5, 2026 03:12
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