From 67690c0db6fff5d79730ddf50cbe59f9050ede2a Mon Sep 17 00:00:00 2001 From: Craig Russell Date: Wed, 11 Dec 2024 12:03:57 +0000 Subject: [PATCH] Fix privacy tests which are currently getting interrupted with the privacy toggle check screen (#5379) Task/Issue URL: https://app.asana.com/0/488551667048375/1208945103446235/f ### Description Fixes the tests which are failing due to a new screen being presented when privacy protections are disabled. The fix is simply backing out of those screens as part of the test scripts. ### Steps to test this PR - [x] Ensure privacy tests succeeded: https://github.com/duckduckgo/Android/actions/runs/12275448579 Co-authored-by: Craig Russell <1336281+CDRussell@users.noreply.github.com> --- .../com/duckduckgo/espresso/privacy/RequestBlockingTest.kt | 4 ++++ .../java/com/duckduckgo/espresso/privacy/SurrogatesTest.kt | 3 +++ 2 files changed, 7 insertions(+) diff --git a/app/src/androidTest/java/com/duckduckgo/espresso/privacy/RequestBlockingTest.kt b/app/src/androidTest/java/com/duckduckgo/espresso/privacy/RequestBlockingTest.kt index be2c5dc2fe76..ff2ffaa0453d 100644 --- a/app/src/androidTest/java/com/duckduckgo/espresso/privacy/RequestBlockingTest.kt +++ b/app/src/androidTest/java/com/duckduckgo/espresso/privacy/RequestBlockingTest.kt @@ -21,6 +21,7 @@ import androidx.test.core.app.* import androidx.test.espresso.Espresso.onView import androidx.test.espresso.IdlingRegistry import androidx.test.espresso.IdlingResource +import androidx.test.espresso.action.ViewActions import androidx.test.espresso.action.ViewActions.click import androidx.test.espresso.matcher.ViewMatchers.* import androidx.test.espresso.web.model.Atoms.script @@ -89,6 +90,9 @@ class RequestBlockingTest { onView(isRoot()).perform(waitForView(withId(R.id.privacyProtectionMenuItem))) onView(withId(R.id.privacyProtectionMenuItem)).perform(click()) + // handle the privacy protection toggle check screen showing + onView(isRoot()).perform(ViewActions.pressBack()) + val idlingResourceForScript: IdlingResource = WebViewIdlingResource(webView!!) IdlingRegistry.getInstance().register(idlingResourceForScript) diff --git a/app/src/androidTest/java/com/duckduckgo/espresso/privacy/SurrogatesTest.kt b/app/src/androidTest/java/com/duckduckgo/espresso/privacy/SurrogatesTest.kt index c1d326b73846..48fba524ec43 100644 --- a/app/src/androidTest/java/com/duckduckgo/espresso/privacy/SurrogatesTest.kt +++ b/app/src/androidTest/java/com/duckduckgo/espresso/privacy/SurrogatesTest.kt @@ -97,6 +97,9 @@ class SurrogatesTest { onView(isRoot()).perform(waitForView(withId(R.id.privacyProtectionMenuItem))) onView(withId(R.id.privacyProtectionMenuItem)).perform(ViewActions.click()) + // handle the privacy protection toggle check screen showing + onView(isRoot()).perform(ViewActions.pressBack()) + val idlingResourceForScript: IdlingResource = WebViewIdlingResource(webView!!) IdlingRegistry.getInstance().register(idlingResourceForScript)