From edb3d8c96fcf02b141219f64e067be99c3300d34 Mon Sep 17 00:00:00 2001
From: Katarzyna Krawczyk <33342488+kkrawczyk123@users.noreply.github.com>
Date: Tue, 21 Jan 2020 13:17:04 +0100
Subject: [PATCH] Add FillBlankForm regression tests (#3598)
* Add fill blank form tests
* Add FillBlankForm regression tests
* Add regression FillBlankForm tests
* Improve test names
---
.../src/androidTest/assets/forms/3403.xml | 198 ++++++
.../src/androidTest/assets/forms/CalcTest.xml | 153 +++++
.../assets/forms/fieldlist-updates_nocsv.xml | 608 ++++++++++++++++++
.../assets/forms/invalid-events.xml | 19 +
.../androidTest/assets/forms/invalid-form.xml | 38 ++
.../assets/forms/nested-repeats-complex.xml | 1 +
.../assets/forms/search_and_select.xml | 1 +
.../assets/forms/select_one_external.xml | 412 ++++++++++++
.../setlocation-action-instance-load.xml | 18 +
.../forms/setlocation-and-audit-location.xml | 44 ++
.../androidTest/assets/media/staff_list.csv | 2 +
.../androidTest/assets/media/staff_rights.csv | 34 +
.../android/regression/FillBlankFormTest.java | 167 ++++-
.../regression/FillBlankInvalidFormTest.java | 45 ++
.../android/support/pages/FormEntryPage.java | 22 +
.../support/pages/GeneralSettingsPage.java | 5 +
.../collect/android/support/pages/Page.java | 39 ++
17 files changed, 1805 insertions(+), 1 deletion(-)
create mode 100644 collect_app/src/androidTest/assets/forms/3403.xml
create mode 100644 collect_app/src/androidTest/assets/forms/CalcTest.xml
create mode 100644 collect_app/src/androidTest/assets/forms/fieldlist-updates_nocsv.xml
create mode 100644 collect_app/src/androidTest/assets/forms/invalid-events.xml
create mode 100644 collect_app/src/androidTest/assets/forms/invalid-form.xml
create mode 100644 collect_app/src/androidTest/assets/forms/nested-repeats-complex.xml
create mode 100644 collect_app/src/androidTest/assets/forms/search_and_select.xml
create mode 100644 collect_app/src/androidTest/assets/forms/select_one_external.xml
create mode 100644 collect_app/src/androidTest/assets/forms/setlocation-action-instance-load.xml
create mode 100644 collect_app/src/androidTest/assets/forms/setlocation-and-audit-location.xml
create mode 100644 collect_app/src/androidTest/assets/media/staff_list.csv
create mode 100644 collect_app/src/androidTest/assets/media/staff_rights.csv
create mode 100644 collect_app/src/androidTest/java/org/odk/collect/android/regression/FillBlankInvalidFormTest.java
diff --git a/collect_app/src/androidTest/assets/forms/3403.xml b/collect_app/src/androidTest/assets/forms/3403.xml
new file mode 100644
index 00000000000..34f63b8f6f6
--- /dev/null
+++ b/collect_app/src/androidTest/assets/forms/3403.xml
@@ -0,0 +1,198 @@
+
+
+
+ 3403_ODK Version 1.23.3 Tester
+
+
+
+
+ FARM ACTIVITIES TO PERFORM:
+
+Please select below the activities you are going to perform at this FARM.
+The activities that appear in the list are the ones you have rights to perform.
+
+
+
+ If selected staff does CALF MONITORING activities
+
+
+ If selected staff does breeding activities
+
+
+ activity_name
+
+
+ activity_name
+
+
+ activity_name
+
+
+
+ activity_name
+
+
+ <br>Please select the FARM/HERD MONITORING activities you are going to perform
+
+
+ <br>Please select the ANIMAL GENERAL MANAGEMENT activities you are going to perform
+
+
+ If selected staff does registration activities
+
+
+ <br>Please select the REGISTRATION activities you are going to perform
+
+
+ <br>Please select the COW/HEIFER MONITORING activities you are going to perform
+
+
+ activity_name
+
+
+ If selected staff does COW/HEIFER MONITORING activities
+
+
+ <br>Please select the ANIMAL BREEDING activities you are going to perform <br>FOR ANIMALS REGISTERED BEFORE TODAY
+
+
+
+ activity_name
+
+
+ If selected staff does animal general management activities
+
+
+ <br>Please select the CALF MONITORING activities you are going to perform
+
+
+ If selected staff does FARM/HERD MONITORING activities
+
+
+ NOT for newly registered animals
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+ _
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/collect_app/src/androidTest/assets/forms/CalcTest.xml b/collect_app/src/androidTest/assets/forms/CalcTest.xml
new file mode 100644
index 00000000000..09128cea486
--- /dev/null
+++ b/collect_app/src/androidTest/assets/forms/CalcTest.xml
@@ -0,0 +1,153 @@
+
+
+
+ CalcTest
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+
+ 1
+
+ -
+
+ 2
+
+
+
+
+ -
+
+ 1
+
+ -
+
+ 2
+
+ -
+
+ 3
+
+ -
+
+ 4
+
+ -
+
+ 5
+
+ -
+
+ 6
+
+ -
+
+ 7
+
+ -
+
+ 8
+
+ -
+
+ 9
+
+ -
+
+ 10
+
+ -
+
+ 11
+
+ -
+
+ 12
+
+ -
+
+ 13
+
+ -
+
+ 14
+
+ -
+
+ 15
+
+ -
+
+ 16
+
+ -
+
+ 17
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/collect_app/src/androidTest/assets/forms/fieldlist-updates_nocsv.xml b/collect_app/src/androidTest/assets/forms/fieldlist-updates_nocsv.xml
new file mode 100644
index 00000000000..0f311db677a
--- /dev/null
+++ b/collect_app/src/androidTest/assets/forms/fieldlist-updates_nocsv.xml
@@ -0,0 +1,608 @@
+
+
+
+ fieldlist-updates
+
+
+
+
+
+
+
+ A
+
+
+ B
+
+
+ C
+
+
+ A1
+
+
+ A2
+
+
+ A3
+
+
+ B1
+
+
+ B2
+
+
+ B3
+
+
+ C1
+
+
+ C2
+
+
+ C3
+
+
+ C4
+
+
+ A1A
+
+
+ A1B
+
+
+ B1A
+
+
+ B1B
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+ static_instance-level1-0
+ a
+
+ -
+ static_instance-level1-1
+ b
+
+ -
+ static_instance-level1-2
+ c
+
+
+
+
+
+ -
+ static_instance-level2-0
+ a
+ a1
+
+ -
+ static_instance-level2-1
+ a
+ a2
+
+ -
+ static_instance-level2-2
+ a
+ a3
+
+ -
+ static_instance-level2-3
+ b
+ b1
+
+ -
+ static_instance-level2-4
+ b
+ b2
+
+ -
+ static_instance-level2-5
+ b
+ b3
+
+ -
+ static_instance-level2-6
+ c
+ c1
+
+ -
+ static_instance-level2-7
+ c
+ c2
+
+ -
+ static_instance-level2-8
+ c
+ c3
+
+ -
+ static_instance-level2-9
+ c
+ c4
+
+
+
+
+
+ -
+ static_instance-level3-0
+ a1a
+ a1
+
+ -
+ static_instance-level3-1
+ a1b
+ a1
+
+ -
+ static_instance-level3-2
+ b1a
+ b1
+
+ -
+ static_instance-level3-3
+ b1b
+ b1
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Please don't use your calculator, !
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+
+ a
+
+ -
+
+ b
+
+ -
+
+ c
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+
+ a
+
+ -
+
+ b
+
+ -
+
+ c
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+
+ name_key
+
+
+
+
+
+
+
+
diff --git a/collect_app/src/androidTest/assets/forms/invalid-events.xml b/collect_app/src/androidTest/assets/forms/invalid-events.xml
new file mode 100644
index 00000000000..b8e71f68fff
--- /dev/null
+++ b/collect_app/src/androidTest/assets/forms/invalid-events.xml
@@ -0,0 +1,19 @@
+
+
+ Invalid events
+
+
+
+
+
+
+
+
+
+
+
+
+ cheese
+
+
+
diff --git a/collect_app/src/androidTest/assets/forms/invalid-form.xml b/collect_app/src/androidTest/assets/forms/invalid-form.xml
new file mode 100644
index 00000000000..33f5a4f86cd
--- /dev/null
+++ b/collect_app/src/androidTest/assets/forms/invalid-form.xml
@@ -0,0 +1,38 @@
+
+
+
+ invalid-form
+
+
+
+
+ label::English
+
+
+ label::English
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/collect_app/src/androidTest/assets/forms/nested-repeats-complex.xml b/collect_app/src/androidTest/assets/forms/nested-repeats-complex.xml
new file mode 100644
index 00000000000..76d82d7ae07
--- /dev/null
+++ b/collect_app/src/androidTest/assets/forms/nested-repeats-complex.xml
@@ -0,0 +1 @@
+nested-repeats-complex
\ No newline at end of file
diff --git a/collect_app/src/androidTest/assets/forms/search_and_select.xml b/collect_app/src/androidTest/assets/forms/search_and_select.xml
new file mode 100644
index 00000000000..8edfa9e02bc
--- /dev/null
+++ b/collect_app/src/androidTest/assets/forms/search_and_select.xml
@@ -0,0 +1 @@
+search_and_select- name_key
- name_key
\ No newline at end of file
diff --git a/collect_app/src/androidTest/assets/forms/select_one_external.xml b/collect_app/src/androidTest/assets/forms/select_one_external.xml
new file mode 100644
index 00000000000..24043103553
--- /dev/null
+++ b/collect_app/src/androidTest/assets/forms/select_one_external.xml
@@ -0,0 +1,412 @@
+
+
+
+ cascading select test
+
+
+
+
+ Le Texas
+
+
+ Le brownsville
+
+
+ Le King
+
+
+ Pays internal
+
+
+ Le Texas
+
+
+ La Redmond
+
+
+ La Washington
+
+
+ Le Tacoma
+
+
+ La Pierce
+
+
+ La Puyallup
+
+
+ Le Texas
+
+
+ Le King
+
+
+ Pays external
+
+
+ Le King
+
+
+ La Washington
+
+
+ La Cameron
+
+
+ Ville external
+
+
+ Le state internal
+
+
+ Le Dumont
+
+
+ La Washington
+
+
+ La Pierce 1
+
+
+ Le Seattle
+
+
+ Ville internal
+
+
+ La Finney
+
+
+ La harlingen
+
+
+ Le state external
+
+
+
+
+ Texas
+
+
+ brownsville
+
+
+ -
+
+
+ Texas
+
+
+ Redmond
+
+
+ Washington
+
+
+ Tacoma
+
+
+ Pierce
+
+
+ King
+
+
+ Puyallup
+
+
+ Texas
+
+
+ harlingen
+
+
+ -
+
+
+ King
+
+
+ Washington
+
+
+ Cameron
+
+
+ -
+
+
+ -
+
+
+ King
+
+
+ Washington
+
+
+ Pierce 1
+
+
+ Seattle
+
+
+ -
+
+
+ Finney
+
+
+ Dumont
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ county internal
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ county external
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ city external
+
+
+ state internal
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ city internal
+
+
+ -
+
+
+ -
+
+
+ state external
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+ static_instance-states-0
+ texas
+
+ -
+ static_instance-states-1
+ washington
+
+
+
+
+
+ -
+ static_instance-cities-0
+ dumont
+ king
+ texas
+
+ -
+ static_instance-cities-1
+ finney
+ king
+ texas
+
+ -
+ static_instance-cities-2
+ brownsville
+ cameron
+ texas
+
+ -
+ static_instance-cities-3
+ harlingen
+ cameron
+ texas
+
+ -
+ static_instance-cities-4
+ seattle
+ king
+ washington
+
+ -
+ static_instance-cities-5
+ redmond
+ king
+ washington
+
+ -
+ static_instance-cities-6
+ tacoma
+ pierce
+ washington
+
+ -
+ static_instance-cities-7
+ puyallup
+ pierce
+ washington
+
+
+
+
+
+ -
+ static_instance-counties-0
+ king
+ washington
+
+ -
+ static_instance-counties-1
+ king_1
+ washington
+
+ -
+ static_instance-counties-2
+ pierce
+ washington
+
+ -
+ static_instance-counties-3
+ pierce_1
+ washington
+
+ -
+ static_instance-counties-4
+ king
+ texas
+
+ -
+ static_instance-counties-5
+ cameron
+ texas
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+
+ texas
+
+ -
+
+ washington
+
+
+
+
+
+
+
+
+
+
+ -
+
+ texas
+
+ -
+
+ washington
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/collect_app/src/androidTest/assets/forms/setlocation-action-instance-load.xml b/collect_app/src/androidTest/assets/forms/setlocation-action-instance-load.xml
new file mode 100644
index 00000000000..4e07340ec82
--- /dev/null
+++ b/collect_app/src/androidTest/assets/forms/setlocation-action-instance-load.xml
@@ -0,0 +1,18 @@
+
+
+
+ setlocation-action-instance-load
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/collect_app/src/androidTest/assets/forms/setlocation-and-audit-location.xml b/collect_app/src/androidTest/assets/forms/setlocation-and-audit-location.xml
new file mode 100644
index 00000000000..e1cbe544c3b
--- /dev/null
+++ b/collect_app/src/androidTest/assets/forms/setlocation-and-audit-location.xml
@@ -0,0 +1,44 @@
+
+
+
+ setlocation-and-audit-location
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/collect_app/src/androidTest/assets/media/staff_list.csv b/collect_app/src/androidTest/assets/media/staff_list.csv
new file mode 100644
index 00000000000..2cbd01e4928
--- /dev/null
+++ b/collect_app/src/androidTest/assets/media/staff_list.csv
@@ -0,0 +1,2 @@
+staff_code,staff_userid,staff_name,staff_password,stafftype_code,stafftype_name,country_code,country_name,does_admin_activities, does_registration_activities,does_farmextra_activities,does_cattlemgmt_activities,does_breeding_activities,does_monitoring_activities,does_group_activities,does_calfmonitoring_activities,does_farmmonitoring_activities
+4,hnjamba,Harrison Njamba,111a222B,1,Data Manager,0,All Countries,1,1,1,1,1,1,1,1,1
diff --git a/collect_app/src/androidTest/assets/media/staff_rights.csv b/collect_app/src/androidTest/assets/media/staff_rights.csv
new file mode 100644
index 00000000000..f3bd4753f27
--- /dev/null
+++ b/collect_app/src/androidTest/assets/media/staff_rights.csv
@@ -0,0 +1,34 @@
+staff_code,activity_code,activity_name,activity_type,activity_order,staff_hasright
+4,1,Create Administrative Areas,1,1,1
+4,2,Register Platform Users,1,2,1
+4,3,New Farmer Registration,2,3,1
+4,22,Household Members (No Demographics),2,4,1
+4,23,Household Members (Full Demographics),2,5,1
+4,4,Registration of Animals,2,6,1
+4,10,Synchronization of Animals,5,7,1
+4,11,Insemination,5,8,1
+4,12,Pregnancy Diagnosis,5,9,1
+4,20,Milk Production,6,10,1
+4,7,Pregnancy Observation,6,11,1
+4,21,Calving Registration,6,12,1
+4,8,Calf Growth Monitoring,8,13,1
+4,26,Milk Utilization,9,14,1
+4,27,Farm Extension Services,9,15,1
+4,9,Animal Exits From Herd,9,16,1
+4,13,Feedback To Household,3,17,1
+4,5,Land Ownership and Use,3,18,1
+4,6,Water Sources and Usage,3,19,1
+4,14,Current Household Livestock Details,4,20,1
+4,19,Cooperative / Group Membership,4,21,1
+4,15,Cattle Housing and Structures,4,22,1
+4,16,Current Cattle Breeding Technologies,4,23,1
+4,17,Current Cattle Health Services,4,24,1
+4,18,Cattle Feeding Systems,4,25,1
+4,24,Group Activity / Training,7,26,1
+4,25,Dairy Cooperative/Groups Profile,7,27,1
+4,-995,NONE,5,1000,1
+4,-994,NONE,4,1000,1
+4,-993,NONE,3,1000,1
+4,-992,NONE,2,1000,1
+4,-991,NONE,1,1000,1
+4,-996,NONE,6,1000,1
diff --git a/collect_app/src/androidTest/java/org/odk/collect/android/regression/FillBlankFormTest.java b/collect_app/src/androidTest/java/org/odk/collect/android/regression/FillBlankFormTest.java
index 0d0babc3a62..389208b61ac 100644
--- a/collect_app/src/androidTest/java/org/odk/collect/android/regression/FillBlankFormTest.java
+++ b/collect_app/src/androidTest/java/org/odk/collect/android/regression/FillBlankFormTest.java
@@ -25,6 +25,7 @@
import org.odk.collect.android.support.ResetStateRule;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collections;
import java.util.List;
@@ -69,7 +70,15 @@ public class FillBlankFormTest extends BaseRegressionTest {
.around(new CopyFormRule("Birds-encrypted.xml"))
.around(new CopyFormRule("validate.xml"))
.around(new CopyFormRule("event-odk-new-repeat.xml"))
- .around(new CopyFormRule("multiple-events.xml"));
+ .around(new CopyFormRule("multiple-events.xml"))
+ .around(new CopyFormRule("CalcTest.xml"))
+ .around(new CopyFormRule("3403.xml", Arrays.asList("staff_list.csv", "staff_rights.csv")))
+ .around(new CopyFormRule("CalcTest.xml"))
+ .around(new CopyFormRule("search_and_select.xml"))
+ .around(new CopyFormRule("select_one_external.xml"))
+ .around(new CopyFormRule("fieldlist-updates_nocsv.xml"))
+ .around(new CopyFormRule("nested-repeats-complex.xml"))
+ .around(new CopyFormRule("repeat_group_form.xml"));
@Test
public void subtext_ShouldDisplayAdditionalInformation() {
@@ -611,4 +620,160 @@ public void questions_shouldHavePrefilledValue() {
.clickSaveAndExit();
}
+ @Test
+ public void when_chooseAnswer_should_beVisibleInNextQuestion() {
+ //TestCase52
+ new MainMenuPage(rule)
+ .startBlankFormWithRepeatGroup("CalcTest")
+ .clickOnAddGroup(new FormEntryPage("CalcTest", rule))
+ .clickOnText("Gillnet")
+ .swipeToNextQuestion()
+ .checkIsTextDisplayed("* 7.2 What is the size of the mesh for the Gillnet ?")
+ .swipeToPreviousQuestion()
+ .clickOnText("Seinenet")
+ .swipeToNextQuestion()
+ .checkIsTextDisplayed("* 7.2 What is the size of the mesh for the Seinenet ?");
+ }
+
+ @Test
+ public void when_scrollQuestionsList_should_questionsNotDisappear() {
+ //TestCase54
+ new MainMenuPage(rule)
+ .startBlankForm("3403_ODK Version 1.23.3 Tester")
+ .clickOnText("New Farmer Registration")
+ .scrollToAndClickText("Insemination")
+ .scrollToAndCheckIsDisplayed("New Farmer Registration");
+ }
+
+ @Test
+ public void missingFileMessage_shouldBeDisplayedIfExternalFIleIsMissing() {
+ //TestCase55
+ new MainMenuPage(rule)
+ .startBlankForm("search_and_select")
+ .checkIsTextDisplayed("File: /storage/emulated/0/odk/forms/search_and_select-media/nombre.csv is missing.")
+ .checkIsTextDisplayed("File: /storage/emulated/0/odk/forms/search_and_select-media/nombre2.csv is missing.")
+ .swipeToNextQuestion()
+ .clickSaveAndExit()
+
+ .startBlankForm("cascading select test")
+ .clickOnText("Texas")
+ .swipeToNextQuestion()
+ .checkIsTextDisplayed("File: /storage/emulated/0/odk/forms/select_one_external-media/itemsets.csv is missing.")
+ .swipeToNextQuestion()
+ .checkIsTextDisplayed("File: /storage/emulated/0/odk/forms/select_one_external-media/itemsets.csv is missing.")
+ .swipeToNextQuestion(4)
+ .clickSaveAndExit()
+
+ .startBlankForm("fieldlist-updates")
+ .clickGoToArrow()
+ .clickGoUpIcon()
+ .clickOnElementInHierarchy(14)
+ .clickOnText("Source15")
+ .checkIsTextDisplayed("File: /storage/emulated/0/odk/forms/fieldlist-updates_nocsv-media/fruits.csv is missing.")
+ .swipeToNextQuestion()
+ .clickSaveAndExit();
+ }
+
+ @Test
+ public void changedName_shouldNotDisappearAfterScreenRotation() {
+ //TestCase13
+ new MainMenuPage(rule)
+ .startBlankForm("All widgets")
+ .clickGoToArrow()
+ .clickJumpEndButton()
+ .clickOnId(R.id.save_name)
+ .inputText("submission")
+ .closeSoftKeyboard()
+ .rotateToLandscape(new FormEntryPage("All widgets", rule))
+ .checkIsTextDisplayed("submission")
+ .rotateToPortrait(new FormEntryPage("All widgets", rule))
+ .checkIsTextDisplayed("submission");
+ }
+
+ @Test
+ public void backwardButton_shouldNotBeClickableOnTheFirstFormPage() {
+ //TestCase14
+ new MainMenuPage(rule)
+ .startBlankForm("All widgets")
+ .checkAreNavigationButtonsNotDisplayed()
+ .clickOptionsIcon()
+ .clickGeneralSettings()
+ .clickOnUserInterface()
+ .clickNavigation()
+ .clickUseNavigationButtons()
+ .pressBack(new GeneralSettingsPage(rule))
+ .pressBack(new FormEntryPage("All widgets", rule))
+ .checkBackNavigationButtonIsNotsDisplayed()
+ .checkNextNavigationButtonIsDisplayed()
+ .rotateToLandscape(new FormEntryPage("All widgets", rule))
+ .checkBackNavigationButtonIsNotsDisplayed()
+ .checkNextNavigationButtonIsDisplayed()
+ .rotateToPortrait(new FormEntryPage("All widgets", rule))
+ .checkBackNavigationButtonIsNotsDisplayed()
+ .checkNextNavigationButtonIsDisplayed();
+ }
+
+ @Test
+ public void groups_shouldBeVisibleInHierarchyView() {
+ //TestCase28
+ new MainMenuPage(rule)
+ .startBlankForm("nested-repeats-complex")
+ .swipeToNextQuestion()
+ .swipeToNextQuestion()
+ .clickOnAddGroup()
+ .inputText("La")
+ .swipeToNextQuestion()
+ .swipeToNextQuestion()
+ .clickOnAddGroup()
+ .inputText("Le")
+ .swipeToNextQuestion()
+ .clickOnAddGroup()
+ .inputText("Be")
+ .swipeToNextQuestion()
+ .clickOnDoNotAddGroup()
+ .clickOnDoNotAddGroup()
+ .clickOnAddGroup()
+ .inputText("Bu")
+ .swipeToNextQuestion()
+ .clickOnDoNotAddGroup()
+ .clickGoToArrow()
+ .clickOnText("Friends")
+ .checkListSizeInHierarchy(1)
+ .clickOnElementInHierarchy(0)
+ .clickOnText("Pets")
+ .checkListSizeInHierarchy(2)
+ .clickGoUpIcon()
+ .clickGoUpIcon()
+ .clickGoUpIcon()
+ .clickOnText("Enemies")
+ .checkListSizeInHierarchy(1);
+ }
+
+ @Test
+ public void hierachyView_shouldNotChangeAfterScreenRotation() {
+ //TestCase29
+ new MainMenuPage(rule)
+ .startBlankFormWithRepeatGroup("Repeat Group")
+ .clickOnDoNotAddGroup(new FormEntryPage("Repeat Group", rule))
+ .clickGoToArrow()
+ .clickGoUpIcon()
+ .checkIfElementInHierarchyMatchesToText("Group Name", 0)
+ .rotateToLandscape(new FormEntryPage("Repeat Group", rule))
+ .checkIfElementInHierarchyMatchesToText("Group Name", 0)
+ .rotateToPortrait(new FormEntryPage("Repeat Group", rule))
+ .checkIfElementInHierarchyMatchesToText("Group Name", 0);
+ }
+
+ @Test
+ public void when_openHierarchyViewFromLastPage_should_mainGroupViewBeVisible() {
+ //TestCase30
+ new MainMenuPage(rule)
+ .startBlankFormWithRepeatGroup("Repeat Group")
+ .clickOnDoNotAddGroup(new FormEntryPage("Repeat Group", rule))
+ .clickGoToArrow()
+ .clickJumpEndButton()
+ .checkIsFormEndScreenVisible()
+ .clickGoToArrow()
+ .checkIfElementInHierarchyMatchesToText("Group Name", 0);
+ }
}
diff --git a/collect_app/src/androidTest/java/org/odk/collect/android/regression/FillBlankInvalidFormTest.java b/collect_app/src/androidTest/java/org/odk/collect/android/regression/FillBlankInvalidFormTest.java
new file mode 100644
index 00000000000..c009c707431
--- /dev/null
+++ b/collect_app/src/androidTest/java/org/odk/collect/android/regression/FillBlankInvalidFormTest.java
@@ -0,0 +1,45 @@
+package org.odk.collect.android.regression;
+
+import android.Manifest;
+
+import androidx.test.rule.GrantPermissionRule;
+import androidx.test.runner.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.CopyFormRule;
+import org.odk.collect.android.support.ResetStateRule;
+import org.odk.collect.android.support.pages.MainMenuPage;
+
+//Issue NODK-244
+@RunWith(AndroidJUnit4.class)
+public class FillBlankInvalidFormTest extends BaseRegressionTest {
+ @Rule
+ public RuleChain copyFormChain = RuleChain
+ .outerRule(GrantPermissionRule.grant(
+ Manifest.permission.READ_EXTERNAL_STORAGE,
+ Manifest.permission.WRITE_EXTERNAL_STORAGE,
+ Manifest.permission.READ_PHONE_STATE)
+ )
+ .around(new ResetStateRule())
+ .around(new CopyFormRule("invalid-events.xml"))
+ .around(new CopyFormRule("invalid-form.xml"))
+ .around(new CopyFormRule("setlocation-and-audit-location.xml"))
+ .around(new CopyFormRule("setlocation-action-instance-load.xml"));
+
+
+ @Test
+ public void brokenForms_shouldNotBeVisibleOnFOrmList() {
+ //TestCase53
+ new MainMenuPage(rule)
+ .clickFillBlankForm()
+ .checkIsSnackbarErrorVisible()
+ .checkIfTextDoesNotExist("Invalid events")
+ .checkIfTextDoesNotExist("invalid-form")
+ .checkIfTextDoesNotExist("setlocation-and-audit-location")
+ .checkIfTextDoesNotExist("setlocation-action-instance-load");
+ }
+
+}
\ No newline at end of file
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 c06663926cf..238a63df39b 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
@@ -22,6 +22,7 @@
import static androidx.test.espresso.matcher.ViewMatchers.withText;
import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation;
import static org.hamcrest.Matchers.allOf;
+import static org.hamcrest.Matchers.not;
import static org.hamcrest.core.StringEndsWith.endsWith;
import static org.odk.collect.android.test.CustomMatchers.withIndex;
@@ -200,4 +201,25 @@ public ChangesReasonPromptPage clickSaveWithChangesReasonPrompt() {
onView(withId(R.id.menu_save)).perform(click());
return new ChangesReasonPromptPage(formName, rule).assertOnPage();
}
+
+ public FormEntryPage checkBackNavigationButtonIsNotsDisplayed() {
+ onView(withId(R.id.form_back_button)).check(matches(not(isDisplayed())));
+ return this;
+ }
+
+ public FormEntryPage checkNextNavigationButtonIsDisplayed() {
+ onView(withId(R.id.form_forward_button)).check(matches(isDisplayed()));
+ return this;
+ }
+
+ public FormEntryPage checkAreNavigationButtonsNotDisplayed() {
+ onView(withId(R.id.form_forward_button)).check(matches(not(isDisplayed())));
+ onView(withId(R.id.form_back_button)).check(matches(not(isDisplayed())));
+ return this;
+ }
+
+ public FormEntryPage checkIsFormEndScreenVisible() {
+ onView(withText(R.string.quit_entry)).check(matches(isDisplayed()));
+ return this;
+ }
}
diff --git a/collect_app/src/androidTest/java/org/odk/collect/android/support/pages/GeneralSettingsPage.java b/collect_app/src/androidTest/java/org/odk/collect/android/support/pages/GeneralSettingsPage.java
index e2e73d4985f..b3fbb619b2d 100644
--- a/collect_app/src/androidTest/java/org/odk/collect/android/support/pages/GeneralSettingsPage.java
+++ b/collect_app/src/androidTest/java/org/odk/collect/android/support/pages/GeneralSettingsPage.java
@@ -137,4 +137,9 @@ public GeneralSettingsPage checkIfServerOptionIsNotDisplayed() {
return this;
}
+ public GeneralSettingsPage clickUseNavigationButtons() {
+ clickOnString(R.string.buttons_navigation);
+ return this;
+ }
+
}
diff --git a/collect_app/src/androidTest/java/org/odk/collect/android/support/pages/Page.java b/collect_app/src/androidTest/java/org/odk/collect/android/support/pages/Page.java
index bd78ffa3bd9..9d41e2304d4 100644
--- a/collect_app/src/androidTest/java/org/odk/collect/android/support/pages/Page.java
+++ b/collect_app/src/androidTest/java/org/odk/collect/android/support/pages/Page.java
@@ -6,13 +6,16 @@
import androidx.test.espresso.Espresso;
import androidx.test.espresso.NoMatchingViewException;
import androidx.test.espresso.ViewAction;
+
import androidx.test.espresso.core.internal.deps.guava.collect.Iterables;
import androidx.test.espresso.matcher.ViewMatchers;
import androidx.test.rule.ActivityTestRule;
import androidx.test.runner.lifecycle.ActivityLifecycleMonitorRegistry;
import androidx.test.runner.lifecycle.Stage;
+import org.odk.collect.android.R;
import org.odk.collect.android.support.actions.RotateAction;
+import org.odk.collect.android.support.matchers.RecyclerViewMatcher;
import timber.log.Timber;
@@ -23,6 +26,7 @@
import static androidx.test.espresso.action.ViewActions.typeText;
import static androidx.test.espresso.assertion.ViewAssertions.doesNotExist;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
+import static androidx.test.espresso.contrib.RecyclerViewActions.scrollToPosition;
import static androidx.test.espresso.matcher.RootMatchers.withDecorView;
import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed;
import static androidx.test.espresso.matcher.ViewMatchers.isEnabled;
@@ -34,8 +38,11 @@
import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not;
+import static org.hamcrest.Matchers.allOf;
import static org.hamcrest.core.StringContains.containsString;
import static org.hamcrest.core.StringEndsWith.endsWith;
+import static org.odk.collect.android.support.actions.NestedScrollToAction.nestedScrollTo;
+import static org.odk.collect.android.support.matchers.RecyclerViewMatcher.withRecyclerView;
import static org.odk.collect.android.test.CustomMatchers.withIndex;
/**
@@ -236,6 +243,38 @@ private static Activity getCurrentActivity() {
return activity[0];
}
+
+ public T checkIsSnackbarErrorVisible() {
+ onView(allOf(withId(R.id.snackbar_text))).check(matches(isDisplayed()));
+ return (T) this;
+ }
+
+ public T scrollToAndClickText(String text) {
+ onView(withText(text)).perform(nestedScrollTo(), click());
+ return (T) this;
+ }
+
+ public T scrollToAndCheckIsDisplayed(String text) {
+ onView(withText(text)).perform(nestedScrollTo());
+ onView(withText(text)).check(matches(isDisplayed()));
+ return (T) this;
+ }
+
+ public T clickOnElementInHierarchy(int index) {
+ onView(withId(R.id.list)).perform(scrollToPosition(index));
+ onView(withRecyclerView(R.id.list).atPositionOnView(index, R.id.primary_text)).perform(click());
+ return (T) this;
+ }
+
+ public T checkListSizeInHierarchy(int index) {
+ onView(withId(R.id.list)).check(matches(RecyclerViewMatcher.withListSize(index)));
+ return (T) this;
+ }
+
+ public T checkIfElementInHierarchyMatchesToText(String text, int index) {
+ onView(withRecyclerView(R.id.list).atPositionOnView(index, R.id.primary_text)).check(matches(withText(text)));
+ return (T) this;
+ }
}