Skip to content

Commit

Permalink
disable test for undoing sections for now
Browse files Browse the repository at this point in the history
  • Loading branch information
mipro98 committed Dec 30, 2024
1 parent 7b3a061 commit 9461638
Showing 1 changed file with 40 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ import androidx.compose.ui.test.onNodeWithContentDescription
import androidx.compose.ui.test.onNodeWithText
import androidx.compose.ui.test.performClick
import androidx.compose.ui.test.performTextInput
import androidx.compose.ui.test.performTouchInput
import androidx.compose.ui.test.swipeLeft
import androidx.navigation.NavHostController
import app.musikus.core.data.Nullable
import app.musikus.core.data.SectionWithLibraryItem
Expand All @@ -28,7 +26,6 @@ import app.musikus.core.data.UUIDConverter
import app.musikus.core.domain.FakeTimeProvider
import app.musikus.core.domain.plus
import app.musikus.core.presentation.MainActivity
import app.musikus.core.presentation.MainUiEvent
import app.musikus.core.presentation.MainViewModel
import app.musikus.library.data.daos.LibraryItem
import app.musikus.library.data.entities.LibraryFolderCreationAttributes
Expand All @@ -41,7 +38,6 @@ import com.google.common.truth.Truth.assertThat
import dagger.hilt.android.testing.HiltAndroidRule
import dagger.hilt.android.testing.HiltAndroidTest
import io.mockk.mockk
import io.mockk.slot
import io.mockk.verify
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.runBlocking
Expand Down Expand Up @@ -199,45 +195,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 Expand Up @@ -323,4 +319,4 @@ class ActiveSessionScreenTest {
)
)
}
}
}

0 comments on commit 9461638

Please sign in to comment.