From a7a18815bfb4ee80738acd9313ba3d5e33019ab5 Mon Sep 17 00:00:00 2001 From: Matthias Emde Date: Fri, 3 Jan 2025 21:07:29 +0100 Subject: [PATCH] disable snackbar while undo is not working --- .../presentation/ActiveSessionScreenTest.kt | 78 +++++++++---------- .../presentation/ActiveSessionScreen.kt | 13 ++-- 2 files changed, 46 insertions(+), 45 deletions(-) diff --git a/app/src/androidTest/java/app/musikus/activesession/presentation/ActiveSessionScreenTest.kt b/app/src/androidTest/java/app/musikus/activesession/presentation/ActiveSessionScreenTest.kt index 7f9a8fae..0c003e79 100644 --- a/app/src/androidTest/java/app/musikus/activesession/presentation/ActiveSessionScreenTest.kt +++ b/app/src/androidTest/java/app/musikus/activesession/presentation/ActiveSessionScreenTest.kt @@ -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() - - 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() +// +// 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() { diff --git a/app/src/main/java/app/musikus/activesession/presentation/ActiveSessionScreen.kt b/app/src/main/java/app/musikus/activesession/presentation/ActiveSessionScreen.kt index e1ec1e8e..7662b81a 100644 --- a/app/src/main/java/app/musikus/activesession/presentation/ActiveSessionScreen.kt +++ b/app/src/main/java/app/musikus/activesession/presentation/ActiveSessionScreen.kt @@ -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(