Skip to content

Commit

Permalink
Restore test
Browse files Browse the repository at this point in the history
  • Loading branch information
Rawa committed Oct 18, 2024
1 parent a600c89 commit 5099ce0
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
package net.mullvad.mullvadvpn.compose.screen

import androidx.compose.ui.test.ExperimentalTestApi
import androidx.compose.ui.test.onNodeWithText
import androidx.compose.ui.test.performClick
import io.mockk.MockKAnnotations
import io.mockk.impl.annotations.MockK
import net.mullvad.mullvadvpn.compose.createEdgeToEdgeComposeExtension
import net.mullvad.mullvadvpn.compose.dialog.ChangelogDialog
import net.mullvad.mullvadvpn.compose.setContentWithTheme
import net.mullvad.mullvadvpn.viewmodel.AppInfoViewModel
import net.mullvad.mullvadvpn.viewmodel.ChangelogUiState
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.extension.RegisterExtension

@OptIn(ExperimentalTestApi::class)
Expand All @@ -19,6 +25,24 @@ class ChangelogDialogTest {
MockKAnnotations.init(this)
}

@Test
fun testShowChangeLogWhenNeeded() =
composeExtension.use {
// Arrange
setContentWithTheme {
ChangelogDialog(
ChangelogUiState(changes = listOf(CHANGELOG_ITEM), version = CHANGELOG_VERSION),
onDismiss = {},
)
}

// Check changelog content showed within dialog
onNodeWithText(CHANGELOG_ITEM).assertExists()

// perform click on Got It button to check if dismiss occur
onNodeWithText(CHANGELOG_BUTTON_TEXT).performClick()
}

companion object {
private const val CHANGELOG_BUTTON_TEXT = "Got it!"
private const val CHANGELOG_ITEM = "Changelog item"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ import net.mullvad.mullvadvpn.ui.serviceconnection.AppVersionInfoRepository
class AppInfoViewModel(
changelogRepository: ChangelogRepository,
appVersionInfoRepository: AppVersionInfoRepository,
val resources: Resources,
val isPlayBuild: Boolean,
val packageName: String,
private val resources: Resources,
private val isPlayBuild: Boolean,
private val packageName: String,
) : ViewModel() {

private val _uiSideEffect = Channel<AppInfoSideEffect>()
Expand Down

0 comments on commit 5099ce0

Please sign in to comment.