summaryrefslogtreecommitdiffhomepage
path: root/android/app/src/test
diff options
context:
space:
mode:
authorDavid Göransson <david.goransson@mullvad.net>2025-01-08 09:41:28 +0100
committerDavid Göransson <david.goransson@mullvad.net>2025-01-09 10:54:46 +0100
commit8fb29be52bf65d9b412d97b8a66171bf5e1f7085 (patch)
treec8c1944e1dc4013a20b0ba6b40a1cd181843511c /android/app/src/test
parente3ea59f53a33eb1202b67e514f721403b10fe2a5 (diff)
downloadmullvadvpn-8fb29be52bf65d9b412d97b8a66171bf5e1f7085.tar.xz
mullvadvpn-8fb29be52bf65d9b412d97b8a66171bf5e1f7085.zip
Update changelog presentation
Diffstat (limited to 'android/app/src/test')
-rw-r--r--android/app/src/test/kotlin/net/mullvad/mullvadvpn/InAppNotificationControllerTest.kt11
-rw-r--r--android/app/src/test/kotlin/net/mullvad/mullvadvpn/repository/ChangelogRepositoryTest.kt11
-rw-r--r--android/app/src/test/kotlin/net/mullvad/mullvadvpn/viewmodel/ConnectViewModelTest.kt5
3 files changed, 26 insertions, 1 deletions
diff --git a/android/app/src/test/kotlin/net/mullvad/mullvadvpn/InAppNotificationControllerTest.kt b/android/app/src/test/kotlin/net/mullvad/mullvadvpn/InAppNotificationControllerTest.kt
index 74b599da97..c8b27f2e6f 100644
--- a/android/app/src/test/kotlin/net/mullvad/mullvadvpn/InAppNotificationControllerTest.kt
+++ b/android/app/src/test/kotlin/net/mullvad/mullvadvpn/InAppNotificationControllerTest.kt
@@ -17,6 +17,7 @@ import net.mullvad.mullvadvpn.lib.model.ErrorState
import net.mullvad.mullvadvpn.repository.InAppNotification
import net.mullvad.mullvadvpn.repository.InAppNotificationController
import net.mullvad.mullvadvpn.usecase.AccountExpiryInAppNotificationUseCase
+import net.mullvad.mullvadvpn.usecase.NewChangelogNotificationUseCase
import net.mullvad.mullvadvpn.usecase.NewDeviceNotificationUseCase
import net.mullvad.mullvadvpn.usecase.TunnelStateNotificationUseCase
import net.mullvad.mullvadvpn.usecase.VersionNotificationUseCase
@@ -33,6 +34,8 @@ class InAppNotificationControllerTest {
private lateinit var inAppNotificationController: InAppNotificationController
private val accountExpiryNotifications = MutableStateFlow(emptyList<InAppNotification>())
private val newDeviceNotifications = MutableStateFlow(emptyList<InAppNotification.NewDevice>())
+ private val newVersionChangelogNotifications =
+ MutableStateFlow(emptyList<InAppNotification.NewVersionChangelog>())
private val versionNotifications = MutableStateFlow(emptyList<InAppNotification>())
private val tunnelStateNotifications = MutableStateFlow(emptyList<InAppNotification>())
@@ -44,10 +47,13 @@ class InAppNotificationControllerTest {
val accountExpiryInAppNotificationUseCase: AccountExpiryInAppNotificationUseCase = mockk()
val newDeviceNotificationUseCase: NewDeviceNotificationUseCase = mockk()
+ val newVersionChangelogUseCase: NewChangelogNotificationUseCase = mockk()
val versionNotificationUseCase: VersionNotificationUseCase = mockk()
val tunnelStateNotificationUseCase: TunnelStateNotificationUseCase = mockk()
every { accountExpiryInAppNotificationUseCase.invoke() } returns accountExpiryNotifications
every { newDeviceNotificationUseCase.invoke() } returns newDeviceNotifications
+ every { newVersionChangelogUseCase.invoke() } returns newVersionChangelogNotifications
+ every { versionNotificationUseCase.invoke() } returns versionNotifications
every { versionNotificationUseCase.invoke() } returns versionNotifications
every { tunnelStateNotificationUseCase.invoke() } returns tunnelStateNotifications
job = Job()
@@ -56,6 +62,7 @@ class InAppNotificationControllerTest {
InAppNotificationController(
accountExpiryInAppNotificationUseCase,
newDeviceNotificationUseCase,
+ newVersionChangelogUseCase,
versionNotificationUseCase,
tunnelStateNotificationUseCase,
CoroutineScope(job + UnconfinedTestDispatcher()),
@@ -73,6 +80,9 @@ class InAppNotificationControllerTest {
val newDevice = InAppNotification.NewDevice("")
newDeviceNotifications.value = listOf(newDevice)
+ val newVersionChangelog = InAppNotification.NewVersionChangelog
+ newVersionChangelogNotifications.value = listOf(newVersionChangelog)
+
val errorState: ErrorState = mockk()
val tunnelStateBlocked = InAppNotification.TunnelStateBlocked
val tunnelStateError = InAppNotification.TunnelStateError(errorState)
@@ -94,6 +104,7 @@ class InAppNotificationControllerTest {
unsupportedVersion,
accountExpiry,
newDevice,
+ newVersionChangelog,
),
notifications,
)
diff --git a/android/app/src/test/kotlin/net/mullvad/mullvadvpn/repository/ChangelogRepositoryTest.kt b/android/app/src/test/kotlin/net/mullvad/mullvadvpn/repository/ChangelogRepositoryTest.kt
index 1524549e57..4d608b7231 100644
--- a/android/app/src/test/kotlin/net/mullvad/mullvadvpn/repository/ChangelogRepositoryTest.kt
+++ b/android/app/src/test/kotlin/net/mullvad/mullvadvpn/repository/ChangelogRepositoryTest.kt
@@ -2,15 +2,24 @@ package net.mullvad.mullvadvpn.repository
import io.mockk.every
import io.mockk.mockk
+import kotlinx.coroutines.ExperimentalCoroutinesApi
+import kotlinx.coroutines.test.UnconfinedTestDispatcher
import net.mullvad.mullvadvpn.lib.common.test.assertLists
import net.mullvad.mullvadvpn.util.IChangelogDataProvider
import org.junit.jupiter.api.Test
+@ExperimentalCoroutinesApi
class ChangelogRepositoryTest {
private val mockDataProvider: IChangelogDataProvider = mockk()
- private val changelogRepository = ChangelogRepository(dataProvider = mockDataProvider)
+ private val changelogRepository =
+ ChangelogRepository(
+ mockDataProvider,
+ mockk(relaxed = true),
+ mockk(),
+ UnconfinedTestDispatcher(),
+ )
@Test
fun `when given a changelog text should return a list of correctly formatted strings`() {
diff --git a/android/app/src/test/kotlin/net/mullvad/mullvadvpn/viewmodel/ConnectViewModelTest.kt b/android/app/src/test/kotlin/net/mullvad/mullvadvpn/viewmodel/ConnectViewModelTest.kt
index 1dab9a4565..1206af7152 100644
--- a/android/app/src/test/kotlin/net/mullvad/mullvadvpn/viewmodel/ConnectViewModelTest.kt
+++ b/android/app/src/test/kotlin/net/mullvad/mullvadvpn/viewmodel/ConnectViewModelTest.kt
@@ -30,6 +30,7 @@ import net.mullvad.mullvadvpn.lib.model.WebsiteAuthToken
import net.mullvad.mullvadvpn.lib.shared.AccountRepository
import net.mullvad.mullvadvpn.lib.shared.ConnectionProxy
import net.mullvad.mullvadvpn.lib.shared.DeviceRepository
+import net.mullvad.mullvadvpn.repository.ChangelogRepository
import net.mullvad.mullvadvpn.repository.InAppNotification
import net.mullvad.mullvadvpn.repository.InAppNotificationController
import net.mullvad.mullvadvpn.ui.serviceconnection.ServiceConnectionManager
@@ -65,6 +66,9 @@ class ConnectViewModelTest {
// Device Repository
private val mockDeviceRepository: DeviceRepository = mockk()
+ // Changelog Repository
+ private val mockChangelogRepository: ChangelogRepository = mockk()
+
// In App Notifications
private val mockInAppNotificationController: InAppNotificationController = mockk()
@@ -113,6 +117,7 @@ class ConnectViewModelTest {
ConnectViewModel(
accountRepository = mockAccountRepository,
deviceRepository = mockDeviceRepository,
+ changelogRepository = mockChangelogRepository,
inAppNotificationController = mockInAppNotificationController,
newDeviceRepository = mockk(),
outOfTimeUseCase = outOfTimeUseCase,