Updated on 2026-08-14
This commit is contained in:
parent
26201c5c0b
commit
0be1358760
39 changed files with 581 additions and 124 deletions
|
|
@ -17,4 +17,7 @@ dependencies {
|
|||
implementation(projects.domain.wallets.models)
|
||||
implementation(projects.domain.visa.models)
|
||||
implementation(projects.domain.feedback.models)
|
||||
|
||||
/** Testing libraries */
|
||||
testImplementation(projects.test.core)
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
package com.tangem.domain.feedback
|
||||
|
||||
import com.tangem.domain.feedback.models.FeedbackEmailType
|
||||
import com.tangem.domain.models.wallet.UserWalletId
|
||||
|
||||
class SendBackupProblemEmailUseCase(
|
||||
private val getWalletMetaInfoUseCase: GetWalletMetaInfoUseCase,
|
||||
private val sendFeedbackEmailUseCase: SendFeedbackEmailUseCase,
|
||||
) {
|
||||
|
||||
suspend operator fun invoke(userWalletId: UserWalletId) {
|
||||
val metaInfo = getWalletMetaInfoUseCase(userWalletId).getOrNull() ?: return
|
||||
sendFeedbackEmailUseCase(type = FeedbackEmailType.BackupProblem(walletMetaInfo = metaInfo))
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
package com.tangem.domain.feedback
|
||||
|
||||
import arrow.core.left
|
||||
import arrow.core.right
|
||||
import com.tangem.domain.feedback.models.FeedbackEmailType
|
||||
import com.tangem.domain.feedback.models.WalletMetaInfo
|
||||
import com.tangem.domain.models.wallet.UserWalletId
|
||||
import io.mockk.clearMocks
|
||||
import io.mockk.coEvery
|
||||
import io.mockk.coVerify
|
||||
import io.mockk.mockk
|
||||
import kotlinx.coroutines.test.runTest
|
||||
import org.junit.jupiter.api.AfterEach
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.junit.jupiter.api.TestInstance
|
||||
|
||||
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
|
||||
internal class SendBackupProblemEmailUseCaseTest {
|
||||
|
||||
private val getWalletMetaInfoUseCase: GetWalletMetaInfoUseCase = mockk()
|
||||
private val sendFeedbackEmailUseCase: SendFeedbackEmailUseCase = mockk(relaxed = true)
|
||||
|
||||
private val useCase = SendBackupProblemEmailUseCase(
|
||||
getWalletMetaInfoUseCase = getWalletMetaInfoUseCase,
|
||||
sendFeedbackEmailUseCase = sendFeedbackEmailUseCase,
|
||||
)
|
||||
|
||||
@AfterEach
|
||||
fun tearDown() {
|
||||
clearMocks(getWalletMetaInfoUseCase, sendFeedbackEmailUseCase)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `does not send email when wallet meta info is unavailable`() = runTest {
|
||||
coEvery { getWalletMetaInfoUseCase(walletId) } returns Throwable().left()
|
||||
|
||||
useCase(walletId)
|
||||
|
||||
coVerify(exactly = 0) { sendFeedbackEmailUseCase(any()) }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `sends backup problem email when wallet meta info is available`() = runTest {
|
||||
val metaInfo = mockk<WalletMetaInfo>()
|
||||
coEvery { getWalletMetaInfoUseCase(walletId) } returns metaInfo.right()
|
||||
|
||||
useCase(walletId)
|
||||
|
||||
coVerify(exactly = 1) {
|
||||
sendFeedbackEmailUseCase(FeedbackEmailType.BackupProblem(walletMetaInfo = metaInfo))
|
||||
}
|
||||
}
|
||||
|
||||
private companion object {
|
||||
val walletId = UserWalletId("011")
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue