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

806-uitest-add-delete #808

Merged
merged 2 commits into from
Jul 8, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
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() }
*/
}
}
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