mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-19 09:33:53 +00:00
bug(core): Fix flaky test by using waitFor. (#5540)
Co-authored-by: Sandy Tao <sandytao520@icloud.com>
This commit is contained in:
@@ -5,6 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { render } from 'ink-testing-library';
|
import { render } from 'ink-testing-library';
|
||||||
|
import { waitFor } from '@testing-library/react';
|
||||||
import { InputPrompt, InputPromptProps } from './InputPrompt.js';
|
import { InputPrompt, InputPromptProps } from './InputPrompt.js';
|
||||||
import type { TextBuffer } from './shared/text-buffer.js';
|
import type { TextBuffer } from './shared/text-buffer.js';
|
||||||
import { Config } from '@google/gemini-cli-core';
|
import { Config } from '@google/gemini-cli-core';
|
||||||
@@ -1226,11 +1227,12 @@ describe('InputPrompt', () => {
|
|||||||
stdin.write('\x12');
|
stdin.write('\x12');
|
||||||
await wait();
|
await wait();
|
||||||
stdin.write('\x1B');
|
stdin.write('\x1B');
|
||||||
await wait();
|
|
||||||
|
|
||||||
const frame = stdout.lastFrame();
|
await waitFor(() => {
|
||||||
expect(frame).not.toContain('(r:)');
|
expect(stdout.lastFrame()).not.toContain('(r:)');
|
||||||
expect(frame).not.toContain('echo hello');
|
});
|
||||||
|
|
||||||
|
expect(stdout.lastFrame()).not.toContain('echo hello');
|
||||||
|
|
||||||
unmount();
|
unmount();
|
||||||
});
|
});
|
||||||
@@ -1240,9 +1242,11 @@ describe('InputPrompt', () => {
|
|||||||
stdin.write('\x12');
|
stdin.write('\x12');
|
||||||
await wait();
|
await wait();
|
||||||
stdin.write('\t');
|
stdin.write('\t');
|
||||||
await wait();
|
|
||||||
|
|
||||||
|
await waitFor(() => {
|
||||||
expect(stdout.lastFrame()).not.toContain('(r:)');
|
expect(stdout.lastFrame()).not.toContain('(r:)');
|
||||||
|
});
|
||||||
|
|
||||||
expect(props.buffer.setText).toHaveBeenCalledWith('echo hello');
|
expect(props.buffer.setText).toHaveBeenCalledWith('echo hello');
|
||||||
unmount();
|
unmount();
|
||||||
});
|
});
|
||||||
@@ -1253,9 +1257,11 @@ describe('InputPrompt', () => {
|
|||||||
await wait();
|
await wait();
|
||||||
expect(stdout.lastFrame()).toContain('(r:)');
|
expect(stdout.lastFrame()).toContain('(r:)');
|
||||||
stdin.write('\r');
|
stdin.write('\r');
|
||||||
await wait();
|
|
||||||
|
|
||||||
|
await waitFor(() => {
|
||||||
expect(stdout.lastFrame()).not.toContain('(r:)');
|
expect(stdout.lastFrame()).not.toContain('(r:)');
|
||||||
|
});
|
||||||
|
|
||||||
expect(props.onSubmit).toHaveBeenCalledWith('echo hello');
|
expect(props.onSubmit).toHaveBeenCalledWith('echo hello');
|
||||||
unmount();
|
unmount();
|
||||||
});
|
});
|
||||||
@@ -1268,9 +1274,10 @@ describe('InputPrompt', () => {
|
|||||||
await wait();
|
await wait();
|
||||||
expect(stdout.lastFrame()).toContain('(r:)');
|
expect(stdout.lastFrame()).toContain('(r:)');
|
||||||
stdin.write('\x1B');
|
stdin.write('\x1B');
|
||||||
await wait();
|
|
||||||
|
|
||||||
|
await waitFor(() => {
|
||||||
expect(stdout.lastFrame()).not.toContain('(r:)');
|
expect(stdout.lastFrame()).not.toContain('(r:)');
|
||||||
|
});
|
||||||
expect(props.buffer.text).toBe('initial text');
|
expect(props.buffer.text).toBe('initial text');
|
||||||
expect(props.buffer.cursor).toEqual([0, 3]);
|
expect(props.buffer.cursor).toEqual([0, 3]);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user