Updated on 2026-08-14

This commit is contained in:
Tangem 2026-07-21 12:15:38 +03:00
parent 3737e94127
commit def54395ce
5 changed files with 11 additions and 65 deletions

View file

@ -20,7 +20,6 @@ import com.tangem.common.constants.TestConstants.ALLURE_LABEL_NAME
import com.tangem.common.constants.TestConstants.ALLURE_LABEL_VALUE
import com.tangem.common.constants.TestConstants.WAIT_UNTIL_TIMEOUT
import com.tangem.common.rules.ApiEnvironmentRule
import com.tangem.data.pay.TangemPayMockControl
import com.tangem.datasource.api.common.config.managers.ApiConfigsManager
import com.tangem.datasource.local.preferences.AppPreferencesStore
import com.tangem.datasource.local.preferences.PreferencesKeys
@ -112,9 +111,6 @@ abstract class BaseTestCase : TestCase(
additionalBeforeSection: () -> Unit = {},
additionalAfterSection: () -> Unit = {},
) = before {
// Reset opt-in Tangem Pay mock switches so a previous Tangem Pay test can't leak an active Payment
// account into the next (e.g. generic openMainScreen) test running in the same process.
TangemPayMockControl.reset()
Allure.label(ALLURE_LABEL_NAME, ALLURE_LABEL_VALUE)
// Setup WireMock redirect for CI with local WireMock instances
val wiremockUrl = InstrumentationRegistry.getArguments().getString(WIREMOCK_BASE_URL_ARG)
@ -184,16 +180,6 @@ abstract class BaseTestCase : TestCase(
fun waitForIdle() = composeTestRule.waitForIdle()
/**
* Opts the current test's wallet into the Tangem Pay mock so it is treated as an existing customer
* (an active Payment account appears). MUST be called before the wallet is imported, so the first
* payment-account status fetch observes it. Paired with the [TangemPayMockControl] reset in [setupHooks],
* which restores the Payment-free default for every other (e.g. generic openMainScreen) test.
*/
fun markExistingTangemPayCustomer() {
TangemPayMockControl.hasTangemPayInWallet = true
}
/**
* Waits until [block] stops throwing (or [timeoutMillis] elapses). Use in scenario (BaseTestCase extension)
* code where flakySafely is unavailable; in test bodies prefer flakySafely.

View file

@ -12,8 +12,8 @@ import com.tangem.screens.tangempay.*
import io.qameta.allure.kotlin.Allure.step
fun BaseTestCase.openTangemPay() {
// Opt this wallet into the Tangem Pay mock (existing customer) before importing the wallet.
markExistingTangemPayCustomer()
// Existing customer: callers set the `tangem_pay_eligibility` scenario to PaeraCustomer (in
// additionalBeforeSection, before this runs), which drives the checkCustomerWalletId mock -> Payment account.
step("Import hot wallet from Tangem Pay seed phrase (with access code)") {
openMainScreenWithExistingHotWallet(SVS_SEED_PHRASE_12, accessCode = TANGEM_PAY_ACCESS_CODE)
}

View file

@ -35,8 +35,6 @@ class TangemPayOnboardingKycTest : BaseTestCase() {
val paeraCustomerState = "PaeraCustomer"
setupHooks(
// Existing customer: opt into the Tangem Pay mock so the Payment account (tile) appears.
additionalBeforeSection = { markExistingTangemPayCustomer() },
additionalAfterSection = {
resetWireMockScenarioState(TANGEM_PAY_ELIGIBILITY_SCENARIO)
},
@ -136,9 +134,6 @@ class TangemPayOnboardingKycTest : BaseTestCase() {
val viewStatusText = getResourceString(CoreResR.string.tangempay_kyc_in_progress_notification_button)
setupHooks(
// Existing customer: the tile must appear so its KYC-status subtitle can be asserted.
// The KYC status itself comes from the WireMock TANGEM_PAY_KYC_STATUS_SCENARIO via getCustomerInfo.
additionalBeforeSection = { markExistingTangemPayCustomer() },
additionalAfterSection = {
resetWireMockScenarioState(TANGEM_PAY_ELIGIBILITY_SCENARIO)
resetWireMockScenarioState(TANGEM_PAY_KYC_STATUS_SCENARIO)
@ -192,9 +187,6 @@ class TangemPayOnboardingKycTest : BaseTestCase() {
val goToSupportText = getResourceString(CoreResR.string.tangempay_go_to_support)
setupHooks(
// Existing customer: the tile must appear so its KYC-status subtitle can be asserted.
// The KYC status itself comes from the WireMock TANGEM_PAY_KYC_STATUS_SCENARIO via getCustomerInfo.
additionalBeforeSection = { markExistingTangemPayCustomer() },
additionalAfterSection = {
resetWireMockScenarioState(TANGEM_PAY_ELIGIBILITY_SCENARIO)
resetWireMockScenarioState(TANGEM_PAY_KYC_STATUS_SCENARIO)