summaryrefslogtreecommitdiff
path: root/packages/cli/src/ui/components/InputPrompt.test.tsx
diff options
context:
space:
mode:
authorJacob Richman <[email protected]>2025-07-25 16:29:15 -0700
committerGitHub <[email protected]>2025-07-25 23:29:15 +0000
commitfb751c542bc935158aaa0d01c0694eb3bb6b2919 (patch)
tree65febc2e5051691ac4e6ffe144abd77817ba83f7 /packages/cli/src/ui/components/InputPrompt.test.tsx
parentf9cfb208974b02218c59a55acddbec07b2514fb7 (diff)
Regression test for paste when the terminal lacks focus. (#4898)
Diffstat (limited to 'packages/cli/src/ui/components/InputPrompt.test.tsx')
-rw-r--r--packages/cli/src/ui/components/InputPrompt.test.tsx31
1 files changed, 31 insertions, 0 deletions
diff --git a/packages/cli/src/ui/components/InputPrompt.test.tsx b/packages/cli/src/ui/components/InputPrompt.test.tsx
index 60ba648d..1d0b868f 100644
--- a/packages/cli/src/ui/components/InputPrompt.test.tsx
+++ b/packages/cli/src/ui/components/InputPrompt.test.tsx
@@ -1121,4 +1121,35 @@ describe('InputPrompt', () => {
unmount();
});
});
+
+ describe('unfocused paste', () => {
+ it('should handle bracketed paste when not focused', async () => {
+ props.focus = false;
+ const { stdin, unmount } = render(<InputPrompt {...props} />);
+ await wait();
+
+ stdin.write('\x1B[200~pasted text\x1B[201~');
+ await wait();
+
+ expect(mockBuffer.handleInput).toHaveBeenCalledWith(
+ expect.objectContaining({
+ paste: true,
+ sequence: 'pasted text',
+ }),
+ );
+ unmount();
+ });
+
+ it('should ignore regular keypresses when not focused', async () => {
+ props.focus = false;
+ const { stdin, unmount } = render(<InputPrompt {...props} />);
+ await wait();
+
+ stdin.write('a');
+ await wait();
+
+ expect(mockBuffer.handleInput).not.toHaveBeenCalled();
+ unmount();
+ });
+ });
});