Skip to content

Commit

Permalink
Split the test into smaller ones
Browse files Browse the repository at this point in the history
  • Loading branch information
grzesiek2010 committed Nov 8, 2024
1 parent cc5c840 commit e484e2e
Show file tree
Hide file tree
Showing 3 changed files with 151 additions and 105 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
package org.odk.collect.android.feature.formentry

import androidx.test.ext.junit.runners.AndroidJUnit4
import org.junit.Rule
import org.junit.Test
import org.junit.rules.RuleChain
import org.junit.runner.RunWith
import org.odk.collect.android.support.rules.CollectTestRule
import org.odk.collect.android.support.rules.TestRuleChain

@RunWith(AndroidJUnit4::class)
class SearchAppearancesTest {
private val rule = CollectTestRule()

@get:Rule
val ruleChain: RuleChain = TestRuleChain.chain().around(rule)

@Test
fun searchFunctionFetchesChoicesForSelectOneFromCSVFile() {
rule.startAtMainMenu()
.copyForm("different-search-appearances.xml", listOf("fruits.csv"))
.startBlankForm("different-search-appearances")
.assertTexts("Mango", "Oranges", "Strawberries")
}

@Test
fun searchAppearanceEnablesFilteringChoicesForSelectOne() {
rule.startAtMainMenu()
.copyForm("different-search-appearances.xml", listOf("fruits.csv"))
.startBlankForm("different-search-appearances")
.clickGoToArrow()
.clickOnQuestion("Static select one with search appearance")
.inputText("w")
.closeSoftKeyboard()
.assertTexts("Wolf", "Warthog")
.assertTextsDoNotExist("Racoon", "Rabbit")
}

@Test
fun autocompleteAppearanceEnablesFilteringChoicesForSelectOne() {
rule.startAtMainMenu()
.copyForm("different-search-appearances.xml", listOf("fruits.csv"))
.startBlankForm("different-search-appearances")
.clickGoToArrow()
.clickOnQuestion("Static select one with autocomplete appearance")
.inputText("r")
.closeSoftKeyboard()
.assertTexts("Warthog", "Raccoon", "Rabbit")
.assertTextDoesNotExist("Wolf")
}

@Test
fun searchFunctionCanBeCombinedWithSearchAppearanceForSelectOne() {
rule.startAtMainMenu()
.copyForm("different-search-appearances.xml", listOf("fruits.csv"))
.startBlankForm("different-search-appearances")
.clickGoToArrow()
.clickOnQuestion("Select one from a CSV using search() appearance/function and search appearance")
.inputText("r")
.closeSoftKeyboard()
.assertTexts("Oranges", "Strawberries")
.assertTextDoesNotExist("Mango")
}

@Test
fun searchFunctionCanBeCombinedWithAutocompleteAppearanceForSelectOne() {
rule.startAtMainMenu()
.copyForm("different-search-appearances.xml", listOf("fruits.csv"))
.startBlankForm("different-search-appearances")
.clickGoToArrow()
.clickOnQuestion("Select one from a CSV using search() appearance/function and autocomplete appearance")
.inputText("n")
.closeSoftKeyboard()
.assertTexts("Mango", "Oranges")
.assertTextDoesNotExist("Strawberries")
}

@Test
fun searchFunctionFetchesChoicesForSelectMultipleFromCSVFile() {
rule.startAtMainMenu()
.copyForm("different-search-appearances.xml", listOf("fruits.csv"))
.startBlankForm("different-search-appearances")
.clickGoToArrow()
.clickOnQuestion("Select multiple from a CSV using search() appearance/function")
.assertTexts("Mango", "Oranges", "Strawberries")
}

@Test
fun searchAppearanceEnablesFilteringChoicesForSelectMultiple() {
rule.startAtMainMenu()
.copyForm("different-search-appearances.xml", listOf("fruits.csv"))
.startBlankForm("different-search-appearances")
.clickGoToArrow()
.clickOnQuestion("Static select multiple with search appearance")
.inputText("w")
.closeSoftKeyboard()
.assertTexts("Wolf", "Warthog")
.assertTextsDoNotExist("Racoon", "Rabbit")
}

@Test
fun autocompleteAppearanceEnablesFilteringChoicesForSelectMultiple() {
rule.startAtMainMenu()
.copyForm("different-search-appearances.xml", listOf("fruits.csv"))
.startBlankForm("different-search-appearances")
.clickGoToArrow()
.clickOnQuestion("Static select multiple with autocomplete appearance")
.inputText("r")
.closeSoftKeyboard()
.assertTexts("Warthog", "Raccoon", "Rabbit")
.assertTextDoesNotExist("Wolf")
}

@Test
fun searchFunctionCanBeCombinedWithSearchAppearanceForSelectMultiple() {
rule.startAtMainMenu()
.copyForm("different-search-appearances.xml", listOf("fruits.csv"))
.startBlankForm("different-search-appearances")
.clickGoToArrow()
.clickOnQuestion("Select multiple from a CSV using search() appearance/function and search appearance")
.inputText("r")
.closeSoftKeyboard()
.assertTexts("Oranges", "Strawberries")
.assertTextDoesNotExist("Mango")
}

@Test
fun searchFunctionCanBeCombinedWithAutocompleteAppearanceForSelectMultiple() {
rule.startAtMainMenu()
.copyForm("different-search-appearances.xml", listOf("fruits.csv"))
.startBlankForm("different-search-appearances")
.clickGoToArrow()
.clickOnQuestion("Select multiple from a CSV using search() appearance/function and autocomplete appearance")
.inputText("n")
.closeSoftKeyboard()
.assertTexts("Mango", "Oranges")
.assertTextDoesNotExist("Strawberries")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
</h:head>
<h:body>
<select1 appearance="search('fruits')" ref="/different-search-appearances/fruit1">
<label>Select from a CSV using search() appearance/function</label>
<label>Select one from a CSV using search() appearance/function</label>
<item>
<label>name</label>
<value>name_key</value>
Expand All @@ -53,7 +53,7 @@
</label>
</input>
<select1 ref="/different-search-appearances/animal1">
<label>Static select with no appearance</label>
<label>Static select one with no appearance</label>
<item>
<label>Wolf</label>
<value>wolf</value>
Expand All @@ -72,7 +72,7 @@
</item>
</select1>
<select1 appearance="search" ref="/different-search-appearances/animal2">
<label>Static select with search appearance</label>
<label>Static select one with search appearance</label>
<item>
<label>Wolf</label>
<value>wolf</value>
Expand All @@ -91,7 +91,7 @@
</item>
</select1>
<select1 appearance="autocomplete" ref="/different-search-appearances/animal3">
<label>Static select with autocomplete appearance</label>
<label>Static select one with autocomplete appearance</label>
<item>
<label>Wolf</label>
<value>wolf</value>
Expand All @@ -110,28 +110,28 @@
</item>
</select1>
<select1 appearance="search search('fruits')" ref="/different-search-appearances/fruit2">
<label>Select from a CSV using search() appearance/function and search appearance</label>
<label>Select one from a CSV using search() appearance/function and search appearance</label>
<item>
<label>name</label>
<value>name_key</value>
</item>
</select1>
<select1 appearance="autocomplete search('fruits')" ref="/different-search-appearances/fruit3">
<label>Select from a CSV using search() appearance/function and autocomplete appearance</label>
<label>Select one from a CSV using search() appearance/function and autocomplete appearance</label>
<item>
<label>name</label>
<value>name_key</value>
</item>
</select1>
<select appearance="search('fruits')" ref="/different-search-appearances/fruit4">
<label>Select from a CSV using search() appearance/function</label>
<label>Select multiple from a CSV using search() appearance/function</label>
<item>
<label>name</label>
<value>name_key</value>
</item>
</select>
<select ref="/different-search-appearances/animal4">
<label>Static select with no appearance</label>
<label>Static select multiple with no appearance</label>
<item>
<label>Wolf</label>
<value>wolf</value>
Expand All @@ -150,7 +150,7 @@
</item>
</select>
<select appearance="search" ref="/different-search-appearances/animal5">
<label>Static select with search appearance</label>
<label>Static select multiple with search appearance</label>
<item>
<label>Wolf</label>
<value>wolf</value>
Expand All @@ -169,7 +169,7 @@
</item>
</select>
<select appearance="autocomplete" ref="/different-search-appearances/animal6">
<label>Static select with autocomplete appearance</label>
<label>Static select multiple with autocomplete appearance</label>
<item>
<label>Wolf</label>
<value>wolf</value>
Expand All @@ -188,14 +188,14 @@
</item>
</select>
<select appearance="search search('fruits')" ref="/different-search-appearances/fruit5">
<label>Select from a CSV using search() appearance/function and search appearance</label>
<label>Select multiple from a CSV using search() appearance/function and search appearance</label>
<item>
<label>name</label>
<value>name_key</value>
</item>
</select>
<select appearance="autocomplete search('fruits')" ref="/different-search-appearances/fruit6">
<label>Select from a CSV using search() appearance/function and autocomplete appearance</label>
<label>Select multiple from a CSV using search() appearance/function and autocomplete appearance</label>
<item>
<label>name</label>
<value>name_key</value>
Expand Down

0 comments on commit e484e2e

Please sign in to comment.