diff --git a/app/src/androidTest/java/com/ivy/wallet/compose/IvyComposeTest.kt b/app/src/androidTest/java/com/ivy/wallet/compose/IvyComposeTest.kt index 0b14f6b553..9fa1a19ca3 100644 --- a/app/src/androidTest/java/com/ivy/wallet/compose/IvyComposeTest.kt +++ b/app/src/androidTest/java/com/ivy/wallet/compose/IvyComposeTest.kt @@ -1,12 +1,17 @@ package com.ivy.wallet.compose import android.content.Context +import android.content.Context.INPUT_METHOD_SERVICE import android.util.Log +import android.view.inputmethod.InputMethodManager +import androidx.activity.ComponentActivity import androidx.compose.ui.test.IdlingResource import androidx.compose.ui.test.SemanticsNodeInteraction +import androidx.compose.ui.test.junit4.AndroidComposeTestRule import androidx.compose.ui.test.junit4.ComposeTestRule import androidx.compose.ui.test.junit4.createAndroidComposeRule import androidx.compose.ui.test.performClick +import androidx.test.ext.junit.rules.ActivityScenarioRule import androidx.test.platform.app.InstrumentationRegistry import androidx.work.Configuration import androidx.work.impl.utils.SynchronousExecutor @@ -191,4 +196,14 @@ fun ComposeTestRule.clickWithRetry( ) } } +} + +fun AndroidComposeTestRule, A>.hideKeyboard() { + with(this.activity) { + if (currentFocus != null) { + val inputMethodManager: InputMethodManager = + this.getSystemService(INPUT_METHOD_SERVICE) as InputMethodManager + inputMethodManager.hideSoftInputFromWindow(currentFocus!!.windowToken, 0) + } + } } \ No newline at end of file diff --git a/app/src/androidTest/java/com/ivy/wallet/compose/helpers/AccountsTab.kt b/app/src/androidTest/java/com/ivy/wallet/compose/helpers/AccountsTab.kt index 6e7437fc4c..1d1f9f5328 100644 --- a/app/src/androidTest/java/com/ivy/wallet/compose/helpers/AccountsTab.kt +++ b/app/src/androidTest/java/com/ivy/wallet/compose/helpers/AccountsTab.kt @@ -6,6 +6,7 @@ import androidx.compose.ui.graphics.Color import androidx.compose.ui.test.* import androidx.compose.ui.test.junit4.AndroidComposeTestRule import androidx.test.ext.junit.rules.ActivityScenarioRule +import com.ivy.wallet.compose.hideKeyboard import com.ivy.wallet.compose.printTree import com.ivy.wallet.ui.theme.Ivy @@ -65,6 +66,8 @@ class AccountsTab( accountModal.apply { enterTitle(name) + composeTestRule.hideKeyboard() + ivyColorPicker.chooseColor(color = color) if (icon != null) { diff --git a/app/src/androidTest/java/com/ivy/wallet/compose/helpers/IvyColorPicker.kt b/app/src/androidTest/java/com/ivy/wallet/compose/helpers/IvyColorPicker.kt index 010f4ea57d..3da9ea5db5 100644 --- a/app/src/androidTest/java/com/ivy/wallet/compose/helpers/IvyColorPicker.kt +++ b/app/src/androidTest/java/com/ivy/wallet/compose/helpers/IvyColorPicker.kt @@ -7,15 +7,12 @@ import androidx.compose.ui.test.junit4.AndroidComposeTestRule import androidx.compose.ui.test.performClick import androidx.compose.ui.test.performScrollTo import androidx.test.ext.junit.rules.ActivityScenarioRule -import com.ivy.wallet.compose.printTree class IvyColorPicker( private val composeTestRule: AndroidComposeTestRule, A> ) { fun chooseColor(color: Color) { - composeTestRule.printTree() - composeTestRule.onNode(hasTestTag("color_item_${color.value}")) .performScrollTo() .performClick()