From 61a71c4fcd4970f98e983438fc4fe86587ed4fe6 Mon Sep 17 00:00:00 2001 From: Pyush Sinha Date: Mon, 20 Oct 2025 13:36:43 -0700 Subject: [PATCH] (fix): remove custom waitFor and use testing-library implementation (#11522) Co-authored-by: Jacob Richman --- .../src/ui/components/SettingsDialog.test.tsx | 24 +------------------ 1 file changed, 1 insertion(+), 23 deletions(-) diff --git a/packages/cli/src/ui/components/SettingsDialog.test.tsx b/packages/cli/src/ui/components/SettingsDialog.test.tsx index ab2b522c19..8a71220c34 100644 --- a/packages/cli/src/ui/components/SettingsDialog.test.tsx +++ b/packages/cli/src/ui/components/SettingsDialog.test.tsx @@ -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;