LLM-24507 Fix flaky by waitForSmartMode -> waitUntilIndexesAreReady

(cherry picked from commit 555cca76017e2802ec4d831d38ac2bdb104afe59)

IJ-MR-214637

(cherry picked from commit e82848e6951b748b010d8ee53df3c60d6d139ba2)

GitOrigin-RevId: 325389b92f9f3b1607b568908623a078a552ace9
This commit is contained in:
Petr Surkov
2026-08-03 14:59:46 +00:00
committed by intellij-monorepo-bot
parent 712c942314
commit ca72854d9f
@@ -7,11 +7,11 @@ import com.intellij.mcpserver.impl.util.asTool
import com.intellij.mcpserver.impl.util.network.McpServerConnectionAddressProvider
import com.intellij.mcpserver.stdio.IJ_MCP_SERVER_PROJECT_PATH
import com.intellij.openapi.application.PathManager
import com.intellij.openapi.project.DumbService
import com.intellij.openapi.project.Project
import com.intellij.openapi.util.Disposer
import com.intellij.openapi.util.use
import com.intellij.openapi.vfs.refreshAndFindVirtualFileOrDirectory
import com.intellij.testFramework.IndexingTestUtil
import com.intellij.testFramework.junit5.TestApplication
import com.intellij.testFramework.junit5.fixture.TestFixture
import com.intellij.testFramework.junit5.fixture.projectFixture
@@ -86,7 +86,10 @@ abstract class McpToolsetTestBase {
@BeforeEach
fun prepareProject() {
project.basePath?.let { Path.of(it).refreshAndFindVirtualFileOrDirectory()?.refresh(false, true) }
DumbService.getInstance(project).waitForSmartMode()
// Wait for queued/running scanning and indexing tasks, not only smart mode: `waitForSmartMode` can return
// while a scanning task is queued but has not flipped the project into dumb mode yet, letting the search
// execute against stale trigram indexes.
IndexingTestUtil.waitUntilIndexesAreReady(project)
}