Updated on 2026-08-14
This commit is contained in:
parent
0d2c403a6a
commit
1c5fa97fdf
2 changed files with 54 additions and 14 deletions
|
|
@ -8,12 +8,18 @@ import java.io.IOException
|
|||
|
||||
/**
|
||||
* Method uses to set WireMock scenario state
|
||||
* @param scenarioName Name of the scenario to modify
|
||||
* @param state The target state to set (must be one of the scenario's possibleStates)
|
||||
* @param baseUrl WireMock base URL
|
||||
* @return true if state was set successfully, false otherwise
|
||||
*/
|
||||
fun setWireMockScenarioState(
|
||||
scenarioName: String,
|
||||
state: String,
|
||||
baseUrl: String = "[REDACTED_ENV_URL]"
|
||||
): Boolean {
|
||||
Timber.i("=== WireMock Scenario Set ===")
|
||||
Timber.i("Setting scenario '$scenarioName' to state: $state")
|
||||
val client = OkHttpClient()
|
||||
val json = """{"state": "$state"}"""
|
||||
val mediaType = "application/json".toMediaType()
|
||||
|
|
@ -93,4 +99,21 @@ fun resetWireMockScenarios(baseUrl: String = "[REDACTED_ENV_URL]"): Boolean {
|
|||
Timber.e(e, "Exception during reset")
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to reset a specific WireMock scenario to its initial state
|
||||
* @param scenarioName Name of the scenario to reset
|
||||
* @param initialState The target state to reset the scenario to (must be one of the scenario's possibleStates)
|
||||
* @param baseUrl WireMock base URL
|
||||
* @return true if reset was successful, false otherwise
|
||||
*/
|
||||
fun resetWireMockScenarioState(
|
||||
scenarioName: String,
|
||||
initialState: String = "Started",
|
||||
baseUrl: String = "[REDACTED_ENV_URL]"
|
||||
): Boolean {
|
||||
Timber.i("=== WireMock Scenario Reset ===")
|
||||
Timber.i("Resetting scenario '$scenarioName' to initial state: $initialState")
|
||||
return setWireMockScenarioState(scenarioName, initialState, baseUrl)
|
||||
}
|
||||
|
|
@ -3,7 +3,7 @@ package com.tangem.tests
|
|||
import com.tangem.common.BaseTestCase
|
||||
import com.tangem.common.constants.TestConstants.TOTAL_BALANCE
|
||||
import com.tangem.common.extensions.clickWithAssertion
|
||||
import com.tangem.common.utils.resetWireMockScenarios
|
||||
import com.tangem.common.utils.resetWireMockScenarioState
|
||||
import com.tangem.common.utils.setWireMockScenarioState
|
||||
import com.tangem.scenarios.OpenMainScreenScenario
|
||||
import com.tangem.screens.*
|
||||
|
|
@ -19,18 +19,20 @@ class BuyTokenTest : BaseTestCase() {
|
|||
@DisplayName("Onramp: error in providers loading")
|
||||
@Test
|
||||
fun errorInProvidersLoadingTest() {
|
||||
val scenarioName = "payment_methods"
|
||||
val tokenTitle = "Bitcoin"
|
||||
val balance = TOTAL_BALANCE
|
||||
|
||||
setupHooks(
|
||||
additionalAfterSection = {
|
||||
resetWireMockScenarios()
|
||||
resetWireMockScenarioState(scenarioName)
|
||||
}
|
||||
).run {
|
||||
val tokenTitle = "Bitcoin"
|
||||
val balance = TOTAL_BALANCE
|
||||
|
||||
resetWireMockScenarios()
|
||||
|
||||
step("Setup WireMock scenario for 'Error' state") {
|
||||
setWireMockScenarioState("payment_methods", "Error")
|
||||
step("Reset WireMock scenario '$scenarioName'") {
|
||||
resetWireMockScenarioState(scenarioName)
|
||||
}
|
||||
step("Setup WireMock scenario '$scenarioName' for 'Error' state") {
|
||||
setWireMockScenarioState(scenarioName, "Error")
|
||||
}
|
||||
step("Open 'Main Screen'") {
|
||||
scenario(OpenMainScreenScenario(composeTestRule))
|
||||
|
|
@ -74,8 +76,11 @@ class BuyTokenTest : BaseTestCase() {
|
|||
val australianDollar = "AUD"
|
||||
val fiatAmount = "1"
|
||||
val tokenAmount = "POL 488.24938338"
|
||||
val scenarioName = "payment_methods"
|
||||
|
||||
resetWireMockScenarios()
|
||||
step("Reset WireMock scenario '$scenarioName'") {
|
||||
resetWireMockScenarioState(scenarioName)
|
||||
}
|
||||
|
||||
step("Open 'Main Screen'") {
|
||||
scenario(OpenMainScreenScenario(composeTestRule))
|
||||
|
|
@ -162,8 +167,11 @@ class BuyTokenTest : BaseTestCase() {
|
|||
val euro = "EUR"
|
||||
val fiatAmount = "1"
|
||||
val tokenAmount = "POL 488.24938338"
|
||||
val scenarioName = "payment_methods"
|
||||
|
||||
resetWireMockScenarios()
|
||||
step("Reset WireMock scenario '$scenarioName'") {
|
||||
resetWireMockScenarioState(scenarioName)
|
||||
}
|
||||
|
||||
step("Open 'Main Screen'") {
|
||||
scenario(OpenMainScreenScenario(composeTestRule))
|
||||
|
|
@ -234,8 +242,11 @@ class BuyTokenTest : BaseTestCase() {
|
|||
val balance = TOTAL_BALANCE
|
||||
val country = "Albania"
|
||||
val unavailableCountry = "Lebanon"
|
||||
val scenarioName = "payment_methods"
|
||||
|
||||
resetWireMockScenarios()
|
||||
step("Reset WireMock scenario '$scenarioName'") {
|
||||
resetWireMockScenarioState(scenarioName)
|
||||
}
|
||||
|
||||
step("Open 'Main Screen'") {
|
||||
scenario(OpenMainScreenScenario(composeTestRule))
|
||||
|
|
@ -320,8 +331,11 @@ class BuyTokenTest : BaseTestCase() {
|
|||
val tokenAmount = "POL 488.24938338"
|
||||
val bestRate = "Best rate"
|
||||
val rate = "-0.00%"
|
||||
val scenarioName = "payment_methods"
|
||||
|
||||
resetWireMockScenarios()
|
||||
step("Reset WireMock scenario '$scenarioName'") {
|
||||
resetWireMockScenarioState(scenarioName)
|
||||
}
|
||||
|
||||
step("Open 'Main Screen'") {
|
||||
scenario(OpenMainScreenScenario(composeTestRule))
|
||||
|
|
@ -422,8 +436,11 @@ class BuyTokenTest : BaseTestCase() {
|
|||
val invoiceRevolutPay = "Invoice Revolut Pay"
|
||||
val sepa = "Sepa"
|
||||
val fiatAmount = "1"
|
||||
val scenarioName = "payment_methods"
|
||||
|
||||
resetWireMockScenarios()
|
||||
step("Reset WireMock scenario '$scenarioName'") {
|
||||
resetWireMockScenarioState(scenarioName)
|
||||
}
|
||||
|
||||
step("Open 'Main Screen'") {
|
||||
scenario(OpenMainScreenScenario(composeTestRule))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue