From ec008a9e1e25fc73baf292fe93d27ba74c58aba6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Wed, 3 Nov 2021 12:31:04 +0100 Subject: [PATCH] MOBILE-3807: Adapt tests to new account menu --- mod/login/tests/behat/app_basic_usage.feature | 34 +++++++++++++------ .../tests/behat/app_quiz_navigation.feature | 5 --- tests/behat/app_behat_runtime.js | 5 ++- tests/behat/behat_app.php | 2 +- tests/behat/navigation_deeplinks.feature | 4 +-- tests/behat/navigation_splitview.feature | 33 +++++++++++------- 6 files changed, 50 insertions(+), 33 deletions(-) diff --git a/mod/login/tests/behat/app_basic_usage.feature b/mod/login/tests/behat/app_basic_usage.feature index a8b683aae..c1b1f5747 100755 --- a/mod/login/tests/behat/app_basic_usage.feature +++ b/mod/login/tests/behat/app_basic_usage.feature @@ -17,7 +17,7 @@ Feature: Test basic usage of login in app | student2 | C1 | student | | teacher1 | C1 | editingteacher | - Scenario: Add a new site in the app & Site name in displayed when adding a new site + Scenario: Add a new account in the app & Site name in displayed when adding a new account When I enter the app And I press the back button in the app And I set the field "Your site" to "$WWWROOT" in the app @@ -30,28 +30,40 @@ Feature: Test basic usage of login in app Then I should find "Acceptance test site" in the app But I should not find "Log in" in the app - Scenario: Add a non existing site + Scenario: Add a non existing account When I enter the app And I log in as "student1" - And I press the main menu button in the app - And I press "Change site" in the app + And I press the accounts menu button in the app + And I press "Log out" in the app And I wait the app to restart - And I press "Add" in the app + And I press "Add a new account" in the app And I set the field "Your site" to "Wrong Site Address" in the app And I press enter in the app Then I should find "Cannot connect" in the app And I should find "Wrong Site Address" in the app - Scenario: Delete a site + Scenario: Add a non existing account from accounts switcher When I enter the app And I log in as "student1" - And I press the main menu button in the app - And I press "Change site" in the app + And I press the accounts menu button in the app + And I press "Switch account" in the app + And I press "Add a new account" in the app + And I wait the app to restart + And I set the field "Your site" to "Wrong Site Address" in the app + And I press enter in the app + Then I should find "Cannot connect" in the app + And I should find "Wrong Site Address" in the app + + Scenario: Delete an account + When I enter the app + And I log in as "student1" + And I press the accounts menu button in the app + And I press "Log out" in the app And I wait the app to restart Then I should find "Acceptance test site" in the app - And I press "Delete" in the app - And I press "Delete" near "Acceptance test site" in the app - And I press "Delete" near "Are you sure you want to delete the site Acceptance test site?" in the app + And I press "Edit accounts list" in the app + And I press "Remove account" near "Acceptance test site" in the app + And I press "Delete" near "Are you sure you want to remove the account on Acceptance test site?" in the app Then I should find "Connect to Moodle" in the app But I should not find "Acceptance test site" in the app diff --git a/mod/quiz/tests/behat/app_quiz_navigation.feature b/mod/quiz/tests/behat/app_quiz_navigation.feature index cf8a69dd4..acf59c360 100644 --- a/mod/quiz/tests/behat/app_quiz_navigation.feature +++ b/mod/quiz/tests/behat/app_quiz_navigation.feature @@ -63,8 +63,3 @@ Feature: Attempt a quiz in app And I press "Submit all and finish" in the app And I press "OK" near "Once you submit" in the app And I should find "Review" in the app - And I press "Home" in the app - And I should find "Are you sure" in the app - And I should find "OK" in the app - And I press "OK" in the app - And I should find "Acceptance test site" in the app diff --git a/tests/behat/app_behat_runtime.js b/tests/behat/app_behat_runtime.js index a21ac38e8..0584a4eb3 100644 --- a/tests/behat/app_behat_runtime.js +++ b/tests/behat/app_behat_runtime.js @@ -514,10 +514,13 @@ break; case 'main menu': foundButton = findElementsBasedOnText({ - text: 'more', + text: 'More', near: { text: 'Notifications' }, })[0]; break; + case 'accounts menu' : + foundButton = findElementsBasedOnText({ text: 'Account' })[0]; + break; case 'page menu': foundButton = findElementsBasedOnText({ text: 'Display options' })[0]; break; diff --git a/tests/behat/behat_app.php b/tests/behat/behat_app.php index 35415822a..ddf4a9ea3 100644 --- a/tests/behat/behat_app.php +++ b/tests/behat/behat_app.php @@ -541,7 +541,7 @@ class behat_app extends behat_base { /** * Presses standard buttons in the app. * - * @Given /^I press the (back|main menu|page menu) button in the app$/ + * @Given /^I press the (back|main menu|page menu|accounts menu) button in the app$/ * @param string $button Button type * @throws DriverException If the button push doesn't work */ diff --git a/tests/behat/navigation_deeplinks.feature b/tests/behat/navigation_deeplinks.feature index e4edc1631..68d1ef148 100644 --- a/tests/behat/navigation_deeplinks.feature +++ b/tests/behat/navigation_deeplinks.feature @@ -25,10 +25,10 @@ Feature: It navigates properly using deep links. Scenario: Receive a push notification When I enter the app And I log in as "student2" - And I press the main menu button in the app + And I press the accounts menu button in the app And I press "Log out" in the app And I wait the app to restart - And I press "Add" in the app + And I press "Add a new account" in the app And I set the field "Your site" to "$WWWROOT" in the app And I press "Connect to your site" in the app And I log in as "student1" diff --git a/tests/behat/navigation_splitview.feature b/tests/behat/navigation_splitview.feature index 78ecda825..4648b023f 100644 --- a/tests/behat/navigation_splitview.feature +++ b/tests/behat/navigation_splitview.feature @@ -24,12 +24,12 @@ Feature: It navigates properly in pages with a split-view component. Scenario: Navigate in grades tab on mobile - # Open more tab + # Open accounts menu Given I enter the app And I log in as "student1" - And I press the main menu button in the app + And I press the accounts menu button in the app - # Open grades tab + # Open grades page When I press "Grades" in the app Then the header should be "Grades" in the app And I should find "Course 1" in the app @@ -51,7 +51,7 @@ Feature: It navigates properly in pages with a split-view component. Then the header should be "Grades" in the app And I should find "Grade category C1" in the app - # Go back to grades tab + # Go back to grades page When I press the back button in the app Then the header should be "Grades" in the app And I should find "Course 1" in the app @@ -73,26 +73,27 @@ Feature: It navigates properly in pages with a split-view component. Then the header should be "Grades" in the app And I should find "Grade category C2" in the app - # Go back to grades tab + # Go back to grades page When I press the back button in the app Then the header should be "Grades" in the app And I should find "Course 1" in the app And I should find "Course 2" in the app - # Go back to more tab + # Go back to main page When I press the back button in the app - Then I should find "Grades" in the app - And I should find "App settings" in the app + Then I should find "Acceptance test site" in the app + And I should find "Account" in the app But I should not find "Back" in the app Scenario: Navigate in grades tab on tablet - # Open more tab + # Open accounts menu Given I enter the app And I change viewport size to "1200x640" And I log in as "student1" + And I press the accounts menu button in the app - # Open grades tab + # Open grades page When I press "Grades" in the app Then the header should be "Grades" in the app And I should find "Course 1" in the app @@ -106,7 +107,7 @@ Feature: It navigates properly in pages with a split-view component. And I should find "20" near "Range" in the app And I should find "40" near "Range" in the app - # Go back to grades tab + # Go back to grades page When I press the back button in the app Then the header should be "Grades" in the app And I should find "Course 1" in the app @@ -125,9 +126,15 @@ Feature: It navigates properly in pages with a split-view component. And I should find "60" near "Range" in the app And I should find "80" near "Range" in the app - # Go back to grades tab + # Go back to grades page When I press the back button in the app Then the header should be "Grades" in the app And I should find "Course 1" in the app And I should find "Course 2" in the app - But I should not find "Back" in the app + And I should find "Back" in the app + + # Go back to main page + When I press the back button in the app + Then I should find "Acceptance test site" in the app + And I should find "Account" in the app + But I should not find "Back" in the app \ No newline at end of file