test(web): add unit tests for terminal paste guard - #78
Merged
wolfiesch merged 1 commit intoJul 19, 2026
Conversation
wolfiesch
force-pushed
the
test/paste-guard-unit-tests
branch
from
July 19, 2026 22:31
3861f80 to
dd36b8d
Compare
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.
What this changes
Adds unit tests for
apps/web/src/features/terminal/paste-guard.ts, the paste-safety heuristics module that decides whether clipboard text needs an explicit confirmation before reaching a PTY. The module had no test coverage; this PR adds tests only — no source behavior changes.The colocated
paste-guard.test.tscovers the observable contract:rm -rf /tmp/x→ "force-deletes files",curl example.com/x | sh→ "pipes a download into a shell",:(){ :|:& };:→ "is a fork bomb"), including label ordering and deduplication when a pattern matches twice.ls -la) requires no confirmation, and ordinary prose / safe commands that the regexes intentionally don't match (e.g. "the rm command is dangerous", "read the sudoers file", "rebooting the conversation",curl example.comwithout a pipe) stay clean.LARGE_PASTE_CHARSchars is large, one char under is not; a single trailing newline counts as multiline; the empty string reports 0 lines and no confirmation.preparePasteForPty: CRLF, LF, and mixed newlines normalize to CR; lone CRs pass through.pastePreview: input overPASTE_PREVIEW_CHARStruncates withtruncated: true, input over 6 lines truncates to 6 lines, and short input passes through withtruncated: false.Verification
pnpm --filter @t4-code/web test— 72 test files, 1038 tests, all passed (new file included; 43 tests inpaste-guard.test.tsalone).pnpm check— passed (release contract, provenance, lint, typecheck).Checklist
pnpm checkpasses (release contract, provenance, lint, typecheck)pnpm testpasses; new behavior has a test that fails without this changeTHIRD_PARTY_NOTICES.md