mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-12 23:21:27 -07:00
(fix): remove custom waitFor and use testing-library implementation (#11522)
Co-authored-by: Jacob Richman <jacob314@gmail.com>
This commit is contained in:
@@ -28,6 +28,7 @@ import { LoadedSettings, SettingScope } from '../../config/settings.js';
|
||||
import { VimModeProvider } from '../contexts/VimModeContext.js';
|
||||
import { KeypressProvider } from '../contexts/KeypressContext.js';
|
||||
import { act } from 'react';
|
||||
import { waitFor } from '@testing-library/react';
|
||||
import { saveModifiedSettings, TEST_ONLY } from '../../utils/settingsUtils.js';
|
||||
import {
|
||||
getSettingsSchema,
|
||||
@@ -248,29 +249,6 @@ describe('SettingsDialog', () => {
|
||||
// Simple delay function for remaining tests that need gradual migration
|
||||
const wait = (ms = 50) => new Promise((resolve) => setTimeout(resolve, ms));
|
||||
|
||||
// Custom waitFor utility for ink testing environment (not compatible with @testing-library/react)
|
||||
const waitFor = async (
|
||||
predicate: () => void,
|
||||
options: { timeout?: number; interval?: number } = {},
|
||||
) => {
|
||||
const { timeout = 1000, interval = 10 } = options;
|
||||
const start = Date.now();
|
||||
let lastError: unknown;
|
||||
while (Date.now() - start < timeout) {
|
||||
try {
|
||||
predicate();
|
||||
return;
|
||||
} catch (e) {
|
||||
lastError = e;
|
||||
}
|
||||
await new Promise((resolve) => setTimeout(resolve, interval));
|
||||
}
|
||||
if (lastError) {
|
||||
throw lastError;
|
||||
}
|
||||
throw new Error('waitFor timed out');
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
// Reset keypress mock state (variables are commented out)
|
||||
// currentKeypressHandler = null;
|
||||
|
||||
Reference in New Issue
Block a user