Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix flaky FieldListUpdateTest test #6077

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -393,16 +392,15 @@ public void searchMinimalInFieldList() {
}

@Test
@Ignore("https://github.com/getodk/collect/issues/5996")
public void listOfQuestionsShouldNotBeScrolledToTheLastEditedQuestionAfterClickingOnAQuestion() {
new FormEntryPage("fieldlist-updates")
.clickGoToArrow()
.clickGoUpIcon()
.clickOnGroup("Long list of questions")
.clickOnQuestion("Question1")
.answerQuestion(0, "X")
.activateTextQuestion(19)
.checkIsTranslationDisplayed("Question20");
.selectTextField("Question20", 19)
.assertText("Question20");
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,17 @@ abstract class Page<T : Page<T>> {
return destination
}

fun selectTextField(label: String, index: Int = 0): T {
closeSoftKeyboard()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you close the keyboard before clicking on another text field then this test does not cover the original scenario anymore and doesn't make sense.
The original issue was that:

  1. There was a long list of questions.
  2. The first question was a text question.
  3. The last question was a numeric question (so that the keyboard type is different and will trigger calling onLayoutChange on odkview once you switch from the first one to the last one).
  4. You add an answer to the first one (so that the text keyboard is open)
  5. Then you click on the last question (and the keyboard needs to be updated which as I said above calls onLayoutChange on odkview).

If you close the keyboard between steps 4 and 5 then onLayoutChange (what was the cause of the issue) will never be called.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah right! Well this is not a good solution then 😆. Back to the drawing board.


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)
Expand Down