Bug 1820984 - Follow-up on loginsAndPasswordsSettingsItemsTest missing steps

fenix/112.0
oana.horvath 1 year ago committed by mergify[bot]
parent b67bfb450c
commit d1ee389f48

@ -1,3 +1,7 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.fenix.ui
import android.os.Build
@ -22,6 +26,12 @@ import org.mozilla.fenix.ui.robots.browserScreen
import org.mozilla.fenix.ui.robots.homeScreen
import org.mozilla.fenix.ui.robots.navigationToolbar
/**
* Tests for verifying:
* - the Logins and Passwords menu and sub-menus.
* - save login prompts.
* - saving logins based on the user's preferences.
*/
class LoginsTest {
private lateinit var mockWebServer: MockWebServer
@ -48,25 +58,48 @@ class LoginsTest {
mockWebServer.shutdown()
}
// Tests the Logins and passwords menu items and default values
@Test
fun loginsAndPasswordsSettingsItemsTest() {
homeScreen {
}.openThreeDotMenu {
}.openSettings {
// Necessary to scroll a little bit for all screen sizes
scrollToElementByText("Logins and passwords")
}.openLoginsAndPasswordSubMenu {
verifyDefaultView()
verifyAutofillInFirefoxToggle(true)
verifyAutofillLoginsInOtherAppsToggle(false)
}
}
// Tests only for initial state without signing in.
// For tests after signing in, see SyncIntegration test suite
@Test
fun loginsAndPasswordsSettingsItemsTest() {
fun savedLoginsMenuItemsTest() {
homeScreen {
}.openThreeDotMenu {
}.openSettings {
// Necessary to scroll a little bit for all screen sizes
TestHelper.scrollToElementByText("Logins and passwords")
scrollToElementByText("Logins and passwords")
}.openLoginsAndPasswordSubMenu {
verifyDefaultView()
verifyDefaultValueAutofillLogins(TestHelper.appContext)
verifyDefaultValueExceptions()
}.openSavedLogins {
verifySecurityPromptForLogins()
tapSetupLater()
// Verify that logins list is empty
// Issue #7272 nothing is shown
}.goBack {
verifyEmptySavedLoginsListView()
}
}
@Test
fun syncLoginsMenuItemsTest() {
homeScreen {
}.openThreeDotMenu {
}.openSettings {
// Necessary to scroll a little bit for all screen sizes
scrollToElementByText("Logins and passwords")
}.openLoginsAndPasswordSubMenu {
}.openSyncLogins {
verifyReadyToScanOption()
verifyUseEmailOption()
@ -98,7 +131,7 @@ class LoginsTest {
browserScreen {
}.openThreeDotMenu {
}.openSettings {
TestHelper.scrollToElementByText("Logins and passwords")
scrollToElementByText("Logins and passwords")
}.openLoginsAndPasswordSubMenu {
verifyDefaultView()
}.openSavedLogins {
@ -152,6 +185,7 @@ class LoginsTest {
verifySecurityPromptForLogins()
tapSetupLater()
// Verify that the login list is empty
verifyEmptySavedLoginsListView()
verifyNotSavedLoginFromPrompt()
}.goBack {
}.openLoginExceptions {
@ -376,7 +410,7 @@ class LoginsTest {
clickDeleteLoginButton()
verifyLoginDeletionPrompt()
clickConfirmDeleteLogin()
// The account remains displayed, see: https://github.com/mozilla-mobile/fenix/issues/23212
// The account remains displayed, see: https://bugzilla.mozilla.org/show_bug.cgi?id=1812431
// verifyNotSavedLoginFromPrompt()
}
}
@ -426,9 +460,9 @@ class LoginsTest {
}.openThreeDotMenu {
}.openSettings {
}.openLoginsAndPasswordSubMenu {
verifyAutofillToggle(true)
clickAutofillOption()
verifyAutofillToggle(false)
verifyAutofillInFirefoxToggle(true)
clickAutofillInFirefoxOption()
verifyAutofillInFirefoxToggle(false)
}.goBack {
}

@ -12,13 +12,14 @@ import androidx.test.espresso.action.ViewActions
import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.matcher.ViewMatchers
import androidx.test.espresso.matcher.ViewMatchers.isChecked
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
import androidx.test.espresso.matcher.ViewMatchers.isNotChecked
import androidx.test.espresso.matcher.ViewMatchers.withClassName
import androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility
import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.espresso.matcher.ViewMatchers.withText
import androidx.test.uiautomator.By
import androidx.test.uiautomator.Until
import org.hamcrest.CoreMatchers
import org.hamcrest.CoreMatchers.allOf
import org.hamcrest.CoreMatchers.endsWith
import org.mozilla.fenix.R
@ -35,8 +36,13 @@ import org.mozilla.fenix.helpers.ext.waitNotNull
class SettingsSubMenuLoginsAndPasswordRobot {
fun verifyDefaultView() {
mDevice.waitNotNull(Until.findObjects(By.text("Sync logins across devices")), TestAssetHelper.waitingTime)
assertDefaultView()
mDevice.waitNotNull(Until.findObjects(By.text("Save logins and passwords")), TestAssetHelper.waitingTime)
saveLoginsAndPasswordButton.check(matches(isDisplayed()))
autofillInFirefoxOption.check(matches(isDisplayed()))
autofillInOtherAppsOption.check(matches(isDisplayed()))
syncLoginsButton.check(matches(isDisplayed()))
savedLoginsButton.check(matches(isDisplayed()))
loginExceptionsButton.check(matches(isDisplayed()))
}
fun verifyDefaultViewBeforeSyncComplete() {
@ -47,14 +53,12 @@ class SettingsSubMenuLoginsAndPasswordRobot {
mDevice.waitNotNull(Until.findObjects(By.text("On")), TestAssetHelper.waitingTime)
}
fun verifyDefaultValueExceptions() = assertDefaultValueExceptions()
fun verifyDefaultValueAutofillLogins(context: Context) = assertDefaultValueAutofillLogins(context)
fun clickAutofillOption() = autofillOption.click()
fun clickAutofillInFirefoxOption() = autofillInFirefoxOption.click()
fun verifyAutofillToggle(enabled: Boolean) =
autofillOption
fun verifyAutofillInFirefoxToggle(enabled: Boolean) {
autofillInFirefoxOption
.check(
matches(
hasCousin(
@ -69,6 +73,24 @@ class SettingsSubMenuLoginsAndPasswordRobot {
),
),
)
}
fun verifyAutofillLoginsInOtherAppsToggle(enabled: Boolean) {
autofillInOtherAppsOption
.check(
matches(
hasCousin(
allOf(
withId(R.id.switch_widget),
if (enabled) {
isChecked()
} else {
isNotChecked()
},
),
),
),
)
}
class Transition {
@ -80,32 +102,28 @@ class SettingsSubMenuLoginsAndPasswordRobot {
}
fun openSavedLogins(interact: SettingsSubMenuLoginsAndPasswordsSavedLoginsRobot.() -> Unit): SettingsSubMenuLoginsAndPasswordsSavedLoginsRobot.Transition {
fun savedLoginsButton() = onView(withText("Saved logins"))
savedLoginsButton().click()
savedLoginsButton.click()
SettingsSubMenuLoginsAndPasswordsSavedLoginsRobot().interact()
return SettingsSubMenuLoginsAndPasswordsSavedLoginsRobot.Transition()
}
fun openLoginExceptions(interact: SettingsSubMenuLoginsAndPasswordsSavedLoginsRobot.() -> Unit): SettingsSubMenuLoginsAndPasswordsSavedLoginsRobot.Transition {
fun loginExceptionsButton() = onView(ViewMatchers.withText("Exceptions"))
loginExceptionsButton().click()
loginExceptionsButton.click()
SettingsSubMenuLoginsAndPasswordsSavedLoginsRobot().interact()
return SettingsSubMenuLoginsAndPasswordsSavedLoginsRobot.Transition()
}
fun openSyncLogins(interact: SettingsTurnOnSyncRobot.() -> Unit): SettingsTurnOnSyncRobot.Transition {
fun syncLoginsButton() = onView(ViewMatchers.withText("Sync logins across devices"))
syncLoginsButton().click()
syncLoginsButton.click()
SettingsTurnOnSyncRobot().interact()
return SettingsTurnOnSyncRobot.Transition()
}
fun openSaveLoginsAndPasswordsOptions(interact: SettingsSubMenuLoginsAndPasswordOptionsToSaveRobot.() -> Unit): SettingsSubMenuLoginsAndPasswordOptionsToSaveRobot.Transition {
fun saveLoginsAndPasswordButton() = onView(withText("Save logins and passwords"))
saveLoginsAndPasswordButton().click()
saveLoginsAndPasswordButton.click()
SettingsSubMenuLoginsAndPasswordOptionsToSaveRobot().interact()
return SettingsSubMenuLoginsAndPasswordOptionsToSaveRobot.Transition()
@ -118,11 +136,16 @@ fun settingsSubMenuLoginsAndPassword(interact: SettingsSubMenuLoginsAndPasswordR
return SettingsSubMenuLoginsAndPasswordRobot.Transition()
}
private fun goBackButton() =
onView(CoreMatchers.allOf(ViewMatchers.withContentDescription("Navigate up")))
private val saveLoginsAndPasswordButton = onView(withText("Save logins and passwords"))
private fun assertDefaultView() = onView(ViewMatchers.withText("Sync logins across devices"))
.check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE)))
private val savedLoginsButton = onView(withText("Saved logins"))
private val syncLoginsButton = onView(withText("Sync logins across devices"))
private val loginExceptionsButton = onView(withText("Exceptions"))
private fun goBackButton() =
onView(allOf(ViewMatchers.withContentDescription("Navigate up")))
private fun assertDefaultValueAutofillLogins(context: Context) = onView(
ViewMatchers.withText(
@ -134,10 +157,6 @@ private fun assertDefaultValueAutofillLogins(context: Context) = onView(
)
.check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE)))
private fun assertDefaultValueExceptions() = onView(ViewMatchers.withText("Exceptions"))
.check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE)))
private fun assertDefaultValueSyncLogins() = onView(ViewMatchers.withText("Sync and save data"))
.check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE)))
private val autofillInFirefoxOption = onView(withText("Autofill in $appName"))
private val autofillOption = onView(withText("Autofill in $appName"))
private val autofillInOtherAppsOption = onView(withText("Autofill in other apps"))

@ -44,6 +44,17 @@ import org.mozilla.fenix.helpers.ext.waitNotNull
class SettingsSubMenuLoginsAndPasswordsSavedLoginsRobot {
fun verifySecurityPromptForLogins() = assertSavedLoginsView()
fun verifyEmptySavedLoginsListView() {
onView(withText(getStringResource(R.string.preferences_passwords_saved_logins_description_empty_text)))
.check(matches(isDisplayed()))
onView(withText(R.string.preferences_passwords_saved_logins_description_empty_learn_more_link))
.check(matches(isDisplayed()))
onView(withText(R.string.preferences_logins_add_login))
.check(matches(isDisplayed()))
}
fun verifySavedLoginsAfterSync() {
mDevice.waitNotNull(
Until.findObjects(By.text("https://accounts.google.com")),

Loading…
Cancel
Save