test(tui): clipboard.ts coverage gap - #22253
Closed
wesleysimplicio wants to merge 1 commit into
Closed
Conversation
…cks) The existing clipboard.test.ts covers the happy paths for pbpaste, PowerShell, wl-paste, and xclip, plus 3 isUsableClipboardText cases (normal/empty/binary). Several real branches had no coverage: isUsableClipboardText: - null input (early !text guard) - NUL byte rejection regardless of surrounding printable text - Tab/CR/LF allowed as non-suspicious whitespace controls - The 2-control floor for short strings (boundary at 2 vs 3) - The 2% scaling on long strings (boundary at 2% vs >2%) - U+FFFD replacement char counted as suspicious readClipboardText: - WSL falls through powershell.exe to xclip on first failure - Returns null if backend resolves with non-string stdout - Bare Linux skips wl-paste and goes straight to xclip writeClipboardText: - Empty string forwarded to backend without short-circuit - Bare Linux returns false when xclip AND xsel both exit non-zero Pure helper coverage; no production change.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds targeted Vitest coverage for previously untested branches in ui-tui/src/lib/clipboard.ts, without changing production behavior. It focuses on edge cases across clipboard text validation and backend fallback logic.
Changes:
- Added new test suite covering additional
isUsableClipboardTextedge cases (null, NUL byte, tolerated controls, 2% threshold, U+FFFD). - Added new test cases for
readClipboardTextfallback/selection behavior (WSL fallback, non-string stdout, bare-Linux path). - Added new test cases for
writeClipboardTextbehavior (empty string passthrough, bare-Linux xclip→xsel failure).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
Author
|
Closing non-fix PR as requested — mantendo apenas PRs de fix. |
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 does this PR do?
ui-tui/src/lib/clipboard.tshad several uncovered branches inclipboard.test.ts:Root cause
The detailed rationale from the original PR body is preserved below. This template update keeps the review structure consistent with #29640.
Fix
Why this shape
This shape mirrors #29640 so reviewers can quickly compare scope, root cause, fix, tests, and related context without having to decode a custom PR description.
Tests
Original body
Related PRs / issues
Original body
Summary
ui-tui/src/lib/clipboard.tshad several uncovered branches inclipboard.test.ts:What Changed
Fluxo
A mudança continua seguindo o fluxo original descrito na seção preservada abaixo, sem ampliar o escopo funcional deste PR.
Visão
A padronização melhora a revisão, reduz ruído e evita deriva de formatação entre PRs abertos.
Test Plan
Original body
Summary
ui-tui/src/lib/clipboard.tshad several uncovered branches inclipboard.test.ts:isUsableClipboardText: null input, NUL-byte rejection mid-text, whitespace-control allowance (\n\r\t), absolute floor of 2 stray controls in short text, the 2% scaling threshold for long text, and U+FFFD replacement-char counting.readClipboardText: WSLpowershell.exefailure →xclipfallback, non-stringstdoutreturningnull, bare-Linux skippingwl-pastestraight toxclip.writeClipboardText: empty-string forwarded to backend (no short-circuit), bare-Linux failing bothxclipandxsel.Adds 13 tests in a new file
clipboardCoverageGap.test.ts— no production code change, only fills gaps.Test plan
npx vitest run src/__tests__/clipboardCoverageGap.test.ts→ 13/13 passui-tuiregression:npx vitest run→ 661/661 passGenerated by Hermes Turbo
Generated by Hermes Turbo