BIT-480, BIT-1386: Allow for saving a text send (#535)

This commit is contained in:
David Perez
2024-06-20 17:08:07 +01:00
committed by Álison Fernandes
parent acb5fce448
commit 4bbda49d74
7 changed files with 60 additions and 29 deletions
@@ -30,6 +30,7 @@ import kotlinx.coroutines.flow.update
import kotlinx.coroutines.test.runTest
import org.junit.Before
import org.junit.Test
import java.time.Instant
class AddSendScreenTest : BaseComposeTest() {
@@ -603,6 +604,8 @@ class AddSendScreenTest : BaseComposeTest() {
noteInput = "",
isHideEmailChecked = false,
isDeactivateChecked = false,
deletionDate = Instant.parse("2023-10-27T12:00:00Z"),
expirationDate = null,
)
private val DEFAULT_SELECTED_TYPE_STATE = AddSendState.ViewState.Content.SendType.Text(
@@ -26,9 +26,16 @@ import org.junit.jupiter.api.AfterEach
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import java.time.Clock
import java.time.Instant
import java.util.TimeZone
class AddSendViewModelTest : BaseViewModelTest() {
private val clock = Clock.fixed(
Instant.parse("2023-10-27T12:00:00Z"),
TimeZone.getTimeZone("UTC").toZoneId(),
)
private val mutableUserStateFlow = MutableStateFlow<UserState?>(DEFAULT_USER_STATE)
private val authRepository: AuthRepository = mockk {
every { userStateFlow } returns mutableUserStateFlow
@@ -329,6 +336,7 @@ class AddSendViewModelTest : BaseViewModelTest() {
savedStateHandle = SavedStateHandle().apply { set("state", state) },
authRepo = authRepository,
environmentRepo = environmentRepository,
clock = clock,
vaultRepo = vaultRepository,
)
@@ -345,6 +353,8 @@ class AddSendViewModelTest : BaseViewModelTest() {
noteInput = "",
isHideEmailChecked = false,
isDeactivateChecked = false,
deletionDate = Instant.parse("2023-11-03T12:00:00Z"),
expirationDate = null,
)
private val DEFAULT_SELECTED_TYPE_STATE = AddSendState.ViewState.Content.SendType.Text(
@@ -27,9 +27,8 @@ class AddSendStateExtensionsTest {
val sendView = createMockSendView(number = 1, type = SendType.FILE).copy(
id = null,
accessId = null,
key = "",
key = "91Xo3Wdf0N0Cc5AHJRC3SQ",
accessCount = 0U,
expirationDate = null,
text = null,
file = SendFileView(
id = "",
@@ -53,9 +52,8 @@ class AddSendStateExtensionsTest {
val sendView = createMockSendView(number = 1, type = SendType.TEXT).copy(
id = null,
accessId = null,
key = "",
key = "91Xo3Wdf0N0Cc5AHJRC3SQ",
accessCount = 0U,
expirationDate = null,
file = null,
)
mockkStatic(Instant::class)
@@ -65,23 +63,27 @@ class AddSendStateExtensionsTest {
assertEquals(sendView, result)
}
companion object {
private val DEFAULT_COMMON_STATE = AddSendState.ViewState.Content.Common(
name = "mockName-1",
maxAccessCount = 1,
passwordInput = "mockPassword-1",
noteInput = "mockNotes-1",
isHideEmailChecked = false,
isDeactivateChecked = false,
deletionDate = Instant.parse("2023-10-27T12:00:00Z"),
expirationDate = Instant.parse("2023-10-27T12:00:00Z"),
)
private val DEFAULT_SELECTED_TYPE_STATE = AddSendState.ViewState.Content.SendType.Text(
input = "mockText-1",
isHideByDefaultChecked = false,
)
private val DEFAULT_VIEW_STATE = AddSendState.ViewState.Content(
common = DEFAULT_COMMON_STATE,
selectedType = DEFAULT_SELECTED_TYPE_STATE,
)
}
}
private val DEFAULT_COMMON_STATE = AddSendState.ViewState.Content.Common(
name = "mockName-1",
maxAccessCount = 1,
passwordInput = "mockPassword-1",
noteInput = "mockNotes-1",
isHideEmailChecked = false,
isDeactivateChecked = false,
)
private val DEFAULT_SELECTED_TYPE_STATE = AddSendState.ViewState.Content.SendType.Text(
input = "mockText-1",
isHideByDefaultChecked = false,
)
private val DEFAULT_VIEW_STATE = AddSendState.ViewState.Content(
common = DEFAULT_COMMON_STATE,
selectedType = DEFAULT_SELECTED_TYPE_STATE,
)