test(cli): fix TextInput timeouts and run only it in CI

This commit is contained in:
mkorwel
2026-04-16 21:58:40 +00:00
parent d87634c904
commit 52d94f740a
2 changed files with 25 additions and 16 deletions
@@ -170,8 +170,11 @@ describe.sequential('TextInput', () => {
});
it('handles character input', async () => {
const { waitUntilReady, unmount } = await render(
const { unmount } = await render(
<TextInput buffer={mockBuffer} onSubmit={onSubmit} onCancel={onCancel} />,
undefined,
undefined,
true,
);
const keypressHandler = mockedUseKeypress.mock.calls[0][0];
@@ -185,17 +188,18 @@ describe.sequential('TextInput', () => {
sequence: 'a',
});
});
await waitUntilReady();
expect(mockBuffer.handleInput).toHaveBeenCalledWith({
name: 'a',
shift: false,
alt: false,
ctrl: false,
cmd: false,
sequence: 'a',
await waitFor(() => {
expect(mockBuffer.handleInput).toHaveBeenCalledWith({
name: 'a',
shift: false,
alt: false,
ctrl: false,
cmd: false,
sequence: 'a',
});
expect(mockBuffer.text).toBe('a');
});
expect(mockBuffer.text).toBe('a');
unmount();
});
@@ -353,8 +357,11 @@ describe.sequential('TextInput', () => {
it('calls onCancel on escape', async () => {
vi.useFakeTimers();
const { waitUntilReady, unmount } = await render(
const { unmount } = await render(
<TextInput buffer={mockBuffer} onCancel={onCancel} onSubmit={onSubmit} />,
undefined,
undefined,
true,
);
const keypressHandler = mockedUseKeypress.mock.calls[0][0];
@@ -368,10 +375,6 @@ describe.sequential('TextInput', () => {
sequence: '',
});
});
// Escape key has a 50ms timeout in KeypressContext, so we need to wrap waitUntilReady in act
await act(async () => {
await waitUntilReady();
});
await waitFor(() => {
expect(onCancel).toHaveBeenCalled();
@@ -419,6 +422,9 @@ describe.sequential('TextInput', () => {
it('registers mouse click handler for free-form text input', async () => {
const { unmount } = await render(
<TextInput buffer={mockBuffer} onSubmit={onSubmit} onCancel={onCancel} />,
undefined,
undefined,
true,
);
expect(mockedUseMouseClick).toHaveBeenCalledWith(
@@ -438,6 +444,9 @@ describe.sequential('TextInput', () => {
onSubmit={onSubmit}
onCancel={onCancel}
/>,
undefined,
undefined,
true,
);
expect(mockedUseMouseClick).toHaveBeenCalledWith(