From a94da4d80443d336dea7828530b97b14b571ab9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Thu, 12 May 2022 15:27:52 +0200 Subject: [PATCH] MOBILE-4061 behat: Generate custom URL to quickly bypass steps on app --- .../tests/behat/behat_app.php | 146 +++++++++++++++--- .../messages/tests/behat/basic_usage.feature | 108 ++++++------- .../messages/tests/behat/navigation.feature | 5 +- .../messages/tests/behat/settings.feature | 5 +- .../tests/behat/basic_usage-310.feature | 8 +- .../assign/tests/behat/basic_usage.feature | 30 ++-- .../mod/assign/tests/behat/navigation.feature | 4 +- .../mod/chat/tests/behat/basic_usage.feature | 14 +- .../mod/chat/tests/behat/navigation.feature | 4 +- .../tests/behat/basic_usage-311.feature | 8 +- .../choice/tests/behat/basic_usage.feature | 28 ++-- .../mod/forum/tests/behat/basic_usage.feature | 58 +++---- .../mod/forum/tests/behat/navigation.feature | 4 +- .../glossary/tests/behat/navigation.feature | 4 +- .../mod/quiz/tests/behat/basic_usage.feature | 16 +- .../quiz/tests/behat/quiz_navigation.feature | 6 +- .../tests/behat/basic_usage-311.feature | 14 +- .../course/tests/behat/basic_usage.feature | 22 ++- .../tests/behat/course_completion-310.feature | 4 +- .../tests/behat/course_completion.feature | 4 +- .../course/tests/behat/courselist-311.feature | 15 +- .../course/tests/behat/courselist.feature | 15 +- .../tests/behat/basic_usage-310.feature | 14 +- .../tests/behat/basic_usage-311.feature | 24 ++- .../courses/tests/behat/basic_usage.feature | 29 ++-- .../login/tests/behat/basic_usage.feature | 5 +- .../mainmenu/tests/behat/mainmenu-311.feature | 10 +- .../mainmenu/tests/behat/mainmenu.feature | 15 +- .../tests/behat/settings_navigation.feature | 6 +- .../siteplugins/tests/behat/plugins.feature | 5 +- .../usertours/tests/behat/usertours.feature | 5 +- src/core/services/sites.ts | 4 +- src/tests/behat/navigation_activities.feature | 4 +- src/tests/behat/navigation_deeplinks.feature | 10 +- .../behat/navigation_externallinks.feature | 4 +- src/tests/behat/navigation_gestures.feature | 8 +- src/tests/behat/navigation_splitview.feature | 6 +- src/tests/behat/performance.feature | 8 +- 38 files changed, 356 insertions(+), 323 deletions(-) diff --git a/local-moodleappbehat/tests/behat/behat_app.php b/local-moodleappbehat/tests/behat/behat_app.php index 098e1a06f..2ff4b7890 100644 --- a/local-moodleappbehat/tests/behat/behat_app.php +++ b/local-moodleappbehat/tests/behat/behat_app.php @@ -125,6 +125,20 @@ class behat_app extends behat_base { $this->enter_site(); } + /** + * Opens the Moodle app in the browser logged in as a user. + * + * @Given /^I enter(ed)? the app as "(.+)"$/ + * @throws DriverException Issue with configuration or feature file + * @throws dml_exception Problem with Moodle setup + * @throws ExpectationException Problem with resizing window + */ + public function i_entered_the_app_as(bool $unused, string $username) { + $this->i_launch_the_app(); + + $this->open_moodleapp_custom_login_url($username); + } + /** * Opens the Moodle app in the browser. * @@ -587,33 +601,27 @@ class behat_app extends behat_base { /** * User enters a course in the app. * - * @Given /^I enter the course "(.+?)"(?: as "(.+)")? in the app$/ + * @Given /^I enter(ed)? the course "(.+?)"(?: as "(.+)")? in the app$/ * @param string $coursename Course name * @throws DriverException If the button push doesn't work */ - public function i_enter_the_course_in_the_app(string $coursename, ?string $username = null) { - if (!is_null($username)) { - $this->i_enter_the_app(); - $this->login($username); + public function i_enter_the_course_in_the_app(bool $unused, string $coursename, ?string $username = null) { + global $DB; + + $courseid = $DB->get_field('course', 'id', [ 'fullname' => $coursename]); + if (!$courseid) { + throw new DriverException("Course '$coursename' not found"); } - $mycoursesfound = $this->evaluate_script("return window.behat.find({ text: 'My courses', selector: 'ion-tab-button'});"); + if ($username) { + $this->i_launch_the_app(); - if ($mycoursesfound !== 'OK') { - // My courses not present enter from Dashboard. - $this->i_press_in_the_app('"Home" "ion-tab-button"'); - $this->i_press_in_the_app('"Dashboard"'); - $this->i_press_in_the_app('"'.$coursename.'" near "Course overview"'); - - $this->wait_for_pending_js(); - - return; + $this->open_moodleapp_custom_login_url($username, "/course/view.php?id=$courseid", '//page-core-course-index'); + } else { + $this->open_moodleapp_custom_url("/course/view.php?id=$courseid", '//page-core-course-index'); } - $this->i_press_in_the_app('"My courses" "ion-tab-button"'); - $this->i_press_in_the_app('"'.$coursename.'"'); - $this->wait_for_pending_js(); } /** @@ -701,25 +709,21 @@ class behat_app extends behat_base { switch ($title) { case 'discussion': $discussion = $DB->get_record('forum_discussions', ['name' => $data->discussion]); - $pageurl = "{$CFG->behat_wwwroot}/mod/forum/discuss.php?d={$discussion->id}"; + $pageurl = "/mod/forum/discuss.php?d={$discussion->id}"; break; case 'forum': $forumdata = $DB->get_record('forum', ['name' => $data->forum]); $cm = get_coursemodule_from_instance('forum', $forumdata->id); - $pageurl = "{$CFG->behat_wwwroot}/mod/forum/view.php?id={$cm->id}"; + $pageurl = "/mod/forum/view.php?id={$cm->id}"; break; default: throw new DriverException('Invalid custom link title - ' . $title); } - $urlscheme = $this->get_mobile_url_scheme(); - $url = "$urlscheme://link=" . urlencode($pageurl); - - $this->evaluate_async_script("return window.behat.handleCustomURL('$url')"); - $this->wait_for_pending_js(); + $this->open_moodleapp_custom_url($pageurl); } /** @@ -1165,6 +1169,98 @@ class behat_app extends behat_base { return $result; } + /** + * Opens a custom URL for automatic login and redirect from the mobile app (and waits to finish.) + * + * @param string $username Of the user that needs to be logged in. + * @param string $path To redirect the user. + * @param string $successXPath If a path is declared, the XPath of the element to lookat after redirect. + */ + private function open_moodleapp_custom_login_url($username, $path = '', string $successXPath = '') { + global $CFG, $DB; + + require_once($CFG->libdir.'/externallib.php'); + require_once($CFG->libdir.'/moodlelib.php'); + + // Ensure the user exists. + $userid = $DB->get_field('user', 'id', [ 'username' => $username ]); + if (!$userid) { + throw new DriverException("User '$username' not found"); + } + + // Get or create the user token. + $service = $DB->get_record('external_services', ['shortname' => 'moodle_mobile_app']); + + $token_params = [ + 'userid' => $userid, + 'externalserviceid' => $service->id, + ]; + $usertoken = $DB->get_record('external_tokens', $token_params); + if (!$usertoken) { + $context = context_system::instance(); + $token = external_generate_token(EXTERNAL_TOKEN_PERMANENT, $service, $userid, $context); + $token_params['token'] = $token; + $privatetoken = $DB->get_field('external_tokens', 'privatetoken', $token_params); + } else { + $token = $usertoken->token; + $privatetoken = $usertoken->privatetoken; + } + + // Generate custom URL. + $parsed_url = parse_url($CFG->behat_wwwroot); + $domain = $parsed_url['host']; + $url = $this->get_mobile_url_scheme() . "://$username@$domain?token=$token&privatetoken=$privatetoken"; + + if (!empty($path)) { + $url .= '&redirect='.urlencode($CFG->behat_wwwroot.$path); + } else { + $successXPath = '//page-core-mainmenu'; + } + + $this->handle_url_and_wait_page_to_load($url, $successXPath); + } + + /** + * Opens a custom URL on the mobile app (and waits to finish.) + * + * @param string $path To navigate. + * @param string $successXPath The XPath of the element to lookat after navigation. + */ + private function open_moodleapp_custom_url(string $path, string $successXPath = '') { + global $CFG; + + $urlscheme = $this->get_mobile_url_scheme(); + $url = "$urlscheme://link=" . urlencode($CFG->behat_wwwroot.$path); + + $this->handle_url_and_wait_page_to_load($url); + } + + /** + * Handles the custom URL on the mobile app (and waits to finish.) + * + * @param string $customurl To navigate. + * @param string $successXPath The XPath of the element to lookat after navigation. + */ + private function handle_url_and_wait_page_to_load(string $customurl, string $successXPath = '') { + // Instead of using evaluate_async_script, we wait for the path to load. + $this->evaluate_script("return window.behat.handleCustomURL('$customurl')"); + + if (!empty($successXPath)) { + // Wait until the page appears. + $this->spin( + function($context, $args) use ($successXPath) { + $found = $context->getSession()->getPage()->find('xpath', $successXPath); + if ($found) { + return true; + } + throw new DriverException('Moodle App custom URL page not loaded'); + }, false, 30); + } + + // Wait for JS to finish as well. + $this->wait_for_pending_js(); + } + /** * Returns the current mobile url scheme of the site. */ diff --git a/src/addons/messages/tests/behat/basic_usage.feature b/src/addons/messages/tests/behat/basic_usage.feature index 638877888..9ef3ed120 100755 --- a/src/addons/messages/tests/behat/basic_usage.feature +++ b/src/addons/messages/tests/behat/basic_usage.feature @@ -20,9 +20,8 @@ Feature: Test basic usage of messages in app | student2 | C1 | student | Scenario: View recent conversations and contacts - When I enter the app - And I log in as "teacher1" - And I press "Messages" in the app + Given I entered the app as "teacher1" + When I press "Messages" in the app And I press "Contacts" in the app Then I should find "No contacts" in the app @@ -37,9 +36,8 @@ Feature: Test basic usage of messages in app And I press "Add" near "Are you sure you want to add Student1 student1 to your contacts?" in the app Then I should find "Contact request sent" in the app - When I enter the app - And I log in as "student1" - And I press "Messages" in the app + Given I entered the app as "student1" + When I press "Messages" in the app And I press "Contacts" in the app And I press "Requests" in the app And I press "Teacher teacher" in the app @@ -57,9 +55,8 @@ Feature: Test basic usage of messages in app And I should find "heeey student" in the app Scenario: Search users - When I enter the app - And I log in as "student1" - And I press "Messages" in the app + Given I entered the app as "student1" + When I press "Messages" in the app And I press "Search people and messages" in the app And I set the field "Search" to "student2" in the app And I press "Search" "button" in the app @@ -70,9 +67,8 @@ Feature: Test basic usage of messages in app Then I should find "Teacher teacher" in the app Scenario: Send/receive messages in existing conversations - When I enter the app - And I log in as "teacher1" - And I press "Messages" in the app + Given I entered the app as "teacher1" + When I press "Messages" in the app And I press "Contacts" in the app And I press "Search people and messages" in the app And I set the field "Search" to "student1" in the app @@ -82,9 +78,8 @@ Feature: Test basic usage of messages in app And I press "Send" in the app Then I should find "heeey student" in the app - When I enter the app - And I log in as "student1" - And I press "Messages" in the app + Given I entered the app as "student1" + When I press "Messages" in the app And I press "Contacts" in the app And I press "Search people and messages" in the app And I set the field "Search" to "teacher" in the app @@ -96,9 +91,8 @@ Feature: Test basic usage of messages in app And I press "Send" in the app Then I should find "hi" in the app - When I enter the app - And I log in as "teacher1" - And I press "Messages" in the app + Given I entered the app as "teacher1" + When I press "Messages" in the app And I press "Search people and messages" in the app And I set the field "Search" to "student1" in the app And I press "Search" "button" in the app @@ -114,9 +108,8 @@ Feature: Test basic usage of messages in app # TODO Fix this test in all Moodle versions Scenario: User profile: send message, add/remove contact - When I enter the app - And I log in as "teacher1" - And I press "Messages" in the app + Given I entered the app as "teacher1" + When I press "Messages" in the app And I press "Contacts" in the app And I press "Search people and messages" in the app And I set the field "Search" to "student" in the app @@ -131,9 +124,8 @@ Feature: Test basic usage of messages in app And I press "Add" in the app Then I should find "Contact request sent" in the app - When I enter the app - And I log in as "student1" - And I press "Messages" in the app + Given I entered the app as "student1" + When I press "Messages" in the app And I press "Contacts" in the app And I press "Requests" in the app And I press "Teacher teacher" in the app @@ -165,9 +157,8 @@ Feature: Test basic usage of messages in app And I should not find "hi" in the app Scenario: Send message offline - When I enter the app - And I log in as "teacher1" - And I press "Messages" in the app + Given I entered the app as "teacher1" + When I press "Messages" in the app And I press "Contacts" in the app And I press "Search people and messages" in the app And I set the field "Search" to "student1" in the app @@ -188,17 +179,15 @@ Feature: Test basic usage of messages in app Then I should find "heeey student" in the app And I should find "byee" in the app - When I enter the app - And I log in as "student1" - And I press "Messages" in the app + Given I entered the app as "student1" + When I press "Messages" in the app And I press "Teacher teacher" in the app Then I should find "heeey student" in the app And I should find "byee" in the app Scenario: Auto-sync messages - When I enter the app - And I log in as "teacher1" - And I press "Messages" in the app + Given I entered the app as "teacher1" + When I press "Messages" in the app And I press "Contacts" in the app And I press "Search people and messages" in the app And I set the field "Search" to "student1" in the app @@ -213,17 +202,15 @@ Feature: Test basic usage of messages in app When I switch offline mode to "false" And I run cron tasks in the app - And I enter the app - And I log in as "student1" + And I enter the app as "student1" And I press "Messages" in the app And I press "Teacher teacher" in the app Then I should find "heeey student" in the app And I should find "byee" in the app Scenario: Search for messages - When I enter the app - And I log in as "teacher1" - And I press "Messages" in the app + Given I entered the app as "teacher1" + When I press "Messages" in the app And I press "Search people and messages" in the app And I set the field "Search" to "student1" in the app And I press "Search" "button" in the app @@ -236,9 +223,8 @@ Feature: Test basic usage of messages in app And I press "Send" in the app Then I should find "search this message" in the app - When I enter the app - And I log in as "student1" - And I press "Messages" in the app + Given I entered the app as "student1" + When I press "Messages" in the app And I press "Search people and messages" in the app And I set the field "Search" to "search this message" in the app And I press "Search" "button" in the app @@ -250,9 +236,8 @@ Feature: Test basic usage of messages in app And I should find "search this message" in the app Scenario: Star/Unstar - When I enter the app - And I log in as "teacher1" - And I press "Messages" in the app + Given I entered the app as "teacher1" + When I press "Messages" in the app And I press "Search people and messages" in the app And I set the field "Search" to "student1" in the app And I press "Search" "button" in the app @@ -261,9 +246,8 @@ Feature: Test basic usage of messages in app And I press "Send" in the app Then I should find "star message" in the app - When I enter the app - And I log in as "student2" - And I press "Messages" in the app + Given I entered the app as "student2" + When I press "Messages" in the app And I press "Search people and messages" in the app And I set the field "Search" to "student1" in the app And I press "Search" "button" in the app @@ -272,9 +256,8 @@ Feature: Test basic usage of messages in app And I press "Send" in the app Then I should find "test message student2" in the app - When I enter the app - And I log in as "student1" - And I press "Messages" in the app + Given I entered the app as "student1" + When I press "Messages" in the app Then I should find "Private (2)" in the app And I should find "Starred (1)" in the app @@ -290,8 +273,8 @@ Feature: Test basic usage of messages in app And I should find "Student1 student1" in the app Scenario: User blocking feature - When I enter the course "Course 1" as "student2" in the app - And I press "Participants" in the app + Given I entered the course "Course 1" as "student2" in the app + When I press "Participants" in the app And I press "Student1 student1" in the app And I press "Message" in the app And I press "Display options" in the app @@ -299,14 +282,14 @@ Feature: Test basic usage of messages in app And I press "Block user" near "Are you sure you want to block Student1 student1?" in the app Then I should find "You have blocked this user" in the app - When I enter the course "Course 1" as "student1" in the app - And I press "Participants" in the app + Given I entered the course "Course 1" as "student1" in the app + When I press "Participants" in the app And I press "Student2 student2" in the app And I press "Message" in the app Then I should find "You are unable to message this user" in the app - When I enter the course "Course 1" as "student2" in the app - And I press "Participants" in the app + Given I entered the course "Course 1" as "student2" in the app + When I press "Participants" in the app And I press "Student1 student1" in the app And I press "Message" in the app And I press "Display options" in the app @@ -317,8 +300,8 @@ Feature: Test basic usage of messages in app And I press "Unblock user" near "Are you sure you want to unblock Student1 student1?" in the app Then I should not find "You have blocked this user" in the app - When I enter the course "Course 1" as "student1" in the app - And I press "Participants" in the app + Given I entered the course "Course 1" as "student1" in the app + When I press "Participants" in the app And I press "Student2 student2" in the app And I press "Message" in the app And I set the field "New message" to "test message" in the app @@ -327,8 +310,8 @@ Feature: Test basic usage of messages in app But I should not find "You are unable to message this user" in the app Scenario: Mute Unmute conversations - When I enter the course "Course 1" as "student1" in the app - And I press "Participants" in the app + Given I entered the course "Course 1" as "student1" in the app + When I press "Participants" in the app And I press "Student2 student2" in the app And I press "Message" in the app And I set the field "New message" to "test message" in the app @@ -354,9 +337,8 @@ Feature: Test basic usage of messages in app And I should find "Muted conversation" in the app Scenario: Self conversations - When I enter the app - And I log in as "student1" - And I press "Messages" in the app + Given I entered the app as "student1" + When I press "Messages" in the app Then I should find "Starred (1)" in the app When I press "Student1 student1" in the app diff --git a/src/addons/messages/tests/behat/navigation.feature b/src/addons/messages/tests/behat/navigation.feature index 5be92c2ca..2fd1e3685 100644 --- a/src/addons/messages/tests/behat/navigation.feature +++ b/src/addons/messages/tests/behat/navigation.feature @@ -15,9 +15,8 @@ Feature: Test messages navigation in the app | student | C1 | student | Scenario: Avoid recursive links to profile - When I enter the app - And I log in as "teacher" - And I press "Messages" in the app + Given I entered the app as "teacher" + When I press "Messages" in the app And I press "Contacts" in the app And I press "Search people and messages" in the app And I set the field "Search" to "student" in the app diff --git a/src/addons/messages/tests/behat/settings.feature b/src/addons/messages/tests/behat/settings.feature index 227ddfc1a..ca2499b48 100644 --- a/src/addons/messages/tests/behat/settings.feature +++ b/src/addons/messages/tests/behat/settings.feature @@ -7,9 +7,8 @@ Feature: Test messages settings | student1 | Scenario: Modify settings - When I enter the app - And I log in as "student1" - And I press "Messages" in the app + Given I entered the app as "student1" + When I press "Messages" in the app And I press "Message preferences" in the app And I select "My contacts only" in the app Then "My contacts only" should be selected in the app diff --git a/src/addons/mod/assign/tests/behat/basic_usage-310.feature b/src/addons/mod/assign/tests/behat/basic_usage-310.feature index 2141af2b9..cdd88aeef 100755 --- a/src/addons/mod/assign/tests/behat/basic_usage-310.feature +++ b/src/addons/mod/assign/tests/behat/basic_usage-310.feature @@ -21,8 +21,8 @@ Feature: Test basic usage of assignment activity in app Scenario: View assign description, due date & View list of student submissions (as teacher) & View own submission or student submission # Create, edit and submit as a student - When I enter the course "Course 1" as "student1" in the app - And I press "assignment1" in the app + Given I entered the course "Course 1" as "student1" in the app + When I press "assignment1" in the app Then the header should be "assignment1" in the app And I should find "Test assignment description1" in the app And I should find "Due date" in the app @@ -47,8 +47,8 @@ Feature: Test basic usage of assignment activity in app And I should find "Submission test edited" in the app # View as a teacher - When I enter the course "Course 1" as "teacher1" in the app - And I press "assignment1" in the app + Given I entered the course "Course 1" as "teacher1" in the app + When I press "assignment1" in the app Then the header should be "assignment1" in the app When I press "Submitted" in the app diff --git a/src/addons/mod/assign/tests/behat/basic_usage.feature b/src/addons/mod/assign/tests/behat/basic_usage.feature index f8521f987..9e26048be 100755 --- a/src/addons/mod/assign/tests/behat/basic_usage.feature +++ b/src/addons/mod/assign/tests/behat/basic_usage.feature @@ -22,8 +22,8 @@ Feature: Test basic usage of assignment activity in app @lms_from3.11 Scenario: View assign description, due date & View list of student submissions (as teacher) & View own submission or student submission # Create, edit and submit as a student - When I enter the course "Course 1" as "student1" in the app - And I press "assignment1" in the app + Given I entered the course "Course 1" as "student1" in the app + When I press "assignment1" in the app Then the header should be "assignment1" in the app And I should find "Test assignment description1" in the app And I should find "Due:" in the app @@ -48,8 +48,8 @@ Feature: Test basic usage of assignment activity in app And I should find "Submission test edited" in the app # View as a teacher - When I enter the course "Course 1" as "teacher1" in the app - And I press "assignment1" in the app + Given I entered the course "Course 1" as "teacher1" in the app + When I press "assignment1" in the app Then the header should be "assignment1" in the app When I press "Submitted" in the app @@ -62,7 +62,7 @@ Feature: Test basic usage of assignment activity in app Scenario: Edit/Add submission (online text) & Add new attempt from previous submission & Submit for grading # Submit first attempt as a student - Given I enter the course "Course 1" as "student1" in the app + Given I entered the course "Course 1" as "student1" in the app And I press "assignment1" in the app And I press "Add submission" in the app And I set the field "Online text submissions" to "Submission test 1st attempt" in the app @@ -71,8 +71,8 @@ Feature: Test basic usage of assignment activity in app And I press "OK" in the app # Allow more attempts as a teacher - When I enter the course "Course 1" as "teacher1" in the app - And I press "assignment1" in the app + Given I entered the course "Course 1" as "teacher1" in the app + When I press "assignment1" in the app And I press "Participants" in the app And I press "Student student" near "assignment1" in the app And I press "Grade" in the app @@ -82,8 +82,8 @@ Feature: Test basic usage of assignment activity in app And I should find "Not graded" in the app # Submit second attempt as a student - When I enter the course "Course 1" as "student1" in the app - And I press "assignment1" in the app + Given I entered the course "Course 1" as "student1" in the app + When I press "assignment1" in the app Then I should find "Reopened" in the app And I should find "2 out of Unlimited" in the app And I should find "Add a new attempt based on previous submission" in the app @@ -100,16 +100,16 @@ Feature: Test basic usage of assignment activity in app And I press "OK" in the app # View second attempt as a teacher - When I enter the course "Course 1" as "teacher1" in the app - And I press "assignment1" in the app + Given I entered the course "Course 1" as "teacher1" in the app + When I press "assignment1" in the app And I press "Participants" in the app And I press "Student student" near "assignment1" in the app Then I should find "Online text submissions" in the app And I should find "Submission test 2nd attempt" in the app Scenario: Add submission offline (online text) & Submit for grading offline & Sync submissions - When I enter the course "Course 1" as "student1" in the app - And I press "assignment1" in the app + Given I entered the course "Course 1" as "student1" in the app + When I press "assignment1" in the app And I press "Add submission" in the app And I switch offline mode to "true" And I set the field "Online text submissions" to "Submission test" in the app @@ -127,8 +127,8 @@ Feature: Test basic usage of assignment activity in app But I should not find "This Assignment has offline data to be synchronised." in the app Scenario: Edit an offline submission before synchronising it - When I enter the course "Course 1" as "student1" in the app - And I press "assignment1" in the app + Given I entered the course "Course 1" as "student1" in the app + When I press "assignment1" in the app And I press "Add submission" in the app And I switch offline mode to "true" And I set the field "Online text submissions" to "Submission test original offline" in the app diff --git a/src/addons/mod/assign/tests/behat/navigation.feature b/src/addons/mod/assign/tests/behat/navigation.feature index 95744dc49..12ee6c291 100644 --- a/src/addons/mod/assign/tests/behat/navigation.feature +++ b/src/addons/mod/assign/tests/behat/navigation.feature @@ -36,7 +36,7 @@ Feature: Test assignments navigation | assignment | student3 | Ipsum | Scenario: Mobile navigation - Given I enter the course "Course 1" as "teacher1" in the app + Given I entered the course "Course 1" as "teacher1" in the app # Initial status When I press "Assignment" in the app @@ -150,7 +150,7 @@ Feature: Test assignments navigation And I should not find "Second Student" in the app Scenario: Tablet navigation - Given I enter the course "Course 1" as "teacher1" in the app + Given I entered the course "Course 1" as "teacher1" in the app And I change viewport size to "1200x640" # Initial status diff --git a/src/addons/mod/chat/tests/behat/basic_usage.feature b/src/addons/mod/chat/tests/behat/basic_usage.feature index ef4f1d2da..d739a2df9 100755 --- a/src/addons/mod/chat/tests/behat/basic_usage.feature +++ b/src/addons/mod/chat/tests/behat/basic_usage.feature @@ -21,8 +21,8 @@ Feature: Test basic usage of chat in app Scenario: Receive and send messages & See connected users, beep and talk to # Send messages as student1 - When I enter the course "Course 1" as "student1" in the app - And I press "Test chat name" in the app + Given I entered the course "Course 1" as "student1" in the app + When I press "Test chat name" in the app Then I should find "Enter the chat" in the app And I should find "Past sessions" in the app @@ -37,8 +37,8 @@ Feature: Test basic usage of chat in app And I should find "I am David" in the app # Read messages, view connected users, send beep and reply as student2 - When I enter the course "Course 1" as "student2" in the app - And I press "Test chat name" in the app + Given I entered the course "Course 1" as "student2" in the app + When I press "Test chat name" in the app And I press "Enter the chat" in the app Then I should find "Hi!" in the app And I should find "I am David" in the app @@ -55,7 +55,7 @@ Feature: Test basic usage of chat in app Scenario: Past sessions shown # Send messages as student1 - Given I enter the course "Course 1" as "student1" in the app + Given I entered the course "Course 1" as "student1" in the app And I press "Test chat name" in the app And I press "Enter the chat" in the app And I set the field "New message" to "Hi!" in the app @@ -67,8 +67,8 @@ Feature: Test basic usage of chat in app Then I should find "I am David" in the app # Read messages from past sessions as student2 - When I enter the course "Course 1" as "student2" in the app - And I press "Test chat name" in the app + Given I entered the course "Course 1" as "student2" in the app + When I press "Test chat name" in the app And I press "Past sessions" in the app And I press "Show incomplete sessions" in the app And I press "david student" near "(2)" in the app diff --git a/src/addons/mod/chat/tests/behat/navigation.feature b/src/addons/mod/chat/tests/behat/navigation.feature index eccea87d3..0b757fb3a 100644 --- a/src/addons/mod/chat/tests/behat/navigation.feature +++ b/src/addons/mod/chat/tests/behat/navigation.feature @@ -18,7 +18,7 @@ Feature: Test chat navigation | chat | Test chat name | Test chat | C1 | chat | 0 | # Create sessions # TODO use generator instead - And I enter the course "Course 1" as "student1" in the app + And I entered the course "Course 1" as "student1" in the app And I press "Test chat name" in the app And I press "Enter the chat" in the app And I set the field "New message" to "Test message" in the app @@ -26,7 +26,7 @@ Feature: Test chat navigation Then I should find "Test message" in the app Scenario: Tablet navigation - Given I enter the course "Course 1" as "student2" in the app + Given I entered the course "Course 1" as "student2" in the app And I change viewport size to "1200x640" # Sessions diff --git a/src/addons/mod/choice/tests/behat/basic_usage-311.feature b/src/addons/mod/choice/tests/behat/basic_usage-311.feature index c5c0c90d3..6ce9f1e60 100755 --- a/src/addons/mod/choice/tests/behat/basic_usage-311.feature +++ b/src/addons/mod/choice/tests/behat/basic_usage-311.feature @@ -22,15 +22,15 @@ Feature: Test basic usage of choice activity in app Given the following "activities" exist: | activity | name | intro | course | idnumber | option | | choice | Choice name | Test choice description | C1 | choice1 | Option 1, Option 2, Option 3 | - And I enter the course "Course 1" as "student1" in the app - And I press "Choice name" in the app + And I entered the course "Course 1" as "student1" in the app + Then I press "Choice name" in the app And I select "Option 2" in the app And I press "Save my choice" in the app And I press "OK" in the app # Download answers as teacher - When I enter the course "Course 1" as "teacher1" in the app - And I press "Choice name" in the app + Given I entered the course "Course 1" as "teacher1" in the app + When I press "Choice name" in the app Then I should find "Test choice description" in the app When I press "Information" in the app diff --git a/src/addons/mod/choice/tests/behat/basic_usage.feature b/src/addons/mod/choice/tests/behat/basic_usage.feature index 73690ccc8..8585a6ab4 100755 --- a/src/addons/mod/choice/tests/behat/basic_usage.feature +++ b/src/addons/mod/choice/tests/behat/basic_usage.feature @@ -21,8 +21,8 @@ Feature: Test basic usage of choice activity in app Given the following "activities" exist: | activity | name | intro | course | idnumber | option | allowmultiple | allowupdate | showresults | | choice | Test single choice name | Test single choice description | C1 | choice1 | Option 1, Option 2, Option 3 | 0 | 0 | 1 | - When I enter the course "Course 1" as "student1" in the app - And I press "Test single choice name" in the app + Given I entered the course "Course 1" as "student1" in the app + When I press "Test single choice name" in the app And I select "Option 1" in the app And I select "Option 2" in the app And I press "Save my choice" in the app @@ -44,8 +44,8 @@ Feature: Test basic usage of choice activity in app Given the following "activities" exist: | activity | name | intro | course | idnumber | option | allowmultiple | allowupdate | showresults | | choice | Test multi choice name | Test multi choice description | C1 | choice2 | Option 1, Option 2, Option 3 | 1 | 1 | 1 | - When I enter the course "Course 1" as "student1" in the app - And I press "Test multi choice name" in the app + Given I entered the course "Course 1" as "student1" in the app + When I press "Test multi choice name" in the app And I select "Option 1" in the app And I select "Option 2" in the app And I press "Save my choice" in the app @@ -72,8 +72,8 @@ Feature: Test basic usage of choice activity in app Given the following "activities" exist: | activity | name | intro | course | idnumber | option | allowmultiple | allowupdate | showresults | | choice | Test single choice name | Test single choice description | C1 | choice1 | Option 1, Option 2, Option 3 | 0 | 0 | 1 | - When I enter the course "Course 1" as "student1" in the app - And I press "Test single choice name" in the app + Given I entered the course "Course 1" as "student1" in the app + When I press "Test single choice name" in the app And I select "Option 1" in the app And I switch offline mode to "true" And I select "Option 2" in the app @@ -104,8 +104,8 @@ Feature: Test basic usage of choice activity in app Given the following "activities" exist: | activity | name | intro | course | idnumber | option | allowmultiple | allowupdate | showresults | | choice | Test single choice name | Test single choice description | C1 | choice1 | Option 1, Option 2, Option 3 | 0 | 0 | 1 | - When I enter the course "Course 1" as "student1" in the app - And I press "Test single choice name" in the app + Given I entered the course "Course 1" as "student1" in the app + When I press "Test single choice name" in the app And I select "Option 1" in the app And I switch offline mode to "true" And I select "Option 2" in the app @@ -131,8 +131,8 @@ Feature: Test basic usage of choice activity in app | activity | name | intro | course | idnumber | option | allowmultiple | allowupdate | showresults | | choice | Test multi choice name | Test multi choice description | C1 | choice2 | Option 1, Option 2, Option 3 | 1 | 1 | 1 | | choice | Test single choice name | Test single choice description | C1 | choice1 | Option 1, Option 2, Option 3 | 0 | 0 | 1 | - When I enter the course "Course 1" as "student1" in the app - And I press "Course downloads" in the app + Given I entered the course "Course 1" as "student1" in the app + When I press "Course downloads" in the app And I press "Download" within "Test single choice name" "ion-item" in the app Then I should find "Downloaded" within "Test single choice name" "ion-item" in the app And I press the back button in the app @@ -171,15 +171,15 @@ Feature: Test basic usage of choice activity in app Given the following "activities" exist: | activity | name | intro | course | idnumber | option | | choice | Choice name | Test choice description | C1 | choice1 | Option 1, Option 2, Option 3 | - And I enter the course "Course 1" as "student1" in the app - And I press "Choice name" in the app + And I entered the course "Course 1" as "student1" in the app + Then I press "Choice name" in the app And I select "Option 2" in the app And I press "Save my choice" in the app And I press "OK" in the app # Download answers as teacher - When I enter the course "Course 1" as "teacher1" in the app - And I press "Choice name" in the app + Given I entered the course "Course 1" as "teacher1" in the app + When I press "Choice name" in the app Then I should find "Test choice description" in the app When I press "Information" in the app diff --git a/src/addons/mod/forum/tests/behat/basic_usage.feature b/src/addons/mod/forum/tests/behat/basic_usage.feature index 88e7aef82..20b075d96 100755 --- a/src/addons/mod/forum/tests/behat/basic_usage.feature +++ b/src/addons/mod/forum/tests/behat/basic_usage.feature @@ -25,8 +25,8 @@ Feature: Test basic usage of forum activity in app | forum | Test forum name | Test forum | C1 | forum | 0 | 1 | 1 | Scenario: Create new discussion - When I enter the course "Course 1" as "student1" in the app - And I press "Test forum name" in the app + Given I entered the course "Course 1" as "student1" in the app + When I press "Test forum name" in the app And I press "Add discussion topic" in the app And I set the field "Subject" to "My happy subject" in the app And I set the field "Message" to "An awesome message" in the app @@ -37,8 +37,8 @@ Feature: Test basic usage of forum activity in app Then I should find "An awesome message" in the app Scenario: Reply a post - When I enter the course "Course 1" as "student1" in the app - And I press "Test forum name" in the app + Given I entered the course "Course 1" as "student1" in the app + When I press "Test forum name" in the app And I press "Add discussion topic" in the app And I set the field "Subject" to "DiscussionSubject" in the app And I set the field "Message" to "DiscussionMessage" in the app @@ -53,8 +53,8 @@ Feature: Test basic usage of forum activity in app And I should find "ReplyMessage" in the app Scenario: Star and pin discussions (student) - When I enter the course "Course 1" as "student1" in the app - And I press "Test forum name" in the app + Given I entered the course "Course 1" as "student1" in the app + When I press "Test forum name" in the app And I press "Add discussion topic" in the app And I set the field "Subject" to "starred subject" in the app And I set the field "Message" to "starred message" in the app @@ -87,8 +87,8 @@ Feature: Test basic usage of forum activity in app Then I should find "normal message" in the app Scenario: Star and pin discussions (teacher) - When I enter the course "Course 1" as "teacher1" in the app - And I press "Test forum name" in the app + Given I entered the course "Course 1" as "teacher1" in the app + When I press "Test forum name" in the app And I press "Add discussion topic" in the app And I set the field "Subject" to "Auto-test star" in the app And I set the field "Message" to "Auto-test star message" in the app @@ -117,8 +117,8 @@ Feature: Test basic usage of forum activity in app And I should find "Auto-test pin" in the app Scenario: Edit a not sent reply offline - When I enter the course "Course 1" as "student1" in the app - And I press "Test forum name" in the app + Given I entered the course "Course 1" as "student1" in the app + When I press "Test forum name" in the app And I press "Add discussion topic" in the app And I set the field "Subject" to "Auto-test" in the app And I set the field "Message" to "Auto-test message" in the app @@ -150,8 +150,8 @@ Feature: Test basic usage of forum activity in app And I should not find "This Discussion has offline data to be synchronised" in the app Scenario: Edit a not sent new discussion offline - When I enter the course "Course 1" as "student1" in the app - And I press "Test forum name" in the app + Given I entered the course "Course 1" as "student1" in the app + When I press "Test forum name" in the app And I switch offline mode to "true" And I press "Add discussion topic" in the app And I set the field "Subject" to "Auto-test" in the app @@ -173,8 +173,8 @@ Feature: Test basic usage of forum activity in app And I should find "Auto-test message edited" in the app Scenario: Edit a forum post (only online) - When I enter the course "Course 1" as "student1" in the app - And I press "Test forum name" in the app + Given I entered the course "Course 1" as "student1" in the app + When I press "Test forum name" in the app And I press "Add discussion topic" in the app And I set the field "Subject" to "Auto-test" in the app And I set the field "Message" to "Auto-test message" in the app @@ -200,8 +200,8 @@ Feature: Test basic usage of forum activity in app # TODO Fix this test in all Moodle versions Scenario: Delete a forum post (only online) - When I enter the course "Course 1" as "student1" in the app - And I press "Test forum name" in the app + Given I entered the course "Course 1" as "student1" in the app + When I press "Test forum name" in the app And I press "Add discussion topic" in the app And I set the field "Subject" to "Auto-test" in the app And I set the field "Message" to "Auto-test message" in the app @@ -233,7 +233,7 @@ Feature: Test basic usage of forum activity in app Then I should not find "Auto-test" in the app Scenario: Add/view ratings - Given I enter the course "Course 1" as "student1" in the app + Given I entered the course "Course 1" as "student1" in the app And I press "Test forum name" in the app And I press "Add discussion topic" in the app And I set the field "Subject" to "Auto-test" in the app @@ -247,8 +247,8 @@ Feature: Test basic usage of forum activity in app And I press "Post to forum" in the app Then I should find "test2" "ion-card" in the app - When I enter the course "Course 1" as "teacher1" in the app - And I press "Test forum name" in the app + Given I entered the course "Course 1" as "teacher1" in the app + When I press "Test forum name" in the app And I press "Auto-test" in the app Then I should find "Reply" in the app @@ -274,16 +274,16 @@ Feature: Test basic usage of forum activity in app And I should find "Average of ratings: 0" in the app But I should not find "Average of ratings: -" in the app - When I enter the course "Course 1" as "student1" in the app - And I press "Test forum name" in the app + Given I entered the course "Course 1" as "student1" in the app + When I press "Test forum name" in the app And I press "Auto-test" in the app Then I should find "Average of ratings: 1" in the app And I should find "Average of ratings: 0" in the app But I should not find "Average of ratings: -" in the app Scenario: Reply a post offline - When I enter the course "Course 1" as "student1" in the app - And I press "Test forum name" in the app + Given I entered the course "Course 1" as "student1" in the app + When I press "Test forum name" in the app And I press "Add discussion topic" in the app And I set the field "Subject" to "DiscussionSubject" in the app And I set the field "Message" to "DiscussionMessage" in the app @@ -312,8 +312,8 @@ Feature: Test basic usage of forum activity in app But I should not find "Not sent" in the app Scenario: New discussion offline & Sync Forum - When I enter the course "Course 1" as "student1" in the app - And I press "Test forum name" in the app + Given I entered the course "Course 1" as "student1" in the app + When I press "Test forum name" in the app And I switch offline mode to "true" And I press "Add discussion topic" in the app And I set the field "Subject" to "DiscussionSubject" in the app @@ -335,8 +335,8 @@ Feature: Test basic usage of forum activity in app And I should not find "This Forum has offline data to be synchronised." in the app Scenario: New discussion offline & Auto-sync forum - When I enter the course "Course 1" as "student1" in the app - And I press "Test forum name" in the app + Given I entered the course "Course 1" as "student1" in the app + When I press "Test forum name" in the app And I switch offline mode to "true" And I press "Add discussion topic" in the app And I set the field "Subject" to "DiscussionSubject" in the app @@ -358,8 +358,8 @@ Feature: Test basic usage of forum activity in app And I should not find "This Forum has offline data to be synchronised." in the app Scenario: Prefetch - When I enter the course "Course 1" as "student1" in the app - And I press "Test forum name" in the app + Given I entered the course "Course 1" as "student1" in the app + When I press "Test forum name" in the app And I press "Add discussion topic" in the app And I set the field "Subject" to "DiscussionSubject 1" in the app And I set the field "Message" to "DiscussionMessage 1" in the app diff --git a/src/addons/mod/forum/tests/behat/navigation.feature b/src/addons/mod/forum/tests/behat/navigation.feature index f325f9738..0ecbb040b 100644 --- a/src/addons/mod/forum/tests/behat/navigation.feature +++ b/src/addons/mod/forum/tests/behat/navigation.feature @@ -42,7 +42,7 @@ Feature: Test forum navigation | Discussion 05 | Discussion 05 | Discussion 05 first reply | Scenario: Mobile navigation - Given I enter the course "Course 1" as "student1" in the app + Given I entered the course "Course 1" as "student1" in the app # By last reply When I press "Forum" in the app @@ -139,7 +139,7 @@ Feature: Test forum navigation # Then I should find "Discussion 20 message" in the app Scenario: Tablet navigation - Given I enter the course "Course 1" as "student1" in the app + Given I entered the course "Course 1" as "student1" in the app And I change viewport size to "1200x640" # By last reply diff --git a/src/addons/mod/glossary/tests/behat/navigation.feature b/src/addons/mod/glossary/tests/behat/navigation.feature index c3fac4b74..cd807e65b 100644 --- a/src/addons/mod/glossary/tests/behat/navigation.feature +++ b/src/addons/mod/glossary/tests/behat/navigation.feature @@ -88,7 +88,7 @@ Feature: Test glossary navigation | glossary | Watermelon | Watermelon is a fruit | student2 | Scenario: Mobile navigation - Given I enter the course "Course 1" as "student1" in the app + Given I entered the course "Course 1" as "student1" in the app # Alphabetically When I press "Fruits glossary" in the app @@ -195,7 +195,7 @@ Feature: Test glossary navigation Then I should find "Acerola is a fruit" in the app Scenario: Tablet navigation - Given I enter the course "Course 1" as "student1" in the app + Given I entered the course "Course 1" as "student1" in the app And I change viewport size to "1200x640" # Alphabetically diff --git a/src/addons/mod/quiz/tests/behat/basic_usage.feature b/src/addons/mod/quiz/tests/behat/basic_usage.feature index 4a5e94ba5..c20850298 100755 --- a/src/addons/mod/quiz/tests/behat/basic_usage.feature +++ b/src/addons/mod/quiz/tests/behat/basic_usage.feature @@ -56,8 +56,8 @@ Feature: Attempt a quiz in app | TF9 | 7 | Scenario: View a quiz entry page (attempts, status, etc.) - When I enter the course "Course 1" as "student1" in the app - And I press "Quiz 1" in the app + Given I entered the course "Course 1" as "student1" in the app + When I press "Quiz 1" in the app And I press "Attempt quiz now" in the app Then I should find "Text of the first question" in the app But I should not find "Text of the second question" in the app @@ -106,8 +106,8 @@ Feature: Attempt a quiz in app And I should find "Question 2" in the app Scenario: Attempt a quiz (all question types) - When I enter the course "Course 1" as "student1" in the app - And I press "Quiz 2" in the app + Given I entered the course "Course 1" as "student1" in the app + When I press "Quiz 2" in the app And I press "Attempt quiz now" in the app And I press "Four" in the app And I press "Three" in the app @@ -143,8 +143,8 @@ Feature: Attempt a quiz in app And I should find "Not yet graded" in the app Scenario: Submit a quiz & Review a quiz attempt - When I enter the course "Course 1" as "student1" in the app - And I press "Quiz 1" in the app + Given I entered the course "Course 1" as "student1" in the app + When I press "Quiz 1" in the app And I press "Attempt quiz now" in the app And I press "True" in the app And I press "Next" near "Question 1" in the app @@ -154,8 +154,8 @@ Feature: Attempt a quiz in app And I press "OK" in the app Then I should find "Review" in the app - When I enter the course "Course 1" as "teacher1" in the app - And I press "Quiz 1" in the app + Given I entered the course "Course 1" as "teacher1" in the app + When I press "Quiz 1" in the app And I press "Information" in the app And I press "Open in browser" in the app And I switch to the browser tab opened by the app diff --git a/src/addons/mod/quiz/tests/behat/quiz_navigation.feature b/src/addons/mod/quiz/tests/behat/quiz_navigation.feature index cf52af5c2..a81c5d0a3 100644 --- a/src/addons/mod/quiz/tests/behat/quiz_navigation.feature +++ b/src/addons/mod/quiz/tests/behat/quiz_navigation.feature @@ -30,10 +30,8 @@ Feature: Attempt a quiz in app | TF2 | 2 | Scenario: Next and previous navigation - Given I enter the app - And I log in as "student1" - When I enter the course "Course 1" in the app - And I press "Quiz 1" in the app + Given I entered the course "Course 1" as "student1" in the app + When I press "Quiz 1" in the app And I press "Attempt quiz now" in the app Then I should find "Text of the first question" in the app But I should not find "Text of the second question" in the app diff --git a/src/core/features/course/tests/behat/basic_usage-311.feature b/src/core/features/course/tests/behat/basic_usage-311.feature index 2f56e7a6a..9622a2904 100755 --- a/src/core/features/course/tests/behat/basic_usage-311.feature +++ b/src/core/features/course/tests/behat/basic_usage-311.feature @@ -72,7 +72,7 @@ Feature: Test basic usage of one course in app | workshop | Test workshop name | Test workshop | C1 | workshop | 0 | 3 | Scenario: Self enrol - Given I enter the course "Course 1" as "teacher1" in the app + Given I entered the course "Course 1" as "teacher1" in the app And I press "Course summary" in the app And I press "Open in browser" in the app And I switch to the browser tab opened by the app @@ -83,9 +83,8 @@ Feature: Test basic usage of one course in app And I follow "Enrolment methods" And I click on "Enable" "icon" in the "Self enrolment (Student)" "table_row" And I close the browser tab opened by the app - When I enter the app - And I log in as "student2" - And I press "Site home" in the app + Given I entered the app as "student2" + When I press "Site home" in the app And I press "Available courses" in the app And I press "Course 1" in the app And I press "Enrol me" in the app @@ -108,7 +107,7 @@ Feature: Test basic usage of one course in app And I should find "Test workshop name" in the app Scenario: Guest access - Given I enter the course "Course 1" as "teacher1" in the app + Given I entered the course "Course 1" as "teacher1" in the app And I press "Course summary" in the app And I press "Open in browser" in the app And I switch to the browser tab opened by the app @@ -119,9 +118,8 @@ Feature: Test basic usage of one course in app And I follow "Enrolment methods" And I click on "Enable" "icon" in the "Guest access" "table_row" And I close the browser tab opened by the app - When I enter the app - And I log in as "student2" - And I press "Site home" in the app + Given I entered the app as "student2" + When I press "Site home" in the app And I press "Available courses" in the app And I press "Course 1" in the app diff --git a/src/core/features/course/tests/behat/basic_usage.feature b/src/core/features/course/tests/behat/basic_usage.feature index 1674a661c..c849ed61d 100755 --- a/src/core/features/course/tests/behat/basic_usage.feature +++ b/src/core/features/course/tests/behat/basic_usage.feature @@ -72,7 +72,7 @@ Feature: Test basic usage of one course in app | workshop | Test workshop name | Test workshop | C1 | workshop | 0 | 3 | Scenario: View course contents - When I enter the course "Course 1" as "student1" in the app + When I entered the course "Course 1" as "student1" in the app Then the header should be "Course 1" in the app And I should find "Choice course 1" in the app And I should find "assignment" in the app @@ -147,7 +147,7 @@ Feature: Test basic usage of one course in app Then the header should be "Test workshop name" in the app Scenario: View section contents - When I enter the course "Course 1" as "student1" in the app + When I entered the course "Course 1" as "student1" in the app Then the header should be "Course 1" in the app And I should find "Choice course 1" in the app And I should find "assignment" in the app @@ -324,7 +324,7 @@ Feature: Test basic usage of one course in app Then the header should be "Test glossary" in the app Scenario: Navigation between sections using the bottom arrows - When I enter the course "Course 1" as "student1" in the app + When I entered the course "Course 1" as "student1" in the app Then the header should be "Course 1" in the app And I should find "Choice course 1" in the app And I should find "assignment" in the app @@ -402,7 +402,7 @@ Feature: Test basic usage of one course in app @lms_from4.0 Scenario: Self enrol - Given I enter the course "Course 1" as "teacher1" in the app + Given I entered the course "Course 1" as "teacher1" in the app And I press "Course summary" in the app And I press "Open in browser" in the app And I switch to the browser tab opened by the app @@ -411,9 +411,8 @@ Feature: Test basic usage of one course in app And I select "Enrolment methods" from the "jump" singleselect And I click on "Enable" "icon" in the "Self enrolment (Student)" "table_row" And I close the browser tab opened by the app - When I enter the app - And I log in as "student2" - And I press "Site home" in the app + Given I entered the app as "student2" + When I press "Site home" in the app And I press "Available courses" in the app And I press "Course 1" in the app And I press "Enrol me" in the app @@ -437,7 +436,7 @@ Feature: Test basic usage of one course in app @lms_from4.0 Scenario: Guest access - Given I enter the course "Course 1" as "teacher1" in the app + Given I entered the course "Course 1" as "teacher1" in the app And I press "Course summary" in the app And I press "Open in browser" in the app And I switch to the browser tab opened by the app @@ -446,9 +445,8 @@ Feature: Test basic usage of one course in app And I select "Enrolment methods" from the "jump" singleselect And I click on "Enable" "icon" in the "Guest access" "table_row" And I close the browser tab opened by the app - When I enter the app - And I log in as "student2" - And I press "Site home" in the app + Given I entered the app as "student2" + When I press "Site home" in the app And I press "Available courses" in the app And I press "Course 1" in the app @@ -476,7 +474,7 @@ Feature: Test basic usage of one course in app | blockname | contextlevel | reference | pagetypepattern | defaultregion | configdata | | html | Course | C1 | course-view-* | site-pre | Tzo4OiJzdGRDbGFzcyI6Mjp7czo1OiJ0aXRsZSI7czoxNToiSFRNTCB0aXRsZSB0ZXN0IjtzOjQ6InRleHQiO3M6OToiYm9keSB0ZXN0Ijt9 | | activity_modules | Course | C1 | course-view-* | site-pre | | - When I enter the course "Course 1" as "student1" in the app + And I entered the course "Course 1" as "student1" in the app Then the header should be "Course 1" in the app And I should find "Choice course 1" in the app And I should find "assignment" in the app diff --git a/src/core/features/course/tests/behat/course_completion-310.feature b/src/core/features/course/tests/behat/course_completion-310.feature index 60571703e..566aa109c 100644 --- a/src/core/features/course/tests/behat/course_completion-310.feature +++ b/src/core/features/course/tests/behat/course_completion-310.feature @@ -20,9 +20,9 @@ Feature: Check course completion feature. | activity | name | course | idnumber | completion | completionview | | forum | First forum | C1 | forum1 | 1 | 0 | | forum | Second forum | C1 | forum2 | 1 | 0 | - When I enter the course "Course 1" as "student1" in the app + And I entered the course "Course 1" as "student1" in the app # Set activities as completed. - And I should find "0%" in the app + Then I should find "0%" in the app And I click on "ion-button[title=\"Not completed: First forum. Select to mark as complete.\"]" "css" And I should find "50%" in the app And I click on "ion-button[title=\"Not completed: Second forum. Select to mark as complete.\"]" "css" diff --git a/src/core/features/course/tests/behat/course_completion.feature b/src/core/features/course/tests/behat/course_completion.feature index 06ab51784..32d9a267c 100644 --- a/src/core/features/course/tests/behat/course_completion.feature +++ b/src/core/features/course/tests/behat/course_completion.feature @@ -21,9 +21,9 @@ Feature: Check course completion feature. | activity | name | course | idnumber | completion | completionview | | forum | First forum | C1 | forum1 | 1 | 0 | | forum | Second forum | C1 | forum2 | 1 | 0 | - When I enter the course "Course 1" as "student1" in the app + And I entered the course "Course 1" as "student1" in the app # Set activities as completed. - And I should find "0%" in the app + Then I should find "0%" in the app And I press "Mark First forum as done" in the app And I should find "50%" in the app And I press "Mark Second forum as done" in the app diff --git a/src/core/features/course/tests/behat/courselist-311.feature b/src/core/features/course/tests/behat/courselist-311.feature index 0fd418c6d..4cdc5fe08 100644 --- a/src/core/features/course/tests/behat/courselist-311.feature +++ b/src/core/features/course/tests/behat/courselist-311.feature @@ -20,16 +20,14 @@ Feature: Test course list shown on app start tab | student2 | C2 | student | Scenario: View courses (shortnames not displayed) - When I enter the app - And I log in as "student1" - Then I should find "Course 1" in the app + Given I entered the app as "student1" + When I should find "Course 1" in the app But I should not find "Course 2" in the app But I should not find "C1" in the app But I should not find "C2" in the app - When I enter the app - And I log in as "student2" - Then I should find "Course 1" in the app + Given I entered the app as "student2" + When I should find "Course 1" in the app And I should find "Course 2" in the app But I should not find "C1" in the app But I should not find "C2" in the app @@ -76,9 +74,8 @@ Feature: Test course list shown on app start tab | student2 | Z8 | student | | student2 | Z9 | student | | student2 | Z10 | student | - When I enter the app - And I log in as "student2" - Then I should find "C1" in the app + Given I entered the app as "student2" + When I should find "C1" in the app And I should find "C2" in the app And I should find "C3" in the app And I should find "C4" in the app diff --git a/src/core/features/course/tests/behat/courselist.feature b/src/core/features/course/tests/behat/courselist.feature index 7d1807ac0..f1d99e1dc 100644 --- a/src/core/features/course/tests/behat/courselist.feature +++ b/src/core/features/course/tests/behat/courselist.feature @@ -21,17 +21,15 @@ Feature: Test course list shown on app start tab @lms_from4.0 Scenario: View courses (shortnames not displayed) - When I enter the app - And I log in as "student1" - And I press "My courses" in the app + Given I entered the app as "student1" + When I press "My courses" in the app Then I should find "Course 1" in the app But I should not find "Course 2" in the app But I should not find "C1" in the app But I should not find "C2" in the app - When I enter the app - And I log in as "student2" - And I press "My courses" in the app + Given I entered the app as "student2" + When I press "My courses" in the app Then I should find "Course 1" in the app And I should find "Course 2" in the app But I should not find "C1" in the app @@ -80,9 +78,8 @@ Feature: Test course list shown on app start tab | student2 | Z8 | student | | student2 | Z9 | student | | student2 | Z10 | student | - When I enter the app - And I log in as "student2" - And I press "My courses" in the app + Given I entered the app as "student2" + When I press "My courses" in the app Then I should find "C1" in the app And I should find "C2" in the app And I should find "C3" in the app diff --git a/src/core/features/courses/tests/behat/basic_usage-310.feature b/src/core/features/courses/tests/behat/basic_usage-310.feature index b22b47163..21691d4f3 100755 --- a/src/core/features/courses/tests/behat/basic_usage-310.feature +++ b/src/core/features/courses/tests/behat/basic_usage-310.feature @@ -36,8 +36,8 @@ Feature: Test basic usage of courses in app Scenario: Links to actions in Timeline work for teachers/students # Configure assignment as teacher - Given I enter the course "Course 1" as "teacher1" in the app - And I press "assignment" in the app + Given I entered the course "Course 1" as "teacher1" in the app + When I press "assignment" in the app And I press "Information" in the app And I press "Open in browser" in the app And I switch to the browser tab opened by the app @@ -51,9 +51,8 @@ Feature: Test basic usage of courses in app And I close the browser tab opened by the app # Submit assignment as student - When I enter the app - And I log in as "student1" - Then I press "Open block drawer" in the app + Given I entered the app as "student1" + When I press "Open block drawer" in the app And I press "Add submission" in the app Then the header should be "assignment" in the app And I should find "Test assignment description" in the app @@ -71,9 +70,8 @@ Feature: Test basic usage of courses in app And I should find "Due date" in the app # Grade assignment as teacher - When I enter the app - And I log in as "teacher1" - Then I press "Open block drawer" in the app + Given I entered the app as "teacher1" + When I press "Open block drawer" in the app And I press "Grade" in the app Then the header should be "assignment" in the app And I should find "Test assignment description" in the app diff --git a/src/core/features/courses/tests/behat/basic_usage-311.feature b/src/core/features/courses/tests/behat/basic_usage-311.feature index 1e543d0e3..40f642f36 100755 --- a/src/core/features/courses/tests/behat/basic_usage-311.feature +++ b/src/core/features/courses/tests/behat/basic_usage-311.feature @@ -35,9 +35,8 @@ Feature: Test basic usage of courses in app | assign | C1 | assign1 | assignment | Test assignment description | 1 | Scenario: "Dashboard" tab displayed in >= 3.3 sites - When I enter the app - And I log in as "student1" - Then I should see "Dashboard" + Given I entered the app as "student1" + When I should see "Dashboard" And the header should be "Acceptance test site" in the app And I should find "Course 1" in the app And I should find "Course 2" in the app @@ -53,9 +52,8 @@ Feature: Test basic usage of courses in app And I should find "Course 3" in the app Scenario: See my courses - When I enter the app - And I log in as "student1" - Then the header should be "Acceptance test site" in the app + Given I entered the app as "student1" + When the header should be "Acceptance test site" in the app And I should find "Course 1" in the app And I should find "Course 2" in the app And I should find "Course 3" in the app @@ -82,8 +80,8 @@ Feature: Test basic usage of courses in app @lms_from3.11 Scenario: Links to actions in Timeline work for teachers/students # Configure assignment as teacher - Given I enter the course "Course 1" as "teacher1" in the app - And I press "assignment" in the app + Given I entered the course "Course 1" as "teacher1" in the app + When I press "assignment" in the app And I press "Information" in the app And I press "Open in browser" in the app And I switch to the browser tab opened by the app @@ -97,9 +95,8 @@ Feature: Test basic usage of courses in app And I close the browser tab opened by the app # Submit assignment as student - When I enter the app - And I log in as "student1" - Then I press "Open block drawer" in the app + Given I entered the app as "student1" + When I press "Open block drawer" in the app And I press "Add submission" in the app Then the header should be "assignment" in the app And I should find "Test assignment description" in the app @@ -117,9 +114,8 @@ Feature: Test basic usage of courses in app And I should find "Due:" in the app # Grade assignment as teacher - When I enter the app - And I log in as "teacher1" - Then I press "Open block drawer" in the app + Given I entered the app as "teacher1" + When I press "Open block drawer" in the app And I press "Grade" in the app Then the header should be "assignment" in the app And I should find "Test assignment description" in the app diff --git a/src/core/features/courses/tests/behat/basic_usage.feature b/src/core/features/courses/tests/behat/basic_usage.feature index beab4df32..313e9b063 100755 --- a/src/core/features/courses/tests/behat/basic_usage.feature +++ b/src/core/features/courses/tests/behat/basic_usage.feature @@ -35,9 +35,8 @@ Feature: Test basic usage of courses in app | assign | C1 | assign1 | assignment | Test assignment description | 1 | Scenario: "Dashboard" tab displayed - When I enter the app - And I log in as "student1" - Then I should see "Dashboard" + Given I entered the app as "student1" + When I should see "Dashboard" And the header should be "Acceptance test site" in the app And I should see "Timeline" And I press "Site home" in the app @@ -50,9 +49,8 @@ Feature: Test basic usage of courses in app And I should find "Course 3" in the app Scenario: See my courses - When I enter the app - And I log in as "student1" - Then the header should be "Acceptance test site" in the app + Given I entered the app as "student1" + When the header should be "Acceptance test site" in the app And I press "My courses" in the app And I should find "Course 1" in the app And I should find "Course 2" in the app @@ -78,9 +76,8 @@ Feature: Test basic usage of courses in app And the header should be "Course 3" in the app Scenario: Search for a course - When I enter the app - And I log in as "student1" - And I press "Search courses" in the app + Given I entered the app as "student1" + When I press "Search courses" in the app And I set the field "Search" to "Course 4" in the app And I press "Search" "button" in the app Then I should find "Course 4" in the app @@ -102,8 +99,8 @@ Feature: Test basic usage of courses in app # TODO remove LMS UI steps in app tests Scenario: Links to actions in Timeline work for teachers/students # Configure assignment as teacher - When I enter the course "Course 1" as "teacher1" in the app - And I press "assignment" in the app + Given I entered the course "Course 1" as "teacher1" in the app + When I press "assignment" in the app And I press "Information" in the app And I press "Open in browser" in the app And I switch to the browser tab opened by the app @@ -116,9 +113,8 @@ Feature: Test basic usage of courses in app And I close the browser tab opened by the app # Submit assignment as student - When I enter the app - And I log in as "student1" - And I press "Add submission" in the app + Given I entered the app as "student1" + When I press "Add submission" in the app Then the header should be "assignment" in the app And I should find "Test assignment description" in the app And I should find "No attempt" in the app @@ -135,9 +131,8 @@ Feature: Test basic usage of courses in app And I should find "Due:" in the app # Grade assignment as teacher - When I enter the app - And I log in as "teacher1" - And I press "Grade" in the app + Given I entered the app as "teacher1" + When I press "Grade" in the app Then the header should be "assignment" in the app And I should find "Test assignment description" in the app And I should find "Time remaining" in the app diff --git a/src/core/features/login/tests/behat/basic_usage.feature b/src/core/features/login/tests/behat/basic_usage.feature index 4230ddfa9..23f314947 100755 --- a/src/core/features/login/tests/behat/basic_usage.feature +++ b/src/core/features/login/tests/behat/basic_usage.feature @@ -63,9 +63,8 @@ Feature: Test basic usage of login in 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 user menu button in the app + Given I entered the app as "student1" + When I press the user 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 diff --git a/src/core/features/mainmenu/tests/behat/mainmenu-311.feature b/src/core/features/mainmenu/tests/behat/mainmenu-311.feature index 955ff09ea..7de9fdce9 100644 --- a/src/core/features/mainmenu/tests/behat/mainmenu-311.feature +++ b/src/core/features/mainmenu/tests/behat/mainmenu-311.feature @@ -9,17 +9,15 @@ Feature: Main Menu opens the right page Scenario: Opens Site Home when defaulthomepage is set to Site Given the following config values are set as admin: | defaulthomepage | 0 | - When I enter the app - And I log in as "student" - Then "Site home" should be selected in the app + Given I entered the app as "student" + When "Site home" should be selected in the app And I should find "Available courses" in the app And "Site home" "text" should appear before "Dashboard" "text" in the ".core-tabs-bar" "css_element" Scenario: Opens Dashboard when defaulthomepage is set to Dashboard Given the following config values are set as admin: | defaulthomepage | 1 | - When I enter the app - And I log in as "student" - Then "Dashboard" should be selected in the app + Given I entered the app as "student" + When "Dashboard" should be selected in the app And I should find "Course overview" in the app And "Dashboard" "text" should appear before "Site home" "text" in the ".core-tabs-bar" "css_element" diff --git a/src/core/features/mainmenu/tests/behat/mainmenu.feature b/src/core/features/mainmenu/tests/behat/mainmenu.feature index 704568a40..d69a64651 100644 --- a/src/core/features/mainmenu/tests/behat/mainmenu.feature +++ b/src/core/features/mainmenu/tests/behat/mainmenu.feature @@ -16,9 +16,8 @@ Feature: Main Menu opens the right page Scenario: Opens Site Home when defaulthomepage is set to Site Given the following config values are set as admin: | defaulthomepage | 0 | - When I enter the app - And I log in as "student" - Then "Site home" should be selected in the app + Given I entered the app as "student" + When "Site home" should be selected in the app And I should find "Available courses" in the app And "Site home" "text" should appear before "Dashboard" "text" in the ".core-tabs-bar" "css_element" And "Home" "text" should appear before "My courses" "text" in the ".mainmenu-tabs" "css_element" @@ -27,9 +26,8 @@ Feature: Main Menu opens the right page Scenario: Opens Dashboard when defaulthomepage is set to Dashboard Given the following config values are set as admin: | defaulthomepage | 1 | - When I enter the app - And I log in as "student" - Then "Dashboard" should be selected in the app + Given I entered the app as "student" + When "Dashboard" should be selected in the app And I should find "Timeline" in the app And "Dashboard" "text" should appear before "Site home" "text" in the ".core-tabs-bar" "css_element" And "Home" "text" should appear before "My courses" "text" in the ".mainmenu-tabs" "css_element" @@ -38,8 +36,7 @@ Feature: Main Menu opens the right page Scenario: Opens My Courses when defaulthomepage is set to My Courses Given the following config values are set as admin: | defaulthomepage | 3 | - When I enter the app - And I log in as "student" - Then "My courses" near "Home" should be selected in the app + Given I entered the app as "student" + When "My courses" near "Home" should be selected in the app And I should find "Course 1" in the app And "My courses" "text" should appear before "Home" "text" in the ".mainmenu-tabs" "css_element" diff --git a/src/core/features/settings/tests/behat/settings_navigation.feature b/src/core/features/settings/tests/behat/settings_navigation.feature index d5cc521e2..e097556ba 100644 --- a/src/core/features/settings/tests/behat/settings_navigation.feature +++ b/src/core/features/settings/tests/behat/settings_navigation.feature @@ -7,8 +7,7 @@ Feature: It navigates properly within settings. | student1 | Scenario: Mobile navigation - Given I enter the app - And I log in as "student1" + Given I entered the app as "student1" # Settings When I press "More" in the app @@ -47,8 +46,7 @@ Feature: It navigates properly within settings. Then I should find "Total space used" in the app Scenario: Tablet navigation - Given I enter the app - And I log in as "student1" + Given I entered the app as "student1" And I change viewport size to "1200x640" # Settings diff --git a/src/core/features/siteplugins/tests/behat/plugins.feature b/src/core/features/siteplugins/tests/behat/plugins.feature index 5055fc707..1c5dca648 100644 --- a/src/core/features/siteplugins/tests/behat/plugins.feature +++ b/src/core/features/siteplugins/tests/behat/plugins.feature @@ -7,9 +7,8 @@ Feature: Plugins work properly. | studentusername | Scenario: See more menu button - When I enter the app - And I log in as "studentusername" - And I press the more menu button in the app + Given I entered the app as "studentusername" + When I press the more menu button in the app Then I should find "Moodle App Behat (auto-generated)" in the app When I press "Moodle App Behat (auto-generated)" in the app diff --git a/src/core/features/usertours/tests/behat/usertours.feature b/src/core/features/usertours/tests/behat/usertours.feature index 778c79845..7a24915de 100644 --- a/src/core/features/usertours/tests/behat/usertours.feature +++ b/src/core/features/usertours/tests/behat/usertours.feature @@ -17,9 +17,8 @@ Feature: User Tours work properly. | disableUserTours | false | Scenario: Acknowledge User Tours - When I enter the app - And I log in as "student1" - Then I should find "Explore your personal area" in the app + Given I entered the app as "student1" + When I should find "Explore your personal area" in the app But I should not find "Expand to explore" in the app When I press "Got it" in the app diff --git a/src/core/services/sites.ts b/src/core/services/sites.ts index 64c5af804..9cddd8b96 100644 --- a/src/core/services/sites.ts +++ b/src/core/services/sites.ts @@ -557,14 +557,14 @@ export class CoreSitesProvider { } // Add site to sites list. - this.addSite(siteId, siteUrl, token, info, privateToken, config, oauthId); + await this.addSite(siteId, siteUrl, token, info, privateToken, config, oauthId); this.sites[siteId] = candidateSite; if (login) { // Turn candidate site into current site. this.currentSite = candidateSite; // Store session. - this.login(siteId); + await this.login(siteId); } else if (this.currentSite && this.currentSite.getId() == siteId) { // Current site has just been updated, trigger the event. CoreEvents.trigger(CoreEvents.SITE_UPDATED, info, siteId); diff --git a/src/tests/behat/navigation_activities.feature b/src/tests/behat/navigation_activities.feature index 1c93c11be..c90b1fc6b 100644 --- a/src/tests/behat/navigation_activities.feature +++ b/src/tests/behat/navigation_activities.feature @@ -18,8 +18,8 @@ Feature: It navigates properly within activities. And I replace the arguments in "page" "content" Scenario: Navigates using deep links - When I enter the course "Course 1" as "student" in the app - And I press "Page" in the app + Given I entered the course "Course 1" as "student" in the app + When I press "Page" in the app And I press "Go to label" in the app Then I should find "Label description" in the app diff --git a/src/tests/behat/navigation_deeplinks.feature b/src/tests/behat/navigation_deeplinks.feature index b59d89794..4394a477f 100644 --- a/src/tests/behat/navigation_deeplinks.feature +++ b/src/tests/behat/navigation_deeplinks.feature @@ -24,9 +24,8 @@ Feature: It navigates properly using deep links. | defaulthomepage | 0 | | Scenario: Receive a push notification - When I enter the app - And I log in as "student2" - And I press the user menu button in the app + Given I entered the app as "student2" + When I press the user 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 @@ -67,9 +66,8 @@ Feature: It navigates properly using deep links. And I should not find "Forum message" in the app Scenario: Open a link with a custom URL that calls WebServices for a logged out site - When I enter the app - And I log in as "student2" - And I press the user menu button in the app + Given I entered the app as "student2" + When I press the user menu button in the app And I press "Log out" in the app And I wait the app to restart And I open a custom link in the app for: diff --git a/src/tests/behat/navigation_externallinks.feature b/src/tests/behat/navigation_externallinks.feature index f49317ac2..7fbd9f133 100644 --- a/src/tests/behat/navigation_externallinks.feature +++ b/src/tests/behat/navigation_externallinks.feature @@ -20,8 +20,8 @@ Feature: It opens external links properly. # This test is flaky and may fail Scenario: Click an external link - When I enter the course "Course 1" as "student1" in the app - And I press "Test forum" in the app + Given I entered the course "Course 1" as "student1" in the app + When I press "Test forum" in the app And I press "Forum topic" in the app And I press "moodle.org external link" in the app Then I should find "You are about to leave the app" in the app diff --git a/src/tests/behat/navigation_gestures.feature b/src/tests/behat/navigation_gestures.feature index 67deefcb3..7b02fd07a 100644 --- a/src/tests/behat/navigation_gestures.feature +++ b/src/tests/behat/navigation_gestures.feature @@ -21,8 +21,8 @@ Feature: It navigates using gestures. | student3 | C1 | student | Scenario: Swipe between participants - When I enter the course "Course 1" as "student1" in the app - And I press "Participants" in the app + Given I entered the course "Course 1" as "student1" in the app + When I press "Participants" in the app And I press "Student First" in the app And I swipe to the left in the app Then I should find "Teacher First" in the app @@ -40,8 +40,8 @@ Feature: It navigates using gestures. Then I should find "Student First" in the app Scenario: Swipe between filtered participants - When I enter the course "Course 1" as "student1" in the app - And I press "Participants" in the app + Given I entered the course "Course 1" as "student1" in the app + When I press "Participants" in the app And I press "Search" in the app And I set the field "Search" to "student" in the app And I press "Search" "button" near "Clear search" in the app diff --git a/src/tests/behat/navigation_splitview.feature b/src/tests/behat/navigation_splitview.feature index 3b6e31359..74f331fbb 100644 --- a/src/tests/behat/navigation_splitview.feature +++ b/src/tests/behat/navigation_splitview.feature @@ -25,8 +25,7 @@ Feature: It navigates properly in pages with a split-view component. Scenario: Navigate in grades tab on mobile # Open user menu - Given I enter the app - And I log in as "student1" + Given I entered the app as "student1" And I press the user menu button in the app # Open grades page @@ -76,9 +75,8 @@ Feature: It navigates properly in pages with a split-view component. Scenario: Navigate in grades tab on tablet # Open user menu - Given I enter the app + Given I entered the app as "student1" And I change viewport size to "1200x640" - And I log in as "student1" And I press the user menu button in the app # Open grades page diff --git a/src/tests/behat/performance.feature b/src/tests/behat/performance.feature index 39a41c5d1..950dfee4e 100644 --- a/src/tests/behat/performance.feature +++ b/src/tests/behat/performance.feature @@ -81,13 +81,7 @@ Feature: Measure performance. Then "Login" should have taken less than 10 seconds Scenario: Open Activity - When I launch the app - Then I should see "Connect to Moodle" - But I should not see "Welcome to the Moodle 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" + Given I entered the app as "student1" Then I press "My courses" in the app And I should find "Course 1" in the app