diff --git a/app/src/androidTest/java/org/mozilla/fenix/experimentintegration/SurveyExperimentIntegrationTest.kt b/app/src/androidTest/java/org/mozilla/fenix/experimentintegration/SurveyExperimentIntegrationTest.kt index 277135cb79..18fb391051 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/experimentintegration/SurveyExperimentIntegrationTest.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/experimentintegration/SurveyExperimentIntegrationTest.kt @@ -22,7 +22,11 @@ class SurveyExperimentIntegrationTest { private val experimentName = "Viewpoint" @get:Rule - val activityTestRule = HomeActivityTestRule() + val activityTestRule = HomeActivityTestRule( + isJumpBackInCFREnabled = false, + isPWAsPromptEnabled = false, + isTCPCFREnabled = false, + ) @Before fun setUp() { @@ -38,7 +42,25 @@ class SurveyExperimentIntegrationTest { fun checkSurveyNavigatesCorrectly() { browserScreen { verifySurveyButton() - }.clickSurveyButton {} + }.clickSurveyButton { + verifyUrl(surveyURL) + } + + homeScreen { + }.openThreeDotMenu { + }.openSettings { + }.openExperimentsMenu { + verifyExperimentExists(experimentName) + } + } + + @Test + fun checkSurveyNoThanksNavigatesCorrectly() { + browserScreen { + verifySurveyNoThanksButton() + }.clickNoThanksSurveyButton { + verifyTabCounter("0") + } homeScreen { }.openThreeDotMenu { diff --git a/app/src/androidTest/java/org/mozilla/fenix/experimentintegration/test_integration.py b/app/src/androidTest/java/org/mozilla/fenix/experimentintegration/test_integration.py index 0794e3386e..9e88c5df69 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/experimentintegration/test_integration.py +++ b/app/src/androidTest/java/org/mozilla/fenix/experimentintegration/test_integration.py @@ -5,3 +5,8 @@ import pytest def test_survey_navigates_correctly(setup_experiment, gradlewbuild, load_branches): setup_experiment(load_branches) gradlewbuild.test("SurveyExperimentIntegrationTest#checkSurveyNavigatesCorrectly") + +@pytest.mark.parametrize("load_branches", [("branch")], indirect=True) +def test_survey_no_thanks_navigates_correctly(setup_experiment, gradlewbuild, load_branches): + setup_experiment(load_branches) + gradlewbuild.test("SurveyExperimentIntegrationTest#checkSurveyNoThanksNavigatesCorrectly") diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/BrowserRobot.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/BrowserRobot.kt index f0093618fa..ebd6515623 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/BrowserRobot.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/BrowserRobot.kt @@ -882,6 +882,17 @@ class BrowserRobot { assertTrue(button.waitForExists(waitingTime)) } + fun verifySurveyNoThanksButton() { + val button = mDevice.findObject( + UiSelector().text( + getStringResource( + R.string.preferences_not_take_survey, + ), + ), + ) + assertTrue(button.waitForExists(waitingTime)) + } + fun clickOpenLinksInAppsDismissCFRButton() = itemWithResIdContainingText( "$packageName:id/dismiss", @@ -900,6 +911,18 @@ class BrowserRobot { button.click() } + fun clickNoThanksSurveyButton() { + val button = mDevice.findObject( + UiSelector().text( + getStringResource( + R.string.preferences_not_take_survey, + ), + ), + ) + button.waitForExists(waitingTime) + button.click() + } + fun longClickToolbar() = mDevice.findObject(By.res("$packageName:id/mozac_browser_toolbar_url_view")).click(LONG_CLICK_DURATION) fun verifyDownloadPromptIsDismissed() = @@ -1235,6 +1258,14 @@ class BrowserRobot { BrowserRobot().interact() return Transition() } + + fun clickNoThanksSurveyButton(interact: BrowserRobot.() -> Unit): BrowserRobot.Transition { + surveyNoThanksButton.waitForExists(waitingTime) + surveyNoThanksButton.click() + + BrowserRobot().interact() + return Transition() + } } } @@ -1387,3 +1418,6 @@ private val contextMenuOpenInExternalApp = private val surveyButton = itemContainingText(getStringResource(R.string.preferences_take_survey)) + +private val surveyNoThanksButton = + itemContainingText(getStringResource(R.string.preferences_not_take_survey))