From 5a6481006d10ae0946ee13e2da75653f0c78f1a5 Mon Sep 17 00:00:00 2001 From: Angelia Dela Cruz Date: Fri, 7 Oct 2022 10:34:24 +0800 Subject: [PATCH 1/2] MDL-75912 behat: Wiki Behat tests now use generators Replace steps that manually add Wiki instances via the UI and use Behat generators. This improves the speed of the Behat test runs. --- admin/tool/usertours/tests/behat/tour_filter.feature | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/admin/tool/usertours/tests/behat/tour_filter.feature b/admin/tool/usertours/tests/behat/tour_filter.feature index cad3d64736f..fb59a64f050 100644 --- a/admin/tool/usertours/tests/behat/tour_filter.feature +++ b/admin/tool/usertours/tests/behat/tour_filter.feature @@ -152,14 +152,11 @@ Feature: Apply tour filters to a tour | fullname | shortname | format | enablecompletion | | Course 1 | C1 | topics | 1 | | Course 2 | C2 | topics | 1 | + And the following "activities" exist: + | activity | course | name | firstpagetitle | wikimode | + | wiki | C1 | Test wiki name | First page | collaborative | And I log in as "admin" - And I am on "Course 1" course homepage with editing mode on - And I add a "Wiki" to section "1" and I fill the form with: - | Wiki name | Test wiki name | - | Description | Test wiki description | - | First page name | First page | - | Wiki mode | Collaborative wiki | - And I am on "Course 2" course homepage + And I am on "Course 2" course homepage with editing mode on And I add a "Forum" to section "1" and I fill the form with: | Forum name | Test forum name | | Forum type | Standard forum for general use | From 725af41225641397236cbadfce11cb4f69013dd0 Mon Sep 17 00:00:00 2001 From: Angelia Dela Cruz Date: Fri, 7 Oct 2022 13:12:21 +0800 Subject: [PATCH 2/2] MDL-75912 behat: Wiki Behat tests optimised Behat cleanup and optimisation --- .../tests/behat/get_and_set_fields.feature | 21 +++++++------------ .../behat/collaborative_individual.feature | 19 ++++------------- mod/wiki/tests/behat/page_history.feature | 2 -- mod/wiki/tests/behat/preview_page.feature | 1 - .../reset_wiki_comments_tags_files.feature | 1 - .../behat/wiki_activity_completion.feature | 3 --- mod/wiki/tests/behat/wiki_comments.feature | 8 ++----- mod/wiki/tests/behat/wiki_search.feature | 7 ------- 8 files changed, 13 insertions(+), 49 deletions(-) diff --git a/admin/tool/behat/tests/behat/get_and_set_fields.feature b/admin/tool/behat/tests/behat/get_and_set_fields.feature index 63b237b81e8..3fd8eaa3cf0 100644 --- a/admin/tool/behat/tests/behat/get_and_set_fields.feature +++ b/admin/tool/behat/tests/behat/get_and_set_fields.feature @@ -30,10 +30,9 @@ Feature: Verify that all form fields values can be get and set | student2 | G2 | | student3 | G2 | And the following "activities" exist: - | activity | course | idnumber | name | intro | firstpagetitle | wikimode | visible | - | wiki | C1 | wiki1 | Test this one | Test this one | Test this one | collaborative | 0 | - And I log in as "admin" - And I am on the "Course 1" "reset" page + | activity | course | idnumber | name | firstpagetitle | wikimode | visible | + | wiki | C1 | wiki1 | Test this one | Test this one | collaborative | 0 | + And I am on the "Course 1" "reset" page logged in as admin # Select (multi-select) - Checking "the select box should contain". And I expand all fieldsets And the "Unenrol users" select box should contain "No roles" @@ -60,16 +59,14 @@ Feature: Verify that all form fields values can be get and set # Checkbox - Checking "I set the field" and "The field matches value" ticked. And I set the field "Force format" to "1" And I press "Save and return to course" - And I am on the "Test this one" "wiki activity" page - And I navigate to "Settings" in current page administration + And I am on the "Test this one" "wiki activity editing" page And I expand all fieldsets And the field "Force format" matches value "1" And the field "Force format" does not match value "" # Checkbox - Checking "I set the field" and "The field matches value" unticked. And I set the field "Force format" to "" And I press "Save and return to course" - And I am on the "Test this one" "wiki activity" page - And I navigate to "Settings" in current page administration + And I am on the "Test this one" "wiki activity editing" page And I expand all fieldsets And the field "Force format" matches value "" And the field "Force format" does not match value "1" @@ -77,8 +74,7 @@ Feature: Verify that all form fields values can be get and set And I set the following fields to these values: | Force format | 1 | And I press "Save and return to course" - And I am on the "Test this one" "wiki activity" page - And I navigate to "Settings" in current page administration + And I am on the "Test this one" "wiki activity editing" page And I expand all fieldsets And the following fields match these values: | Force format | 1 | @@ -88,8 +84,7 @@ Feature: Verify that all form fields values can be get and set And I set the following fields to these values: | Force format | | And I press "Save and return to course" - And I am on the "Test this one" "wiki activity" page - And I navigate to "Settings" in current page administration + And I am on the "Test this one" "wiki activity editing" page And I expand all fieldsets And the following fields match these values: | Force format | | @@ -142,8 +137,6 @@ Feature: Verify that all form fields values can be get and set And I navigate to "Settings" in current page administration And the field "Course ID number" matches value "Course id number" - Scenario: with JS disabled all form fields getters and setters works as expected - @javascript Scenario: with JS enabled all form fields getters and setters works as expected Then I am on the "Course 1" "groups" page diff --git a/mod/wiki/tests/behat/collaborative_individual.feature b/mod/wiki/tests/behat/collaborative_individual.feature index 2e8b8869495..8a0ef0dffe5 100644 --- a/mod/wiki/tests/behat/collaborative_individual.feature +++ b/mod/wiki/tests/behat/collaborative_individual.feature @@ -19,18 +19,10 @@ Feature: A teacher can set a wiki to be collaborative or individual | teacher1 | C1 | editingteacher | | student1 | C1 | student | | student2 | C1 | student | - And the following "activity" exists: - | course | C1 | - | activity | wiki | - | name | Collaborative wiki name | - | firstpagetitle | Collaborative index | - | wikimode | collaborative | - And the following "activity" exists: - | course | C1 | - | activity | wiki | - | name | Individual wiki name | - | firstpagetitle | Individual index | - | wikimode | individual | + And the following "activities" exist: + | activity | course | name | firstpagetitle | wikimode | + | wiki | C1 | Collaborative wiki name | Collaborative index | collaborative | + | wiki | C1 | Individual wiki name | Individual index | individual | And I am on the "Collaborative wiki name" "wiki activity" page logged in as teacher1 And I press "Create page" And I set the following fields to these values: @@ -41,7 +33,6 @@ Feature: A teacher can set a wiki to be collaborative or individual And I set the following fields to these values: | HTML format | Individual teacher1 edition | And I press "Save" - And I log out And I am on the "Collaborative wiki name" "wiki activity" page logged in as student1 Then I should see "Collaborative teacher1 edition" And I select "Edit" from the "jump" singleselect @@ -56,7 +47,6 @@ Feature: A teacher can set a wiki to be collaborative or individual And I set the following fields to these values: | HTML format | Individual student1 edition | And I press "Save" - And I log out And I am on the "Individual wiki name" "wiki activity" page logged in as student2 And I should not see "Individual teacher1 edition" And I should not see "Individual student1 edition" @@ -64,7 +54,6 @@ Feature: A teacher can set a wiki to be collaborative or individual And I set the following fields to these values: | HTML format | Individual student2 edition | And I press "Save" - And I log out And I am on the "Collaborative wiki name" "wiki activity" page logged in as teacher1 And I should see "Collaborative student1 edition" And I am on the "Individual wiki name" "wiki activity" page diff --git a/mod/wiki/tests/behat/page_history.feature b/mod/wiki/tests/behat/page_history.feature index a93c2228655..f12f2dd598b 100644 --- a/mod/wiki/tests/behat/page_history.feature +++ b/mod/wiki/tests/behat/page_history.feature @@ -30,13 +30,11 @@ Feature: A history of each wiki page is available And I set the following fields to these values: | HTML format | First edition | And I press "Save" - And I log out When I am on the "Test wiki name" "wiki activity" page logged in as student1 And I select "Edit" from the "jump" singleselect And I set the following fields to these values: | HTML format | Second edition | And I press "Save" - And I log out When I am on the "Test wiki name" "wiki activity" page logged in as student2 And I select "Edit" from the "jump" singleselect And I set the following fields to these values: diff --git a/mod/wiki/tests/behat/preview_page.feature b/mod/wiki/tests/behat/preview_page.feature index 3be647c35b1..c154e3c0b6b 100644 --- a/mod/wiki/tests/behat/preview_page.feature +++ b/mod/wiki/tests/behat/preview_page.feature @@ -20,7 +20,6 @@ Feature: Edited wiki pages may be previewed before saving | activity | wiki | | course | C1 | | name | Test wiki name | - | intro | Test wiki description | | wikimode | collaborative | And I am on the "Test wiki name" "wiki activity" page logged in as student1 When I press "Create page" diff --git a/mod/wiki/tests/behat/reset_wiki_comments_tags_files.feature b/mod/wiki/tests/behat/reset_wiki_comments_tags_files.feature index 9d51e6bbd7e..50af88e3aa9 100644 --- a/mod/wiki/tests/behat/reset_wiki_comments_tags_files.feature +++ b/mod/wiki/tests/behat/reset_wiki_comments_tags_files.feature @@ -18,7 +18,6 @@ Feature: Teachers can reset wiki pages, tags and files | activity | wiki | | course | C1 | | name | Test wiki name | - | intro | Test wiki description | | wikimode | collaborative | And I am on the "Test wiki name" "wiki activity" page logged in as teacher1 And I press "Create page" diff --git a/mod/wiki/tests/behat/wiki_activity_completion.feature b/mod/wiki/tests/behat/wiki_activity_completion.feature index 334df81ab85..e574210ce6e 100644 --- a/mod/wiki/tests/behat/wiki_activity_completion.feature +++ b/mod/wiki/tests/behat/wiki_activity_completion.feature @@ -21,12 +21,10 @@ Feature: View activity completion information in the Wiki activity | course | C1 | | idnumber | mh1 | | name | Music history | - | section | 1 | | completion | 2 | | completionview | 1 | And I am on the "Music history" "wiki activity" page logged in as teacher1 And I click on "Create page" "button" - And I log out Scenario: View automatic completion items as a teacher and confirm all tabs display conditions When I am on the "Music history" "wiki activity" page logged in as teacher1 @@ -57,7 +55,6 @@ Feature: View activity completion information in the Wiki activity And I press "Save and display" # 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" "wiki activity" page logged in as student1 Then the manual completion button of "Music history" is displayed as "Mark as done" diff --git a/mod/wiki/tests/behat/wiki_comments.feature b/mod/wiki/tests/behat/wiki_comments.feature index 2b9c864a241..858830127ca 100644 --- a/mod/wiki/tests/behat/wiki_comments.feature +++ b/mod/wiki/tests/behat/wiki_comments.feature @@ -22,7 +22,6 @@ Feature: Users can comment on wiki pages | activity | wiki | | course | C1 | | name | Test wiki name | - | intro | Test wiki description | | firstpagetitle | First page | | wikimode | collaborative | And I am on the "Test wiki name" "wiki activity" page logged in as teacher1 @@ -30,7 +29,6 @@ Feature: Users can comment on wiki pages And I set the following fields to these values: | HTML format | First edition | And I press "Save" - And I log out And I am on the "Test wiki name" "wiki activity" page logged in as student1 And I select "Comments" from the "jump" singleselect And I follow "Add comment" @@ -54,16 +52,14 @@ Feature: Users can comment on wiki pages @javascript Scenario: Student cannot edit another student's comment - When I log out - And I am on the "Test wiki name" "wiki activity" page logged in as student2 + When I am on the "Test wiki name" "wiki activity" page logged in as student2 And I select "Comments" from the "jump" singleselect Then "Edit" "link" should not exist in the "wiki-comments" "table" And "Delete" "link" should not exist in the "wiki-comments" "table" @javascript Scenario: Teacher can delete a student comment - When I log out - And I am on the "Test wiki name" "wiki activity" page logged in as teacher1 + When I am on the "Test wiki name" "wiki activity" page logged in as teacher1 And I select "Comments" from the "jump" singleselect Then "Edit" "link" should not exist in the "wiki-comments" "table" And "Delete" "link" should exist in the "wiki-comments" "table" diff --git a/mod/wiki/tests/behat/wiki_search.feature b/mod/wiki/tests/behat/wiki_search.feature index 47d10cd9108..6ad2b5e8b15 100644 --- a/mod/wiki/tests/behat/wiki_search.feature +++ b/mod/wiki/tests/behat/wiki_search.feature @@ -32,8 +32,6 @@ Feature: Users can search wikis And I set the following fields to these values: | HTML format | Collaborative teacher1 page [[new page]] | And I press "Save" - And I am on "Course 1" course homepage - And I log out And I am on the "Collaborative wiki name" "wiki activity" page logged in as student1 And I follow "new page" And I press "Create page" @@ -66,7 +64,6 @@ Feature: Users can search wikis And I set the following fields to these values: | HTML format | Individual teacher1 page | And I press "Save" - And I log out And I am on the "Individual wiki name" "wiki activity" page logged in as student1 And I press "Create page" And I set the following fields to these values: @@ -76,7 +73,6 @@ Feature: Users can search wikis And I press "Search wikis" Then I should see "Individual student1 page" And I should not see "Individual teacher1 page" - And I log out And I am on the "Individual wiki name" "wiki activity" page logged in as student2 And I press "Create page" And I set the following fields to these values: @@ -87,7 +83,6 @@ Feature: Users can search wikis And I should see "Individual student2 page" And I should not see "Individual student1 page" And I should not see "Individual teacher1 page" - And I log out And I am on the "Individual wiki name" "wiki activity" page logged in as teacher1 And I set the field "searchstring" to "page" And I press "Search wikis" @@ -136,7 +131,6 @@ Feature: Users can search wikis And I set the following fields to these values: | HTML format | Group2 teacher1 page [[new page2]] | And I press "Save" - And I log out And I am on the "Group wiki name" "wiki activity" page logged in as student1 And I follow "new page1" And I press "Create page" @@ -149,7 +143,6 @@ Feature: Users can search wikis And I should not see "Group2 teacher1 page" And I should see "Group1 student1 new page" And I should not see "All participants teacher1 page" - And I log out And I am on the "Group wiki name" "wiki activity" page logged in as student2 And I follow "new page2" And I press "Create page"