From 8815ecb3fd7ce17e117ae4f2f5adda2c9314f0c9 Mon Sep 17 00:00:00 2001 From: Simey Lameze Date: Tue, 16 Jan 2024 09:57:58 +0800 Subject: [PATCH] MDL-80613 behat: convert manual completion steps to use generators --- .../activity_completion_criteria.feature | 10 +++------- .../completion_course_page_display.feature | 10 ++-------- .../behat/enable_manual_complete_mark.feature | 19 ++++++------------- .../restrict_section_availability.feature | 14 +++++--------- course/tests/behat/section_visibility.feature | 11 +++-------- .../behat/chat_activity_completion.feature | 13 ++----------- ...ata_activity_completion_pass_grade.feature | 14 +++----------- ...rum_activity_completion_pass_grade.feature | 13 +++---------- ...ary_activity_completion_pass_grade.feature | 16 +++------------- .../h5pactivity_completion_pass_grade.feature | 12 ++---------- .../behat/label_activity_completion.feature | 16 ++++------------ .../resource_activity_completion.feature | 18 +++++------------- 12 files changed, 41 insertions(+), 125 deletions(-) diff --git a/completion/tests/behat/activity_completion_criteria.feature b/completion/tests/behat/activity_completion_criteria.feature index 50084de7c0b..cbb8faffde0 100644 --- a/completion/tests/behat/activity_completion_criteria.feature +++ b/completion/tests/behat/activity_completion_criteria.feature @@ -5,8 +5,8 @@ Feature: Allow to mark course as completed without cron for activity completion Background: Given the following "courses" exist: - | fullname | shortname | category | - | Completion course | CC1 | 0 | + | fullname | shortname | category | enablecompletion | + | Completion course | CC1 | 0 | 1 | And the following "users" exist: | username | firstname | lastname | email | | student1 | Student | First | student1@example.com | @@ -25,11 +25,7 @@ Feature: Allow to mark course as completed without cron for activity completion And the following "blocks" exist: | blockname | contextlevel | reference | pagetypepattern | defaultregion | | completionstatus | Course | CC1 | course-view-* | side-pre | - And I am on the "Completion course" "course editing" page logged in as admin - And I expand all fieldsets - And I set the field "Enable completion tracking" to "Yes" - And I click on "Save and display" "button" - And I am on the "Test assignment name" "assign activity editing" page + And I am on the "Test assignment name" "assign activity editing" page logged in as admin And I follow "Expand all" And I set the field "Completion tracking" to "Show activity as complete when conditions are met" And I set the field "completionusegrade" to "1" diff --git a/completion/tests/behat/completion_course_page_display.feature b/completion/tests/behat/completion_course_page_display.feature index f09e8024788..43f56b2b405 100644 --- a/completion/tests/behat/completion_course_page_display.feature +++ b/completion/tests/behat/completion_course_page_display.feature @@ -6,8 +6,8 @@ Feature: Show activity completion status or activity completion configuration on Background: Given the following "courses" exist: - | fullname | shortname | category | - | Course 1 | C1 | 0 | + | fullname | shortname | category | enablecompletion | + | Course 1 | C1 | 0 | 1 | And the following "users" exist: | username | firstname | lastname | email | | teacher1 | Teacher | First | teacher1@example.com | @@ -18,12 +18,6 @@ Feature: Show activity completion status or activity completion configuration on | teacher1 | C1 | editingteacher | | teacher2 | C1 | teacher | | student1 | C1 | student | - And I log in as "teacher1" - And I am on "Course 1" course homepage with editing mode on - And I navigate to "Settings" in current page administration - And I set the following fields to these values: - | Enable completion tracking | Yes | - And I press "Save and display" And the following "activities" exist: | activity | course | idnumber | name | intro | completion | completionview | completionexpected | | assign | C1 | assign1 | Test assignment name | Test assignment description | 2 | 1 | 0 | diff --git a/completion/tests/behat/enable_manual_complete_mark.feature b/completion/tests/behat/enable_manual_complete_mark.feature index 2a178e1fb89..f0de2dac860 100644 --- a/completion/tests/behat/enable_manual_complete_mark.feature +++ b/completion/tests/behat/enable_manual_complete_mark.feature @@ -7,8 +7,8 @@ Feature: Allow students to manually mark an activity as complete @javascript Scenario: Mark an activity as completed Given the following "courses" exist: - | fullname | shortname | category | - | Course 1 | C1 | 0 | + | fullname | shortname | category | enablecompletion | + | Course 1 | C1 | 0 | 1 | And the following "users" exist: | username | firstname | lastname | email | | teacher1 | Teacher | First | teacher1@example.com | @@ -18,18 +18,11 @@ Feature: Allow students to manually mark an activity as complete | teacher1 | C1 | editingteacher | | student1 | C1 | student | And the following "activity" exists: - | activity | forum | - | course | C1 | - | name | Test forum name | + | activity | forum | + | course | C1 | + | name | Test forum name | + | completion | 1 | And I am on the "Course 1" course page logged in as teacher1 - And I navigate to "Settings" in current page administration - And I set the following fields to these values: - | Enable completion tracking | Yes | - And I press "Save and display" - And I am on the "Test forum name" "forum activity editing" page - And I set the following fields to these values: - | completion | 1 | - And I press "Save and return to course" And "Student First" user has not completed "Test forum name" activity And I am on the "Course 1" course page logged in as student1 When I toggle the manual completion state of "Test forum name" diff --git a/completion/tests/behat/restrict_section_availability.feature b/completion/tests/behat/restrict_section_availability.feature index fac52c7296e..40f6b765605 100644 --- a/completion/tests/behat/restrict_section_availability.feature +++ b/completion/tests/behat/restrict_section_availability.feature @@ -6,8 +6,8 @@ Feature: Restrict sections availability through completion or grade conditions Background: Given the following "courses" exist: - | fullname | shortname | category | - | Course 1 | C1 | 0 | + | fullname | shortname | category | enablecompletion | + | Course 1 | C1 | 0 | 1 | And the following "users" exist: | username | firstname | lastname | email | | teacher1 | Teacher | First | teacher1@example.com | @@ -23,15 +23,11 @@ Feature: Restrict sections availability through completion or grade conditions @javascript Scenario: Show section greyed-out to student when completion condition is not satisfied - Given I log in as "teacher1" - And I am on "Course 1" course homepage with editing mode on - And I navigate to "Settings" in current page administration - And I set the following fields to these values: - | Enable completion tracking | Yes | - And I press "Save and display" - And the following "activities" exist: + Given the following "activities" exist: | activity | course | section | intro | completion | idnumber | | label | C1 | 1 | Test label | 1 | 1 | + And I log in as "teacher1" + And I am on "Course 1" course homepage with editing mode on When I edit the section "2" And I expand all fieldsets And I click on "Add restriction..." "button" diff --git a/course/tests/behat/section_visibility.feature b/course/tests/behat/section_visibility.feature index a47f07983eb..db42867ab8b 100644 --- a/course/tests/behat/section_visibility.feature +++ b/course/tests/behat/section_visibility.feature @@ -10,8 +10,8 @@ Feature: Show/hide course sections | teacher1 | Teacher | 1 | teacher1@example.com | | student1 | Student | 1 | student1@example.com | And the following "courses" exist: - | fullname | shortname | format | hiddensections | - | Course 1 | C1 | topics | 0 | + | fullname | shortname | format | hiddensections | enablecompletion | coursedisplay | + | Course 1 | C1 | topics | 0 | 1 | 1 | And the following "course enrolments" exist: | user | course | role | | teacher1 | C1 | editingteacher | @@ -76,12 +76,7 @@ Feature: Show/hide course sections @javascript Scenario: Students can not navigate to restricted sections - Given I navigate to "Settings" in current page administration - And I set the following fields to these values: - | Course layout | Show one section per page | - | Enable completion tracking | Yes | - And I press "Save and display" - And the following "activities" exist: + Given the following "activities" exist: | activity | course | section | name | completion | | label | C1 | 1 | Test label | 1 | And I edit the section "2" diff --git a/mod/chat/tests/behat/chat_activity_completion.feature b/mod/chat/tests/behat/chat_activity_completion.feature index fd8e20f4334..1068ea23b77 100644 --- a/mod/chat/tests/behat/chat_activity_completion.feature +++ b/mod/chat/tests/behat/chat_activity_completion.feature @@ -10,21 +10,12 @@ Feature: View activity completion information in the chat activity | student1 | Vinnie | Student1 | student1@example.com | | teacher1 | Darrell | Teacher1 | teacher1@example.com | And the following "courses" exist: - | fullname | shortname | category | - | Course 1 | C1 | 0 | + | fullname | shortname | category | enablecompletion | + | Course 1 | C1 | 0 | 1 | And the following "course enrolments" exist: | user | course | role | | student1 | C1 | student | | teacher1 | C1 | editingteacher | - And I log in as "teacher1" - And I am on "Course 1" course homepage - And I navigate to "Settings" in current page administration - And I expand all fieldsets - And I set the following fields to these values: - | Enable completion tracking | Yes | - | Show activity completion conditions | Yes | - And I press "Save and display" - And I log out Scenario: View automatic completion items Given I log in as "teacher1" diff --git a/mod/data/tests/behat/data_activity_completion_pass_grade.feature b/mod/data/tests/behat/data_activity_completion_pass_grade.feature index a624cfb62f5..5c006cf5542 100644 --- a/mod/data/tests/behat/data_activity_completion_pass_grade.feature +++ b/mod/data/tests/behat/data_activity_completion_pass_grade.feature @@ -12,28 +12,20 @@ Feature: Completion pass grade | student2 | Vinnie | Student2 | student2@example.com | | teacher1 | Darrell | Teacher1 | teacher1@example.com | And the following "courses" exist: - | fullname | shortname | category | - | Course 1 | C1 | 0 | + | fullname | shortname | category | enablecompletion | + | Course 1 | C1 | 0 | 1 | And the following "course enrolments" exist: | user | course | role | | student1 | C1 | student | | student2 | C1 | student | | teacher1 | C1 | editingteacher | - And I log in as "teacher1" - And I am on "Course 1" course homepage - And I navigate to "Settings" in current page administration - And I expand all fieldsets - And I set the following fields to these values: - | Enable completion tracking | Yes | - | Show activity completion conditions | Yes | - And I press "Save and display" And the following "activity" exists: | activity | data | | course | C1 | | idnumber | mh1 | | name | Music history | | section | 1 | - And I am on the "Music history" "data activity" page + And I am on the "Music history" "data activity" page logged in as teacher1 And I navigate to "Settings" in current page administration And I expand all fieldsets And I set the following fields to these values: diff --git a/mod/forum/tests/behat/forum_activity_completion_pass_grade.feature b/mod/forum/tests/behat/forum_activity_completion_pass_grade.feature index 9d1034f532d..9e75dd6fd69 100644 --- a/mod/forum/tests/behat/forum_activity_completion_pass_grade.feature +++ b/mod/forum/tests/behat/forum_activity_completion_pass_grade.feature @@ -10,25 +10,18 @@ Feature: Completion pass grade view activity completion in the forum activity | student1 | Vinnie | Student1 | student1@example.com | | teacher1 | Darrell | Teacher1 | teacher1@example.com | And the following "courses" exist: - | fullname | shortname | category | - | Course 1 | C1 | 0 | + | fullname | shortname | category | enablecompletion | + | Course 1 | C1 | 0 | 1 | And the following "course enrolments" exist: | user | course | role | | student1 | C1 | student | | teacher1 | C1 | editingteacher | - And I am on the "Course 1" course page logged in as teacher1 - And I navigate to "Settings" in current page administration - And I expand all fieldsets - And I set the following fields to these values: - | Enable completion tracking | Yes | - | Show activity completion conditions | Yes | - And I press "Save and display" And the following "activity" exists: | activity | forum | | course | C1 | | idnumber | mh1 | | name | Music history | - And I am on the "Music history" "forum activity editing" page + And I am on the "Music history" "forum activity editing" page logged in as teacher1 And I expand all fieldsets And I set the following fields to these values: | Whole forum grading > Type | Point | diff --git a/mod/glossary/tests/behat/glossary_activity_completion_pass_grade.feature b/mod/glossary/tests/behat/glossary_activity_completion_pass_grade.feature index 7ffd5405008..7106a579494 100644 --- a/mod/glossary/tests/behat/glossary_activity_completion_pass_grade.feature +++ b/mod/glossary/tests/behat/glossary_activity_completion_pass_grade.feature @@ -10,29 +10,19 @@ Feature: Pass grade completion in the glossary activity | student1 | Vinnie | Student1 | student1@example.com | | teacher1 | Darrell | Teacher1 | teacher1@example.com | And the following "courses" exist: - | fullname | shortname | category | - | Course 1 | C1 | 0 | + | fullname | shortname | category | enablecompletion | + | Course 1 | C1 | 0 | 1 | And the following "course enrolments" exist: | user | course | role | | student1 | C1 | student | | teacher1 | C1 | editingteacher | - And I log in as "teacher1" - And I am on "Course 1" course homepage - And I navigate to "Settings" in current page administration - And I expand all fieldsets - And I set the following fields to these values: - | Enable completion tracking | Yes | - | Show activity completion conditions | Yes | - And I press "Save and display" And the following "activity" exists: | activity | glossary | | course | C1 | | idnumber | mh1 | | name | Music history | | section | 1 | - And I am on "Course 1" course homepage - And I follow "Music history" - And I navigate to "Settings" in current page administration + When I am on the "Music history" "glossary activity editing" page logged in as teacher1 And I expand all fieldsets And I set the following fields to these values: | Aggregate type | Average of ratings | diff --git a/mod/h5pactivity/tests/behat/h5pactivity_completion_pass_grade.feature b/mod/h5pactivity/tests/behat/h5pactivity_completion_pass_grade.feature index 65db8ba44b3..112e9b940db 100644 --- a/mod/h5pactivity/tests/behat/h5pactivity_completion_pass_grade.feature +++ b/mod/h5pactivity/tests/behat/h5pactivity_completion_pass_grade.feature @@ -9,21 +9,14 @@ Feature: Pass grade activity completion information in the h5p activity | student3 | Vinnie | Student3 | student3@example.com | | teacher1 | Darrell | Teacher1 | teacher1@example.com | And the following "courses" exist: - | fullname | shortname | category | - | Course 1 | C1 | 0 | + | fullname | shortname | category | enablecompletion | + | Course 1 | C1 | 0 | 1 | And the following "course enrolments" exist: | user | course | role | | student1 | C1 | student | | student2 | C1 | student | | student3 | C1 | student | | teacher1 | C1 | editingteacher | - And I am on the "Course 1" "Course" page logged in as "admin" - And I navigate to "Settings" in current page administration - And I expand all fieldsets - And I set the following fields to these values: - | Enable completion tracking | Yes | - | Show activity completion conditions | Yes | - And I press "Save and display" And the following "activity" exists: | activity | h5pactivity | | course | C1 | @@ -34,7 +27,6 @@ Feature: Pass grade activity completion information in the h5p activity | completionpassgrade | 1 | | gradepass | 25 | | packagefilepath | h5p/tests/fixtures/filltheblanks.h5p | - And I log out Scenario: View automatic completion items # Teacher view. diff --git a/mod/label/tests/behat/label_activity_completion.feature b/mod/label/tests/behat/label_activity_completion.feature index c6a8cad300c..431428eae8a 100644 --- a/mod/label/tests/behat/label_activity_completion.feature +++ b/mod/label/tests/behat/label_activity_completion.feature @@ -10,20 +10,12 @@ Feature: View activity completion information for the label | student1 | Vinnie | Student1 | student1@example.com | | teacher1 | Darrell | Teacher1 | teacher1@example.com | And the following "courses" exist: - | fullname | shortname | category | - | Course 1 | C1 | 0 | + | fullname | shortname | category | enablecompletion | + | Course 1 | C1 | 0 | 1 | And the following "course enrolments" exist: | user | course | role | | student1 | C1 | student | | teacher1 | C1 | editingteacher | - And I log in as "teacher1" - And I am on "Course 1" course homepage - And I navigate to "Settings" in current page administration - And I expand all fieldsets - And I set the following fields to these values: - | Enable completion tracking | Yes | - | Show activity completion conditions | No | - And I press "Save and display" And the following "activity" exists: | activity | label | | course | C1 | @@ -33,7 +25,7 @@ Feature: View activity completion information for the label @javascript Scenario: The manual completion button will be shown on the course page if the Show activity completion conditions is set to No - Given I am on "Course 1" course homepage + Given I am on the "Course 1" course page logged in as teacher1 # Teacher view. And the manual completion button for "Test label 1" should exist And the manual completion button for "Test label 1" should be disabled @@ -48,7 +40,7 @@ Feature: View activity completion information for the label @javascript Scenario: The manual completion button will be shown on the course page if the Show activity completion conditions is set to Yes - Given I am on "Course 1" course homepage + Given I am on the "Course 1" course page logged in as teacher1 And I navigate to "Settings" in current page administration And I expand all fieldsets And I set the field "Show activity completion conditions" to "Yes" diff --git a/mod/resource/tests/behat/resource_activity_completion.feature b/mod/resource/tests/behat/resource_activity_completion.feature index 645a86be35d..5d321d69f60 100644 --- a/mod/resource/tests/behat/resource_activity_completion.feature +++ b/mod/resource/tests/behat/resource_activity_completion.feature @@ -10,28 +10,21 @@ Feature: View activity completion information for file resources | student1 | Vinnie | Student1 | student1@example.com | | teacher1 | Darrell | Teacher1 | teacher1@example.com | And the following "courses" exist: - | fullname | shortname | category | - | Course 1 | C1 | 0 | + | fullname | shortname | category | enablecompletion | + | Course 1 | C1 | 0 | 1 | And the following "course enrolments" exist: | user | course | role | | student1 | C1 | student | | teacher1 | C1 | editingteacher | And the following config values are set as admin: | displayoptions | 0,1,2,3,4,5,6 | resource | - And I am on the "Course 1" course page logged in as teacher1 - And I navigate to "Settings" in current page administration - And I expand all fieldsets - And I set the following fields to these values: - | Enable completion tracking | Yes | - | Show activity completion conditions | No | - And I press "Save and display" @javascript Scenario Outline: The manual completion button will be shown on the course page for Open, In pop-up, New window and Force download display mode if Show activity completion conditions is set to No Given the following "activities" exist: | activity | course | name | display | showsize | showtype | showdate | completion | defaultfilename | popupwidth | popupheight | uploaded | | resource | C1 | Myfile | | 0 | 0 | 0 | 1 | mod/resource/tests/fixtures/samplefile.txt | 620 | 450 | 1 | - And I am on "Course 1" course homepage with editing mode on + And I am on the "Course 1" course page logged in as teacher1 # Teacher view. And the manual completion button for "Myfile" should exist And the manual completion button for "Myfile" should be disabled @@ -54,8 +47,7 @@ Feature: View activity completion information for file resources Given the following "activities" exist: | activity | course | name | display | defaultfilename | uploaded | | resource | C1 | Myfile | 1 | mod/resource/tests/fixtures/samplefile.txt | 1 | - And I am on "Course 1" course homepage with editing mode on - And I navigate to "Settings" in current page administration + And I am on the "Course 1" "course editing" page logged in as "teacher1" And I expand all fieldsets And I set the field "Show activity completion conditions" to "Yes" And I press "Save and display" @@ -82,7 +74,7 @@ Feature: View activity completion information for file resources Given the following "activities" exist: | activity | course | name | display | defaultfilename | uploaded | | resource | C1 | Myfile | 1 | mod/resource/tests/fixtures/samplefile.txt | 1 | - And I navigate to "Settings" in current page administration + And I am on the "Course 1" "course editing" page logged in as "teacher1" And I expand all fieldsets And I set the field "Show activity completion conditions" to "Yes" And I press "Save and display"