Fix rebasing issue with Login URIs (#866)

This commit is contained in:
Brian Yencho 2024-01-29 23:27:46 -06:00 committed by Álison Fernandes
parent 1e64c82e83
commit 085fa0153d
2 changed files with 33 additions and 2 deletions

View file

@ -3,6 +3,8 @@ package com.x8bit.bitwarden.ui.vault.feature.addedit.util
import com.x8bit.bitwarden.data.autofill.model.AutofillSelectionData
import com.x8bit.bitwarden.ui.platform.base.util.toHostOrPathOrNull
import com.x8bit.bitwarden.ui.vault.feature.addedit.VaultAddEditState
import com.x8bit.bitwarden.ui.vault.feature.addedit.model.UriItem
import java.util.UUID
/**
* Returns pre-filled content that may be used for an "add" type
@ -18,7 +20,13 @@ fun AutofillSelectionData.toDefaultAddTypeContent(): VaultAddEditState.ViewState
AutofillSelectionData.Type.LOGIN -> {
VaultAddEditState.ViewState.Content.ItemType.Login(
uri = uri.orEmpty(),
uriList = listOf(
UriItem(
id = UUID.randomUUID().toString(),
uri = uri,
match = null,
),
),
)
}
}

View file

@ -2,10 +2,26 @@ package com.x8bit.bitwarden.ui.vault.feature.addedit.util
import com.x8bit.bitwarden.data.autofill.model.AutofillSelectionData
import com.x8bit.bitwarden.ui.vault.feature.addedit.VaultAddEditState
import com.x8bit.bitwarden.ui.vault.feature.addedit.model.UriItem
import io.mockk.every
import io.mockk.mockkStatic
import io.mockk.unmockkStatic
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import java.util.UUID
class AutofillSelectionDataExtensionsTest {
@BeforeEach
fun setUp() {
mockkStatic(UUID::randomUUID)
}
@BeforeEach
fun tearDown() {
unmockkStatic(UUID::randomUUID)
}
@Test
fun `toDefaultAddTypeContent for a Card type should return the correct Content`() {
assertEquals(
@ -23,13 +39,20 @@ class AutofillSelectionDataExtensionsTest {
@Test
fun `toDefaultAddTypeContent for a Login type should return the correct Content`() {
every { UUID.randomUUID().toString() } returns "uuid"
assertEquals(
VaultAddEditState.ViewState.Content(
common = VaultAddEditState.ViewState.Content.Common(
name = "www.test.com",
),
type = VaultAddEditState.ViewState.Content.ItemType.Login(
uri = "https://www.test.com",
uriList = listOf(
UriItem(
id = "uuid",
uri = "https://www.test.com",
match = null,
),
),
),
),
AutofillSelectionData(