Skip to content

Commit

Permalink
MDL-68093 forum: Add behat tests for non-participation groups
Browse files Browse the repository at this point in the history
  • Loading branch information
marxjohnson committed Mar 14, 2023
1 parent 7f9e7f2 commit a1b1af7
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 9 deletions.
36 changes: 31 additions & 5 deletions mod/forum/tests/behat/separate_group_discussions.feature
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ Feature: Posting to all groups in a separate group discussion is restricted to u
| noneditor2 | Non-editing teacher | 2 | noneditor2@example.com |
| student1 | Student | 1 | student1@example.com |
| student2 | Student | 2 | student2@example.com |
| student3 | Student | 3 | student3@example.com |
| student4 | Student | 4 | student4@example.com |
And the following "courses" exist:
| fullname | shortname | category |
| Course 1 | C1 | 0 |
Expand All @@ -22,11 +24,14 @@ Feature: Posting to all groups in a separate group discussion is restricted to u
| noneditor2 | C1 | teacher |
| student1 | C1 | student |
| student2 | C1 | student |
| student3 | C1 | student |
| student4 | C1 | student |
And the following "groups" exist:
| name | course | idnumber |
| Group A | C1 | G1 |
| Group B | C1 | G2 |
| Group C | C1 | G3 |
| name | course | idnumber | participation |
| Group A | C1 | G1 | 1 |
| Group B | C1 | G2 | 1 |
| Group C | C1 | G3 | 1 |
| Group D | C1 | G4 | 0 |
And the following "group members" exist:
| user | group |
| teacher1 | G1 |
Expand All @@ -39,6 +44,7 @@ Feature: Posting to all groups in a separate group discussion is restricted to u
| student1 | G1 |
| student2 | G1 |
| student2 | G2 |
| student3 | G4 |
And the following "activities" exist:
| activity | name | intro | course | idnumber | groupmode |
| forum | Standard forum name | Standard forum description | C1 | sepgroups | 1 |
Expand All @@ -57,6 +63,7 @@ Feature: Posting to all groups in a separate group discussion is restricted to u
And the "Separate groups" select box should contain "Group A"
And the "Separate groups" select box should contain "Group B"
And the "Separate groups" select box should contain "Group C"
And the "Separate groups" select box should not contain "Group D"
And I select "All participants" from the "Separate groups" singleselect
And I should see "Initial Disc ALL"
And I should see "Initial Disc G1"
Expand All @@ -73,7 +80,7 @@ Feature: Posting to all groups in a separate group discussion is restricted to u
But I should not see "Initial Disc G1"
And I should not see "Initial Disc G3"

Scenario: Teacher with accessallgroups can select any group when posting
Scenario: Teacher with accessallgroups can select any participation group when posting
Given I log in as "teacher1"
And I am on "Course 1" course homepage
And I follow "Standard forum name"
Expand All @@ -83,6 +90,7 @@ Feature: Posting to all groups in a separate group discussion is restricted to u
And the "Group" select box should contain "Group A"
And the "Group" select box should contain "Group B"
And the "Group" select box should contain "Group C"
And the "Group" select box should not contain "Group D"
And I should see "Post a copy to all groups"

Scenario: Teacher with accessallgroups can post in groups they are a member of
Expand Down Expand Up @@ -193,6 +201,24 @@ Feature: Posting to all groups in a separate group discussion is restricted to u
And I should see "Group A" in the "Student -> B" "table_row"
And I should not see "Group B" in the "Student -> B" "table_row"

Scenario: Students in no group can see all group discussions, but not post.
Given I log in as "student4"
And I am on "Course 1" course homepage
When I follow "Standard forum name"
Then I should see "All participants"
And I should see "Initial Disc ALL"
And I should see "You are not able to create a discussion"
And I should not see "Add discussion topic"

Scenario: Students in non-participation groups can see all group discussions, but not post.
Given I log in as "student3"
And I am on "Course 1" course homepage
When I follow "Standard forum name"
Then I should see "All participants"
And I should see "Initial Disc ALL"
And I should see "You are not able to create a discussion"
And I should not see "Add discussion topic"

Scenario: Students in multiple group can post in all of their group individually
Given I log in as "student2"
And I am on "Course 1" course homepage
Expand Down
43 changes: 39 additions & 4 deletions mod/forum/tests/behat/visible_group_discussions.feature
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ Feature: Posting to all groups in a visible group discussion is restricted to us
| teacher1 | Teacher | 1 | teacher1@example.com |
| student1 | Student | 1 | student1@example.com |
| student2 | Student | 2 | student2@example.com |
| student3 | Student | 3 | student3@example.com |
| student4 | Student | 4 | student4@example.com |
And the following "courses" exist:
| fullname | shortname | category |
| Course 1 | C1 | 0 |
Expand All @@ -18,18 +20,22 @@ Feature: Posting to all groups in a visible group discussion is restricted to us
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |
| student2 | C1 | student |
| student3 | C1 | student |
| student4 | C1 | student |
And the following "groups" exist:
| name | course | idnumber |
| Group A | C1 | G1 |
| Group B | C1 | G2 |
| Group C | C1 | G3 |
| name | course | idnumber | participation |
| Group A | C1 | G1 | 1 |
| Group B | C1 | G2 | 1 |
| Group C | C1 | G3 | 1 |
| Group D | C1 | G4 | 0 |
And the following "group members" exist:
| user | group |
| teacher1 | G1 |
| teacher1 | G2 |
| student1 | G1 |
| student2 | G1 |
| student2 | G2 |
| student3 | G4 |
And the following "activities" exist:
| activity | name | intro | course | idnumber | groupmode |
| forum | Standard forum name | Standard forum description | C1 | groups | 2 |
Expand All @@ -48,6 +54,7 @@ Feature: Posting to all groups in a visible group discussion is restricted to us
And the "Visible groups" select box should contain "Group A"
And the "Visible groups" select box should contain "Group B"
And the "Visible groups" select box should contain "Group C"
And the "Visible groups" select box should not contain "Group D"
And I select "All participants" from the "Visible groups" singleselect
And I should see "Initial Disc ALL"
And I should see "Initial Disc G1"
Expand All @@ -74,6 +81,7 @@ Feature: Posting to all groups in a visible group discussion is restricted to us
And the "Group" select box should contain "Group A"
And the "Group" select box should contain "Group B"
And the "Group" select box should contain "Group C"
And the "Group" select box should not contain "Group D"
And I should see "Post a copy to all groups"

Scenario: Teacher with accessallgroups can post in groups they are a member of
Expand Down Expand Up @@ -174,6 +182,7 @@ Feature: Posting to all groups in a visible group discussion is restricted to us
And the "Visible groups" select box should contain "Group A"
And the "Visible groups" select box should contain "Group B"
And the "Visible groups" select box should contain "Group C"
And the "Visible groups" select box should not contain "Group D"
And I select "All participants" from the "Visible groups" singleselect
And I should see "Initial Disc ALL"
And I should see "Initial Disc G1"
Expand All @@ -200,6 +209,7 @@ Feature: Posting to all groups in a visible group discussion is restricted to us
And I should see "Group A"
And I should not see "Group B"
And I should not see "Group C"
And I should not see "Group D"
And I should not see "Post a copy to all groups"
And I set the following fields to these values:
| Subject | Student -> B |
Expand All @@ -220,6 +230,7 @@ Feature: Posting to all groups in a visible group discussion is restricted to us
And the "Group" select box should contain "Group A"
And the "Group" select box should contain "Group B"
And the "Group" select box should not contain "Group C"
And the "Group" select box should not contain "Group D"
And I should not see "Post a copy to all groups"
And I set the following fields to these values:
| Subject | Student -> B |
Expand Down Expand Up @@ -254,3 +265,27 @@ Feature: Posting to all groups in a visible group discussion is restricted to us
And I should not see "Group B" in the "Student -> A" "table_row"
And I select "Group B" from the "Visible groups" singleselect
And I should not see "Student -> A"

Scenario: Students in no group can see all discussions, but not post.
Given I log in as "student4"
And I am on "Course 1" course homepage
When I follow "Standard forum name"
And I select "All participants" from the "Visible groups" singleselect
Then I should see "Initial Disc ALL"
And I should see "Initial Disc G1"
And I should see "Initial Disc G2"
And I should see "Initial Disc G2"
And I should see "You are not able to create a discussion"
And I should not see "Add discussion topic"

Scenario: Students in non-participation groups can see all discussions, but not post.
Given I log in as "student3"
And I am on "Course 1" course homepage
When I follow "Standard forum name"
And I select "All participants" from the "Visible groups" singleselect
Then I should see "Initial Disc ALL"
And I should see "Initial Disc G1"
And I should see "Initial Disc G2"
And I should see "Initial Disc G2"
And I should see "You are not able to create a discussion"
And I should not see "Add discussion topic"

0 comments on commit a1b1af7

Please sign in to comment.