Skip to content

Commit

Permalink
MDL-76652 behat: use data generator and remove duplicated steps
Browse files Browse the repository at this point in the history
  • Loading branch information
lameze committed Jan 9, 2023
1 parent 33b7115 commit e1204dc
Showing 1 changed file with 9 additions and 35 deletions.
44 changes: 9 additions & 35 deletions mod/forum/tests/behat/discussion_post_threshold_warning.feature
Expand Up @@ -5,32 +5,22 @@ Feature: An admin or teacher sets the post threshold for blocking and warning
Background:
Given the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | Teacher | 1 | teacher1@example.com |
| student1 | Student | 1 | student1@example.com |
| student2 | Student | 1 | student2@example.com |
And the following "courses" exist:
| fullname | shortname | category |
| Course 1 | C1 | 0 |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
| user | course | role |
| student1 | C1 | student |
| student2 | C1 | student |
And the following "activities" exist:
| activity | name | intro | course | idnumber | groupmode |
| forum | Test forum name | Test forum name | C1 | forum | 0 |
| activity | name | course | blockperiod | blockafter | warnafter |
| forum | Test forum name | C1 | 172800 | 3 | 2 |

@javascript
Scenario: A student should not be able to post new discussion or reply to the existing discussion once the threshold block count is reached
Given I am on the "Test forum name" "forum activity" page logged in as teacher1
And I navigate to "Settings" in current page administration
And I expand all fieldsets
And I set the field "Time period for blocking" to "2 days"
And I set the field "Post threshold for blocking" to "3"
And I set the field "Post threshold for warning" to "2"
And I press "Save and display"
And I log out
And I am on the "Test forum name" "forum activity" page logged in as student1
Given I am on the "Test forum name" "forum activity" page logged in as student1
When I add a new discussion to "Test forum name" forum with:
| Subject | Test post subject one |
| Message | Test post message one |
Expand Down Expand Up @@ -60,15 +50,7 @@ Feature: An admin or teacher sets the post threshold for blocking and warning

@javascript
Scenario: A student should see warning when the post is about to reach threshold when experimental nested discussion view is set
Given I am on the "Test forum name" "forum activity" page logged in as teacher1
And I navigate to "Settings" in current page administration
And I expand all fieldsets
And I set the field "Time period for blocking" to "2 days"
And I set the field "Post threshold for blocking" to "3"
And I set the field "Post threshold for warning" to "2"
And I press "Save and display"
And I log out
And I am on the "Test forum name" "forum activity" page logged in as student1
Given I am on the "Test forum name" "forum activity" page logged in as student1
When I add a new discussion to "Test forum name" forum with:
| Subject | Test post subject one |
| Message | Test post message one |
Expand All @@ -87,18 +69,10 @@ Feature: An admin or teacher sets the post threshold for blocking and warning
Then I should see "You are approaching the posting threshold. You have posted 2 times in the last 2 days and the limit is 3 posts."

@javascript
Scenario: A student with postwithoutthrottling capability should be able to post unlimited number of times
Scenario: A student with 'mod/forum:postwithoutthrottling' capability should be able to post unlimited number of times
Given the following "permission overrides" exist:
| capability | permission | role | contextlevel | reference |
| mod/forum:postwithoutthrottling | Allow | student | Course | C1 |
And I am on the "Test forum name" "forum activity" page logged in as "teacher1"
And I navigate to "Settings" in current page administration
And I expand all fieldsets
And I set the field "Time period for blocking" to "2 days"
And I set the field "Post threshold for blocking" to "3"
And I set the field "Post threshold for warning" to "2"
And I press "Save and display"
And I log out
| capability | permission | role | contextlevel | reference |
| mod/forum:postwithoutthrottling | Allow | student | Course | C1 |
And I am on the "Test forum name" "forum activity" page logged in as student1
And I should see "This forum has a limit to the number of forum postings you can make in a given time period - this is currently set at 3 posting(s) in 2 days"
When I add a new discussion to "Test forum name" forum with:
Expand All @@ -111,7 +85,7 @@ Feature: An admin or teacher sets the post threshold for blocking and warning
# Verify that when navigated to one of the topics and then click reply the warning notification is shown.
And I click on "Test post subject two" "link"
And I click on "Reply" "link"
# With mod/forum:postwithoutthrottling capability the message below should not be displayed.
# With 'mod/forum:postwithoutthrottling' assigned capability the message below should not be displayed.
And I should not see "You are approaching the posting threshold. You have posted 2 times in the last 2 days and the limit is 3 posts."
And I click on "Test forum name" "link"
And I add a new discussion to "Test forum name" forum with:
Expand Down

0 comments on commit e1204dc

Please sign in to comment.