Skip to content
This repository has been archived by the owner on Dec 14, 2021. It is now read-only.

Commit

Permalink
806-uitest-add-delete (#808)
Browse files Browse the repository at this point in the history
  • Loading branch information
isabelrios authored Jul 8, 2019
1 parent a4d1ccd commit ec56009
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* 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 mozilla.lockbox.robots

import br.com.concretesolutions.kappuccino.actions.ClickActions
import br.com.concretesolutions.kappuccino.assertions.VisibilityAssertions
import mozilla.lockbox.R

// DeleteCredentialDisclaimer
class DeleteCredentialDisclaimerRobot : BaseTestRobot {

override fun exists() = VisibilityAssertions.displayed { id(R.id.alertTitle) }

fun tapCancelButton() = ClickActions.click { text(R.string.cancel) }
fun tapDeleteButton() = ClickActions.click { text("DELETE") }
}

fun deleteCredentialDisclaimer(f: DeleteCredentialDisclaimerRobot.() -> Unit) = DeleteCredentialDisclaimerRobot().apply(f)
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ class ItemDetailRobot : BaseTestRobot {
fun toastIsDisplayed(id: Int, activityRule: ActivityTestRule<RootActivity>) =
onView(withText(id)).inRoot(withDecorView(not(`is`(activityRule.activity.getWindow().decorView))))
.check(matches(isDisplayed()))

fun tapKebabMenu() = ClickActions.click { id(R.id.kebabMenu) }
}

fun itemDetail(f: ItemDetailRobot.() -> Unit) = ItemDetailRobot().apply(f)
21 changes: 21 additions & 0 deletions app/src/androidTest/java/mozilla/lockbox/robots/KebabMenuRobot.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* 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 mozilla.lockbox.robots

import br.com.concretesolutions.kappuccino.actions.ClickActions
import br.com.concretesolutions.kappuccino.assertions.VisibilityAssertions
import mozilla.lockbox.R

// KebabMenu
class KebabMenuRobot : BaseTestRobot {
override fun exists() = VisibilityAssertions.displayed { text("Delete") }

fun tapEditButton() = ClickActions.click { text(R.string.edit) }
fun tapDeleteButton() = ClickActions.click { text(R.string.delete) }
}

fun kebabMenu(f: KebabMenuRobot.() -> Unit) = KebabMenuRobot().apply(f)
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import kotlinx.coroutines.ExperimentalCoroutinesApi
import mozilla.lockbox.R
import mozilla.lockbox.robots.itemDetail
import mozilla.lockbox.robots.itemList
import mozilla.lockbox.robots.kebabMenu
import mozilla.lockbox.robots.deleteCredentialDisclaimer
import mozilla.lockbox.view.RootActivity
import org.junit.Rule
import org.junit.Test
Expand Down Expand Up @@ -40,4 +42,22 @@ open class ItemDetailsTest {
itemDetail { tapCopyPass() }
itemDetail { toastIsDisplayed(R.string.toast_password_copied, activityRule) }
}

@Test
fun deleteItem() {
navigator.gotoItemDetailKebabMenu()
kebabMenu { tapDeleteButton() }
// First tap on Cancel delete credencial
deleteCredentialDisclaimer { tapCancelButton() }
itemDetail { exists() }
// Now delete the credential
// Disabled until issue #807 is fixed
// and logins can be added after removal
/*
itemDetail { tapKebabMenu() }
kebabMenu { tapDeleteButton() }
deleteCredentialDisclaimer { tapDeleteButton() }
itemList { exists() }
*/
}
}
8 changes: 8 additions & 0 deletions app/src/androidTest/java/mozilla/lockbox/uiTests/Navigator.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import mozilla.lockbox.robots.fingerprintOnboardingScreen
import mozilla.lockbox.robots.fxaLogin
import mozilla.lockbox.robots.itemDetail
import mozilla.lockbox.robots.itemList
import mozilla.lockbox.robots.kebabMenu
import mozilla.lockbox.robots.lockScreen
import mozilla.lockbox.robots.onboardingConfirmationScreen
import mozilla.lockbox.robots.securityDisclaimer
Expand Down Expand Up @@ -292,6 +293,13 @@ class Navigator {
itemDetail { exists() }
}

fun gotoItemDetailKebabMenu(position: Int = 0) {
gotoItemList()
gotoItemDetail_from_itemList(position)
itemDetail { tapKebabMenu() }
kebabMenu { exists() }
}

fun back(remainInApplication: Boolean = true) {
closeSoftKeyboard()
try {
Expand Down

0 comments on commit ec56009

Please sign in to comment.