From 83908a5a7280afe1a66ab613791018654faae081 Mon Sep 17 00:00:00 2001 From: Callum Stott Date: Tue, 2 Apr 2024 17:25:16 +0100 Subject: [PATCH] Create page for select minimal dialog --- .../feature/formentry/FieldListUpdateTest.java | 10 +++++----- .../feature/formmanagement/BulkFinalizationTest.kt | 2 +- .../android/regression/FillBlankFormTest.java | 6 +++--- .../android/support/pages/AddNewRepeatDialog.java | 4 ++-- .../pages/BulkFinalizationConfirmationDialogPage.kt | 4 ++-- .../android/support/pages/FormEntryPage.java | 13 ++++++------- .../android/support/pages/FormHierarchyPage.java | 2 +- .../android/support/pages/ListPreferenceDialog.java | 2 +- .../odk/collect/android/support/pages/OkDialog.java | 2 +- .../org/odk/collect/android/support/pages/Page.kt | 8 ++++++-- .../support/pages/ProjectSettingsDialogPage.kt | 7 +++---- .../support/pages/QrCodeProjectCreatorDialogPage.kt | 7 +++---- .../support/pages/SaveOrIgnoreDrawingDialog.kt | 4 ++-- .../support/pages/SavepointRecoveryDialogPage.kt | 4 ++-- .../support/pages/SelectMinimalDialogPage.kt | 12 ++++++++++++ 15 files changed, 50 insertions(+), 37 deletions(-) create mode 100644 collect_app/src/androidTest/java/org/odk/collect/android/support/pages/SelectMinimalDialogPage.kt 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 57b3d3452af..df21aa249a8 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 @@ -271,17 +271,17 @@ public void selectionChangeAtOneCascadeLevelWithMinimalAppearance_ShouldUpdateNe .clickOnQuestion("Level1") .assertTextsDoNotExist("A1", "B1", "C1", "A1A") // No choices should be shown for levels 2 and 3 when no selection is made for level 1 .openSelectMinimalDialog(0) - .clickOnText("C") // Selecting C for level 1 should only reveal options for C at level 2 + .selectItem("C") // Selecting C for level 1 should only reveal options for C at level 2 .assertTextsDoNotExist("A1", "B1") .openSelectMinimalDialog(1) - .clickOnText("C1") + .selectItem("C1") .assertTextDoesNotExist("A1A") .clickOnText("C") .clickOnText("A") // Selecting A for level 1 should reveal options for A at level 2 .openSelectMinimalDialog(1) .assertText("A1") .assertTextsDoNotExist("A1A", "B1", "C1") - .clickOnText("A1") // Selecting A1 for level 2 should reveal options for A1 at level 3 + .selectItem("A1") // Selecting A1 for level 2 should reveal options for A1 at level 3 .openSelectMinimalDialog(2) .assertText("A1A") .assertTextsDoNotExist("B1A", "B1", "C1"); @@ -387,7 +387,7 @@ public void searchMinimalInFieldList() { .clickOnQuestion("Source15") .openSelectMinimalDialog() .assertTexts("Mango", "Oranges", "Strawberries") - .clickOnText("Strawberries") + .selectItem("Strawberries") .assertText("Target15") .assertSelectMinimalDialogAnswer("Strawberries"); } @@ -417,7 +417,7 @@ public void recordingAudio_ShouldChangeRelevanceOfRelatedField() { .clickOnContentDescription(org.odk.collect.strings.R.string.stop_recording) .checkIsTranslationDisplayed("Target16") .clickOnString(org.odk.collect.strings.R.string.delete_answer_file) - .clickOnButtonInDialog(org.odk.collect.strings.R.string.delete_answer_file, new FormEntryPage("fieldlist-updates")) + .clickOnTextInDialog(org.odk.collect.strings.R.string.delete_answer_file, new FormEntryPage("fieldlist-updates")) .assertTextDoesNotExist("Target16"); } diff --git a/collect_app/src/androidTest/java/org/odk/collect/android/feature/formmanagement/BulkFinalizationTest.kt b/collect_app/src/androidTest/java/org/odk/collect/android/feature/formmanagement/BulkFinalizationTest.kt index 5d53dde6396..f0bc52421f5 100644 --- a/collect_app/src/androidTest/java/org/odk/collect/android/feature/formmanagement/BulkFinalizationTest.kt +++ b/collect_app/src/androidTest/java/org/odk/collect/android/feature/formmanagement/BulkFinalizationTest.kt @@ -103,7 +103,7 @@ class BulkFinalizationTest { .clickOptionsIcon(string.finalize_all_drafts) .clickOnString(string.finalize_all_drafts) - .clickOnButtonInDialog(string.finalize, EditSavedFormPage(false)) + .clickOnTextInDialog(string.finalize, EditSavedFormPage(false)) .checkIsSnackbarWithQuantityDisplayed(plurals.bulk_finalize_failure, 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 99dd6df6ee2..903931daa21 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 @@ -419,13 +419,13 @@ public void bigForm_ShouldBeFilledSuccessfully() { .startBlankForm("Nigeria Wards") .assertQuestion("State") .openSelectMinimalDialog() - .clickOnText("Adamawa") + .selectItem("Adamawa") .swipeToNextQuestion("LGA", true) .openSelectMinimalDialog() - .clickOnText("Ganye") + .selectItem("Ganye") .swipeToNextQuestion("Ward", true) .openSelectMinimalDialog() - .clickOnText("Jaggu") + .selectItem("Jaggu") .swipeToNextQuestion("Comments") .swipeToEndScreen() .clickFinalize(); diff --git a/collect_app/src/androidTest/java/org/odk/collect/android/support/pages/AddNewRepeatDialog.java b/collect_app/src/androidTest/java/org/odk/collect/android/support/pages/AddNewRepeatDialog.java index 49bd6f80856..5bb573d10c4 100644 --- a/collect_app/src/androidTest/java/org/odk/collect/android/support/pages/AddNewRepeatDialog.java +++ b/collect_app/src/androidTest/java/org/odk/collect/android/support/pages/AddNewRepeatDialog.java @@ -23,11 +23,11 @@ public AddNewRepeatDialog assertOnPage() { } public > D clickOnAdd(D destination) { - return clickOnButtonInDialog(org.odk.collect.strings.R.string.add_repeat, destination); + return clickOnTextInDialog(org.odk.collect.strings.R.string.add_repeat, destination); } public > D clickOnDoNotAdd(D destination) { - return clickOnButtonInDialog(org.odk.collect.strings.R.string.dont_add_repeat, destination); + return clickOnTextInDialog(org.odk.collect.strings.R.string.dont_add_repeat, destination); } } diff --git a/collect_app/src/androidTest/java/org/odk/collect/android/support/pages/BulkFinalizationConfirmationDialogPage.kt b/collect_app/src/androidTest/java/org/odk/collect/android/support/pages/BulkFinalizationConfirmationDialogPage.kt index 4585fea8df6..f72c414fd17 100644 --- a/collect_app/src/androidTest/java/org/odk/collect/android/support/pages/BulkFinalizationConfirmationDialogPage.kt +++ b/collect_app/src/androidTest/java/org/odk/collect/android/support/pages/BulkFinalizationConfirmationDialogPage.kt @@ -21,10 +21,10 @@ class BulkFinalizationConfirmationDialogPage(private val count: Int) : Page assertOnPage() { } public T clickOption(int option) { - return clickOnButtonInDialog(option, page); + return clickOnTextInDialog(option, page); } } diff --git a/collect_app/src/androidTest/java/org/odk/collect/android/support/pages/OkDialog.java b/collect_app/src/androidTest/java/org/odk/collect/android/support/pages/OkDialog.java index 16ff67360ec..2cac7db56b8 100644 --- a/collect_app/src/androidTest/java/org/odk/collect/android/support/pages/OkDialog.java +++ b/collect_app/src/androidTest/java/org/odk/collect/android/support/pages/OkDialog.java @@ -31,6 +31,6 @@ public OkDialog assertOnPage() { } public > D clickOK(D destination) { - return clickOnButtonInDialog(org.odk.collect.strings.R.string.ok, destination); + return clickOnTextInDialog(org.odk.collect.strings.R.string.ok, destination); } } 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 3aa2f22780f..d22ee04faea 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 @@ -273,9 +273,13 @@ abstract class Page> { return destination!!.assertOnPage() } - fun ?> clickOnButtonInDialog(buttonText: Int, destination: D): D { + fun ?> clickOnTextInDialog(buttonText: Int, destination: D): D { + return clickOnTextInDialog(getTranslatedString(buttonText), destination) + } + + fun ?> clickOnTextInDialog(buttonText: String, destination: D): D { waitForDialogToSettle() - onView(withText(getTranslatedString(buttonText))) + onView(withText(buttonText)) .inRoot(isDialog()) .perform(click()) return destination!!.assertOnPage() diff --git a/collect_app/src/androidTest/java/org/odk/collect/android/support/pages/ProjectSettingsDialogPage.kt b/collect_app/src/androidTest/java/org/odk/collect/android/support/pages/ProjectSettingsDialogPage.kt index aeaa8e6b38c..dc22928343c 100644 --- a/collect_app/src/androidTest/java/org/odk/collect/android/support/pages/ProjectSettingsDialogPage.kt +++ b/collect_app/src/androidTest/java/org/odk/collect/android/support/pages/ProjectSettingsDialogPage.kt @@ -10,7 +10,6 @@ import androidx.test.espresso.matcher.ViewMatchers.isDisplayed import androidx.test.espresso.matcher.ViewMatchers.withContentDescription import androidx.test.espresso.matcher.ViewMatchers.withText import org.hamcrest.Matchers.allOf -import org.odk.collect.android.R import org.odk.collect.android.support.WaitFor internal class ProjectSettingsDialogPage : Page() { @@ -21,21 +20,21 @@ internal class ProjectSettingsDialogPage : Page() { } fun clickSettings(): ProjectSettingsPage { - return clickOnButtonInDialog( + return clickOnTextInDialog( org.odk.collect.strings.R.string.settings, ProjectSettingsPage() ) } fun clickAbout(): AboutPage { - return clickOnButtonInDialog( + return clickOnTextInDialog( org.odk.collect.strings.R.string.about_preferences, AboutPage() ) } fun clickAddProject(): QrCodeProjectCreatorDialogPage { - return clickOnButtonInDialog( + return clickOnTextInDialog( org.odk.collect.strings.R.string.add_project, QrCodeProjectCreatorDialogPage() ) diff --git a/collect_app/src/androidTest/java/org/odk/collect/android/support/pages/QrCodeProjectCreatorDialogPage.kt b/collect_app/src/androidTest/java/org/odk/collect/android/support/pages/QrCodeProjectCreatorDialogPage.kt index 4a7c98ce27f..bc47884d66f 100644 --- a/collect_app/src/androidTest/java/org/odk/collect/android/support/pages/QrCodeProjectCreatorDialogPage.kt +++ b/collect_app/src/androidTest/java/org/odk/collect/android/support/pages/QrCodeProjectCreatorDialogPage.kt @@ -5,7 +5,6 @@ import androidx.test.espresso.assertion.ViewAssertions.matches import androidx.test.espresso.matcher.RootMatchers.isDialog import androidx.test.espresso.matcher.ViewMatchers.isDisplayed import androidx.test.espresso.matcher.ViewMatchers.withText -import org.odk.collect.android.R class QrCodeProjectCreatorDialogPage : Page() { override fun assertOnPage(): QrCodeProjectCreatorDialogPage { @@ -14,7 +13,7 @@ class QrCodeProjectCreatorDialogPage : Page() { } fun switchToManualMode(): ManualProjectCreatorDialogPage { - return clickOnButtonInDialog(org.odk.collect.strings.R.string.configure_manually, ManualProjectCreatorDialogPage()) + return clickOnTextInDialog(org.odk.collect.strings.R.string.configure_manually, ManualProjectCreatorDialogPage()) } fun assertDuplicateDialogShown(): QrCodeProjectCreatorDialogPage { @@ -26,10 +25,10 @@ class QrCodeProjectCreatorDialogPage : Page() { } fun switchToExistingProject(): MainMenuPage { - return clickOnButtonInDialog(org.odk.collect.strings.R.string.switch_to_existing, MainMenuPage()) + return clickOnTextInDialog(org.odk.collect.strings.R.string.switch_to_existing, MainMenuPage()) } fun addDuplicateProject(): MainMenuPage { - return clickOnButtonInDialog(org.odk.collect.strings.R.string.add_duplicate_project, MainMenuPage()) + return clickOnTextInDialog(org.odk.collect.strings.R.string.add_duplicate_project, MainMenuPage()) } } diff --git a/collect_app/src/androidTest/java/org/odk/collect/android/support/pages/SaveOrIgnoreDrawingDialog.kt b/collect_app/src/androidTest/java/org/odk/collect/android/support/pages/SaveOrIgnoreDrawingDialog.kt index 02b02e43505..b0559a07f5d 100644 --- a/collect_app/src/androidTest/java/org/odk/collect/android/support/pages/SaveOrIgnoreDrawingDialog.kt +++ b/collect_app/src/androidTest/java/org/odk/collect/android/support/pages/SaveOrIgnoreDrawingDialog.kt @@ -12,10 +12,10 @@ class SaveOrIgnoreDrawingDialog>( } fun clickSaveChanges(): D { - return clickOnButtonInDialog(org.odk.collect.strings.R.string.keep_changes, destination) + return clickOnTextInDialog(org.odk.collect.strings.R.string.keep_changes, destination) } fun clickDiscardChanges(): D { - return clickOnButtonInDialog(org.odk.collect.strings.R.string.discard_changes, destination) + return clickOnTextInDialog(org.odk.collect.strings.R.string.discard_changes, destination) } } diff --git a/collect_app/src/androidTest/java/org/odk/collect/android/support/pages/SavepointRecoveryDialogPage.kt b/collect_app/src/androidTest/java/org/odk/collect/android/support/pages/SavepointRecoveryDialogPage.kt index e26358f4bbb..76ee26e13be 100644 --- a/collect_app/src/androidTest/java/org/odk/collect/android/support/pages/SavepointRecoveryDialogPage.kt +++ b/collect_app/src/androidTest/java/org/odk/collect/android/support/pages/SavepointRecoveryDialogPage.kt @@ -15,10 +15,10 @@ class SavepointRecoveryDialogPage : Page() { } fun > clickRecover(destination: D): D { - return this.clickOnButtonInDialog(R.string.recover, destination) + return this.clickOnTextInDialog(R.string.recover, destination) } fun > clickDoNotRecover(destination: D): D { - return this.clickOnButtonInDialog(R.string.do_not_recover, destination) + return this.clickOnTextInDialog(R.string.do_not_recover, destination) } } diff --git a/collect_app/src/androidTest/java/org/odk/collect/android/support/pages/SelectMinimalDialogPage.kt b/collect_app/src/androidTest/java/org/odk/collect/android/support/pages/SelectMinimalDialogPage.kt new file mode 100644 index 00000000000..0bfc188f81b --- /dev/null +++ b/collect_app/src/androidTest/java/org/odk/collect/android/support/pages/SelectMinimalDialogPage.kt @@ -0,0 +1,12 @@ +package org.odk.collect.android.support.pages + +class SelectMinimalDialogPage(private val formName: String) : Page() { + override fun assertOnPage(): SelectMinimalDialogPage { + assertTextDoesNotExist(formName) + return this + } + + fun selectItem(item: String): FormEntryPage { + return clickOnTextInDialog(item, FormEntryPage(formName)) + } +}