[driver] Add KDoc about correct usage of waitForProjectOpen and waitForIndicators

GitOrigin-RevId: fefc7acea0ac7b62f029120710d2c734f8781d58
This commit is contained in:
Anna Koehler
2024-07-11 18:07:16 +02:00
committed by intellij-monorepo-bot
parent b66ffeeffd
commit 8a627f258e

View File

@@ -20,20 +20,37 @@ fun Driver.areIndicatorsVisible(project: Project): Boolean {
return getProgressIndicators(project).isNotEmpty()
}
/**
* !!!ATTENTION!!!
*
* The only guarantee you have after this method is that reference to Project won't be null.
* The UI, Project View, services and everything else might not be yet initialized.
* Use [waitForIndicators] instead if you're not 100% sure otherwise you might get flaky test.
* Also, you can avoid calling this method before [waitForIndicators] since it also waits for open project.
*/
fun Driver.waitForProjectOpen(timeout: Duration = 1.minutes) {
waitFor("Project is opened", timeout) {
isProjectOpened()
}
}
/**
* Method waits till project is opened and there are no indicators for 10 seconds.
*/
fun Driver.waitForIndicators(project: Project, timeout: Duration) {
waitForIndicators({ project }, timeout)
}
/**
* Method waits till project is opened and there are no indicators for 10 seconds.
*/
fun Driver.waitForIndicators(timeout: Duration) {
waitForIndicators(::singleProject, timeout)
}
/**
* Method waits till project is opened and there are no indicators for 10 seconds.
*/
private fun Driver.waitForIndicators(projectGet: () -> Project, timeout: Duration) {
var smartLongEnoughStart: Instant? = null