From 4958cb42451085faabb2e523e0bb89115a493da2 Mon Sep 17 00:00:00 2001 From: Ferran Recio Date: Wed, 13 Dec 2023 12:38:03 +0100 Subject: [PATCH] MDL-79029 behat: optimize behat tests Replace some add activity to section steps to the new add activity to course section so they are faster and do not require javascript. --- .../tests/behat/add_filetypes.feature | 3 +-- .../tests/behat/private_ruleset.feature | 3 +-- course/tests/behat/add_activities.feature | 22 ++++++------------- .../videojs/tests/behat/modules.feature | 2 +- 4 files changed, 10 insertions(+), 20 deletions(-) diff --git a/admin/tool/filetypes/tests/behat/add_filetypes.feature b/admin/tool/filetypes/tests/behat/add_filetypes.feature index 90e8d21adcc..de8d5550b77 100644 --- a/admin/tool/filetypes/tests/behat/add_filetypes.feature +++ b/admin/tool/filetypes/tests/behat/add_filetypes.feature @@ -120,8 +120,7 @@ Feature: Add customised file types | Custom description | Froggy file | And I press "Save changes" # Create a resource activity and add it to a course - And I am on "Course 1" course homepage with editing mode on - When I add a "File" to section "1" + When I add a resource activity to course "Course 1" section "1" And I set the following fields to these values: | Name | An example of customised file type | | Description | File description | diff --git a/availability/tests/behat/private_ruleset.feature b/availability/tests/behat/private_ruleset.feature index 142f9858d4a..fa60a6948a4 100644 --- a/availability/tests/behat/private_ruleset.feature +++ b/availability/tests/behat/private_ruleset.feature @@ -21,8 +21,7 @@ Feature: Private rule sets | Group A | C1 | GA | 0 | | Group B | C1 | GB | 1 | And I log in as "teacher1" - And I am on "Course 1" course homepage with editing mode on - And I add a "Page" to section "1" + And I add a page activity to course "Course 1" section "1" And I expand all fieldsets Scenario: Add restriction with visible condition (must match), display option should be active diff --git a/course/tests/behat/add_activities.feature b/course/tests/behat/add_activities.feature index 47d76d7ec0c..08f489dfba9 100644 --- a/course/tests/behat/add_activities.feature +++ b/course/tests/behat/add_activities.feature @@ -11,15 +11,13 @@ Feature: Add activities to courses @javascript Scenario: Add an activity to a course - Given I am on the "Course 1" Course page logged in as admin - And I am on "Course 1" course homepage with editing mode on - When I add a "Database" to section "3" and I fill the form with: + Given I log in as "admin" + When I add a data activity to course "Course 1" section "3" and I fill the form with: | Name | Test name | | Description | Test database description | | ID number | TESTNAME | | Allow comments on entries | Yes | | Force language | English | - And I turn editing mode off Then I should not see "Adding a new" And I turn editing mode on And I open "Test name" actions menu @@ -30,32 +28,26 @@ Feature: Add activities to courses | Allow comments on entries | Yes | | Force language | English ‎(en)‎ | - @javascript Scenario: Add an activity supplying only the name - Given I am on the "Course 1" Course page logged in as admin - And I am on "Course 1" course homepage with editing mode on - When I add a "Database" to section "3" and I fill the form with: + Given I log in as "admin" + When I add a data activity to course "Course 1" section "3" and I fill the form with: | Name | Test name | Then I should see "Test name" - @javascript Scenario: Set activity description to required then add an activity supplying only the name Given the following config values are set as admin: | requiremodintro | 1 | - And I am on the "Course 1" Course page logged in as admin - And I am on "Course 1" course homepage with editing mode on - And I add a "Database" to section "3" and I fill the form with: + And I log in as "admin" + And I add a data activity to course "Course 1" section "3" and I fill the form with: | Name | Test name | Then I should see "Required" - @javascript Scenario: The activity description should use the user's preferred editor on creation Given the following "user preferences" exist: | user | preference | value | | admin | htmleditor | textarea | And I am logged in as admin - And I am on "Course 1" course homepage with editing mode on - When I add a "Database" to section "3" + When I add a data activity to course "Course 1" section "3" Then the field "Description format" matches value "0" @javascript diff --git a/media/player/videojs/tests/behat/modules.feature b/media/player/videojs/tests/behat/modules.feature index 90da7466d20..e02bcd63d25 100644 --- a/media/player/videojs/tests/behat/modules.feature +++ b/media/player/videojs/tests/behat/modules.feature @@ -24,7 +24,7 @@ Feature: Embed videos without the media filter @javascript Scenario: Add a video as a File resource. Make sure media filters work - When I add a "File" to section "1" + When I add a "File" to section "1" using the activity chooser And I set the following fields to these values: | Name | Video File | | Description | Example of a video file |