Commit d25cbebe authored by isabelrios's avatar isabelrios Committed by Richard Pappalardo
Browse files

For #7563 - Sync integration logins (#7564)

* sync-integration-logins-test

* improve checks for logins test

* fixing ktlint issues

* uncomment lines

* address reviewer comments

* fix ui tests after robot change

* fix lint
parent fe92332f
Loading
Loading
Loading
Loading
+34 −3
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ import org.junit.Test
import org.mozilla.fenix.helpers.HomeActivityTestRule
import org.mozilla.fenix.ui.robots.homeScreen
import org.mozilla.fenix.ui.robots.accountSettings
import org.mozilla.fenix.ui.robots.settingsSubMenuLoginsAndPassword

import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.uiautomator.UiDevice
@@ -28,7 +29,6 @@ import androidx.test.uiautomator.Until
import org.hamcrest.Matchers.allOf
import org.mozilla.fenix.R
import org.mozilla.fenix.helpers.TestAssetHelper

import org.mozilla.fenix.helpers.ext.waitNotNull

@Suppress("RECEIVER_NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS")
@@ -82,6 +82,37 @@ class SyncIntegrationTest {
        }
    }

    @Test
    fun checkLoginsFromDesktopTest() {
        homeScreen {
        }.openThreeDotMenu {
        }.openSettings {
        }.openLoginsAndPasswordSubMenu {
        }.openSyncLogins {
            // Tap to sign in from Logins menu
            tapOnUseEmailToSignIn()
            typeEmail()
            tapOnContinueButton()
            typePassword()
            tapOnSignIn()
        }
        // Automatically goes back to Logins and passwords view
        settingsSubMenuLoginsAndPassword {
            verifyDefaultView()
            // Sync logings option is set to Off, no synced logins yet
            verifyDefaultViewBeforeSyncComplete()
        }.openSavedLogins {
            // Discard the secure your device message
            tapSetupLater()
            // Check the logins synced
            verifySavedLoginsAfterSync()
        }.goBack {
            // After checking the synced logins
            // on Logins and Passwords menu the Sync logins option is set to On
            verifyDefaultViewAfterSync()
        }
    }

    /* These tests will be running in the future
    // once the test above runs successfully and
    // the environment is stable
@@ -187,7 +218,7 @@ class SyncIntegrationTest {
}

fun settingsAccount() = onView(allOf(withText("Turn on Sync"))).perform(click())
fun tapInToolBar() = onView(withId(org.mozilla.fenix.R.id.toolbar_wrapper))
fun awesomeBar() = onView(withId(org.mozilla.fenix.R.id.mozac_browser_toolbar_edit_url_view))
fun tapInToolBar() = onView(withId(R.id.toolbar_wrapper))
fun awesomeBar() = onView(withId(R.id.mozac_browser_toolbar_edit_url_view))
fun useEmailInsteadButton() = onView(withId(R.id.signInEmailButton)).perform(click())
fun enterAccountSettings() = onView(withId(R.id.email)).perform(click())
+5 −0
Original line number Diff line number Diff line
@@ -14,3 +14,8 @@ def test_sync_bookmark_from_device(tps, gradlewbuild):
    os.chdir('app/src/androidTest/java/org/mozilla/fenix/syncintegration/')
    tps.run('test_bookmark.js')
    gradlewbuild.test('checkBookmarkFromDesktopTest')

def test_sync_logins_from_device(tps, gradlewbuild):
    os.chdir('app/src/androidTest/java/org/mozilla/fenix/syncintegration/')
    tps.run('test_logins.js')
    gradlewbuild.test('checkLoginsFromDesktopTest')
+30 −0
Original line number Diff line number Diff line
/* Any copyright is dedicated to the Public Domain.
   http://creativecommons.org/publicdomain/zero/1.0/ */

/*
 * The list of phases mapped to their corresponding profiles.  The object
 * here must be in strict JSON format, as it will get parsed by the Python
 * testrunner (no single quotes, extra comma's, etc).
 */
EnableEngines(["passwords"]);

var phases = { "phase1": "profile1" };


// expected tabs state
var password_list = [{ 
    hostname: "https://accounts.google.com",
    submitURL: "https://accounts.google.com/signin/challenge/sl/password",
    realm: null,
    username: "iosmztest",
    password: "test15mz",
    usernameField: "Email",
    passwordField: "Passwd",
  }];

// sync and verify tabs
Phase("phase1", [
  [Sync],
  [Passwords.add, password_list],
  [Sync]
]);
 No newline at end of file
+1 −0
Original line number Diff line number Diff line
@@ -138,6 +138,7 @@ class SettingsRobot {
        }

        fun openLoginsAndPasswordSubMenu(interact: SettingsSubMenuLoginsAndPasswordRobot.() -> Unit): SettingsSubMenuLoginsAndPasswordRobot.Transition {
            TestHelper.scrollToElementByText("Logins and passwords")
            fun loginsAndPasswordsButton() = onView(ViewMatchers.withText("Logins and passwords"))
            loginsAndPasswordsButton().click()

+22 −1
Original line number Diff line number Diff line
@@ -12,16 +12,32 @@ import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.matcher.ViewMatchers
import androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.uiautomator.By
import androidx.test.uiautomator.UiDevice
import androidx.test.uiautomator.Until
import org.hamcrest.CoreMatchers
import org.mozilla.fenix.helpers.TestAssetHelper
import org.mozilla.fenix.helpers.click
import org.mozilla.fenix.helpers.ext.waitNotNull

/**
 * Implementation of Robot Pattern for the Privacy Settings > logins and passwords sub menu
 */
class SettingsSubMenuLoginsAndPasswordRobot {

    fun verifyDefaultView() = assertDefaultView()
    fun verifyDefaultView() {
        mDevice.waitNotNull(Until.findObjects(By.text("Sync logins")), TestAssetHelper.waitingTime)
        assertDefaultView()
    }

    fun verifyDefaultViewBeforeSyncComplete() {
        mDevice.waitNotNull(Until.findObjects(By.text("Off")), TestAssetHelper.waitingTime)
    }

    fun verifyDefaultViewAfterSync() {
        mDevice.waitNotNull(Until.findObjects(By.text("On")), TestAssetHelper.waitingTime)
    }

    fun verifyDefaultValueSyncLogins() = asserDefaultValueSyncLogins()

    class Transition {
@@ -52,6 +68,11 @@ class SettingsSubMenuLoginsAndPasswordRobot {
    }
}

fun settingsSubMenuLoginsAndPassword(interact: SettingsSubMenuLoginsAndPasswordRobot.() -> Unit): SettingsSubMenuLoginsAndPasswordRobot.Transition {
    SettingsSubMenuLoginsAndPasswordRobot().interact()
    return SettingsSubMenuLoginsAndPasswordRobot.Transition()
}

private fun goBackButton() =
        onView(CoreMatchers.allOf(ViewMatchers.withContentDescription("Navigate up")))

Loading