From e7d32b89ac7b4b7f75fce73eb97d675ffffe699e Mon Sep 17 00:00:00 2001 From: Angelia Dela Cruz Date: Mon, 24 Oct 2022 14:19:01 +0800 Subject: [PATCH 1/2] MDL-75961 behat: IMSCP behat generators use UI Replace steps that manually add IMSCP instances via the UI and use Behat generators. This improves the speed of the Behat test runs. --- .../behat/display_imscp_description.feature | 40 ++++--------------- .../behat/imscp_activity_completion.feature | 29 ++++---------- .../behat/imscp_activity_creation_ui.feature | 25 ++++++++++++ 3 files changed, 40 insertions(+), 54 deletions(-) create mode 100644 mod/imscp/tests/behat/imscp_activity_creation_ui.feature diff --git a/mod/imscp/tests/behat/display_imscp_description.feature b/mod/imscp/tests/behat/display_imscp_description.feature index 929821b7827..d9e90beb173 100644 --- a/mod/imscp/tests/behat/display_imscp_description.feature +++ b/mod/imscp/tests/behat/display_imscp_description.feature @@ -1,4 +1,4 @@ -@mod @mod_imscp +@mod @mod_imscp @javascript @_file_upload Feature: Display the IMS content package description in the IMSCP and optionally in the course In order to display the the IMS content package description description in the course As a teacher @@ -14,52 +14,26 @@ Feature: Display the IMS content package description in the IMSCP and optionally And the following "course enrolments" exist: | user | course | role | | teacher1 | C1 | editingteacher | + And the following "activities" exist: + | activity | course | name | intro | packagefilepath | + | imscp | C1 | Test IMS content package | Test IMS content package description | mod/imscp/tests/packages/singelscobasic.zip | - @javascript @_file_upload Scenario: Description is displayed in the IMS content package - Given I log in as "teacher1" - And I am on "Course 1" course homepage with editing mode on - And I add a "IMS content package" to section "1" - And I set the following fields to these values: - | Name | Test IMS content package | - | Description | Test IMS content package description | - And I upload "mod/imscp/tests/packages/singlescobasic.zip" file to "Package file" filemanager - And I click on "Save and display" "button" - When I am on the "Test IMS content package" "imscp activity" page + When I am on the "Test IMS content package" "imscp activity" page logged in as teacher1 Then I should see "Test IMS content package description" - @javascript @_file_upload Scenario: Show IMS description in the course homepage - Given I log in as "teacher1" - And I am on "Course 1" course homepage with editing mode on - And I add a "IMS content package" to section "1" - And I set the following fields to these values: - | Name | Test IMS content package | - | Description | Test IMS content package description | - And I upload "mod/imscp/tests/packages/singlescobasic.zip" file to "Package file" filemanager - And I click on "Save and display" "button" - When I am on the "Test IMS content package" "imscp activity editing" page + When I am on the "Test IMS content package" "imscp activity editing" page logged in as teacher1 And the following fields match these values: | Display description on course page | | And I set the following fields to these values: | Display description on course page | 1 | And I press "Save and return to course" - When I am on "Course 1" course homepage Then I should see "Test IMS content package description" - @javascript @_file_upload Scenario: Hide IMS description in the course homepage - Given I log in as "teacher1" - And I am on "Course 1" course homepage with editing mode on - And I add a "IMS content package" to section "1" - And I set the following fields to these values: - | Name | Test IMS content package | - | Description | Test IMS content package description | - And I upload "mod/imscp/tests/packages/singlescobasic.zip" file to "Package file" filemanager - And I click on "Save and display" "button" - When I am on the "Test IMS content package" "imscp activity editing" page + When I am on the "Test IMS content package" "imscp activity editing" page logged in as teacher1 And the following fields match these values: | Display description on course page | | And I press "Save and return to course" - When I am on "Course 1" course homepage Then I should not see "Test IMS content package description" diff --git a/mod/imscp/tests/behat/imscp_activity_completion.feature b/mod/imscp/tests/behat/imscp_activity_completion.feature index ece52d2f66b..436bc0550eb 100644 --- a/mod/imscp/tests/behat/imscp_activity_completion.feature +++ b/mod/imscp/tests/behat/imscp_activity_completion.feature @@ -18,33 +18,20 @@ Feature: View activity completion information in the IMS content package activit | teacher1 | C1 | editingteacher | Scenario: View automatic completion items - Given I log in as "teacher1" - And I am on "Course 1" course homepage with editing mode on - And I add a "IMS content package" to section "1" - And I set the following fields to these values: - | Name | Music history | - | Completion tracking | Show activity as complete when conditions are met | - | Require view | 1 | - And I upload "mod/imscp/tests/packages/singlescobasic.zip" file to "Package file" filemanager - And I click on "Save and display" "button" - And I am on "Course 1" course homepage + Given the following "activities" exist: + | activity | course | name | completion | completionview | packagefilepath | + | imscp | C1 | Music history | 2 | 1 | mod/imscp/tests/pacakges/singescobbasic.zip | # Teacher view. - And I am on the "Music history" "imscp activity" page - And I log out + And I am on the "Music history" "imscp activity" page logged in as teacher1 # Student view. When I am on the "Music history" "imscp activity" page logged in as student1 Then the "View" completion condition of "Music history" is displayed as "done" Scenario: Use manual completion - Given I log in as "teacher1" - And I am on "Course 1" course homepage with editing mode on - And I add a "IMS content package" to section "1" - And I set the following fields to these values: - | Name | Music history | - | Completion tracking | Students can manually mark the activity as completed | - And I upload "mod/imscp/tests/packages/singlescobasic.zip" file to "Package file" filemanager - And I click on "Save and display" "button" - And I am on the "Music history" "imscp activity" page + Given the following "activities" exist: + | activity | course | name | completion | packagefilepath | + | imscp | C1 | Music history | 1 | mod/imscp/tests/packages/singescobasic.zip | + And I am on the "Music history" "imscp activity" page logged in as teacher1 # Teacher view. And the manual completion button for "Music history" should be disabled And I log out diff --git a/mod/imscp/tests/behat/imscp_activity_creation_ui.feature b/mod/imscp/tests/behat/imscp_activity_creation_ui.feature new file mode 100644 index 00000000000..0f4d184bfff --- /dev/null +++ b/mod/imscp/tests/behat/imscp_activity_creation_ui.feature @@ -0,0 +1,25 @@ +@mod @mod_imscp @javascript @_file_upload +Feature: Create an IMSCP activity through UI + In order to confirm that IMSCP activity creation via UI works correctly + + Background: + Given the following "users" exist: + | username | firstname | lastname | email | + | teacher1 | Teacher | 1 | teacher1@example.com | + And the following "courses" exist: + | fullname | shortname | format | + | Course 1 | C1 | topics | + And the following "course enrolments" exist: + | user | course | role | + | teacher1 | C1 | editingteacher | + + Scenario: IMS activity is created using UI + Given I am on the "Course 1" course page logged in as teacher1 + And I turn editing mode on + And I add a "IMS content package" to section "1" + And I set the following fields to these values: + | Name | Test IMS content package 2 | + | Description | Test IMS content package description | + And I upload "mod/imscp/tests/packages/singlescobasic.zip" file to "Package file" filemanager + When I press "Save and return to course" + Then I should see "Test IMS content package 2" From b12f9147080856bd32ec9caebb39448ef5fcba67 Mon Sep 17 00:00:00 2001 From: Simey Lameze Date: Wed, 24 May 2023 10:20:40 +0800 Subject: [PATCH 2/2] MDL-75961 behat: review and enhance mod_imscp tests This commit makes the following improvements to mod_imscp tests: * Removes unnecessary @javascript and @_file_upload tags from non-JS tests. * Removes user/enrol data generation from tests that can be performed as admin. * Removes "I log out" and other unnecessary steps. --- .../tests/behat/display_imscp_description.feature | 2 +- .../tests/behat/imscp_activity_completion.feature | 6 ++---- .../tests/behat/imscp_activity_creation_ui.feature | 10 ++-------- 3 files changed, 5 insertions(+), 13 deletions(-) diff --git a/mod/imscp/tests/behat/display_imscp_description.feature b/mod/imscp/tests/behat/display_imscp_description.feature index d9e90beb173..209dd7439b3 100644 --- a/mod/imscp/tests/behat/display_imscp_description.feature +++ b/mod/imscp/tests/behat/display_imscp_description.feature @@ -1,4 +1,4 @@ -@mod @mod_imscp @javascript @_file_upload +@mod @mod_imscp Feature: Display the IMS content package description in the IMSCP and optionally in the course In order to display the the IMS content package description description in the course As a teacher diff --git a/mod/imscp/tests/behat/imscp_activity_completion.feature b/mod/imscp/tests/behat/imscp_activity_completion.feature index 436bc0550eb..2d9d2bec481 100644 --- a/mod/imscp/tests/behat/imscp_activity_completion.feature +++ b/mod/imscp/tests/behat/imscp_activity_completion.feature @@ -1,4 +1,4 @@ -@mod @mod_imscp @_file_upload @core_completion @javascript +@mod @mod_imscp @core_completion Feature: View activity completion information in the IMS content package activity In order to have visibility of IMS content package completion requirements As a student @@ -21,12 +21,11 @@ Feature: View activity completion information in the IMS content package activit Given the following "activities" exist: | activity | course | name | completion | completionview | packagefilepath | | imscp | C1 | Music history | 2 | 1 | mod/imscp/tests/pacakges/singescobbasic.zip | - # Teacher view. - And I am on the "Music history" "imscp activity" page logged in as teacher1 # Student view. When I am on the "Music history" "imscp activity" page logged in as student1 Then the "View" completion condition of "Music history" is displayed as "done" + @javascript Scenario: Use manual completion Given the following "activities" exist: | activity | course | name | completion | packagefilepath | @@ -34,7 +33,6 @@ Feature: View activity completion information in the IMS content package activit And I am on the "Music history" "imscp activity" page logged in as teacher1 # Teacher view. And the manual completion button for "Music history" should be disabled - And I log out # Student view. When I am on the "Music history" "imscp activity" page logged in as student1 Then the manual completion button of "Music history" is displayed as "Mark as done" diff --git a/mod/imscp/tests/behat/imscp_activity_creation_ui.feature b/mod/imscp/tests/behat/imscp_activity_creation_ui.feature index 0f4d184bfff..d556d8e891b 100644 --- a/mod/imscp/tests/behat/imscp_activity_creation_ui.feature +++ b/mod/imscp/tests/behat/imscp_activity_creation_ui.feature @@ -3,18 +3,12 @@ Feature: Create an IMSCP activity through UI In order to confirm that IMSCP activity creation via UI works correctly Background: - Given the following "users" exist: - | username | firstname | lastname | email | - | teacher1 | Teacher | 1 | teacher1@example.com | - And the following "courses" exist: + Given the following "courses" exist: | fullname | shortname | format | | Course 1 | C1 | topics | - And the following "course enrolments" exist: - | user | course | role | - | teacher1 | C1 | editingteacher | Scenario: IMS activity is created using UI - Given I am on the "Course 1" course page logged in as teacher1 + Given I am on the "Course 1" course page logged in as admin And I turn editing mode on And I add a "IMS content package" to section "1" And I set the following fields to these values: