From 9a929f684c637932ae5f53b78f2c4910ab26669c Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Thu, 21 Nov 2024 15:29:18 +0100 Subject: [PATCH] MOBILE-4028 behat: Fix test after changes in links workflow Before MOBILE-4028, links could be treated before authenticating to a site, and this meant that the 'navigateToModule' function used 'getAndOpenCourse', which opened first the course and then the activity. Now the links are treated after authenticating, and this means that the activity is opened directly, without opening the course first. --- .../assign/tests/behat/basic_usage.feature | 14 ++-- .../tests/behat/basic_usage.feature | 6 +- .../choice/tests/behat/basic_usage.feature | 6 +- src/addons/mod/data/tests/behat/sync.feature | 71 +++++++++++-------- .../mod/forum/tests/behat/basic_usage.feature | 3 +- .../mod/forum/tests/behat/groups.feature | 19 +++-- .../glossary/tests/behat/basic_usage.feature | 3 +- .../mod/quiz/tests/behat/can_review.feature | 5 +- .../survey/tests/behat/basic_usage.feature | 5 +- .../workshop/tests/behat/basic_usage.feature | 3 +- .../tests/behat/showloginform_setting.feature | 2 +- .../settings/tests/behat/sync.feature | 3 +- src/core/tests/behat/open_files.feature | 3 +- 13 files changed, 89 insertions(+), 54 deletions(-) diff --git a/src/addons/mod/assign/tests/behat/basic_usage.feature b/src/addons/mod/assign/tests/behat/basic_usage.feature index 9cbf92c17..9adc224cb 100755 --- a/src/addons/mod/assign/tests/behat/basic_usage.feature +++ b/src/addons/mod/assign/tests/behat/basic_usage.feature @@ -132,7 +132,8 @@ Feature: Test basic usage of assignment activity in app Then I should find "No attempt" in the app Scenario: Add submission offline (online text) & Submit for grading offline & Sync submissions - Given I entered the assign activity "assignment1" on 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 When I press "Add submission" in the app And I switch network connection to offline And I set the field "Online text submissions" to "Submission test" in the app @@ -150,7 +151,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 - Given I entered the assign activity "assignment1" on 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 When I press "Add submission" in the app And I switch network connection to offline And I set the field "Online text submissions" to "Submission test original offline" in the app @@ -178,8 +180,9 @@ Feature: Test basic usage of assignment activity in app @lms_from4.5 Scenario: Remove submission offline and syncrhonize it - Given I entered the assign activity "assignment1" on course "Course 1" as "student1" in the app - And I press "Add submission" in the app + Given I entered the course "Course 1" as "student1" in the app + And I press "assignment1" in the app + When I press "Add submission" in the app And I set the field "Online text submissions" to "Submission test" in the app And I press "Save" in the app Then I should find "Draft (not submitted)" in the app @@ -223,7 +226,8 @@ Feature: Test basic usage of assignment activity in app @lms_from4.5 Scenario: Add submission offline after removing a submission offline - Given I entered the assign activity "assignment1" on 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 When I press "Add submission" in the app And I set the field "Online text submissions" to "Submission test online" in the app And I press "Save" in the app diff --git a/src/addons/mod/bigbluebuttonbn/tests/behat/basic_usage.feature b/src/addons/mod/bigbluebuttonbn/tests/behat/basic_usage.feature index 739cada78..f7260640f 100755 --- a/src/addons/mod/bigbluebuttonbn/tests/behat/basic_usage.feature +++ b/src/addons/mod/bigbluebuttonbn/tests/behat/basic_usage.feature @@ -25,7 +25,8 @@ Feature: Test basic usage of BBB activity in app | bigbluebuttonbn | BBB 1 | Test BBB description | C1 | bbb1 | 0 | ## 1 January 2050 00:00 ## | 0 | | bigbluebuttonbn | BBB 2 | Test BBB description | C1 | bbb2 | 0 | 0 | ## 1 January 2000 00:00 ## | | bigbluebuttonbn | BBB 3 | Test BBB description | C1 | bbb3 | 0 | ## 1 January 2000 00:00 ## | ## 1 January 2050 00:00 ## | - And I entered the bigbluebuttonbn activity "BBB 1" on course "Course 1" as "student1" in the app + And I entered the course "Course 1" as "student1" in the app + And I press "BBB 1" in the app Then I should find "The session has not started yet." in the app And I should find "Saturday, 1 January 2050, 12:00 AM" within "Open" "ion-item" in the app @@ -107,7 +108,8 @@ Feature: Test basic usage of BBB activity in app | bigbluebuttonbn | Room & recordings | C1 | bbb1 | 0 | | bigbluebuttonbn | Room only | C1 | bbb2 | 1 | | bigbluebuttonbn | Recordings only | C1 | bbb3 | 2 | - And I entered the bigbluebuttonbn activity "Room & recordings" on course "Course 1" as "student1" in the app + And I entered the course "Course 1" as "student1" in the app + And I press "Room & recordings" in the app Then I should find "This room is ready. You can join the session now." in the app And I should be able to press "Join session" in the app And I should find "Recordings" 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 5d087bfdf..fb44f8a54 100755 --- a/src/addons/mod/choice/tests/behat/basic_usage.feature +++ b/src/addons/mod/choice/tests/behat/basic_usage.feature @@ -21,7 +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 | - And I entered the choice activity "Test single choice name" on course "Course 1" as "student1" in the app + And I entered the course "Course 1" as "student1" in the app + And I press "Test single choice name" in the app When I select "Option 1" in the app And I select "Option 2" in the app And I press "Save my choice" in the app @@ -74,7 +75,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 | - And I entered the choice activity "Test single choice name" on course "Course 1" as "student1" in the app + And I entered the course "Course 1" as "student1" in the app + And I press "Test single choice name" in the app When I select "Option 1" in the app And I switch network connection to offline And I select "Option 2" in the app diff --git a/src/addons/mod/data/tests/behat/sync.feature b/src/addons/mod/data/tests/behat/sync.feature index 50dccc49a..94d2e5a9c 100644 --- a/src/addons/mod/data/tests/behat/sync.feature +++ b/src/addons/mod/data/tests/behat/sync.feature @@ -28,9 +28,11 @@ Feature: Users can store entries in database activities when offline and sync wh | data1 | text | Description | Link description | Scenario: Create entry (offline) - Given I entered the data activity "Web links" on course "Course 1" as "student1" in the app + Given I entered the course "Course 1" as "student1" in the app + And I press "Web links" in the app And I switch network connection to offline - And I should find "No entries yet" in the app + Then I should find "No entries yet" in the app + When I press "Add entry" in the app And I set the following fields to these values in the app: | URL | https://moodle.org/ | @@ -39,29 +41,33 @@ Feature: Users can store entries in database activities when offline and sync wh Then I should find "https://moodle.org/" in the app And I should find "Moodle community site" in the app And I should find "This Database has offline data to be synchronised" in the app - And I go back in the app + + When I go back in the app And I switch network connection to wifi And I press "Web links" near "General" in the app - And I should find "https://moodle.org/" in the app + Then I should find "https://moodle.org/" in the app And I should find "Moodle community site" in the app And I should not find "This Database has offline data to be synchronised" in the app Scenario: Update entry (offline) & Delete entry (offline) - Given I entered the data activity "Web links" on course "Course 1" as "student1" in the app - And I should find "No entries yet" in the app - And I press "Add entry" in the app + Given I entered the course "Course 1" as "student1" in the app + And I press "Web links" in the app + Then I should find "No entries yet" in the app + + When I press "Add entry" in the app And I set the following fields to these values in the app: | URL | https://moodle.org/ | | Description | Moodle community site | And I press "Save" near "Web links" in the app - And I should find "https://moodle.org/" in the app + Then I should find "https://moodle.org/" in the app And I should find "Moodle community site" in the app - And I press "Information" in the app + + When I press "Information" in the app And I press "Download" in the app And I wait until the page is ready And I close the popup in the app And I switch network connection to offline - When I press "Actions menu" in the app + And I press "Actions menu" in the app And I press "Edit" in the app And I set the following fields to these values in the app: | URL | https://moodlecloud.com/ | @@ -72,55 +78,64 @@ Feature: Users can store entries in database activities when offline and sync wh And I should find "https://moodlecloud.com/" in the app And I should find "Moodle Cloud" in the app And I should find "This Database has offline data to be synchronised" in the app - And I go back in the app + + When I go back in the app And I switch network connection to wifi And I press "Web links" near "General" in the app - And I should not find "https://moodle.org/" in the app + Then I should not find "https://moodle.org/" in the app And I should not find "Moodle community site" in the app And I should find "https://moodlecloud.com/" in the app And I should find "Moodle Cloud" in the app And I should not find "This Database has offline data to be synchronised" in the app - And I press "Information" in the app + + When I press "Information" in the app And I press "Refresh" in the app And I wait until the page is ready And I switch network connection to offline And I press "Actions menu" in the app And I press "Delete" in the app - And I should find "Are you sure you want to delete this entry?" in the app - And I press "Delete" in the app - And I should find "https://moodlecloud.com/" in the app + Then I should find "Are you sure you want to delete this entry?" in the app + + When I press "Delete" in the app + Then I should find "https://moodlecloud.com/" in the app And I should find "Moodle Cloud" in the app And I should find "This Database has offline data to be synchronised" in the app - And I go back in the app + + When I go back in the app And I switch network connection to wifi And I press "Web links" near "General" in the app - And I should not find "https://moodlecloud.com/" in the app + Then I should not find "https://moodlecloud.com/" in the app And I should not find "Moodle Cloud" in the app And I should not find "This Database has offline data to be synchronised" in the app Scenario: Students can undo deleting entries to a database in the app while offline - Given I entered the data activity "Web links" on course "Course 1" as "student1" in the app - And I should find "No entries yet" in the app - And I press "Add entry" in the app + Given I entered the course "Course 1" as "student1" in the app + And I press "Web links" in the app + Then I should find "No entries yet" in the app + + When I press "Add entry" in the app And I set the following fields to these values in the app: | URL | https://moodle.org/ | | Description | Moodle community site | And I press "Save" near "Web links" in the app - And I should find "https://moodle.org/" in the app + Then I should find "https://moodle.org/" in the app And I should find "Moodle community site" in the app - And I press "Information" in the app + + When I press "Information" in the app And I press "Download" in the app And I wait until the page is ready And I close the popup in the app - When I switch network connection to offline + And I switch network connection to offline And I press "Actions menu" in the app And I press "Delete" in the app - And I should find "Are you sure you want to delete this entry?" in the app - And I press "Delete" in the app - And I should find "https://moodle.org/" in the app + Then I should find "Are you sure you want to delete this entry?" in the app + + When I press "Delete" in the app + Then I should find "https://moodle.org/" in the app And I should find "Moodle community site" in the app And I should find "This Database has offline data to be synchronised" in the app - And I press "Actions menu" in the app + + When I press "Actions menu" in the app And I press "Restore" in the app And I go back in the app And I switch network connection to wifi diff --git a/src/addons/mod/forum/tests/behat/basic_usage.feature b/src/addons/mod/forum/tests/behat/basic_usage.feature index e0aebd9be..61dffc7b6 100755 --- a/src/addons/mod/forum/tests/behat/basic_usage.feature +++ b/src/addons/mod/forum/tests/behat/basic_usage.feature @@ -276,7 +276,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 - Given I entered the forum activity "Test forum name" on 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 When I switch network connection to offline And I press "Add discussion topic" in the app And I set the following fields to these values in the app: diff --git a/src/addons/mod/forum/tests/behat/groups.feature b/src/addons/mod/forum/tests/behat/groups.feature index 8c7aba79e..3cbdc09ef 100755 --- a/src/addons/mod/forum/tests/behat/groups.feature +++ b/src/addons/mod/forum/tests/behat/groups.feature @@ -35,7 +35,8 @@ Feature: Test usage of forum activity with groups in app | forum2 | Disc vis ALL | Disc vis ALL | Disc vis ALL content | All participants | Scenario: Student can only see the right groups - Given I entered the forum activity "Separate groups forum" on course "Course 1" as "student1" in the app + Given I entered the course "Course 1" as "student1" in the app + And I press "Separate groups forum" in the app Then I should find "Disc sep G1" in the app And I should find "Disc sep ALL" in the app But I should not find "Disc sep G2" in the app @@ -65,7 +66,8 @@ Feature: Test usage of forum activity with groups in app But I should not find "Disc vis G2" in the app Scenario: Teacher can see all groups - Given I entered the forum activity "Separate groups forum" on course "Course 1" as "teacher1" in the app + Given I entered the course "Course 1" as "teacher1" in the app + And I press "Separate groups forum" in the app When I press "Separate groups" in the app Then I should find "All participants" in the app And I should find "Group 1" in the app @@ -107,7 +109,8 @@ Feature: Test usage of forum activity with groups in app But I should not find "Disc vis G2" in the app Scenario: Student can only add discussions in his groups - Given I entered the forum activity "Separate groups forum" on course "Course 1" as "student1" in the app + Given I entered the course "Course 1" as "student1" in the app + And I press "Separate groups forum" in the app When I press "Add discussion topic" in the app And I press "Advanced" in the app Then I should not find "Post a copy to all groups" in the app @@ -165,8 +168,9 @@ Feature: Test usage of forum activity with groups in app Then I should find "My happy subject" in the app Scenario: Teacher can add discussion to any group - Given I entered the forum activity "Separate groups forum" on course "Course 1" as "teacher1" in the app - And I press "Separate groups" in the app + Given I entered the course "Course 1" as "teacher1" in the app + And I press "Separate groups forum" in the app + When I press "Separate groups" in the app And I press "All participants" in the app And I press "Add discussion topic" in the app And I press "Advanced" in the app @@ -279,8 +283,9 @@ Feature: Test usage of forum activity with groups in app Then I should find "My third subject" in the app Scenario: Teacher can post a copy in all groups - Given I entered the forum activity "Separate groups forum" on course "Course 1" as "teacher1" in the app - And I press "Separate groups" in the app + Given I entered the course "Course 1" as "teacher1" in the app + And I press "Separate groups forum" in the app + When I press "Separate groups" in the app And I press "Group 1" in the app And I press "Add discussion topic" in the app And I press "Advanced" 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 b11156c46..c3ccd71ad 100644 --- a/src/addons/mod/glossary/tests/behat/basic_usage.feature +++ b/src/addons/mod/glossary/tests/behat/basic_usage.feature @@ -52,7 +52,8 @@ Feature: Test basic usage of glossary in app Scenario: Navigate to glossary terms by link (auto-linking) Given the "glossary" filter is "on" - And I entered the glossary activity "Test glossary" on course "Course 1" as "student1" in the app + And I entered the course "Course 1" as "student1" in the app + And I press "Test glossary" in the app Then the header should be "Test glossary" in the app And I should find "Eggplant" in the app And I should find "Cucumber" in the app diff --git a/src/addons/mod/quiz/tests/behat/can_review.feature b/src/addons/mod/quiz/tests/behat/can_review.feature index 870be3bb2..364d1dfeb 100644 --- a/src/addons/mod/quiz/tests/behat/can_review.feature +++ b/src/addons/mod/quiz/tests/behat/can_review.feature @@ -49,8 +49,9 @@ Feature: Users can only review attempts that are allowed to be reviewed | 1 | True | Scenario: Can review only when the attempt is allowed to be reviewed - Given I entered the quiz activity "Quiz review after immed" on course "Course 1" as "student1" in the app - And I press "Attempt 1" in the app + Given I entered the course "Course 1" as "student1" in the app + And I press "Quiz review after immed" in the app + When I press "Attempt 1" in the app Then I should not be able to press "Review" in the app When I go back in the app diff --git a/src/addons/mod/survey/tests/behat/basic_usage.feature b/src/addons/mod/survey/tests/behat/basic_usage.feature index 894f90f37..5ee4ed3e6 100755 --- a/src/addons/mod/survey/tests/behat/basic_usage.feature +++ b/src/addons/mod/survey/tests/behat/basic_usage.feature @@ -238,8 +238,9 @@ Feature: Test basic usage of survey activity in app Given the following "activities" exist: | activity | name | intro | template | course | idnumber | groupmode | | survey | Test survey critical incidents | Test survey1 | 5 | C1 | survey1 | 0 | - Given I entered the survey activity "Test survey critical incidents" on course "Course 1" as "student1" in the app - And I switch network connection to offline + And I entered the course "Course 1" as "student1" in the app + And I press "Test survey critical incidents" in the app + When I switch network connection to offline And I press "Submit" in the app And I press "OK" in the app Then I should see "This Survey has offline data to be synchronised." diff --git a/src/addons/mod/workshop/tests/behat/basic_usage.feature b/src/addons/mod/workshop/tests/behat/basic_usage.feature index 06441f66d..1199f166f 100644 --- a/src/addons/mod/workshop/tests/behat/basic_usage.feature +++ b/src/addons/mod/workshop/tests/behat/basic_usage.feature @@ -130,7 +130,8 @@ Feature: Test basic usage of workshop activity in app | \mod_workshop\event\course_module_viewed | workshop | Test workshop | Course 1 | Scenario: Prefetch a workshop - Given I entered the workshop activity "workshop" on course "Course 1" as "teacher1" in the app + Given I entered the course "Course 1" as "teacher1" in the app + And I press "workshop" in the app When I press "Information" in the app And I press "Download" in the app And I press "Close" in the app diff --git a/src/core/features/login/tests/behat/showloginform_setting.feature b/src/core/features/login/tests/behat/showloginform_setting.feature index 7da2d8b77..0c6a2581c 100644 --- a/src/core/features/login/tests/behat/showloginform_setting.feature +++ b/src/core/features/login/tests/behat/showloginform_setting.feature @@ -48,7 +48,7 @@ Feature: Test showloginform setting in the app And I press "Moodle Mobile" in the app And I press "Developer options" in the app And I press "Always show login form" in the app - And I go back 4 times in the app + And I go back to the root page in the app And I press "david student" in the app Then the header should be "Reconnect" in the app And I should find "Log in" "ion-button" in the app diff --git a/src/core/features/settings/tests/behat/sync.feature b/src/core/features/settings/tests/behat/sync.feature index 22020eec2..564ab37b1 100644 --- a/src/core/features/settings/tests/behat/sync.feature +++ b/src/core/features/settings/tests/behat/sync.feature @@ -19,7 +19,8 @@ Feature: It synchronise sites properly Scenario: Sync the current site # Add something offline - Given I entered the choice activity "Sync choice" on course "Course 1" as "student1" in the app + Given I entered the course "Course 1" as "student1" in the app + And I press "Sync choice" in the app When I switch network connection to offline And I select "Option 1" in the app And I press "Save my choice" in the app diff --git a/src/core/tests/behat/open_files.feature b/src/core/tests/behat/open_files.feature index 9e7e097b9..9f675e067 100644 --- a/src/core/tests/behat/open_files.feature +++ b/src/core/tests/behat/open_files.feature @@ -21,7 +21,8 @@ Feature: It opens files properly. | resource | Test DOC | Test DOC description | 5 | C1 | A doc.doc | And the following config values are set as admin: | filetypeexclusionlist | rtf,doc | tool_mobile | - And I entered the resource activity "Test TXT" on course "Course 1" as "student1" in the app + And I entered the course "Course 1" as "student1" in the app + And I press "Test TXT" in the app When I press "Open" in the app Then the app should have opened a browser tab with url "^blob:"