From 73a08e3ccda1ce14bf125553990f1a4d0973afea Mon Sep 17 00:00:00 2001 From: Angelia Dela Cruz Date: Mon, 19 Jun 2023 16:46:29 +0800 Subject: [PATCH 1/2] MDL-78498 Behat: Use data generators for forum posts and replies This commit does few things: * Replace manual forum posts and replies to use data generator. * It also changes the code to handle social forums. * Other behat clean-ups and optimization. Co-authored-by: Simey Lameze --- .../tests/behat/protecteddelete.feature | 38 ++++-------- .../social_adjust_discussion_count.feature | 11 ++-- .../graderescale_for_forum_pointscale.feature | 6 +- .../tests/behat/modgrade_validation.feature | 6 +- .../tests/behat/private_replies.feature | 25 ++++---- mod/forum/tests/behat/add_forum.feature | 24 ++++---- mod/forum/tests/behat/advanced_search.feature | 6 +- mod/forum/tests/behat/discussion_lock.feature | 17 +++--- .../tests/behat/discussion_navigation.feature | 55 +++++++++--------- .../behat/discussion_subscriptions.feature | 58 +++++++++---------- .../tests/behat/edit_post_student.feature | 7 ++- mod/forum/tests/behat/edit_tags.feature | 7 ++- .../tests/behat/favourite_discussion.feature | 26 ++++----- .../behat/forum_activity_breadcrumbs.feature | 23 ++++---- .../tests/behat/forum_subscriptions.feature | 14 ++--- mod/forum/tests/behat/guest_users.feature | 26 ++++----- .../behat/h5p_inline_editing_content.feature | 9 ++- mod/forum/tests/behat/move_discussion.feature | 12 ++-- mod/forum/tests/behat/my_forum_posts.feature | 12 ++-- .../behat/post_to_multiple_groups.feature | 4 +- .../behat/posts_ordering_general.feature | 13 +++-- mod/forum/tests/behat/private_replies.feature | 6 +- mod/forum/tests/behat/recent_activity.feature | 56 ++++++++---------- ...ate_group_single_group_discussions.feature | 12 ++-- .../tests/behat/timed_discussions.feature | 21 ++----- 25 files changed, 227 insertions(+), 267 deletions(-) diff --git a/admin/tool/dataprivacy/tests/behat/protecteddelete.feature b/admin/tool/dataprivacy/tests/behat/protecteddelete.feature index b4e36dde72d..978da609881 100644 --- a/admin/tool/dataprivacy/tests/behat/protecteddelete.feature +++ b/admin/tool/dataprivacy/tests/behat/protecteddelete.feature @@ -30,6 +30,12 @@ Feature: Protected data should not be deleted | Site purpose | PT1H | 0 | | prot | P1D | 1 | | unprot | P1D | 0 | + And the following "mod_forum > discussions" exist: + | user | forum | name | message | + | u1 | forump1 | Discussion subject | Test post in forump1 | + | u1 | forumu1 | Discussion subject | Test post in forumu1 | + | u1 | forump2 | Discussion subject | Test post in forump2 | + | u1 | forumu2 | Discussion subject | Test post in forumu2 | And I set the category and purpose for the "forump1" "forum" in course "C1" to "CAT" and "prot" And I set the category and purpose for the "forump2" "forum" in course "C2" to "CAT" and "prot" And I set the category and purpose for the "forumu1" "forum" in course "C1" to "CAT" and "unprot" @@ -38,47 +44,25 @@ Feature: Protected data should not be deleted @javascripta Scenario: Unexpired and protected data is not removed - Given I log in as "u1" - And I am on "C1" course homepage - And I add a new discussion to "forump1" forum with: - | Subject | Discussion subject | - | Message | Test post in forump1 | - And I am on "C1" course homepage - And I add a new discussion to "forumu1" forum with: - | Subject | Discussion subject | - | Message | Test post in forumu1 | - And I am on "C2" course homepage - And I add a new discussion to "forump2" forum with: - | Subject | Discussion subject | - | Message | Test post in forump2 | - And I am on "C2" course homepage - And I add a new discussion to "forumu2" forum with: - | Subject | Discussion subject | - | Message | Test post in forumu2 | - And I log out - And I log in as "admin" + Given I log in as "admin" And I create a dataprivacy "delete" request for "u1" And I approve a dataprivacy "delete" request for "u1" And I run all adhoc tasks And I navigate to "Users > Privacy and policies > Data requests" in site administration And I should see "Deleted" in the "u1" "table_row" - And I am on "C1" course homepage - And I follow "forump1" + And I am on the "forump1" "forum activity" page And I follow "Discussion subject" Then I should not see "Test post in forump1" - When I am on "C1" course homepage - And I follow "forumu1" + When I am on the "forumu1" "forum activity" page And I follow "Discussion subject" Then I should not see "Test post in forumu1" - And I am on "C2" course homepage - And I follow "forump2" + And I am on the "forump2" "forum activity" page And I follow "Discussion subject" Then I should see "Test post in forump2" - When I am on "C2" course homepage - And I follow "forumu2" + When I am on the "forumu2" "forum activity" page And I follow "Discussion subject" Then I should not see "Test post in forumu2" diff --git a/course/format/social/tests/behat/social_adjust_discussion_count.feature b/course/format/social/tests/behat/social_adjust_discussion_count.feature index 2fec3514751..07d11ae0182 100644 --- a/course/format/social/tests/behat/social_adjust_discussion_count.feature +++ b/course/format/social/tests/behat/social_adjust_discussion_count.feature @@ -105,11 +105,10 @@ Feature: Change number of discussions displayed | Message | This is forum post one | And I press "Post to forum" And I wait to be redirected - And I am on "Course 1" course homepage + And I am on the "C1" "course editing" page logged in as teacher1 Scenario: When number of discussions is decreased fewer discussions appear - Given I navigate to "Settings" in current page administration - And I set the following fields to these values: + Given I set the following fields to these values: | numdiscussions | 5 | When I press "Save and display" Then I should see "This is forum post one" @@ -117,8 +116,7 @@ Feature: Change number of discussions displayed And I should not see "This is forum post six" Scenario: When number of discussions is decreased to less than 1 only 1 discussion should appear - Given I navigate to "Settings" in current page administration - And I set the following fields to these values: + Given I set the following fields to these values: | numdiscussions | -1 | When I press "Save and display" Then I should see "This is forum post one" @@ -126,8 +124,7 @@ Feature: Change number of discussions displayed And I should not see "This is forum post ten" Scenario: When number of discussions is increased more discussions appear - Given I navigate to "Settings" in current page administration - And I set the following fields to these values: + Given I set the following fields to these values: | numdiscussions | 9 | When I press "Save and display" Then I should see "This is forum post one" diff --git a/lib/form/tests/behat/graderescale_for_forum_pointscale.feature b/lib/form/tests/behat/graderescale_for_forum_pointscale.feature index 62a7c3f4d9f..7e213d937f7 100644 --- a/lib/form/tests/behat/graderescale_for_forum_pointscale.feature +++ b/lib/form/tests/behat/graderescale_for_forum_pointscale.feature @@ -21,9 +21,9 @@ Feature: Using the forum activities which support point scale | activity | forum | | name | Test forum name | | idnumber | forum1 | - And the following forum discussions exist in course "Course 1": - | user | forum | name | message | - | student1 | Test forum name | Discussion subject | Test post in forum 1 | + And the following "mod_forum > discussions" exist: + | user | forum | name | message | + | student1 | forum1 | Discussion subject | Test post in forum 1 | @javascript Scenario: Forum rescale grade should not be possible when users are graded diff --git a/lib/form/tests/behat/modgrade_validation.feature b/lib/form/tests/behat/modgrade_validation.feature index 96b3245b395..41f36ca4a35 100644 --- a/lib/form/tests/behat/modgrade_validation.feature +++ b/lib/form/tests/behat/modgrade_validation.feature @@ -24,9 +24,9 @@ Feature: Using the activity grade form element | activity | course | section | name | intro | idnumber | type | groupmode | | assign | C1 | 1 | Test assignment name | Test assignment description | | | | | forum | C1 | 1 | Test forum name | | forum1 | general | 0 | - And the following forum discussions exist in course "Course 1": - | user | forum | name | message | - | student1 | Test forum name | Discussion subject | Discussion message | + And the following "mod_forum > discussions" exist: + | user | forum | name | message | + | student1 | forum1 | Discussion subject | Discussion message | @javascript Scenario: Being able to change the grade type, scale and maximum grade when there are no grades diff --git a/mod/forum/report/summary/tests/behat/private_replies.feature b/mod/forum/report/summary/tests/behat/private_replies.feature index 8979ca4ee13..c166db4d014 100644 --- a/mod/forum/report/summary/tests/behat/private_replies.feature +++ b/mod/forum/report/summary/tests/behat/private_replies.feature @@ -23,20 +23,17 @@ Feature: Include private replies in the summary report And the following "activities" exist: | activity | name | course | idnumber | | forum | forum1 | C1 | forum1 | - And the following forum discussions exist in course "Course 1": - | user | forum | name | message | - | teacher1 | forum1 | discussion1 | t1 earliest | - | teacher1 | forum1 | discussion2 | t1 between | - | student1 | forum1 | discussion3 | s1 latest | - And the following forum replies exist in course "Course 1": - | user | forum | discussion | subject | message | - | teacher1 | forum1 | discussion1 | t1 between | t1 between | - | teacher1 | forum1 | discussion2 | t1 latest | t1 latest | - | student1 | forum1 | discussion1 | s1 earliest | s1 earliest | - And I am on the "Course 1" course page logged in as teacher1 - And I reply "s1 earliest" post from "discussion1" forum with: - | Message | This is a private reply | - | Reply privately | 1 | + And the following "mod_forum > discussions" exist: + | user | forum | name | message | + | teacher1 | forum1 | discussion1 | t1 earliest | + | teacher1 | forum1 | discussion2 | t1 between | + | teacher1 | forum1 | discussion3 | s1 latest | + And the following "mod_forum > posts" exist: + | user | parentsubject | subject | message | privatereplyto | + | teacher1 | discussion1 | t1 between | t1 between | | + | teacher1 | discussion2 | t1 latest | t1 latest | | + | student1 | discussion1 | s1 earliest | s1 earliest | | + | teacher1 | s1 earliest | This is a private reply | This is a private reply | 1 | Scenario: Private replies are counted for Teacher When I am on the forum1 "forum activity" page logged in as teacher2 diff --git a/mod/forum/tests/behat/add_forum.feature b/mod/forum/tests/behat/add_forum.feature index 187cbd1dc66..e88dd30c7e3 100644 --- a/mod/forum/tests/behat/add_forum.feature +++ b/mod/forum/tests/behat/add_forum.feature @@ -17,16 +17,20 @@ Feature: Add forum activities and discussions | user | course | role | | teacher1 | C1 | editingteacher | | student1 | C1 | student | - And the following "activity" exists: - | activity | forum | - | course | C1 | - | name | Test forum name | - | type | general | - And the following forum discussions exist in course "Course 1": - | user | forum | name | message | attachments | - | teacher1 | Test forum name | Forum post 1 | this is the body | | - | student1 | Test forum name | Post with attachment | this is the body | empty.txt | - And I log in as "student1" + And I log in as "teacher1" + And I am on "Course 1" 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 | + | Description | Test forum description | + And I add a new discussion to "Test forum name" forum with: + | Subject | Forum post 1 | + | Message | This is the body | + And I am on the "Course 1" course page logged in as student1 + When I add a new discussion to "Test forum name" forum with: + | Subject | Post with attachment | + | Message | This is the body | + | Attachment | lib/tests/fixtures/empty.txt | And I reply "Forum post 1" post from "Test forum name" forum with: | Subject | Reply with attachment | | Message | This is the body | diff --git a/mod/forum/tests/behat/advanced_search.feature b/mod/forum/tests/behat/advanced_search.feature index 3b032263b9a..45f3bb5c405 100644 --- a/mod/forum/tests/behat/advanced_search.feature +++ b/mod/forum/tests/behat/advanced_search.feature @@ -117,8 +117,7 @@ Feature: The forum search allows users to perform advanced searches for forum po @javascript Scenario: Perform an advanced search on starred discussions without text Given I am on the "Announcements" "forum activity" page logged in as student1 - And I click on "Your subjective" action menu - And I follow "Star this discussion" + And I click on "Star this discussion" "link" in the "Your subjective" "table_row" And I press "Search" And I should see "Please enter search terms into one or more of the following fields" And I set the field "starredonly" to "1" @@ -129,8 +128,7 @@ Feature: The forum search allows users to perform advanced searches for forum po @javascript Scenario: Perform an advanced search on starred discussions with text Given I am on the "Announcements" "forum activity" page logged in as student1 - And I click on "Your subjective" action menu - And I follow "Star this discussion" + And I click on "Star this discussion" "link" in the "Your subjective" "table_row" And I press "Search" And I should see "Please enter search terms into one or more of the following fields" And I set the field "words" to "message" diff --git a/mod/forum/tests/behat/discussion_lock.feature b/mod/forum/tests/behat/discussion_lock.feature index 5adf1c9d837..92d90905903 100644 --- a/mod/forum/tests/behat/discussion_lock.feature +++ b/mod/forum/tests/behat/discussion_lock.feature @@ -15,14 +15,15 @@ Feature: As a teacher, you can manually lock individual discussions when viewing | course | C1 | | activity | forum | | name | Test forum name | - And the following forum discussions exist in course "Course 1": - | user | forum | name | message | - | admin | Test forum name | Discussion 1 | Discussion contents 1, first message | - | admin | Test forum name | Discussion 2 | Discussion contents 2, first message | - And the following forum replies exist in course "Course 1": - | user | forum | discussion | subject | message | - | admin | Test forum name | Discussion 1 | Reply 1 to discussion 1 | Discussion contents 1, second message | - | admin | Test forum name | Discussion 2 | Reply 1 to discussion 2 | Discussion contents 2, second message | + | idnumber | forum1 | + And the following "mod_forum > discussions" exist: + | user | forum | name | message | + | admin | forum1 | Discussion 1 | Discussion contents 1, first message | + | admin | forum1 | Discussion 2 | Discussion contents 2, first message | + And the following "mod_forum > posts" exist: + | user | parentsubject | subject | message | + | admin | Discussion 1 | Reply 1 to discussion 1 | Discussion contents 1, second message | + | admin | Discussion 2 | Reply 1 to discussion 2 | Discussion contents 2, second message | Scenario: Lock a discussion and view Given I am on the "Course 1" course page logged in as admin diff --git a/mod/forum/tests/behat/discussion_navigation.feature b/mod/forum/tests/behat/discussion_navigation.feature index 60759e8f11c..4caa84a7081 100644 --- a/mod/forum/tests/behat/discussion_navigation.feature +++ b/mod/forum/tests/behat/discussion_navigation.feature @@ -33,19 +33,12 @@ Feature: A user can navigate to previous and next discussions Given the following "activities" exist: | activity | name | course | idnumber | groupmode | | forum | Test forum name | C1 | forum | 0 | + And the following "mod_forum > discussions" exist: + | user | forum | name | message | + | teacher1 | forum | Discussion 1 | Test post message | + | teacher1 | forum | Discussion 2 | Test post message | + | teacher1 | forum | Discussion 3 | Test post message | And I am on the "Test forum name" "forum activity" page logged in as teacher1 - And I add a new discussion to "Test forum name" forum with: - | Subject | Discussion 1 | - | Message | Test post message | - And I wait "1" seconds - And I add a new discussion to "Test forum name" forum with: - | Subject | Discussion 2 | - | Message | Test post message | - And I wait "1" seconds - And I add a new discussion to "Test forum name" forum with: - | Subject | Discussion 3 | - | Message | Test post message | - And I wait "1" seconds When I follow "Discussion 3" Then I should not see "Discussion 1" And I should see "Discussion 2" @@ -72,14 +65,16 @@ Feature: A user can navigate to previous and next discussions Given the following "activities" exist: | activity | name | course | idnumber | groupmode | | forum | Test forum name | C1 | forum | 2 | - And the following forum discussions exist in course "Course 1": - | user | forum | name | message | group | - | teacher1 | Test forum name | Discussion 1 Group 0 | Test post message | | - | teacher1 | Test forum name | Discussion 2 Group 0 | Test post message | | - | teacher1 | Test forum name | Discussion 1 Group 1 | Test post message | G1 | - | teacher1 | Test forum name | Discussion 2 Group 1 | Test post message | G1 | - | teacher1 | Test forum name | Discussion 1 Group 2 | Test post message | G2 | - | teacher1 | Test forum name | Discussion 2 Group 2 | Test post message | G2 | + And the following "mod_forum > discussions" exist: + | user | forum | name | message | + | student1 | forum | Discussion 1 Group 0 | Test post message | + | student1 | forum | Discussion 2 Group 0 | Test post message | + And the following "mod_forum > discussions" exist: + | user | forum | name | message | group | + | student1 | forum | Discussion 1 Group 1 | Test post message | G1 | + | student1 | forum | Discussion 2 Group 1 | Test post message | G1 | + | student1 | forum | Discussion 1 Group 2 | Test post message | G2 | + | student1 | forum | Discussion 2 Group 2 | Test post message | G2 | When I am on the "Test forum name" "forum activity" page logged in as student1 And I select "All participants" from the "Visible groups" singleselect And I follow "Discussion 1 Group 0" @@ -99,7 +94,7 @@ Feature: A user can navigate to previous and next discussions And I follow "Test forum name" And I select "Group 1" from the "Visible groups" singleselect And I follow "Discussion 1 Group 1" - Then I should see "Discussion 2 Group 0" + And I should see "Discussion 2 Group 0" And I should see "Discussion 2 Group 1" And I follow "Discussion 2 Group 1" And I should see "Discussion 1 Group 1" @@ -109,14 +104,16 @@ Feature: A user can navigate to previous and next discussions Given the following "activities" exist: | activity | name | course | idnumber | groupmode | | forum | Test forum name | C1 | forum | 1 | - And the following forum discussions exist in course "Course 1": - | user | forum | name | message | group | - | teacher1 | Test forum name | Discussion 1 Group 0 | Test post message | | - | teacher1 | Test forum name | Discussion 2 Group 0 | Test post message | | - | teacher1 | Test forum name | Discussion 1 Group 1 | Test post message | G1 | - | teacher1 | Test forum name | Discussion 2 Group 1 | Test post message | G1 | - | teacher1 | Test forum name | Discussion 1 Group 2 | Test post message | G2 | - | teacher1 | Test forum name | Discussion 2 Group 2 | Test post message | G2 | + And the following "mod_forum > discussions" exist: + | user | forum | name | message | + | student1 | forum | Discussion 1 Group 0 | Test post message | + | student1 | forum | Discussion 2 Group 0 | Test post message | + And the following "mod_forum > discussions" exist: + | user | forum | name | message | group | + | student1 | forum | Discussion 1 Group 1 | Test post message | G1 | + | student1 | forum | Discussion 2 Group 1 | Test post message | G1 | + | student1 | forum | Discussion 1 Group 2 | Test post message | G2 | + | student1 | forum | Discussion 2 Group 2 | Test post message | G2 | When I am on the "Test forum name" "forum activity" page logged in as student1 And I follow "Discussion 1 Group 1" Then I should see "Discussion 2 Group 0" diff --git a/mod/forum/tests/behat/discussion_subscriptions.feature b/mod/forum/tests/behat/discussion_subscriptions.feature index e708d8af71b..198d2495c6e 100644 --- a/mod/forum/tests/behat/discussion_subscriptions.feature +++ b/mod/forum/tests/behat/discussion_subscriptions.feature @@ -24,10 +24,10 @@ Feature: A user can control their own subscription preferences for a discussion | name | Test forum name | | type | general | | forcesubscribe | 0 | - And the following forum discussions exist in course "Course 1": - | user | forum | name | message | - | admin | Test forum name | Test post subject one | Test post message one | - | admin | Test forum name | Test post subject two | Test post message two | + And the following "mod_forum > discussions" exist: + | user | forum | name | message | + | admin | forum1 | Test post subject one | Test post message one | + | admin | forum1 | Test post subject two | Test post message two | When I am on the "Test forum name" "forum activity" page logged in as student1 Then I can subscribe to this forum And "Subscribe to this discussion" "checkbox" should exist in the "Test post subject one" "table_row" @@ -64,10 +64,10 @@ Feature: A user can control their own subscription preferences for a discussion | name | Test forum name | | type | general | | forcesubscribe | 2 | - And the following forum discussions exist in course "Course 1": - | user | forum | name | message | - | admin | Test forum name | Test post subject one | Test post message one | - | admin | Test forum name | Test post subject two | Test post message two | + And the following "mod_forum > discussions" exist: + | user | forum | name | message | + | admin | forum1 | Test post subject one | Test post message one | + | admin | forum1 | Test post subject two | Test post message two | When I am on the "Test forum name" "forum activity" page logged in as student1 Then I can unsubscribe from this forum And "Unsubscribe from this discussion" "checkbox" should exist in the "Test post subject one" "table_row" @@ -104,10 +104,10 @@ Feature: A user can control their own subscription preferences for a discussion | name | Test forum name | | type | general | | forcesubscribe | 0 | - And the following forum discussions exist in course "Course 1": - | user | forum | name | message | - | admin | Test forum name | Test post subject one | Test post message one | - | admin | Test forum name | Test post subject two | Test post message two | + And the following "mod_forum > discussions" exist: + | user | forum | name | message | + | admin | forum1 | Test post subject one | Test post message one | + | admin | forum1 | Test post subject two | Test post message two | And I am on the "Test forum name" "forum activity" page logged in as student1 And I can subscribe to this forum And "Subscribe to this discussion" "checkbox" should exist in the "Test post subject one" "table_row" @@ -138,10 +138,10 @@ Feature: A user can control their own subscription preferences for a discussion | name | Test forum name | | type | general | | forcesubscribe | 0 | - And the following forum discussions exist in course "Course 1": - | user | forum | name | message | - | admin | Test forum name | Test post subject one | Test post message one | - | admin | Test forum name | Test post subject two | Test post message two | + And the following "mod_forum > discussions" exist: + | user | forum | name | message | + | admin | forum1 | Test post subject one | Test post message one | + | admin | forum1 | Test post subject two | Test post message two | When I am on the "Test forum name" "forum activity" page logged in as student1 And I should see "Subscribe to forum" And I reply "Test post subject one" post from "Test forum name" forum with: @@ -171,10 +171,10 @@ Feature: A user can control their own subscription preferences for a discussion | name | Test forum name | | type | general | | forcesubscribe | 2 | - And the following forum discussions exist in course "Course 1": - | user | forum | name | message | - | admin | Test forum name | Test post subject one | Test post message one | - | admin | Test forum name | Test post subject two | Test post message two | + And the following "mod_forum > discussions" exist: + | user | forum | name | message | + | admin | forum1 | Test post subject one | Test post message one | + | admin | forum1 | Test post subject two | Test post message two | # added for this scenario And the following "users" exist: | username | firstname | lastname | email | @@ -207,9 +207,9 @@ Feature: A user can control their own subscription preferences for a discussion Given the following "activities" exist: | activity | name | course | section | idnumber | type | | forum | Test forum name | Acceptance test site | 1 | forum1 | general | - And the following forum discussions exist in course "Acceptance test site": - | user | forum | name | message | - | admin | Test forum name | Test post subject one | Test post message one | + And the following "mod_forum > discussions" exist: + | user | forum | name | message | + | admin | forum1 | Test post subject one | Test post message one | When I am on the "Test forum name" "forum activity" page logged in as guest Then "Subscribe to this discussion" "checkbox" should not exist in the "Test post subject one" "table_row" And "Unsubscribe from this discussion" "checkbox" should not exist in the "Test post subject one" "table_row" @@ -221,9 +221,9 @@ Feature: A user can control their own subscription preferences for a discussion Given the following "activities" exist: | activity | name | course | section | idnumber | type | | forum | Test forum name | Acceptance test site | 1 | forum1 | general | - And the following forum discussions exist in course "Acceptance test site": - | user | forum | name | message | - | admin | Test forum name | Test post subject one | Test post message one | + And the following "mod_forum > discussions" exist: + | user | forum | name | message | + | admin | forum1 | Test post subject one | Test post message one | When I am on site homepage And I follow "Test forum name" Then "Subscribe to this discussion" "checkbox" should not exist in the "Test post subject one" "table_row" @@ -240,9 +240,9 @@ Feature: A user can control their own subscription preferences for a discussion | name | Test forum name | | type | general | | forcesubscribe | 0 | - And the following forum discussions exist in course "Course 1": - | user | forum | name | message | - | admin | Test forum name | Test post subject one | Test post message one | + And the following "mod_forum > discussions" exist: + | user | forum | name | message | + | admin | forum1 | Test post subject one | Test post message one | When I am on the "Test forum name" "forum activity" page logged in as student1 Then "Subscribe to forum" "link" should exist And I follow "Test post subject one" diff --git a/mod/forum/tests/behat/edit_post_student.feature b/mod/forum/tests/behat/edit_post_student.feature index 1e866bc520e..af0cdddb1e9 100644 --- a/mod/forum/tests/behat/edit_post_student.feature +++ b/mod/forum/tests/behat/edit_post_student.feature @@ -18,9 +18,10 @@ Feature: Students can edit or delete their forum posts within a set time limit | activity | name | course | idnumber | | forum | Test forum name | C1 | forum | And I am on the "Course 1" course page logged in as student1 - And I add a new discussion to "Test forum name" forum with: - | Subject | Forum post subject | - | Message | This is the body | + And the following "mod_forum > discussions" exist: + | user | forum | name | message | + | student1 | forum | Forum post subject | This is the body | + And I am on the "Test forum name" "forum activity" page Scenario: Edit forum post Given I follow "Forum post subject" diff --git a/mod/forum/tests/behat/edit_tags.feature b/mod/forum/tests/behat/edit_tags.feature index 94dc1b4d128..83a6d60d5a0 100644 --- a/mod/forum/tests/behat/edit_tags.feature +++ b/mod/forum/tests/behat/edit_tags.feature @@ -20,9 +20,10 @@ Feature: Edited forum posts handle tags correctly | course | C1 | | activity | forum | | name | Test forum name | - And the following forum discussions exist in course "Course 1": - | user | forum | name | message | - | teacher1 | Test forum name | Teacher post subject | Teacher post message | + | idnumber | forum1 | + And the following "mod_forum > discussions" exist: + | user | forum | name | message | + | teacher1 | forum1 | Teacher post subject | Teacher post message | @javascript Scenario: Forum post edition of custom tags works as expected diff --git a/mod/forum/tests/behat/favourite_discussion.feature b/mod/forum/tests/behat/favourite_discussion.feature index eaf3822f404..b1743cf9555 100644 --- a/mod/forum/tests/behat/favourite_discussion.feature +++ b/mod/forum/tests/behat/favourite_discussion.feature @@ -15,19 +15,17 @@ Feature: A student can favourite a discussion via the forum settings menu | course | C1 | | activity | forum | | name | Test forum name | - And the following forum discussions exist in course "Course 1": - | user | forum | name | message | - | admin | Test forum name | Discussion 1 | Discussion contents 1, first message | - And the following forum replies exist in course "Course 1": - | user | forum | discussion | name | message | - | admin | Test forum name | Discussion 1 | Reply 1 to discussion 1 | Discussion contents 1, second message | + | idnumber | forum1 | + And the following "mod_forum > discussions" exist: + | user | forum | name | message | + | admin | forum1 | Discussion 1 | Discussion contents 1, first message | + And the following "mod_forum > posts" exist: + | user | parentsubject | subject | message | + | admin | Discussion 1 | Reply 1 to discussion 1 | Discussion contents 1, second message | + | student1 | Discussion 1 | Reply 2 to discussion 1 | Discussion contents 1, third message | Scenario: Student can favourite a discussion from within an individual discussion - Given I am on the "Course 1" Course page logged in as student1 - And I reply "Discussion 1" post from "Test forum name" forum with: - | Subject | Reply 2 to discussion 1 | - | Message | Discussion contents 1, third message | - And I wait until the page is ready + Given I am on the "Test forum name" "forum activity" page logged in as student1 When I open the action menu in "[data-container='discussion-tools']" "css_element" And I click on "[title='Star this discussion']" "css_element" And I wait "3" seconds @@ -35,11 +33,7 @@ Feature: A student can favourite a discussion via the forum settings menu And I click on "[title='Unstar this discussion']" "css_element" Scenario: Student can favourite a discussion from the discussion list - Given I am on the "Course 1" Course page logged in as student1 - And I reply "Discussion 1" post from "Test forum name" forum with: - | Subject | Reply 2 to discussion 1 | - | Message | Discussion contents 1, third message | - When I am on the "Test forum name" "forum activity" page + When I am on the "Test forum name" "forum activity" page logged in as student1 And I click on "Discussion 1" action menu And I click on "[title='Star this discussion']" "css_element" And I click on "Discussion 1" action menu diff --git a/mod/forum/tests/behat/forum_activity_breadcrumbs.feature b/mod/forum/tests/behat/forum_activity_breadcrumbs.feature index ca01b8ce908..f84c1076364 100644 --- a/mod/forum/tests/behat/forum_activity_breadcrumbs.feature +++ b/mod/forum/tests/behat/forum_activity_breadcrumbs.feature @@ -12,9 +12,10 @@ Feature: A teacher or admin can view breadcrumbs in the reply, delete, split, ed | user | course | role | | teacher | C1 | editingteacher | And the following "activity" exists: - | course | C1 | - | activity | forum | - | name | Test forum name | + | course | C1 | + | activity | forum | + | name | Test forum name | + | idnumber | forum1 | Scenario: A teacher views add discussion topics advanced page Given I am on the "Test forum name" "forum activity" page logged in as teacher @@ -25,14 +26,14 @@ Feature: A teacher or admin can view breadcrumbs in the reply, delete, split, ed And I should see "Test forum name" in the ".breadcrumb" "css_element" Scenario: A teacher adds posts and then verifies the breadcrumbs in the links - Given I am on the "Course 1" course page logged in as teacher - And I add a new discussion to "Test forum name" forum with: - | Subject | Test post subject one | - | Message | Test post message one | - And I reply "Test post subject one" post from "Test forum name" forum with: - | Subject | Reply 1 to discussion 1 | - | Message | Discussion contents 1, second message | - And I should see "Settings" in the "//div[@class='ml-auto dropdown']" "xpath_element" + Given the following "mod_forum > discussions" exist: + | user | forum | name | message | + | teacher | forum1 | Test post subject one | Test post message one | + And the following "mod_forum > posts" exist: + | user | parentsubject | subject | message | + | teacher | Test post subject one | Reply 1 to discussion 1 | Discussion contents 1, second message | + And I am on the "Test forum name" "forum activity" page logged in as teacher + And I follow "Test post subject one" When I follow "Edit" Then I should see "Edit discussion topic" And I should see "Edit discussion topic" in the ".breadcrumb" "css_element" diff --git a/mod/forum/tests/behat/forum_subscriptions.feature b/mod/forum/tests/behat/forum_subscriptions.feature index d6d1d84727d..8af07c1a342 100644 --- a/mod/forum/tests/behat/forum_subscriptions.feature +++ b/mod/forum/tests/behat/forum_subscriptions.feature @@ -20,11 +20,10 @@ Feature: A user can control their own subscription preferences for a forum And the following "mod_forum > discussions" exist: | forum | course | user | name | message | | forum1 | C1 | admin | Test post subject | Test post message | - And I log in as "admin" + And I am on the "Test forum name" "forum activity editing" page logged in as admin Scenario: A disallowed subscription forum cannot be subscribed to - Given I am on the "Test forum name" "forum activity editing" page - And I set the following fields to these values: + Given I set the following fields to these values: | Subscription mode | Subscription disabled | And I press "Save and return to course" When I am on the "Test forum name" "forum activity" page logged in as student1 @@ -34,8 +33,7 @@ Feature: A user can control their own subscription preferences for a forum And "You are not subscribed to this discussion. Click to subscribe." "link" should not exist in the "Test post subject" "table_row" Scenario: A forced subscription forum cannot be subscribed to - Given I am on the "Test forum name" "forum activity editing" page - And I set the following fields to these values: + Given I set the following fields to these values: | Subscription mode | Forced subscription | And I press "Save and return to course" When I am on the "Test forum name" "forum activity" page logged in as student1 @@ -45,8 +43,7 @@ Feature: A user can control their own subscription preferences for a forum And "You are not subscribed to this discussion. Click to subscribe." "link" should not exist in the "Test post subject" "table_row" Scenario: An optional forum can be subscribed to - Given I am on the "Test forum name" "forum activity editing" page - And I set the following fields to these values: + Given I set the following fields to these values: | Subscription mode | Optional subscription | And I press "Save and return to course" When I am on the "Test forum name" "forum activity" page logged in as student1 @@ -58,8 +55,7 @@ Feature: A user can control their own subscription preferences for a forum And I should not see "Subscribe to forum" Scenario: An Automatic forum can be unsubscribed from - Given I am on the "Test forum name" "forum activity editing" page - And I set the following fields to these values: + Given I set the following fields to these values: | Subscription mode | Auto subscription | And I press "Save and return to course" When I am on the "Test forum name" "forum activity" page logged in as student1 diff --git a/mod/forum/tests/behat/guest_users.feature b/mod/forum/tests/behat/guest_users.feature index aba0defa276..88cc39e25fd 100644 --- a/mod/forum/tests/behat/guest_users.feature +++ b/mod/forum/tests/behat/guest_users.feature @@ -23,9 +23,9 @@ Feature: Guest and not logged users could see the option to add new post or repl Given the following "activities" exist: | activity | name | course | idnumber | type | | forum | Forum | C1 | forum | | - And I add a new discussion to "Forum" forum with: - | Subject | Forum discussion 1 | - | Message | How awesome is this forum discussion? | + And the following "mod_forum > discussions" exist: + | user | forum | name | message | + | teacher | forum | Forum discussion 1 | How awesome is this forum discussion? | And I log out And I am on "Course 1" course homepage When I press "Access as a guest" @@ -56,10 +56,10 @@ Feature: Guest and not logged users could see the option to add new post or repl Scenario: As a not enrolled guest I don't see the option to add a new discussion in a blog type forum Given the following "activities" exist: | activity | name | course | idnumber | type | - | forum | Forum | C1 | forum | blog | - And I add a new discussion to "Forum" forum with: - | Subject | Forum discussion 1 | - | Message | How awesome is this forum discussion? | + | forum | Forum | C1 | forum | blog | + And the following "mod_forum > discussions" exist: + | user | forum | name | message | + | teacher | forum | Forum discussion 1 | How awesome is this forum discussion? | And I log out And I am on "Course 1" course homepage When I press "Access as a guest" @@ -74,9 +74,9 @@ Feature: Guest and not logged users could see the option to add new post or repl And the following "activities" exist: | activity | name | course | idnumber | type | | forum | Forum | C1 | forum | | - And I add a new discussion to "Forum" forum with: - | Subject | Forum discussion 1 | - | Message | How awesome is this forum discussion? | + And the following "mod_forum > discussions" exist: + | user | forum | name | message | + | teacher | forum | Forum discussion 1 | How awesome is this forum discussion? | And I log out And I am on "Course 1" course homepage When I press "Access as a guest" @@ -125,9 +125,9 @@ Feature: Guest and not logged users could see the option to add new post or repl And the following "activities" exist: | activity | name | course | idnumber | type | | forum | Forum | C1 | forum | blog | - And I add a new discussion to "Forum" forum with: - | Subject | Forum discussion 1 | - | Message | How awesome is this forum discussion? | + And the following "mod_forum > discussions" exist: + | user | forum | name | message | + | teacher | forum | Forum discussion 1 | How awesome is this forum discussion? | And I log out And I am on "Course 1" course homepage When I press "Access as a guest" diff --git a/mod/forum/tests/behat/h5p_inline_editing_content.feature b/mod/forum/tests/behat/h5p_inline_editing_content.feature index 92868c04481..69728bc3328 100644 --- a/mod/forum/tests/behat/h5p_inline_editing_content.feature +++ b/mod/forum/tests/behat/h5p_inline_editing_content.feature @@ -73,9 +73,13 @@ Feature: Inline editing H5P content in mod_forum @javascript @repository_contentbank Scenario: Edit H5P content from a forum post + Given the following "mod_forum > discussions" exist: + | user | forum | name | message | + | admin | 1 | Forum post by admin | Forum post by admin | Given I am on the "ForumName1" "forum activity" page logged in as admin + And I follow "Forum post by admin" + And I click on "Edit" "link" # Add H5P content to a forum post as admin. - And I click on "Add discussion topic" "link" And I set the following fields to these values: | Subject | Forum post by admin | And I click on "Insert H5P" "button" in the "#fitem_id_message" "css_element" @@ -84,8 +88,7 @@ Feature: Inline editing H5P content in mod_forum And I click on "Greeting card" "file" in repository content area And I click on "Select this file" "button" And I click on "Insert H5P" "button" in the "Insert H5P" "dialogue" - And I press "Post to forum" - And I follow "Forum post by admin" + And I press "Save changes" And I switch to "h5p-iframe" class iframe And I switch to "h5p-iframe" class iframe And I should see "Hello world!" diff --git a/mod/forum/tests/behat/move_discussion.feature b/mod/forum/tests/behat/move_discussion.feature index 9a823319d8a..d773716fc2d 100644 --- a/mod/forum/tests/behat/move_discussion.feature +++ b/mod/forum/tests/behat/move_discussion.feature @@ -19,12 +19,12 @@ Feature: A teacher can move discussions between forums Scenario: A teacher can move discussions Given the following "activities" exist: - | activity | name | course | idnumber | groupmode | - | forum | Test forum 1 | C1 | forum | 0 | - | forum | Test forum 2 | C1 | forum | 0 | - And the following forum discussions exist in course "Course 1": - | user | forum | name | message | - | student1 | Test forum 1 | Discussion 1 | Test post message | + | activity | name | course | idnumber | groupmode | + | forum | Test forum 1 | C1 | forum1 | 0 | + | forum | Test forum 2 | C1 | forum2 | 0 | + And the following "mod_forum > discussions" exist: + | user | forum | name | message | + | student1 | forum1 | Discussion 1 | Test post message | And I am on the "Test forum 1" "forum activity" page logged in as teacher1 And I follow "Discussion 1" When I set the field "jump" to "Test forum 2" diff --git a/mod/forum/tests/behat/my_forum_posts.feature b/mod/forum/tests/behat/my_forum_posts.feature index 35a1d0afe7f..27cbdcc3b94 100644 --- a/mod/forum/tests/behat/my_forum_posts.feature +++ b/mod/forum/tests/behat/my_forum_posts.feature @@ -17,12 +17,12 @@ Feature: A user can view their posts and discussions And the following "activities" exist: | activity | name | course | idnumber | groupmode | | forum | Test forum name | C1 | forum | 0 | - And the following forum discussions exist in course "Course 1": - | user | forum | name | message | - | student1 | Test forum name | Forum discussion 1 | How awesome is this forum discussion? | - And the following forum replies exist in course "Course 1": - | user | forum | discussion | message | - | student1 | Test forum name | Forum discussion 1 | Actually, I've seen better. | + And the following "mod_forum > discussions" exist: + | user | forum | name | message | + | student1 | forum | Forum discussion 1 | How awesome is this forum discussion? | + And the following "mod_forum > posts" exist: + | user | parentsubject | subject | message | + | student1 | Forum discussion 1 | Actually, I've seen better. | Actually, I've seen better. | And I log in as "student1" When I follow "Profile" in the user menu And I follow "Forum posts" diff --git a/mod/forum/tests/behat/post_to_multiple_groups.feature b/mod/forum/tests/behat/post_to_multiple_groups.feature index e5da6205963..b191a6f4b66 100644 --- a/mod/forum/tests/behat/post_to_multiple_groups.feature +++ b/mod/forum/tests/behat/post_to_multiple_groups.feature @@ -79,12 +79,12 @@ Feature: A user with access to multiple groups should be able to post a copy of Then I should see "Discussion 1" And I am on the "Visible group forum" "forum activity" page logged in as student2 And I should see "Discussion 1" - And I am on the "Visible group forum" "forum activity" page logged in as student2 + And I am on the "Visible group forum" "forum activity" page logged in as student3 And I should see "Discussion 1" Scenario: Teacher is unable to post a copy of a message to all groups in a no group forum Given I am on the "No group forum" "forum activity" page logged in as teacher1 - And I click on "Add discussion topic" "link" + When I click on "Add discussion topic" "link" Then I should not see "Post a copy to all groups" Scenario: Posts to all groups that have groupings should only display within the grouping and not to other groups diff --git a/mod/forum/tests/behat/posts_ordering_general.feature b/mod/forum/tests/behat/posts_ordering_general.feature index a577be71de4..7bf0bf286ac 100644 --- a/mod/forum/tests/behat/posts_ordering_general.feature +++ b/mod/forum/tests/behat/posts_ordering_general.feature @@ -20,14 +20,15 @@ Feature: New discussions and discussions with recently added replies are display | course | C1 | | activity | forum | | name | Course general forum | + | idnumber | forum1 | # # Add three posts into the blog. # - And the following forum discussions exist in course "Course 1": - | user | forum | name | message | timemodified | - | student1 | Course general forum | Forum post 1 | This is the first post | ##now +1 second## | - | student1 | Course general forum | Forum post 2 | This is the second post | ##now +2 second## | - | student1 | Course general forum | Forum post 3 | This is the third post | ##now +3 second## | + And the following "mod_forum > discussions" exist: + | user | forum | name | message | timemodified | + | student1 | forum1 | Forum post 1 | This is the first post | ##now +1 second## | + | student1 | forum1 | Forum post 2 | This is the second post | ##now +2 second## | + | student1 | forum1 | Forum post 3 | This is the third post | ##now +3 second## | # # We need javascript/wait to prevent creation of the posts in the same second. The threads @@ -51,7 +52,7 @@ Feature: New discussions and discussions with recently added replies are display # And I am on the "Course general forum" "forum activity" page logged in as teacher1 And I follow "Forum post 1" - And I reply "Forum post 1" post from "Course general forum" forum with: + When I reply "Forum post 1" post from "Course general forum" forum with: | Message | Reply to the first post | And I am on the "Course general forum" "forum activity" page # diff --git a/mod/forum/tests/behat/private_replies.feature b/mod/forum/tests/behat/private_replies.feature index 9abe1d0d4ec..ec64e3632bc 100644 --- a/mod/forum/tests/behat/private_replies.feature +++ b/mod/forum/tests/behat/private_replies.feature @@ -23,9 +23,9 @@ Feature: Forum posts can be replied to in private | teacher2 | C1 | editingteacher | | student1 | C1 | student | | student2 | C1 | student | - And the following forum discussions exist in course "Science 101": - | user | forum | name | message | - | student1 | Study discussions | Answers to the homework | Here are the answers to last night's homework. | + And the following "mod_forum > discussions" exist: + | user | forum | name | message | + | student1 | forum | Answers to the homework | Here are the answers to last night's homework. | And I am on the "Science 101" course page logged in as teacher1 And I reply "Answers to the homework" post from "Study discussions" forum with: | Message | How about you and I have a meeting after class about plagiarism? | diff --git a/mod/forum/tests/behat/recent_activity.feature b/mod/forum/tests/behat/recent_activity.feature index 86574b8e6c2..8769e57af18 100644 --- a/mod/forum/tests/behat/recent_activity.feature +++ b/mod/forum/tests/behat/recent_activity.feature @@ -41,33 +41,30 @@ Feature: Users can see the relevant recent forum posts from the recent activity And I log in as "teacher1" Scenario: Recent forum activity with separate group discussion - Given I add a new discussion to "Separate groups forum" forum with: - | Subject | Group 1 separate discussion | - | Message | Group 1 members only | - | Group | Group 1 | + Given the following "mod_forum > discussions" exist: + | user | forum | name | message | group | + | teacher1 | forum1 | Group 1 separate discussion | Group 1 members only | G1 | When I am on the "Course 1" course page logged in as student1 Then I should see "Group 1 separate discussion" in the "Recent activity" "block" And I am on the "Course 1" course page logged in as student2 And I should not see "Group 1 separate discussion" in the "Recent activity" "block" Scenario: Recent forum activity with visible groups discussion - Given I add a new discussion to "Visible groups forum" forum with: - | Subject | Group 1 visible discussion | - | Message | Not just for group 1 members | - | Group | Group 1 | + Given the following "mod_forum > discussions" exist: + | user | forum | name | message | group | + | teacher1 | forum2 | Group 1 visible discussion | Not just for group 1 members | G1 | When I am on the "Course 1" course page logged in as student1 Then I should see "Group 1 visible discussion" in the "Recent activity" "block" And I am on the "Course 1" course page logged in as student2 And I should see "Group 1 visible discussion" in the "Recent activity" "block" Scenario: Recent forum activity with recent post as a private reply - Given I add a new discussion to "Standard forum" forum with: - | Subject | Standard forum discussion | - | Message | Discuss anything under the sun here! | - And I reply "Standard forum discussion" post from "Standard forum" forum with: - | Subject | Teacher's private reply | - | Message | This is a private reply | - | Reply privately | 1 | + Given the following "mod_forum > discussions" exist: + | user | forum | name | message | + | teacher1 | forum3 | Standard forum discussion | Discuss anything under the sun here! | + And the following "mod_forum > posts" exist: + | user | parentsubject | subject | message | privatereplyto | + | teacher1 | Standard forum discussion | Teacher's private reply | This is a private reply | 1 | And I am on "Course 1" course homepage And I should see "Standard forum discussion" in the "Recent activity" "block" And I should see "Teacher's private reply" in the "Recent activity" "block" @@ -76,23 +73,22 @@ Feature: Users can see the relevant recent forum posts from the recent activity But I should not see "Teacher's private reply" in the "Recent activity" "block" Scenario: Recent forum activity with recent post in a hidden forum - Given the following forum discussions exist in course "Course 1": - | user | forum | name | message | - | teacher1 | Hidden forum | Hidden discussion | Should be hidden! | + Given the following "mod_forum > discussions" exist: + | user | forum | name | message | + | teacher1 | forum4 | Hidden discussion | Should be hidden! | And I am on "Course 1" course homepage And I should see "Hidden discussion" in the "Recent activity" "block" When I am on the "Course 1" course page logged in as student1 Then I should not see "Hidden discussion" in the "Recent activity" "block" Scenario: Recent forum activity with question and answer forum - Given I add a new question to "Q&A forum" forum with: - | Subject | The egg vs the chicken | - | Message | Which came first? The egg or the chicken? | + Given the following "mod_forum > discussions" exist: + | user | forum | name | message | + | teacher1 | forum5 | The egg vs the chicken | Which came first? The egg or the chicken? | + And the following "mod_forum > posts" exist: + | user | parentsubject | subject | message | + | student1 | The egg vs the chicken | Student 1's answer | The egg! | And I am on the "Course 1" course page logged in as student1 - And I reply "The egg vs the chicken" post from "Q&A forum" forum with: - | Subject | Student 1's answer | - | Message | The egg! | - And I am on "Course 1" course homepage And I should see "The egg vs the chicken" in the "Recent activity" "block" And I should see "Student 1's answer" in the "Recent activity" "block" And the following config values are set as admin: @@ -109,13 +105,9 @@ Feature: Users can see the relevant recent forum posts from the recent activity And I should see "Student 2's answer" in the "Recent activity" "block" Scenario: Recent forum activity with timed discussion - Given I add a new discussion to "Standard forum" forum with: - | Subject | Timed discussion | - | Message | Discuss anything under the sun here... no more!!! | - | timeend[enabled] | 1 | - | timeend[year] | 2020 | - | timeend[month] | 1 | - | timeend[day] | 1 | + Given the following "mod_forum > discussions" exist: + | user | forum | name | message | timeend | + | teacher1 | forum3 | Timed discussion | Discuss anything under the sun here... no more!!! | ##1 Jan 2020 08:00## | And I am on "Course 1" course homepage And I should see "Timed discussion" in the "Recent activity" "block" When I am on the "Course 1" course page logged in as student1 diff --git a/mod/forum/tests/behat/separate_group_single_group_discussions.feature b/mod/forum/tests/behat/separate_group_single_group_discussions.feature index 6ddf9a37cce..5232ad3cea7 100644 --- a/mod/forum/tests/behat/separate_group_single_group_discussions.feature +++ b/mod/forum/tests/behat/separate_group_single_group_discussions.feature @@ -39,9 +39,9 @@ Feature: Posting to groups in a separate group discussion when restricted to gro | G1 | G1G2 | | G2 | G2G1 | And the following "activities" exist: - | activity | course | idnumber | name | type | groupmode | grouping | - | forum | C1 | 00001 | Multiple groups forum | general | 1 | G1 | - | forum | C1 | 00001 | Single groups forum | general | 1 | G2 | + | activity | course | idnumber | name | intro | type | section | groupmode | grouping | + | forum | C1 | 00001 | Multiple groups forum | Standard forum description | general | 1 | 1 | G1 | + | forum | C1 | 00001 | Single groups forum | Standard forum description | general | 1 | 1 | G2 | Scenario: Teacher with accessallgroups can post in all groups Given I am on the "Multiple groups forum" "forum activity" page logged in as teacher1 @@ -50,7 +50,8 @@ Feature: Posting to groups in a separate group discussion when restricted to gro Then the "Group" select box should contain "All participants" And the "Group" select box should contain "G1G1" And the "Group" select box should contain "G1G2" - And I am on the "Single groups forum" "forum activity" page + And I am on "Course 1" course homepage + And I follow "Single groups forum" And I click on "Add discussion topic" "link" And I click on "Advanced" "button" And the "Group" select box should contain "All participants" @@ -64,7 +65,8 @@ Feature: Posting to groups in a separate group discussion when restricted to gro Then the "Group" select box should not contain "All participants" And the "Group" select box should contain "G1G1" And the "Group" select box should contain "G1G2" - And I am on the "Single groups forum" "forum activity" page + And I am on "Course 1" course homepage + And I follow "Single groups forum" And I click on "Add discussion topic" "link" And I click on "Advanced" "button" And I should see "G2G1" diff --git a/mod/forum/tests/behat/timed_discussions.feature b/mod/forum/tests/behat/timed_discussions.feature index 15cb6bd991d..54d7af870b6 100644 --- a/mod/forum/tests/behat/timed_discussions.feature +++ b/mod/forum/tests/behat/timed_discussions.feature @@ -17,23 +17,14 @@ Feature: Users can choose to set start and end time for display of their discuss And the following "activities" exist: | activity | name | course | idnumber | type | | forum | Test forum name | C1 | forump1 | general | - And I log in as "admin" + And the following "mod_forum > discussions" exist: + | user | forum | name | message | timeend | timestart | + | admin | forump1 | Discussion 1 | Discussion contents 1, first message | | | + | admin | forump1 | Discussion 2 timed not visible | Discussion contents 2, first message | ##1 Jan 2014 08:00## | | + | admin | forump1 | Discussion 3 timed visible now | Discussion contents 3, first message | | 1 | And the following config values are set as admin: | forum_enabletimedposts | 1 | - And I am on "Course 1" course homepage - And I add a new discussion to "Test forum name" forum with: - | Subject | Discussion 1 | - | Message | Discussion contents 1, first message | - And I add a new discussion to "Test forum name" forum with: - | Subject | Discussion 2 timed not visible | - | Message | Discussion contents 2, first message | - | timeend[enabled] | 1 | - | timeend[year] | 2014 | - And I add a new discussion to "Test forum name" forum with: - | Subject | Discussion 3 timed visible now | - | Message | Discussion contents 3, first message | - | timestart[enabled] | 1 | - And I am on the "Test forum name" "forum activity" page + And I am on the "Test forum name" "forum activity" page logged in as admin And I should see "Discussion 2 timed" And I should see "Discussion 3 timed" And "[data-region=timed-label]" "css_element" should exist From 33d829716e22aa98b47b39e91b477972b66deb7a Mon Sep 17 00:00:00 2001 From: Simey Lameze Date: Tue, 18 Jul 2023 16:35:30 +0800 Subject: [PATCH 2/2] MDL-78498 behat: add support for private replies This commit adds support for private replies in the 'the following forum replies exist in course' custom step. --- mod/forum/tests/behat/behat_mod_forum.php | 5 +++++ mod/forum/tests/behat/private_replies.feature | 7 +++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/mod/forum/tests/behat/behat_mod_forum.php b/mod/forum/tests/behat/behat_mod_forum.php index 9173933426c..acbd688ad46 100644 --- a/mod/forum/tests/behat/behat_mod_forum.php +++ b/mod/forum/tests/behat/behat_mod_forum.php @@ -250,6 +250,11 @@ class behat_mod_forum extends behat_base { $cm = get_coursemodule_from_instance('forum', $replyinfo['forum']); } + // Get the user id of the user to whom the reply is private. + if (!empty($replyinfo['privatereplyto'])) { + $replyinfo['privatereplyto'] = $this->get_user_id($replyinfo['privatereplyto']); + } + // Create the reply post. $reply = $forumgenerator->create_post($replyinfo); diff --git a/mod/forum/tests/behat/private_replies.feature b/mod/forum/tests/behat/private_replies.feature index ec64e3632bc..a647363115d 100644 --- a/mod/forum/tests/behat/private_replies.feature +++ b/mod/forum/tests/behat/private_replies.feature @@ -26,10 +26,9 @@ Feature: Forum posts can be replied to in private And the following "mod_forum > discussions" exist: | user | forum | name | message | | student1 | forum | Answers to the homework | Here are the answers to last night's homework. | - And I am on the "Science 101" course page logged in as teacher1 - And I reply "Answers to the homework" post from "Study discussions" forum with: - | Message | How about you and I have a meeting after class about plagiarism? | - | Reply privately | 1 | + And the following forum replies exist in course "Science 101": + | user | forum | discussion | message | privatereplyto | + | teacher1 | Study discussions | Answers to the homework |How about you and I have a meeting after class about plagiarism?| student1 | Scenario: As a teacher I can see my own response Given I am on the "Study discussions" "forum activity" page logged in as teacher1