Skip to content

test(terminal-report-filter): cover synthetic + replay report validators#293

Open
dormouse-bot wants to merge 1 commit into
mainfrom
nightly/report-filter-tests
Open

test(terminal-report-filter): cover synthetic + replay report validators#293
dormouse-bot wants to merge 1 commit into
mainfrom
nightly/report-filter-tests

Conversation

@dormouse-bot

Copy link
Copy Markdown
Collaborator

Surfaced by the nightly code-quality survey.

terminal-report-filter.ts had test coverage only for stripMouseReportsFromInput. Its two most complex exports — inputIsSyntheticTerminalReport and inputIsReplayTerminalReport — had none anywhere in the repo, despite being consumed by the replay/lifecycle path to decide whether inbound data is a synthetic terminal report that should be filtered rather than shown to the user.

Both are tokenizer/validators built from concatenated CSI/SS3/OSC (and, for replay, DCS/focus) regexes with an all-chunks-must-validate rule. A regression in the token set or the ^(?:…)$ anchoring — e.g. loosening the . fallback — could let real user input be misclassified as a synthetic report and silently dropped, with nothing to catch it.

This PR adds tests pinning the current behavior:

  • Whole-string-is-reports acceptance (DSR, CPR, SS3, OSC; multiple concatenated reports).
  • Rejection of empty input and of any input containing plain-text bytes (the every-chunk-must-validate contract, including a report with a trailing stray char).
  • For the replay validator specifically: acceptance of genuine responses (CPR, DSR, primary DA, focus in/out) and rejection of non-report escapes like \x1b[2J (clear screen).

No production code changes — coverage only. All 11 tests in the file pass locally (vitest run src/lib/terminal-report-filter.test.ts).

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying mouseterm with  Cloudflare Pages  Cloudflare Pages

Latest commit: c681bec
Status: ✅  Deploy successful!
Preview URL: https://edb4f4d3.mouseterm.pages.dev
Branch Preview URL: https://nightly-report-filter-tests.mouseterm.pages.dev

View logs

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