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

Skip to content

Add fast-check property tests for placeholder and pii-redact Luhn#136

Merged
twschiller merged 1 commit into
mainfrom
add-fast-check-property-tests
Jun 4, 2026
Merged

Add fast-check property tests for placeholder and pii-redact Luhn#136
twschiller merged 1 commit into
mainfrom
add-fast-check-property-tests

Conversation

@twschiller

Copy link
Copy Markdown
Contributor

Summary

  • Adds fast-check as a dev dependency in extension/.
  • Property tests for replaceMatchesInTextNode (extension/src/lib/__tests__/placeholder.property.test.ts): no-op on empty matches; one inline placeholder per disjoint match; non-matched text preserved exactly and in order; reveal round-trips back to the original text; overlapping matches are dropped, not double-replaced.
  • Property tests for the Luhn-gated card detector in pii-redact (extension/src/rules/__tests__/pii-redact.property.test.ts): every Luhn-valid 13–19-digit number is masked; the same numbers with a single-digit flip (Luhn-invalid, same shape) are left alone.

Why fast-check here

These two surfaces have small invariants that are tedious to enumerate by example: the placeholder replacer is cursor-driven and easy to break on overlap/order changes, and the Luhn check sits behind a regex that admits many digit shapes the checksum then has to reject. Property tests give us a regression net for refactors without us having to hand-build cases at every boundary.

Test plan

  • bun run preflight — biome, eslint, tsc (src + tests), knip, jest with coverage (1015 tests, both new suites included).

🤖 Generated with Claude Code

Property-based tests cover invariants that example-based tests can't
easily enumerate: that `replaceMatchesInTextNode` preserves all
non-matched text, emits exactly one inline placeholder per disjoint
match, and round-trips through reveal back to the original text; and
that the PII detector masks every Luhn-valid card number while leaving
Luhn-invalid digit runs of the same shape alone.

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

vercel Bot commented Jun 4, 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 4, 2026 9:35pm

Request Review

@twschiller twschiller merged commit 8de7857 into main Jun 4, 2026
7 checks passed
@twschiller twschiller deleted the add-fast-check-property-tests branch June 4, 2026 21:39
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