Skip to content

Commit

Permalink
Update Label/Folder Form VM + tests
Browse files Browse the repository at this point in the history
NOJIRA
  • Loading branch information
nick0602 authored and MargeBot committed Sep 30, 2024
1 parent 04f6c9c commit 86013f4
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ class LabelFormViewModel @Inject constructor(
isLabelLimitReached && isUserUpgrading -> return emitNewStateFor(LabelFormEvent.UpsellingInProgress)

isLabelLimitReached -> {
val shouldShowUpselling = observeUpsellingVisibility(UpsellingEntryPoint.BottomSheet.Folders).first()
val shouldShowUpselling = observeUpsellingVisibility(UpsellingEntryPoint.BottomSheet.Labels).first()
return if (shouldShowUpselling) {
emitNewStateFor(LabelFormEvent.ShowUpselling)
} else emitNewStateFor(LabelFormEvent.LabelLimitReached)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import ch.protonmail.android.maillabel.presentation.R
import ch.protonmail.android.maillabel.presentation.getHexStringFromColor
import ch.protonmail.android.mailsettings.domain.model.FolderColorSettings
import ch.protonmail.android.mailsettings.domain.usecase.ObserveFolderColorSettings
import ch.protonmail.android.mailupselling.domain.model.UpsellingEntryPoint
import ch.protonmail.android.mailupselling.domain.model.UserUpgradeState
import ch.protonmail.android.mailupselling.presentation.model.BottomSheetVisibilityEffect
import ch.protonmail.android.mailupselling.presentation.usecase.ObserveUpsellingVisibility
Expand Down Expand Up @@ -544,7 +545,7 @@ class FolderFormViewModelTest {
val loadedState = loadedCreateState
every { savedStateHandle.get<String>(FolderFormScreen.FolderFormLabelIdKey) } returns null
coEvery { isLabelLimitReached.invoke(userId, LabelType.MessageFolder) } returns true.right()
coEvery { observeUpsellingVisibility.invoke(any()) } returns flowOf(true)
coEvery { observeUpsellingVisibility.invoke(UpsellingEntryPoint.BottomSheet.Folders) } returns flowOf(true)

folderFormViewModel.state.test {
// Initial loaded state
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import ch.protonmail.android.maillabel.domain.usecase.IsLabelNameAllowed
import ch.protonmail.android.maillabel.domain.usecase.UpdateLabel
import ch.protonmail.android.maillabel.presentation.R
import ch.protonmail.android.maillabel.presentation.getHexStringFromColor
import ch.protonmail.android.mailupselling.domain.model.UpsellingEntryPoint
import ch.protonmail.android.mailupselling.domain.model.UserUpgradeState
import ch.protonmail.android.mailupselling.presentation.model.BottomSheetVisibilityEffect
import ch.protonmail.android.mailupselling.presentation.usecase.ObserveUpsellingVisibility
Expand Down Expand Up @@ -426,7 +427,7 @@ class LabelFormViewModelTest {
val loadedState = loadedCreateState
every { savedStateHandle.get<String>(LabelFormScreen.LabelFormLabelIdKey) } returns null
coEvery { isLabelLimitReached.invoke(userId, LabelType.MessageLabel) } returns true.right()
coEvery { observeUpsellingVisibility.invoke(any()) } returns flowOf(true)
coEvery { observeUpsellingVisibility.invoke(UpsellingEntryPoint.BottomSheet.Labels) } returns flowOf(true)

labelFormViewModel.state.test {
// Initial loaded state
Expand Down

0 comments on commit 86013f4

Please sign in to comment.