This commit is contained in:
Matt Gibson 2024-10-23 09:09:06 -07:00
parent c88157fbce
commit 991c82b277
No known key found for this signature in database
GPG key ID: 7CBCA182C13B0912
5 changed files with 54 additions and 1 deletions

View file

@ -21,7 +21,7 @@ fun NotificationCenterActionItem(
val contentDescription = stringResource(id = R.string.account)
BitwardenStandardIconButton(
vectorIconRes = R.drawable.ic_search,
vectorIconRes = R.drawable.ic,
contentDescription = contentDescription,
onClick = onClick,
modifier = Modifier.testTag(tag = "NotificationCenter"),

View file

@ -8,6 +8,7 @@ import com.x8bit.bitwarden.data.vault.datasource.disk.dao.FakeCiphersDao
import com.x8bit.bitwarden.data.vault.datasource.disk.dao.FakeCollectionsDao
import com.x8bit.bitwarden.data.vault.datasource.disk.dao.FakeDomainsDao
import com.x8bit.bitwarden.data.vault.datasource.disk.dao.FakeFoldersDao
import com.x8bit.bitwarden.data.vault.datasource.disk.dao.FakeOfflineCiphersDao
import com.x8bit.bitwarden.data.vault.datasource.disk.dao.FakeSendsDao
import com.x8bit.bitwarden.data.vault.datasource.disk.entity.CipherEntity
import com.x8bit.bitwarden.data.vault.datasource.disk.entity.CollectionEntity
@ -37,6 +38,7 @@ class VaultDiskSourceTest {
private val json = PlatformNetworkModule.providesJson()
private val dispatcherManager: FakeDispatcherManager = FakeDispatcherManager()
private lateinit var ciphersDao: FakeCiphersDao
private lateinit var offlineCiphersDao: FakeOfflineCiphersDao
private lateinit var collectionsDao: FakeCollectionsDao
private lateinit var domainsDao: FakeDomainsDao
private lateinit var foldersDao: FakeFoldersDao
@ -47,6 +49,7 @@ class VaultDiskSourceTest {
@BeforeEach
fun setup() {
ciphersDao = FakeCiphersDao()
offlineCiphersDao = FakeOfflineCiphersDao()
collectionsDao = FakeCollectionsDao()
domainsDao = FakeDomainsDao()
foldersDao = FakeFoldersDao()
@ -57,6 +60,7 @@ class VaultDiskSourceTest {
domainsDao = domainsDao,
foldersDao = foldersDao,
sendsDao = sendsDao,
offlineCiphersDao = offlineCiphersDao,
json = json,
dispatcherManager = dispatcherManager,
)

View file

@ -0,0 +1,46 @@
package com.x8bit.bitwarden.data.vault.datasource.disk.dao
import com.x8bit.bitwarden.data.platform.repository.util.bufferedMutableSharedFlow
import com.x8bit.bitwarden.data.vault.datasource.disk.entity.OfflineCipherEntity
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.map
class FakeOfflineCiphersDao : OfflineCiphersDao {
val storedCiphers = mutableListOf<OfflineCipherEntity>()
var deleteCipherCalled: Boolean = false
var deleteCiphersCalled: Boolean = false
var insertCiphersCalled: Boolean = false
private val ciphersFlow = bufferedMutableSharedFlow<List<OfflineCipherEntity>>(replay = 1)
init {
ciphersFlow.tryEmit(emptyList())
}
override suspend fun deleteAllCiphers(userId: String): Int {
deleteCiphersCalled = true
val count = storedCiphers.count { it.userId == userId }
storedCiphers.removeAll { it.userId == userId }
ciphersFlow.tryEmit(storedCiphers.toList())
return count
}
override suspend fun deleteCipher(userId: String, cipherId: String): Int {
deleteCipherCalled = true
val count = storedCiphers.count { it.userId == userId && it.id == cipherId }
storedCiphers.removeAll { it.userId == userId && it.id == cipherId }
ciphersFlow.tryEmit(storedCiphers.toList())
return count
}
override suspend fun insertCiphers(ciphers: List<OfflineCipherEntity>) {
storedCiphers.addAll(ciphers)
ciphersFlow.tryEmit(ciphers.toList())
insertCiphersCalled = true
}
override fun getAllCiphers(userId: String): Flow<List<OfflineCipherEntity>> =
ciphersFlow.map { ciphers -> ciphers.filter { it.userId == userId } }
}

View file

@ -43,6 +43,7 @@ import com.x8bit.bitwarden.ui.util.performLockAccountClick
import com.x8bit.bitwarden.ui.util.performLogoutAccountClick
import com.x8bit.bitwarden.ui.util.performRemoveAccountClick
import com.x8bit.bitwarden.ui.util.performYesDialogButtonClick
import com.x8bit.bitwarden.ui.vault.feature.vault.model.NotificationSummary
import com.x8bit.bitwarden.ui.vault.feature.vault.model.VaultFilterData
import com.x8bit.bitwarden.ui.vault.feature.vault.model.VaultFilterType
import com.x8bit.bitwarden.ui.vault.model.VaultItemListingType
@ -1256,6 +1257,7 @@ private val DEFAULT_STATE: VaultState = VaultState(
hideNotificationsDialog = true,
isRefreshing = false,
showImportActionCard = false,
notificationSummaries = listOf()
)
private val DEFAULT_CONTENT_VIEW_STATE: VaultState.ViewState.Content = VaultState.ViewState.Content(

View file

@ -1729,4 +1729,5 @@ private fun createMockVaultState(
hideNotificationsDialog = true,
showImportActionCard = true,
isRefreshing = false,
notificationSummaries = listOf()
)