Skip to content

Commit

Permalink
disable snackbar while undo is not working
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiasemde committed Jan 3, 2025
1 parent 37b2fad commit a7a1881
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -199,45 +199,45 @@ class ActiveSessionScreenTest {
assertThat(sessions).isEmpty()
}

@Test
fun deleteAndRedoSection() = runTest {
// Start session
composeRule.onNodeWithContentDescription("Start practicing").performClick()
composeRule.onNodeWithText("TestItem1").performClick()

// Advance time
fakeTimeProvider.advanceTimeBy(3.minutes)

// Start next section
composeRule.onNodeWithContentDescription("Next item").performClick()
composeRule.onNodeWithText("TestItem2").performClick()

// Delete previous section
composeRule.onNodeWithText("TestItem1").performTouchInput { swipeLeft() }

composeRule.awaitIdle()

// Assert showSnackbar is called
val uiEventSlot = slot<MainUiEvent>()

verify(exactly = 1) {
mainViewModel.onUiEvent(capture(uiEventSlot))
}

val uiEvent = uiEventSlot.captured
check(uiEvent is MainUiEvent.ShowSnackbar)
assertThat(uiEvent.message).isEqualTo("Section deleted")
check(uiEvent.onUndo != null)

// Assert section is deleted
composeRule.onNodeWithContentDescription("TestItem1").assertIsNotDisplayed()

// Undo delete
uiEvent.onUndo.invoke()

// Assert section is restored (TODO: this is not implemented yet)
composeRule.onNodeWithContentDescription("TestItem1").assertIsNotDisplayed()
}
// @Test
// fun deleteAndRedoSection() = runTest {
// // Start session
// composeRule.onNodeWithContentDescription("Start practicing").performClick()
// composeRule.onNodeWithText("TestItem1").performClick()
//
// // Advance time
// fakeTimeProvider.advanceTimeBy(3.minutes)
//
// // Start next section
// composeRule.onNodeWithContentDescription("Next item").performClick()
// composeRule.onNodeWithText("TestItem2").performClick()
//
// // Delete previous section
// composeRule.onNodeWithText("TestItem1").performTouchInput { swipeLeft() }
//
// composeRule.awaitIdle()
//
// // Assert showSnackbar is called
// val uiEventSlot = slot<MainUiEvent>()
//
// verify(exactly = 1) {
// mainViewModel.onUiEvent(capture(uiEventSlot))
// }
//
// val uiEvent = uiEventSlot.captured
// check(uiEvent is MainUiEvent.ShowSnackbar)
// assertThat(uiEvent.message).isEqualTo("Section deleted")
// check(uiEvent.onUndo != null)
//
// // Assert section is deleted
// composeRule.onNodeWithContentDescription("TestItem1").assertIsNotDisplayed()
//
// // Undo delete
// uiEvent.onUndo.invoke()
//
// // Assert section is restored (TODO: this is not implemented yet)
// composeRule.onNodeWithContentDescription("TestItem1").assertIsNotDisplayed()
// }

@Test
fun finishButtonDisabledForEmptySession() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1159,12 +1159,13 @@ private fun SectionListElement(
deleted = deleted,
onDeleted = {
onSectionDeleted(item)
showSnackbar(
MainUiEvent.ShowSnackbar(
message = context.getString(R.string.active_session_sections_list_element_deleted),
onUndo = { }
)
)
// as long as we don't have undo, we don't need to show a snackbar
// showSnackbar(
// MainUiEvent.ShowSnackbar(
// message = context.getString(R.string.active_session_sections_list_element_deleted),
// onUndo = { }
// )
// )
}
) {
Surface(
Expand Down

0 comments on commit a7a1881

Please sign in to comment.