From 16f5f767b25edea3faea5ed6df2cc07aa8460335 Mon Sep 17 00:00:00 2001 From: Adam Weidman <65992621+adamfweidman@users.noreply.github.com> Date: Wed, 22 Oct 2025 00:18:23 +0200 Subject: [PATCH] chore: use waitFor rather than wait (#11616) --- .../src/ui/components/InputPrompt.test.tsx | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/packages/cli/src/ui/components/InputPrompt.test.tsx b/packages/cli/src/ui/components/InputPrompt.test.tsx index e54015cbf0..4055c2f78c 100644 --- a/packages/cli/src/ui/components/InputPrompt.test.tsx +++ b/packages/cli/src/ui/components/InputPrompt.test.tsx @@ -1837,13 +1837,14 @@ describe('InputPrompt', () => { act(() => { stdin.write('\x12'); }); - await wait(); - const frame = stdout.lastFrame(); - expect(frame).toContain('(r:)'); - expect(frame).toContain('echo hello'); - expect(frame).toContain('echo world'); - expect(frame).toContain('ls'); + await waitFor(() => { + const frame = stdout.lastFrame(); + expect(frame).toContain('(r:)'); + expect(frame).toContain('echo hello'); + expect(frame).toContain('echo world'); + expect(frame).toContain('ls'); + }); unmount(); }); @@ -1898,10 +1899,11 @@ describe('InputPrompt', () => { act(() => { stdin.write('\x12'); }); - await wait(); // Verify reverse search is active - expect(stdout.lastFrame()).toContain('(r:)'); + await waitFor(() => { + expect(stdout.lastFrame()).toContain('(r:)'); + }); // Press Tab to complete the highlighted entry act(() => { @@ -1934,9 +1936,10 @@ describe('InputPrompt', () => { act(() => { stdin.write('\x12'); }); - await wait(); - expect(stdout.lastFrame()).toContain('(r:)'); + await waitFor(() => { + expect(stdout.lastFrame()).toContain('(r:)'); + }); act(() => { stdin.write('\r'); @@ -1958,7 +1961,6 @@ describe('InputPrompt', () => { props.buffer.cursor = initialCursor; // Mock the reverse search completion to be active and then reset - const mockResetCompletionState = vi.fn(); mockedUseReverseSearchCompletion.mockImplementation( (buffer, shellHistory, reverseSearchActiveFromInputPrompt) => ({ ...mockReverseSearchCompletion, @@ -1966,7 +1968,6 @@ describe('InputPrompt', () => { ? [{ label: 'history item', value: 'history item' }] : [], showSuggestions: reverseSearchActiveFromInputPrompt, - resetCompletionState: mockResetCompletionState, }), ); @@ -1979,9 +1980,10 @@ describe('InputPrompt', () => { act(() => { stdin.write('\x12'); }); - await wait(); - expect(stdout.lastFrame()).toContain('(r:)'); + await waitFor(() => { + expect(stdout.lastFrame()).toContain('(r:)'); + }); // Press kitty escape key act(() => { @@ -1990,12 +1992,10 @@ describe('InputPrompt', () => { await waitFor(() => { expect(stdout.lastFrame()).not.toContain('(r:)'); - expect(mockResetCompletionState).toHaveBeenCalled(); + expect(props.buffer.text).toBe(initialText); + expect(props.buffer.cursor).toEqual(initialCursor); }); - expect(props.buffer.text).toBe(initialText); - expect(props.buffer.cursor).toEqual(initialCursor); - unmount(); }); });