From c802300b918b92acd7a0f4f0ff0414a1ac30748c Mon Sep 17 00:00:00 2001 From: Victor Andreasson Date: Sat, 11 May 2024 10:09:08 +0200 Subject: [PATCH] Handle flaky Espresso test --- .../java/com/orgzly/android/espresso/ShareActivityTest.kt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/src/androidTest/java/com/orgzly/android/espresso/ShareActivityTest.kt b/app/src/androidTest/java/com/orgzly/android/espresso/ShareActivityTest.kt index 57271ad6c..539b11baa 100644 --- a/app/src/androidTest/java/com/orgzly/android/espresso/ShareActivityTest.kt +++ b/app/src/androidTest/java/com/orgzly/android/espresso/ShareActivityTest.kt @@ -8,6 +8,7 @@ import androidx.test.core.app.ActivityScenario import androidx.test.espresso.Espresso.onView import androidx.test.espresso.action.ViewActions.click import androidx.test.espresso.assertion.ViewAssertions.matches +import androidx.test.espresso.matcher.ViewMatchers.isRoot import androidx.test.espresso.matcher.ViewMatchers.withId import androidx.test.espresso.matcher.ViewMatchers.withText import com.orgzly.R @@ -92,6 +93,8 @@ class ShareActivityTest : OrgzlyTest() { onView(withId(R.id.location_button)).perform(scroll(), click()) onView(withText("book-two")).perform(click()) + SystemClock.sleep(100) + onView(isRoot()).perform(waitId(R.id.location_button, 5000)) onView(withId(R.id.location_button)).check(matches(withText("book-two"))) scenario.onActivity { activity ->