diff --git a/local_moodleappbehat/tests/behat/behat_app.php b/local_moodleappbehat/tests/behat/behat_app.php index ceda8b943..59ece39db 100644 --- a/local_moodleappbehat/tests/behat/behat_app.php +++ b/local_moodleappbehat/tests/behat/behat_app.php @@ -574,7 +574,7 @@ class behat_app extends behat_app_helper { /** * Performs a pull to refresh gesture. * - * @When /^I pull to refresh in the app$/ + * @When I pull to refresh in the app * @throws DriverException If the gesture is not available */ public function i_pull_to_refresh_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 446e32a74..67e535139 100755 --- a/src/addons/mod/assign/tests/behat/basic_usage.feature +++ b/src/addons/mod/assign/tests/behat/basic_usage.feature @@ -79,6 +79,7 @@ Feature: Test basic usage of assignment activity in app # Submit second attempt as a student Given I entered the assign activity "assignment1" on course "Course 1" as "student1" in the app + When I pull to refresh 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 @@ -97,6 +98,7 @@ Feature: Test basic usage of assignment activity in app # View second attempt as a teacher Given I entered the assign activity "assignment1" on course "Course 1" as "teacher1" in the app When I press "Participants" in the app + And I pull to refresh 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 diff --git a/src/addons/mod/chat/tests/behat/basic_usage.feature b/src/addons/mod/chat/tests/behat/basic_usage.feature index 35a4972f6..8b0cd1f65 100755 --- a/src/addons/mod/chat/tests/behat/basic_usage.feature +++ b/src/addons/mod/chat/tests/behat/basic_usage.feature @@ -34,6 +34,9 @@ Feature: Test basic usage of chat in app And I press "Send" in the app Then I should find "Hi!" in the app And I should find "I am David" in the app + # Confirm leave the page + And I press the back button in the app + And I press "OK" in the app # Read messages, view connected users, send beep and reply as student2 Given I entered the chat activity "Test chat name" on course "Course 1" as "student2" in the app @@ -62,6 +65,9 @@ Feature: Test basic usage of chat in app When I set the field "New message" to "I am David" in the app And I press "Send" in the app Then I should find "I am David" in the app + # Confirm leave the page + And I press the back button in the app + And I press "OK" in the app # Read messages from past sessions as student2 Given I entered the chat activity "Test chat name" on course "Course 1" as "student2" in the app diff --git a/src/addons/mod/chat/tests/behat/navigation.feature b/src/addons/mod/chat/tests/behat/navigation.feature index 3490ea6f0..75b06cd18 100644 --- a/src/addons/mod/chat/tests/behat/navigation.feature +++ b/src/addons/mod/chat/tests/behat/navigation.feature @@ -23,6 +23,9 @@ Feature: Test chat navigation And I set the field "New message" to "Test message" in the app And I press "Send" in the app Then I should find "Test message" in the app + # Confirm leave the page + And I press the back button in the app + And I press "OK" in the app Scenario: Tablet navigation on chat Given I entered the course "Course 1" as "student2" in the app diff --git a/src/addons/mod/glossary/tests/behat/basic_usage.feature b/src/addons/mod/glossary/tests/behat/basic_usage.feature index a2209d84b..6a32f476c 100644 --- a/src/addons/mod/glossary/tests/behat/basic_usage.feature +++ b/src/addons/mod/glossary/tests/behat/basic_usage.feature @@ -100,6 +100,7 @@ Feature: Test basic usage of glossary in app # View comments as a student Given I entered the glossary activity "Test glossary" on course "Course 1" as "student1" in the app And I press "Eggplant" in the app + When I pull to refresh in the app Then I should find "Comments (2)" in the app When I press "Comments" in the app diff --git a/src/core/features/comments/tests/behat/basic_usage.feature b/src/core/features/comments/tests/behat/basic_usage.feature index 01ebe7a67..f63f872fc 100644 --- a/src/core/features/comments/tests/behat/basic_usage.feature +++ b/src/core/features/comments/tests/behat/basic_usage.feature @@ -36,8 +36,8 @@ Feature: Test basic usage of comments in app | Field description | Test field description | And I press "Save" And I close the browser tab opened by the app - When I entered the course "Course 1" as "teacher1" in the app - And I press "Data" in the app + + When I pull to refresh in the app And I press "Add entries" in the app And I set the field "Test field name" to "Test" in the app And I press "Save" in the app @@ -75,7 +75,7 @@ Feature: Test basic usage of comments in app Scenario: Add comments offline & Delete comments offline & Sync comments (database) Given I entered the data activity "Data" on course "Course 1" as "teacher1" in the app - When I press "Information" 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 And I log in as "teacher1" @@ -85,8 +85,8 @@ Feature: Test basic usage of comments in app And I press "Save" And I close the browser tab opened by the app - Given I entered the data activity "Data" on course "Course 1" as "teacher1" in the app - Then I press "Add entries" in the app + When I pull to refresh in the app + And I press "Add entries" in the app And I set the field "Test field name" to "Test" in the app And I press "Save" in the app And I press "More" 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 9be9bcf6d..3f4a3587a 100755 --- a/src/core/features/course/tests/behat/basic_usage.feature +++ b/src/core/features/course/tests/behat/basic_usage.feature @@ -411,6 +411,7 @@ 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 + Given I entered the app as "student2" When I press "Site home" in the app And I press "Available courses" 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 b61cbd65d..803f091fa 100755 --- a/src/core/features/courses/tests/behat/basic_usage.feature +++ b/src/core/features/courses/tests/behat/basic_usage.feature @@ -148,9 +148,12 @@ Feature: Test basic usage of courses in app # Grade assignment as teacher Given I entered the app as "teacher1" - When I press "Grade" in the app + When I pull to refresh 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 + + When I pull to refresh in the app + Then I should find "Test assignment description" in the app And I should find "Time remaining" in the app When I press "Needs grading" in the app diff --git a/src/testing/services/behat-runtime.ts b/src/testing/services/behat-runtime.ts index b9c971d2b..6161c0fd3 100644 --- a/src/testing/services/behat-runtime.ts +++ b/src/testing/services/behat-runtime.ts @@ -25,8 +25,6 @@ import { CoreCronDelegate, CoreCronDelegateService } from '@services/cron'; import { CoreLoadingComponent } from '@components/loading/loading'; import { CoreComponentsRegistry } from '@singletons/components-registry'; import { CoreDom } from '@singletons/dom'; -import { IonRefresher } from '@ionic/angular'; -import { CoreCoursesDashboardPage } from '@features/courses/pages/dashboard/dashboard'; import { Injectable } from '@angular/core'; import { CoreSites, CoreSitesProvider } from '@services/sites'; @@ -353,23 +351,17 @@ export class TestingBehatRuntimeService { this.log('Action - pullToRefresh'); try { - // TODO We should generalize this to work with other pages. It's not possible to use - // an IonRefresher instance because it doesn't expose any methods to trigger refresh, - // so we'll have to find another way. - - const dashboard = this.getAngularInstance( - 'page-core-courses-dashboard', - 'CoreCoursesDashboardPage', + // 'el' is protected, but there's no other way to trigger refresh programatically. + const ionRefresher = this.getAngularInstance<{ el: HTMLIonRefresherElement }>( + 'ion-refresher', + 'IonRefresher', ); - if (!dashboard) { - return 'ERROR: It\'s not possible to pull to refresh the current page ' - + '(the dashboard page is the only one supported at the moment).'; + if (!ionRefresher) { + return 'ERROR: It\'s not possible to pull to refresh the current page.'; } - await new Promise(resolve => { - dashboard.refreshDashboard({ complete: resolve } as IonRefresher); - }); + ionRefresher.el.dispatchEvent(new CustomEvent('ionRefresh')); return 'OK'; } catch (error) {