Updated on 2026-08-14
This commit is contained in:
parent
03c5bdd053
commit
d2d15bdbb9
4 changed files with 46 additions and 6 deletions
|
|
@ -30,7 +30,7 @@ class GetContactsUseCase(
|
|||
private fun Contact.matches(query: String): Boolean {
|
||||
val isNameContaining = name.value.contains(other = query, ignoreCase = true)
|
||||
val isAddressContaining = addresses.any { addressEntry ->
|
||||
addressEntry.address.contains(other = query, ignoreCase = true)
|
||||
addressEntry.address.contains(other = query, ignoreCase = false)
|
||||
}
|
||||
return isNameContaining || isAddressContaining
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,6 +53,41 @@ class GetContactsUseCaseTest {
|
|||
assertThat(result).containsExactly(bob)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `GIVEN address query matching case WHEN invoke THEN returns matching contact`() = runTest {
|
||||
// Arrange
|
||||
val carol = contact(name = "Carol", address = "0xAbCdEf")
|
||||
every { repository.getAllContacts() } returns flowOf(listOf(alice, carol))
|
||||
|
||||
// Act
|
||||
val result = useCase(query = "0xAbCdEf").first()
|
||||
|
||||
// Assert
|
||||
assertThat(result).containsExactly(carol)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `GIVEN address query with different case WHEN invoke THEN returns empty`() = runTest {
|
||||
// Arrange
|
||||
val carol = contact(name = "Carol", address = "0xAbCdEf")
|
||||
every { repository.getAllContacts() } returns flowOf(listOf(alice, carol))
|
||||
|
||||
// Act
|
||||
val result = useCase(query = "0xabcdef").first()
|
||||
|
||||
// Assert
|
||||
assertThat(result).isEmpty()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `GIVEN name query with different case WHEN invoke THEN returns matching contact`() = runTest {
|
||||
// Act
|
||||
val result = useCase(query = "ALICE").first()
|
||||
|
||||
// Assert
|
||||
assertThat(result).containsExactly(alice)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `GIVEN blank query WHEN invoke THEN returns all contacts unfiltered`() = runTest {
|
||||
// Act
|
||||
|
|
|
|||
|
|
@ -128,6 +128,7 @@ dependencies {
|
|||
implementation(projects.domain.yieldSupply.models)
|
||||
|
||||
/** Feature Apis */
|
||||
api(projects.features.addressBook.api)
|
||||
api(projects.features.biometry.api)
|
||||
api(projects.features.commonFeatures.api)
|
||||
api(projects.features.feed.api)
|
||||
|
|
|
|||
|
|
@ -61,6 +61,7 @@ import com.tangem.feature.wallet.presentation.wallet.state.transformers.*
|
|||
import com.tangem.feature.wallet.presentation.wallet.state.utils.WalletEventSender
|
||||
import com.tangem.feature.wallet.presentation.wallet.ui.components.visa.KycRejectedCallbacks
|
||||
import com.tangem.feature.wallet.presentation.wallet.utils.ScreenLifecycleProvider
|
||||
import com.tangem.features.addressbook.AddressBookFeatureToggles
|
||||
import com.tangem.features.biometry.AskBiometryComponent
|
||||
import com.tangem.features.hotwallet.HotWalletFeatureToggles
|
||||
import com.tangem.features.pushnotifications.api.PushNotificationsModelCallbacks
|
||||
|
|
@ -127,6 +128,7 @@ internal class WalletModel @Inject constructor(
|
|||
private val hotWalletFeatureToggles: HotWalletFeatureToggles,
|
||||
private val walletFeatureToggles: WalletFeatureToggles,
|
||||
private val pushNotificationSettingsFeatureToggles: PushNotificationSettingsFeatureToggles,
|
||||
private val addressBookFeatureToggles: AddressBookFeatureToggles,
|
||||
private val startAssetsDiscoveryUseCase: StartAssetsDiscoveryUseCase,
|
||||
private val syncAddressBooksUseCase: SyncAddressBooksUseCase,
|
||||
val screenLifecycleProvider: ScreenLifecycleProvider,
|
||||
|
|
@ -164,7 +166,7 @@ internal class WalletModel @Inject constructor(
|
|||
subscribeToMainScreenQrScanning()
|
||||
enableNotificationsIfNeeded()
|
||||
applyPendingAssetsDiscovery()
|
||||
syncAddressBooks()
|
||||
syncAddressBooksIfNeeded()
|
||||
|
||||
clickIntents.initialize(innerWalletRouter, modelScope)
|
||||
|
||||
|
|
@ -882,12 +884,14 @@ internal class WalletModel @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
private fun syncAddressBooks() {
|
||||
private fun syncAddressBooksIfNeeded() {
|
||||
if (addressBookFeatureToggles.isAddressBookEnabled) {
|
||||
modelScope.launch {
|
||||
syncAddressBooksUseCase()
|
||||
.onLeft { TangemLogger.e("Failed to sync address books: $it") }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun enableNotificationsIfNeeded() {
|
||||
modelScope.launch {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue