MDL-70152 behat: Forum behat generators use UI

Replace steps that manually add forum and forum post instances
via the UI and use Behat generators. This improves the speed of
Behat test runs.
This commit is contained in:
Angelia Dela Cruz 2022-01-17 17:47:48 +08:00
parent 505940f91e
commit 640db57c0e
19 changed files with 196 additions and 280 deletions

View file

@ -17,22 +17,18 @@ Feature: Add forum activities and discussions
| user | course | role |
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |
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 log out
And the following "activity" exists:
| activity | forum |
| course | C1 |
| section | 1 |
| name | Test forum name |
| type | general |
| description | Test forum description |
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 am on "Course 1" course homepage
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 |

View file

@ -13,16 +13,20 @@ Feature: Add forum activities and discussions utilizing the inline add discussio
| user | course | role |
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |
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 log out
And the following "activity" exists:
| activity | forum |
| course | C1 |
| section | 1 |
| idnumber | 0001 |
| name | Test forum name |
| description | Test forum description |
| type | general |
And the following "mod_forum > discussion" exists:
| forum | 0001 |
| course | C1 |
| user | teacher1 |
| name | Forum post 1 |
| message | This is the body |
Scenario: Student can add a discussion via the inline form
Given I log in as "student1"

View file

@ -19,12 +19,9 @@ Feature: Teachers can edit or delete any forum post
And the following "activities" exist:
| activity | name | intro | course | section | idnumber |
| forum | Test forum name | Test forum description | C1 | 1 | forum1 |
And I log in as "teacher1"
And I am on "Course 1" course homepage
And I add a new discussion to "Test forum name" forum with:
| Subject | Teacher post subject |
| Message | Teacher post message |
And I log out
And the following "mod_forum > discussions" exist:
| forum | course | user | name | message |
| forum1 | C1 | teacher1 | Teacher post subject | Teacher post message |
And I log in as "student1"
And I am on "Course 1" course homepage
And I reply "Teacher post subject" post from "Test forum name" forum with:

View file

@ -14,26 +14,21 @@ Feature: A user can control their own subscription preferences for a forum
And the following "course enrolments" exist:
| user | course | role |
| student1 | C1 | student |
And the following "activities" exist:
| activity | course | idnumber | name | intro | type | section |
| forum | C1 | forum1 | Test forum name | Test forum description | general | 1 |
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"
Scenario: A disallowed subscription forum cannot be subscribed to
Given the following "activity" exists:
| activity | forum |
| course | C1 |
| idnumber | forum1 |
| name | Test forum name |
| intro | Test forum description |
| type | general |
| section | 1 |
And I am on "Course 1" course homepage
Given I follow "Test forum name"
Given I am on "Course 1" course homepage
And I follow "Test forum name"
And I navigate to "Settings" in current page administration
And I set the following fields to these values:
| Subscription mode | Subscription disabled |
And I press "Save and return to course"
And I add a new discussion to "Test forum name" forum with:
| Subject | Test post subject |
| Message | Test post message |
And I log out
When I log in as "student1"
And I am on "Course 1" course homepage
@ -44,23 +39,12 @@ 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 the following "activity" exists:
| activity | forum |
| course | C1 |
| idnumber | forum1 |
| name | Test forum name |
| intro | Test forum description |
| type | general |
| section | 1 |
And I am on "Course 1" course homepage
Given I follow "Test forum name"
Given I am on "Course 1" course homepage
And I follow "Test forum name"
And I navigate to "Settings" in current page administration
And I set the following fields to these values:
| Subscription mode | Forced subscription |
And I press "Save and return to course"
And I add a new discussion to "Test forum name" forum with:
| Subject | Test post subject |
| Message | Test post message |
And I log out
When I log in as "student1"
And I am on "Course 1" course homepage
@ -71,23 +55,12 @@ 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 the following "activity" exists:
| activity | forum |
| course | C1 |
| idnumber | forum1 |
| name | Test forum name |
| intro | Test forum description |
| type | general |
| section | 1 |
And I am on "Course 1" course homepage
Given I follow "Test forum name"
Given I am on "Course 1" course homepage
And I follow "Test forum name"
And I navigate to "Settings" in current page administration
And I set the following fields to these values:
| Subscription mode | Optional subscription |
And I press "Save and return to course"
And I add a new discussion to "Test forum name" forum with:
| Subject | Test post subject |
| Message | Test post message |
And I log out
When I log in as "student1"
And I am on "Course 1" course homepage
@ -100,23 +73,12 @@ 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 the following "activity" exists:
| activity | forum |
| course | C1 |
| idnumber | forum1 |
| name | Test forum name |
| intro | Test forum description |
| type | general |
| section | 1 |
And I am on "Course 1" course homepage
Given I follow "Test forum name"
Given I am on "Course 1" course homepage
And I follow "Test forum name"
And I navigate to "Settings" in current page administration
And I set the following fields to these values:
| Subscription mode | Auto subscription |
And I press "Save and return to course"
And I add a new discussion to "Test forum name" forum with:
| Subject | Test post subject |
| Message | Test post message |
And I log out
When I log in as "student1"
And I am on "Course 1" course homepage

View file

@ -34,17 +34,17 @@ Feature: As a teacher I need to see an accurate list of subscribed users
And the following "grouping groups" exist:
| grouping | group |
| GG1 | G1 |
And the following "activities" exist:
| activity | course | idnumber | section | type | name | description | forcesubscribe |
| forum | C1 | 1 | 1 | general | Forced Forum 1 | Test forum description | 1 |
| forum | C1 | 0001 | 1 | general | Forced Forum 2 | Test forum description | |
| forum | C1 | 0002 | 1 | general | Forced Forum 3 | Test forum description | 2 |
And I log in as "teacher"
And I am on "Course 1" course homepage with editing mode on
@javascript
Scenario: A forced forum lists all subscribers
When I add a "Forum" to section "1" and I fill the form with:
| Forum name | Forced Forum 1 |
| Forum type | Standard forum for general use |
| Description | Test forum description |
| Subscription mode | Forced subscription |
And I am on the "Forced Forum 1" "forum activity" page
When I am on the "Forced Forum 1" "forum activity" page
And I navigate to "Subscriptions" in current page administration
Then I should see "Student 1"
And I should see "Teacher Teacher"
@ -63,15 +63,7 @@ Feature: As a teacher I need to see an accurate list of subscribed users
And I should not see "Student 3"
Scenario: A forced forum does not allow to edit the subscribers
Given the following "activity" exists:
| activity | forum |
| name | Forced Forum 2 |
| intro | Test forum description |
| type | general |
| course | C1 |
| idnumber | 0001 |
| section | 1 |
And I am on the "Forced Forum 2" "forum activity" page
Given I am on the "Forced Forum 2" "forum activity" page
And I navigate to "Settings" in current page administration
And I set the following fields to these values:
| Subscription mode | Forced subscription |
@ -85,16 +77,7 @@ Feature: As a teacher I need to see an accurate list of subscribed users
And I should see "Student 3"
Scenario: A forced and hidden forum lists only teachers
Given the following "activity" exists:
| activity | forum |
| name | Forced Forum 2 |
| intro | Test forum description |
| type | general |
| course | C1 |
| idnumber | 0001 |
| section | 1 |
And I am on "Course 1" course homepage
And I am on the "Forced Forum 2" "forum activity editing" page
Given I am on the "Forced Forum 2" "forum activity editing" page
And I set the following fields to these values:
| Subscription mode | Forced subscription |
| Availability | Hide on course page |
@ -108,19 +91,14 @@ Feature: As a teacher I need to see an accurate list of subscribed users
@javascript
Scenario: An automatic forum lists all subscribers
When I add a "Forum" to section "1" and I fill the form with:
| Forum name | Forced Forum 1 |
| Forum type | Standard forum for general use |
| Description | Test forum description |
| Subscription mode | Auto subscription |
And I am on the "Forced Forum 1" "forum activity" page
When I am on the "Forced Forum 3" "forum activity" page
And I navigate to "Subscriptions" in current page administration
Then I should see "Student 1"
And I should see "Teacher Teacher"
And I should see "Student 2"
And I should see "Student 3"
And I am on "Course 1" course homepage
And I am on the "Forced Forum 1" "forum activity editing" page
And I am on the "Forced Forum 3" "forum activity editing" page
And I expand all fieldsets
And I click on "Add restriction..." "button"
And I click on "Grouping" "button" in the "Add restriction..." "dialogue"

View file

@ -23,17 +23,22 @@ Feature: I can grade a students interaction across a forum
And the following "scales" exist:
| name | scale |
| Test Scale 1 | Disappointing, Good, Very good, Excellent |
And the following "activity" exists:
| activity | forum |
| course | C1 |
| idnumber | 0001 |
| name | Test Forum 1 |
| description | Test |
| section | 1 |
And I log in as "teacher1"
And I change window size to "large"
And I am on "Course 1" course homepage
And I turn editing mode on
Scenario: Ensure that forum grade settings do not leak to Ratings
Given I add a "Forum" to section "1"
Given I am on the "Test Forum 1" "forum activity" page
And I navigate to "Settings" in current page administration
And I expand all fieldsets
And I set the following fields to these values:
| Forum name | Test Forum 1 |
| Description | Test |
# Fields should be hidden when grading is not set.
When I set the field "Whole forum grading > Type" to "None"
@ -74,11 +79,9 @@ Feature: I can grade a students interaction across a forum
And I should see "Tutor" in the "Parent category" "fieldset"
Scenario: Ensure that Ratings settings do not leak to Forum grading
Given I add a "Forum" to section "1"
Given I am on the "Test Forum 1" "forum activity" page
And I navigate to "Settings" in current page administration
And I expand all fieldsets
And I set the following fields to these values:
| Forum name | Test Forum 1 |
| Description | Test |
# Fields should be hidden when grading is not set.
When I set the field "Ratings > Aggregate type" to "No ratings"
@ -130,17 +133,10 @@ Feature: I can grade a students interaction across a forum
And I should see "Tutor" in the "Parent category" "fieldset"
Scenario: Setting both a rating and a whole forum grade does not bleed
Given the following "activity" exists:
| activity | forum |
| course | C1 |
| idnumber | 0001 |
| name | Test Forum 1 |
| intro | Test |
| section | 1 |
And I am on "Course 1" course homepage
And I follow "Test Forum 1"
Given I am on the "Test Forum 1" "forum activity" page
And I navigate to "Settings" in current page administration
And I expand all fieldsets
And I set the field "Ratings > Aggregate type" to "Count of ratings"
And I set the field "Ratings > Type" to "Point"
And I set the field "Ratings > Maximum grade" to "100"

View file

@ -13,18 +13,17 @@ Feature: Students can reply to a discussion in page.
| user | course | role |
| student1 | C1 | student |
| teacher1 | C1 | editingteacher |
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 |
| Description | Test forum description |
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 |
| Message | Discussion contents 2, first message |
And I log out
And the following "activity" exists:
| activity | forum |
| course | C1 |
| section | 1 |
| idnumber | 0001 |
| name | Test forum name |
| description | Test forum description |
And the following "mod_forum > discussions" exist:
| forum | course | user | name | message |
| 0001 | C1 | teacher1 | Discussion 1 | Discussion contents 1, first message |
| 0001 | C1 | teacher1 | Discussion 2 | Discussion contents 2, first message |
Scenario: Confirm inpage replies work
Given I log in as "student1"

View file

@ -32,10 +32,16 @@ Feature: I can grade a students by group with separate groups
| student1 | G3 |
| student2 | G3 |
| student3 | G3 |
And the following "activity" exists:
| activity | forum |
| course | C1 |
| section | 1 |
| name | Test Forum 1 |
| intro | Test |
And I log in as "teacher1"
And I am on "Course 1" course homepage
And I turn editing mode on
And I add a "Forum" to section "1"
And I am on the "Test Forum 1" "forum activity editing" page logged in as teacher1
And I expand all fieldsets
And I set the following fields to these values:
| Forum name | Test Forum 1 |

View file

@ -21,12 +21,9 @@ Feature: Forum discussions can be split
And the following "activities" exist:
| activity | name | intro | course | idnumber | type |
| forum | Study discussions | Forum to discuss your coursework. | C1 | forump1 | general |
And I log in as "teacher1"
And I am on "Science 101" course homepage
And I add a new discussion to "Study discussions" forum with:
| Subject | Photosynthesis discussion |
| Message | Lets discuss our learning about Photosynthesis this week in this thread. |
And I log out
And the following "mod_forum > discussions" exist:
| forum | course | user | name | message |
| forump1 | C1 | teacher1 | Photosynthesis discussion | Lets discuss our learning about Photosynthesis this week in this thread. |
And I log in as "student1"
And I am on "Science 101" course homepage
And I reply "Photosynthesis discussion" post from "Study discussions" forum with: