Add the UI for the overflow menu (#570)

This commit is contained in:
David Perez
2024-01-10 22:17:36 -06:00
committed by GitHub
parent 404f617e22
commit 009195d4cb
4 changed files with 244 additions and 0 deletions

View File

@@ -9,6 +9,8 @@ import androidx.compose.ui.test.filterToOne
import androidx.compose.ui.test.hasAnyAncestor
import androidx.compose.ui.test.hasSetTextAction
import androidx.compose.ui.test.isDialog
import androidx.compose.ui.test.isDisplayed
import androidx.compose.ui.test.isPopup
import androidx.compose.ui.test.onAllNodesWithText
import androidx.compose.ui.test.onNodeWithContentDescription
import androidx.compose.ui.test.onNodeWithText
@@ -89,6 +91,110 @@ class AddSendScreenTest : BaseComposeTest() {
verify { viewModel.trySendAction(AddSendAction.SaveClick) }
}
@Test
fun `on overflow button click should display overflow menu`() {
mutableStateFlow.value = DEFAULT_STATE.copy(
addSendType = AddSendType.EditItem(sendItemId = "sendId"),
)
composeTestRule
.onNodeWithContentDescription("More")
.performClick()
composeTestRule
.onNodeWithText("Remove password")
.assert(hasAnyAncestor(isPopup()))
.isDisplayed()
composeTestRule
.onNodeWithText("Copy link")
.assert(hasAnyAncestor(isPopup()))
.isDisplayed()
composeTestRule
.onNodeWithText("Share link")
.assert(hasAnyAncestor(isPopup()))
.isDisplayed()
composeTestRule
.onNodeWithText("Delete")
.assert(hasAnyAncestor(isPopup()))
.isDisplayed()
}
@Test
fun `on overflow remove password button click should send RemovePasswordClick`() {
mutableStateFlow.value = DEFAULT_STATE.copy(
addSendType = AddSendType.EditItem(sendItemId = "sendId"),
)
composeTestRule
.onNodeWithContentDescription("More")
.performClick()
composeTestRule
.onNodeWithText("Remove password")
.performClick()
verify(exactly = 1) {
viewModel.trySendAction(AddSendAction.RemovePasswordClick)
}
}
@Test
fun `on overflow remove Share link button click should send ShareLinkClick`() {
mutableStateFlow.value = DEFAULT_STATE.copy(
addSendType = AddSendType.EditItem(sendItemId = "sendId"),
)
composeTestRule
.onNodeWithContentDescription("More")
.performClick()
composeTestRule
.onNodeWithText("Share link")
.performClick()
verify(exactly = 1) {
viewModel.trySendAction(AddSendAction.ShareLinkClick)
}
}
@Test
fun `on overflow remove Delete button click should send DeleteClick`() {
mutableStateFlow.value = DEFAULT_STATE.copy(
addSendType = AddSendType.EditItem(sendItemId = "sendId"),
)
composeTestRule
.onNodeWithContentDescription("More")
.performClick()
composeTestRule
.onNodeWithText("Delete")
.performClick()
verify(exactly = 1) {
viewModel.trySendAction(AddSendAction.DeleteClick)
}
}
@Test
fun `on overflow remove Copy link button click should send CopyLinkClick`() {
mutableStateFlow.value = DEFAULT_STATE.copy(
addSendType = AddSendType.EditItem(sendItemId = "sendId"),
)
composeTestRule
.onNodeWithContentDescription("More")
.performClick()
composeTestRule
.onNodeWithText("Copy link")
.performClick()
verify(exactly = 1) {
viewModel.trySendAction(AddSendAction.CopyLinkClick)
}
}
@Test
fun `on name input change should send NameChange`() {
composeTestRule

View File

@@ -168,6 +168,58 @@ class AddSendViewModelTest : BaseViewModelTest() {
)
}
@Test
fun `CopyLinkClick should send ShowToast`() = runTest {
val viewModel = createViewModel(
state = DEFAULT_STATE.copy(addSendType = AddSendType.EditItem("sendId")),
addSendType = AddSendType.EditItem("sendId"),
)
viewModel.eventFlow.test {
viewModel.trySendAction(AddSendAction.CopyLinkClick)
assertEquals(AddSendEvent.ShowToast("Not yet implemented"), awaitItem())
}
}
@Test
fun `DeleteClick should send ShowToast`() = runTest {
val viewModel = createViewModel(
state = DEFAULT_STATE.copy(addSendType = AddSendType.EditItem("sendId")),
addSendType = AddSendType.EditItem("sendId"),
)
viewModel.eventFlow.test {
viewModel.trySendAction(AddSendAction.DeleteClick)
assertEquals(AddSendEvent.ShowToast("Not yet implemented"), awaitItem())
}
}
@Test
fun `RemovePasswordClick should send ShowToast`() = runTest {
val viewModel = createViewModel(
state = DEFAULT_STATE.copy(addSendType = AddSendType.EditItem("sendId")),
addSendType = AddSendType.EditItem("sendId"),
)
viewModel.eventFlow.test {
viewModel.trySendAction(AddSendAction.RemovePasswordClick)
assertEquals(AddSendEvent.ShowToast("Not yet implemented"), awaitItem())
}
}
@Test
fun `ShareLinkClick should send ShowToast`() = runTest {
val viewModel = createViewModel(
state = DEFAULT_STATE.copy(addSendType = AddSendType.EditItem("sendId")),
addSendType = AddSendType.EditItem("sendId"),
)
viewModel.eventFlow.test {
viewModel.trySendAction(AddSendAction.ShareLinkClick)
assertEquals(AddSendEvent.ShowToast("Not yet implemented"), awaitItem())
}
}
@Test
fun `DismissDialogClick should clear the dialog state`() {
val viewModel = createViewModel(