Regression test for paste when the terminal lacks focus. (#4898)

This commit is contained in:
Jacob Richman 2025-07-25 16:29:15 -07:00 committed by GitHub
parent f9cfb20897
commit fb751c542b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 31 additions and 0 deletions

View File

@ -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();
});
});
});