From 47ed39935903df59e9a3588f74d3e2172deaf05f Mon Sep 17 00:00:00 2001 From: Callum Stott Date: Wed, 10 Apr 2024 17:27:35 +0100 Subject: [PATCH] Fix flaky test --- .../feature/formentry/FieldListUpdateTest.java | 6 ++---- .../collect/android/support/pages/FormEntryPage.java | 6 ------ .../org/odk/collect/android/support/pages/Page.kt | 11 +++++++++++ 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/collect_app/src/androidTest/java/org/odk/collect/android/feature/formentry/FieldListUpdateTest.java b/collect_app/src/androidTest/java/org/odk/collect/android/feature/formentry/FieldListUpdateTest.java index df21aa249a8..7d08d56e8bf 100644 --- a/collect_app/src/androidTest/java/org/odk/collect/android/feature/formentry/FieldListUpdateTest.java +++ b/collect_app/src/androidTest/java/org/odk/collect/android/feature/formentry/FieldListUpdateTest.java @@ -57,7 +57,6 @@ import androidx.test.espresso.matcher.ViewMatchers; import org.hamcrest.Matcher; -import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; import org.junit.rules.RuleChain; @@ -393,7 +392,6 @@ public void searchMinimalInFieldList() { } @Test - @Ignore("https://github.com/getodk/collect/issues/5996") public void listOfQuestionsShouldNotBeScrolledToTheLastEditedQuestionAfterClickingOnAQuestion() { new FormEntryPage("fieldlist-updates") .clickGoToArrow() @@ -401,8 +399,8 @@ public void listOfQuestionsShouldNotBeScrolledToTheLastEditedQuestionAfterClicki .clickOnGroup("Long list of questions") .clickOnQuestion("Question1") .answerQuestion(0, "X") - .activateTextQuestion(19) - .checkIsTranslationDisplayed("Question20"); + .selectTextField("Question20", 19) + .assertText("Question20"); } @Test diff --git a/collect_app/src/androidTest/java/org/odk/collect/android/support/pages/FormEntryPage.java b/collect_app/src/androidTest/java/org/odk/collect/android/support/pages/FormEntryPage.java index 7ae75db0bac..7a18f9deeb4 100644 --- a/collect_app/src/androidTest/java/org/odk/collect/android/support/pages/FormEntryPage.java +++ b/collect_app/src/androidTest/java/org/odk/collect/android/support/pages/FormEntryPage.java @@ -302,12 +302,6 @@ public FormEntryPage answerQuestion(int index, String answer) { return this; } - public FormEntryPage activateTextQuestion(int index) { - onView(withIndex(withClassName(endsWith("EditText")), index)).perform(scrollTo()); - onView(withIndex(withClassName(endsWith("EditText")), index)).perform(click()); - return this; - } - public FormEntryPage assertQuestion(String text) { return assertQuestion(text, false); } diff --git a/collect_app/src/androidTest/java/org/odk/collect/android/support/pages/Page.kt b/collect_app/src/androidTest/java/org/odk/collect/android/support/pages/Page.kt index 7607d6c078c..3d5c0885785 100644 --- a/collect_app/src/androidTest/java/org/odk/collect/android/support/pages/Page.kt +++ b/collect_app/src/androidTest/java/org/odk/collect/android/support/pages/Page.kt @@ -557,6 +557,17 @@ abstract class Page> { return destination } + fun selectTextField(label: String, index: Int = 0): T { + closeSoftKeyboard() + + onView(withIndex(withClassName(endsWith("EditText")), index)).perform(scrollTo()) + + assertText(label) + onView(withIndex(withClassName(endsWith("EditText")), index)).perform(click()) + + return this as T + } + companion object { private fun rotateToLandscape(): ViewAction { return RotateAction(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE)