diff --git a/mod/choice/tests/behat/app_basic_usage.feature b/mod/choice/tests/behat/app_basic_usage.feature index a51feb430..5de9ffaf8 100755 --- a/mod/choice/tests/behat/app_basic_usage.feature +++ b/mod/choice/tests/behat/app_basic_usage.feature @@ -132,7 +132,6 @@ Feature: Test basic usage of choice activity in app | 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 summary" in the app And 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 diff --git a/mod/course/tests/behat/app_basic_usage.feature b/mod/course/tests/behat/app_basic_usage.feature index 885796a8a..2caa3442f 100755 --- a/mod/course/tests/behat/app_basic_usage.feature +++ b/mod/course/tests/behat/app_basic_usage.feature @@ -449,7 +449,8 @@ Feature: Test basic usage of one course in app And I press "Site home" in the app And I press "Available courses" in the app And I press "Course 1" in the app - Then I should find "Course downloads" in the app + + Then I should find "Course summary" in the app And I should find "Course" in the app When I press "Course" "ion-button" in the app diff --git a/mod/courses/tests/behat/app_basic_usage.feature b/mod/courses/tests/behat/app_basic_usage.feature index 7c3ea7d4f..5cb9f3953 100755 --- a/mod/courses/tests/behat/app_basic_usage.feature +++ b/mod/courses/tests/behat/app_basic_usage.feature @@ -108,7 +108,7 @@ Feature: Test basic usage of courses in app And I switch to the browser tab opened by the app And I log in as "teacher1" And I navigate to "Settings" in current page administration - And I press "Expand all" + And I click on "Expand all" "link" And I click on "duedate[enabled]" "checkbox" And I click on "gradingduedate[enabled]" "checkbox" And I press "Save and return to course" diff --git a/mod/forum/tests/behat/app_basic_usage.feature b/mod/forum/tests/behat/app_basic_usage.feature index 032b16fd2..6d59c7db0 100755 --- a/mod/forum/tests/behat/app_basic_usage.feature +++ b/mod/forum/tests/behat/app_basic_usage.feature @@ -182,7 +182,6 @@ Feature: Test basic usage of forum activity in app Then I should find "Auto-test" in the app When I press the back button in the app - And I press "Course summary" in the app And I press "Course downloads" in the app And I press "Download" within "Test forum name" "ion-item" in the app And I press the back button in the app @@ -209,7 +208,6 @@ Feature: Test basic usage of forum activity in app Then I should find "Auto-test" in the app When I press the back button in the app - And I press "Course summary" in the app And I press "Course downloads" in the app And I press "Download" within "Test forum name" "ion-item" in the app And I press the back button in the app @@ -264,7 +262,7 @@ Feature: Test basic usage of forum activity in app And I press the back button in the app Then I should find "This Forum has offline data to be synchronised." in the app - When I press "Information" near "Test forum name" in the app + When I press "Information" in the app And I press "Synchronise now" in the app Then I should not find "This Forum has offline data to be synchronised." in the app @@ -288,7 +286,6 @@ Feature: Test basic usage of forum activity in app And I set the field "Message" to "DiscussionMessage" in the app And I press "Post to forum" in the app And I press the back button in the app - And I press "Course summary" in the app And I press "Course downloads" in the app And I press "Download" within "Test forum name" "ion-item" in the app And I press the back button in the app @@ -326,7 +323,7 @@ Feature: Test basic usage of forum activity in app When I switch offline mode to "false" And I press the back button in the app And I press "Test forum name" in the app - And I press "Information" near "Test forum name" in the app + And I press "Information" in the app And I press "Refresh" in the app And I press "DiscussionSubject" near "Sort by last post creation date in descending order" in the app Then I should find "DiscussionSubject" in the app @@ -367,7 +364,6 @@ Feature: Test basic usage of forum activity in app Then I should find "DiscussionSubject 1" in the app When I press the back button in the app - And I press "Course summary" in the app And I press "Course downloads" in the app And I press "Download" within "Test forum name" "ion-item" in the app Then I should find "Downloaded" within "Test forum name" "ion-item" in the app diff --git a/mod/quiz/tests/behat/app_basic_usage.feature b/mod/quiz/tests/behat/app_basic_usage.feature index f9f654800..4a5e94ba5 100755 --- a/mod/quiz/tests/behat/app_basic_usage.feature +++ b/mod/quiz/tests/behat/app_basic_usage.feature @@ -79,14 +79,14 @@ Feature: Attempt a quiz in app But I should not find "Text of the second question" in the app When I press "Next" near "Question 1" in the app - And I press "Next" near "Quiz 1" in the app + And I press "Submit" near "Quiz 1" in the app Then I should find "Summary of attempt" in the app - When I press "Return to attempt" in the app + When I press "Not yet answered" within "2" "ion-item" in the app Then I should find "Text of the second question" in the app But I should not find "Text of the first question" in the app - When I press "Next" in the app + When I press "Submit" in the app And I press "Submit all and finish" in the app Then I should find "Once you submit" in the app @@ -95,7 +95,7 @@ Feature: Attempt a quiz in app When I press "Submit all and finish" in the app And I press "OK" near "Once you submit" in the app - Then I should find "Review of attempt 1" in the app + Then I should find "Review" in the app And I should find "Started on" in the app And I should find "State" in the app And I should find "Completed on" in the app @@ -111,11 +111,11 @@ Feature: Attempt a quiz in app And I press "Attempt quiz now" in the app And I press "Four" in the app And I press "Three" in the app - And I press "Next" "ion-button" near "Quiz 2" in the app + And I press "Next" near "Quiz 2" in the app And I set the field "Answer" to "testing" in the app - And I press "Next" "ion-button" near "Question 2" in the app + And I press "Next" near "Question 2" in the app And I set the field "Answer" to "5" in the app - And I press "Next" "ion-button" near "Question 3" in the app + And I press "Next" near "Question 3" in the app And I set the field "Answer" to "Testing an essay" in the app And I press "Next" "ion-button" near "Question 4" in the app And I press "quick" ".drag" in the app @@ -124,21 +124,21 @@ Feature: Attempt a quiz in app And I press "" ".place2.drop" in the app And I press "lazy" ".drag" in the app And I press "" ".place3.drop" in the app - And I press "Next" "ion-button" near "Question 5" in the app + And I press "Next" near "Question 5" in the app And I press "True" in the app - And I press "Next" "ion-button" near "Question 6" in the app + And I press "Next" near "Question 6" in the app And I press "Choose... , frog" in the app And I press "amphibian" in the app And I press "Choose... , newt" in the app And I press "insect" in the app And I press "Choose... , cat" in the app And I press "mammal" in the app - And I press "Next" "ion-button" near "Question 7" in the app + And I press "Submit" near "Question 7" in the app Then I should not find "Not yet answered" in the app When I press "Submit all and finish" in the app And I press "OK" in the app - Then I should find "Review of attempt 1" in the app + Then I should find "Review" in the app And I should find "Finished" in the app And I should find "Not yet graded" in the app @@ -149,10 +149,10 @@ Feature: Attempt a quiz in app And I press "True" in the app And I press "Next" near "Question 1" in the app And I press "False" in the app - And I press "Next" near "Question 2" in the app + And I press "Submit" near "Question 2" in the app And I press "Submit all and finish" in the app And I press "OK" in the app - Then I should find "Review of attempt 1" 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 diff --git a/mod/quiz/tests/behat/app_quiz_navigation.feature b/mod/quiz/tests/behat/app_quiz_navigation.feature index 6cd114a3b..cf52af5c2 100644 --- a/mod/quiz/tests/behat/app_quiz_navigation.feature +++ b/mod/quiz/tests/behat/app_quiz_navigation.feature @@ -36,30 +36,39 @@ Feature: Attempt a quiz in app And 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 - And I should not find "Text of the second question" in the app - And I press "Next" near "Question 1" in the app - And I should find "Text of the second question" in the app - And I should not find "Text of the first question" in the app - And I press "Previous" near "Question 2" in the app - And I should not find "Text of the second question" in the app - And I should find "Text of the first question" in the app - And I press "Next" near "Quiz 1" in the app - And I should find "Text of the second question" in the app - And I should not find "Text of the first question" in the app - And I press "Previous" near "Quiz 1" in the app - And I should not find "Text of the second question" in the app - And I should find "Text of the first question" in the app - And I press "Next" near "Question 1" in the app - And I press "Next" near "Quiz 1" in the app - And I should find "Summary of attempt" in the app - And I press "Return to attempt" in the app - And I should find "Text of the second question" in the app - And I should not find "Text of the first question" in the app - And I press "Next" in the app - And I press "Submit all and finish" in the app - And I should find "Once you submit" in the app - And I press "Cancel" near "Once you submit" in the app - And I should find "Summary of attempt" in the app + But I should not find "Text of the second question" in the app + + When I press "Next" near "Question 1" in the app + Then I should find "Text of the second question" in the app + But I should not find "Text of the first question" in the app + + When I press "Previous" near "Question 2" 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 + + When I press "Next" near "Quiz 1" in the app + Then I should find "Text of the second question" in the app + But I should not find "Text of the first question" in the app + + When I press "Previous" near "Quiz 1" 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 + + When I press "Next" near "Question 1" in the app + And I press "Submit" in the app + Then I should find "Summary of attempt" in the app + + When I press "Not yet answered" within "2" "ion-item" in the app + Then I should find "Text of the second question" in the app + But I should not find "Text of the first question" in the app + + When I press "Submit" in the app And I press "Submit all and finish" in the app + Then I should find "Once you submit" in the app + + When I press "Cancel" near "Once you submit" in the app + Then I should find "Summary of attempt" in the app + + When 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 + Then I should find "Review" in the app diff --git a/tests/behat/behat_app.php b/tests/behat/behat_app.php index d056fc1be..603e298d2 100644 --- a/tests/behat/behat_app.php +++ b/tests/behat/behat_app.php @@ -242,6 +242,9 @@ class behat_app extends behat_base { $method = 'swipe' . ucwords($direction); $this->evaluate_script("behat.getAngularInstance('ion-content', 'CoreSwipeNavigationDirective').$method()"); + + // Wait swipe animation to finish. + $this->getSession()->wait(300); } /** @@ -504,8 +507,14 @@ class behat_app extends behat_base { throw new DriverException('Moodle app not found in browser'); }, false, 60); - // Run the scripts to install Moodle 'pending' checks. - $this->execute_script(file_get_contents(__DIR__ . '/app_behat_runtime.js')); + // Inject Behat JavaScript runtime. + global $CFG; + + $this->execute_script(" + var script = document.createElement('script'); + script.src = '{$CFG->behat_wwwroot}/local/moodlemobileapp/tests/behat/app_behat_runtime.js'; + document.body.append(script); + "); if ($restart) { // Assert initial page.