Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove update available message #6428

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -597,50 +597,11 @@ class ConnectScreenTest {
}
}

@Test
fun testOutdatedVersionNotification() {
composeExtension.use {
// Arrange
val versionInfo =
VersionInfo(
currentVersion = "1.0",
isSupported = true,
suggestedUpgradeVersion = "1.1"
)
setContentWithTheme {
ConnectScreen(
state =
ConnectUiState(
location = null,
selectedRelayItemTitle = null,
tunnelState = TunnelState.Connecting(null, null),
inAddress = null,
outAddress = "",
showLocation = false,
deviceName = "",
daysLeftUntilExpiry = null,
inAppNotification = InAppNotification.UpdateAvailable(versionInfo),
isPlayBuild = false
),
)
}

// Assert
onNodeWithText("UPDATE AVAILABLE").assertExists()
onNodeWithText("Install Mullvad VPN (1.1) to stay up to date").assertExists()
}
}

@Test
fun testUnsupportedVersionNotification() {
composeExtension.use {
// Arrange
val versionInfo =
VersionInfo(
currentVersion = "1.0",
isSupported = false,
suggestedUpgradeVersion = "1.1"
)
val versionInfo = VersionInfo(currentVersion = "1.0", isSupported = false)
setContentWithTheme {
ConnectScreen(
state =
Expand Down Expand Up @@ -702,12 +663,7 @@ class ConnectScreenTest {
composeExtension.use {
// Arrange
val mockedClickHandler: () -> Unit = mockk(relaxed = true)
val versionInfo =
VersionInfo(
isSupported = false,
currentVersion = "",
suggestedUpgradeVersion = "1.1"
)
val versionInfo = VersionInfo(isSupported = false, currentVersion = "")
setContentWithTheme {
ConnectScreen(
onUpdateVersionClick = mockedClickHandler,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class SettingsScreenTest {
SettingsUiState(
appVersion = "",
isLoggedIn = true,
isUpdateAvailable = true,
isSupportedVersion = true,
isPlayBuild = false
),
)
Expand All @@ -54,7 +54,7 @@ class SettingsScreenTest {
SettingsUiState(
appVersion = "",
isLoggedIn = false,
isUpdateAvailable = true,
isSupportedVersion = true,
isPlayBuild = false
),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.tooling.preview.Preview
import net.mullvad.mullvadvpn.R
Expand Down Expand Up @@ -95,7 +94,7 @@ internal fun NavigationTitleView(
Image(
painter = painterResource(id = R.drawable.icon_alert),
modifier = Modifier.padding(end = Dimens.smallPadding),
contentDescription = stringResource(id = R.string.update_available)
contentDescription = null
)
}
Text(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,7 @@ private fun PreviewNotificationBanner() {
val bannerDataList =
listOf(
InAppNotification.UnsupportedVersion(
versionInfo =
VersionInfo(
currentVersion = "1.0",
isSupported = false,
suggestedUpgradeVersion = null
),
versionInfo = VersionInfo(currentVersion = "1.0", isSupported = false),
),
InAppNotification.AccountExpiry(expiry = DateTime.now()),
InAppNotification.TunnelStateBlocked,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,19 +93,6 @@ fun InAppNotification.toNotificationData(
if (isPlayBuild) null
else NotificationAction(R.drawable.icon_extlink, onClickUpdateVersion)
)
is InAppNotification.UpdateAvailable ->
NotificationData(
title = stringResource(id = R.string.update_available),
message =
stringResource(
id = R.string.update_available_description,
versionInfo.suggestedUpgradeVersion ?: ""
),
statusLevel = StatusLevel.Warning,
action =
if (isPlayBuild) null
else NotificationAction(R.drawable.icon_extlink, onClickUpdateVersion)
)
}

@Composable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ private fun PreviewSettings() {
SettingsUiState(
appVersion = "2222.22",
isLoggedIn = true,
isUpdateAvailable = true,
isSupportedVersion = true,
isPlayBuild = false
),
)
Expand Down Expand Up @@ -172,13 +172,13 @@ private fun AppVersion(context: Context, state: SettingsUiState) {
)
}
},
showWarning = state.isUpdateAvailable,
showWarning = !state.isSupportedVersion,
isRowEnabled = !state.isPlayBuild
)

if (state.isUpdateAvailable) {
if (!state.isSupportedVersion) {
Text(
text = stringResource(id = R.string.update_available_footer),
text = stringResource(id = R.string.unsupported_version_description),
style = MaterialTheme.typography.labelMedium,
color = MaterialTheme.colorScheme.onSecondary,
modifier =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ package net.mullvad.mullvadvpn.compose.state
data class SettingsUiState(
val appVersion: String,
val isLoggedIn: Boolean,
val isUpdateAvailable: Boolean,
val isSupportedVersion: Boolean,
val isPlayBuild: Boolean
)
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,6 @@ sealed class InAppNotification {
override val statusLevel = StatusLevel.Info
override val priority: Long = 1001
}

data class UpdateAvailable(val versionInfo: VersionInfo) : InAppNotification() {
override val statusLevel = StatusLevel.Info
override val priority: Long = 1000
}
}

class InAppNotificationController(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
package net.mullvad.mullvadvpn.ui

data class VersionInfo(
val currentVersion: String,
val isSupported: Boolean,
val suggestedUpgradeVersion: String?
) {
val isUpdateAvailable: Boolean = suggestedUpgradeVersion != null
}
data class VersionInfo(val currentVersion: String, val isSupported: Boolean)
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ class AppVersionInfoRepository(
) {
fun versionInfo(): Flow<VersionInfo> =
managementService.versionInfo.map { appVersionInfo ->
VersionInfo(
currentVersion = buildVersion.name,
isSupported = appVersionInfo.supported,
suggestedUpgradeVersion = appVersionInfo.suggestedUpgrade,
)
VersionInfo(currentVersion = buildVersion.name, isSupported = appVersionInfo.supported)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,9 @@ class VersionNotificationUseCase(
operator fun invoke() =
appVersionInfoRepository
.versionInfo()
.map { versionInfo ->
listOfNotNull(
unsupportedVersionNotification(versionInfo),
updateAvailableNotification(versionInfo)
)
}
.map { versionInfo -> listOfNotNull(unsupportedVersionNotification(versionInfo)) }
.distinctUntilChanged()

private fun updateAvailableNotification(versionInfo: VersionInfo): InAppNotification? {
if (!isVersionInfoNotificationEnabled) {
return null
}

return if (versionInfo.isUpdateAvailable) {
InAppNotification.UpdateAvailable(versionInfo)
} else null
}

private fun unsupportedVersionNotification(versionInfo: VersionInfo): InAppNotification? {
if (!isVersionInfoNotificationEnabled) {
return null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ class SettingsViewModel(
SettingsUiState(
isLoggedIn = deviceState is DeviceState.LoggedIn,
appVersion = versionInfo.currentVersion,
isUpdateAvailable =
versionInfo.let { it.isSupported.not() || it.isUpdateAvailable },
isSupportedVersion = versionInfo.isSupported,
isPlayBuild = isPlayBuild
)
}
Expand All @@ -35,7 +34,7 @@ class SettingsViewModel(
SettingsUiState(
appVersion = "",
isLoggedIn = false,
isUpdateAvailable = false,
isSupportedVersion = true,
isPlayBuild
)
)
Expand All @@ -47,7 +46,7 @@ class SettingsViewModel(
SettingsUiState(
appVersion = "",
isLoggedIn = false,
isUpdateAvailable = false,
isSupportedVersion = true,
isPlayBuild
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@ class InAppNotificationControllerTest {
tunnelStateNotifications.value = listOf(tunnelStateBlocked, tunnelStateError)

val unsupportedVersion = InAppNotification.UnsupportedVersion(mockk())
val updateAvailable = InAppNotification.UpdateAvailable(mockk())
versionNotifications.value = listOf(unsupportedVersion, updateAvailable)
versionNotifications.value = listOf(unsupportedVersion)

val accountExpiry = InAppNotification.AccountExpiry(DateTime.now())
accountExpiryNotifications.value = listOf(accountExpiry)
Expand All @@ -93,7 +92,6 @@ class InAppNotificationControllerTest {
unsupportedVersion,
accountExpiry,
newDevice,
updateAvailable,
),
notifications
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@ class VersionNotificationUseCaseTest {

private val mockAppVersionInfoRepository: AppVersionInfoRepository = mockk()

private val versionInfo =
MutableStateFlow(
VersionInfo(currentVersion = "", isSupported = true, suggestedUpgradeVersion = null)
)
private val versionInfo = MutableStateFlow(VersionInfo(currentVersion = "", isSupported = true))
private lateinit var versionNotificationUseCase: VersionNotificationUseCase

@BeforeEach
Expand All @@ -52,28 +49,6 @@ class VersionNotificationUseCaseTest {
versionNotificationUseCase().test { assertTrue { awaitItem().isEmpty() } }
}

@Test
fun `when a new version is available use case should emit UpdateAvailable with new version`() =
runTest {
versionNotificationUseCase().test {
// Arrange, Act
val upgradeVersionInfo =
VersionInfo(
currentVersion = "1.0",
isSupported = true,
suggestedUpgradeVersion = "1.1"
)
awaitItem()
versionInfo.value = upgradeVersionInfo

// Assert
assertEquals(
awaitItem(),
listOf(InAppNotification.UpdateAvailable(upgradeVersionInfo))
)
}
}

@Test
fun `when an unsupported version use case should emit UnsupportedVersion notification`() =
runTest {
Expand All @@ -83,7 +58,6 @@ class VersionNotificationUseCaseTest {
VersionInfo(
currentVersion = "1.0",
isSupported = false,
suggestedUpgradeVersion = null
)
awaitItem()
versionInfo.value = upgradeVersionInfo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ class SettingsViewModelTest {
private val mockAppVersionInfoRepository: AppVersionInfoRepository = mockk()

private val versionInfo =
MutableStateFlow(
VersionInfo(currentVersion = "", isSupported = false, suggestedUpgradeVersion = null)
)
MutableStateFlow(VersionInfo(currentVersion = "", isSupported = false))

private lateinit var viewModel: SettingsViewModel

Expand Down Expand Up @@ -60,53 +58,30 @@ class SettingsViewModelTest {
}

@Test
fun `when AppVersionInfoCache returns isOutdated false uiState should return isUpdateAvailable false`() =
fun `when AppVersionInfoRepository returns isSupported true uiState should return isSupportedVersion true`() =
runTest {
// Arrange
val versionInfoTestItem =
VersionInfo(
currentVersion = "1.0",
isSupported = true,
suggestedUpgradeVersion = null
)

// Act, Assert
viewModel.uiState.test {
awaitItem() // Wait for initial value

versionInfo.value = versionInfoTestItem
val result = awaitItem()
assertEquals(false, result.isUpdateAvailable)
}
}

@Test
fun `when AppVersionInfoCache returns isSupported false uiState should return isUpdateAvailable true`() =
runTest {
// Arrange
val versionInfoTestItem =
VersionInfo(currentVersion = "", isSupported = false, suggestedUpgradeVersion = "")
val versionInfoTestItem = VersionInfo(currentVersion = "", isSupported = true)
versionInfo.value = versionInfoTestItem

// Act, Assert
viewModel.uiState.test {
val result = awaitItem()
assertEquals(true, result.isUpdateAvailable)
assertEquals(true, result.isSupportedVersion)
}
}

@Test
fun `when AppVersionInfoCache returns isOutdated true uiState should return isUpdateAvailable true`() =
fun `when AppVersionInfoRepository returns isSupported false uiState should return isSupportedVersion false`() =
runTest {
// Arrange
val versionInfoTestItem =
VersionInfo(currentVersion = "", isSupported = true, suggestedUpgradeVersion = "")
val versionInfoTestItem = VersionInfo(currentVersion = "", isSupported = false)
versionInfo.value = versionInfoTestItem

// Act, Assert
viewModel.uiState.test {
val result = awaitItem()
assertEquals(true, result.isUpdateAvailable)
assertEquals(false, result.isSupportedVersion)
}
}
}
Loading
Loading