MDL-66979 behat: Switch to generators

These steps were creating content manually in an unnecessary fashion. I
had to debug some issues with features in these areas so took the time
to update them to make use of data generators, which are significantly
faster.
This commit is contained in:
Andrew Nicols 2020-11-13 09:30:18 +08:00
parent 7d777911af
commit a61c4fbce3
4 changed files with 161 additions and 150 deletions

View File

@ -46,49 +46,46 @@ Feature: View structural changes in recent activity block
| GG3 | G2 |
Scenario: Check that Added module information is displayed respecting view capability
Given I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
And I add the "Recent activity" block
When I add a "Forum" to section "1" and I fill the form with:
| name | ForumVisibleGroups |
| Description | No description |
| groupmode | Visible groups |
And I add a "Forum" to section "1" and I fill the form with:
| name | ForumSeparateGroups |
| Description | No description |
| groupmode | Separate groups |
And I add a "Forum" to section "1" and I fill the form with:
| name | ForumHidden |
| Description | No description |
| Availability | 0 |
And I add a "Forum" to section "1" and I fill the form with:
| name | ForumNoGroups |
| Description | No description |
| groupmode | No groups |
And I add a "Forum" to section "2" and I fill the form with:
| name | ForumVisibleGroupsG1 |
| Description | No description |
| groupmode | Visible groups |
| Grouping | Grouping 1 |
Given the following "activities" exist:
| activity | course | section | name | idnumber | description | groupmode | grouping | visible |
| forum | C1 | 1 | ForumVisibleGroups | forum1 | No description | 2 | | 1 |
| forum | C1 | 1 | ForumSeparateGroups | forum2 | No description | 1 | | 1 |
| forum | C1 | 1 | ForumHidden | forum3 | No description | 1 | | 0 |
| forum | C1 | 1 | ForumNoGroups | forum4 | No description | 0 | | 1 |
| forum | C1 | 2 | ForumVisibleGroupsG1 | forum5 | No description | 2 | GG1 | 1 |
| forum | C1 | 2 | ForumSeparateGroupsG1 | forum6 | No description | 1 | GG1 | 1 |
| forum | C1 | 3 | ForumVisibleGroupsG2 | forum7 | No description | 2 | GG2 | 1 |
| forum | C1 | 3 | ForumSeparateGroupsG2 | forum8 | No description | 1 | GG2 | 1 |
And I log in as "teacher1"
And I am on "Course 1" course homepage
And I click on "ForumVisibleGroupsG1" "link"
And I click on "Edit settings" "link"
And I set the following fields to these values:
| Access restrictions | Grouping: Grouping 1 |
And I add a "Forum" to section "2" and I fill the form with:
| name | ForumSeparateGroupsG1 |
| Description | No description |
| groupmode | Separate groups |
| Grouping | Grouping 1 |
| Access restrictions | Grouping: Grouping 1 |
And I add a "Forum" to section "3" and I fill the form with:
| name | ForumVisibleGroupsG2 |
| Description | No description |
| groupmode | Visible groups |
| Grouping | Grouping 2 |
And I press "Save and return to course"
And I click on "ForumSeparateGroupsG1" "link"
And I click on "Edit settings" "link"
And I set the following fields to these values:
| Access restrictions | Grouping: Grouping 1 |
And I press "Save and return to course"
And I click on "ForumVisibleGroupsG2" "link"
And I click on "Edit settings" "link"
And I set the following fields to these values:
| Access restrictions | Grouping: Grouping 2 |
And I add a "Forum" to section "3" and I fill the form with:
| name | ForumSeparateGroupsG2 |
| Description | No description |
| groupmode | Separate groups |
| Grouping | Grouping 2 |
| Access restrictions | Grouping: Grouping 2 |
And I press "Save and return to course"
And I click on "ForumSeparateGroupsG2" "link"
And I click on "Edit settings" "link"
And I set the following fields to these values:
| Access restrictions | Grouping: Grouping 2 |
And I press "Save and return to course"
And I am on "Course 1" course homepage with editing mode on
When I add the "Recent activity" block
Then I should see "ForumVisibleGroups" in the "Recent activity" "block"
And I should see "ForumSeparateGroups" in the "Recent activity" "block"
And I should see "ForumNoGroups" in the "Recent activity" "block"
@ -98,6 +95,7 @@ Feature: View structural changes in recent activity block
And I should see "ForumVisibleGroupsG2" in the "Recent activity" "block"
And I should see "ForumSeparateGroupsG2" in the "Recent activity" "block"
And I log out
And I log in as "student1"
And I am on "Course 1" course homepage
And I should see "ForumVisibleGroups" in the "Recent activity" "block"
@ -109,6 +107,7 @@ Feature: View structural changes in recent activity block
And I should not see "ForumVisibleGroupsG2" in the "Recent activity" "block"
And I should not see "ForumSeparateGroupsG2" in the "Recent activity" "block"
And I log out
And I log in as "student2"
And I am on "Course 1" course homepage
And I should see "ForumVisibleGroups" in the "Recent activity" "block"
@ -120,6 +119,7 @@ Feature: View structural changes in recent activity block
And I should see "ForumVisibleGroupsG2" in the "Recent activity" "block"
And I should see "ForumSeparateGroupsG2" in the "Recent activity" "block"
And I log out
And I log in as "student3"
And I am on "Course 1" course homepage
And I should see "ForumVisibleGroups" in the "Recent activity" "block"
@ -131,6 +131,7 @@ Feature: View structural changes in recent activity block
And I should see "ForumVisibleGroupsG2" in the "Recent activity" "block"
And I should see "ForumSeparateGroupsG2" in the "Recent activity" "block"
And I log out
# Teachers have capability to see all groups and hidden activities
And I log in as "assistant1"
And I am on "Course 1" course homepage
@ -142,15 +143,20 @@ Feature: View structural changes in recent activity block
And I log out
Scenario: Updates and deletes in recent activity block
Given the following "activity" exists:
| activity | forum |
| course | C1 |
| idnumber | forum1 |
| name | ForumNew |
| description | No description |
When I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
And I add the "Recent activity" block
And I add a "Forum" to section "1" and I fill the form with:
| name | ForumNew |
| Description | No description |
Then I should see "Added Forum" in the "Recent activity" "block"
And I should see "ForumNew" in the "Recent activity" "block"
And I log out
# Update forum as a teacher after a second to ensure we have a new timestamp for recent activity.
And I wait "1" seconds
And I log in as "student1"
And I am on "Course 1" course homepage
@ -159,6 +165,7 @@ Feature: View structural changes in recent activity block
And I log out
# Update forum as a teacher after a second to ensure we have a new timestamp for recent activity.
And I wait "1" seconds
# Update forum as a teacher
And I log in as "teacher1"
And I am on "Course 1" course homepage
@ -170,6 +177,7 @@ Feature: View structural changes in recent activity block
And I log out
And I wait "1" seconds
# Student 1 already saw that forum was created, now he can see that forum was updated
And I log in as "student1"
And I am on "Course 1" course homepage
And I should not see "Added Forum" in the "Recent activity" "block"
@ -179,6 +187,7 @@ Feature: View structural changes in recent activity block
And I log out
And I wait "1" seconds
# Student 2 has bigger interval and he can see one entry that forum was created but with the new name
And I log in as "student2"
And I am on "Course 1" course homepage
And I should see "Added Forum" in the "Recent activity" "block"
@ -188,6 +197,7 @@ Feature: View structural changes in recent activity block
And I log out
And I wait "1" seconds
# Delete forum as a teacher
And I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
And I delete "ForumUpdated" activity
@ -195,6 +205,7 @@ Feature: View structural changes in recent activity block
And I log out
And I wait "1" seconds
# Students 1 and 2 see that forum was deleted
And I log in as "student1"
And I am on "Course 1" course homepage
And I should not see "Added Forum" in the "Recent activity" "block"
@ -205,6 +216,7 @@ Feature: View structural changes in recent activity block
And I log out
And I wait "1" seconds
# Student 3 never knew that forum was created, so he does not see anything
And I log in as "student3"
And I am on "Course 1" course homepage
And I should not see "Added Forum" in the "Recent activity" "block"
@ -212,4 +224,3 @@ Feature: View structural changes in recent activity block
And I should not see "Updated Forum" in the "Recent activity" "block"
And I should not see "ForumUpdated" in the "Recent activity" "block"
And I should not see "Deleted Forum" in the "Recent activity" "block"
And I log out

View File

@ -4,34 +4,39 @@ Feature: In an assignment, teachers can change filters in the grading app
As a teacher
I need to preserve filter settings between the grader app and grading table.
@javascript
Scenario: Set filters in the grading table and see them in the grading app
Background:
Given the following "courses" exist:
| fullname | shortname | category | groupmode |
| Course 1 | C1 | 0 | 1 |
| Course 1 | C1 | 0 | 1 |
And the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | Teacher | 1 | teacher1@example.com |
| student1 | Student | 1 | student1@example.com |
| student2 | Student | 2 | student2@example.com |
| marker1 | Marker | 1 | marker1@example.com |
| marker2 | Marker | 2 | marker2@example.com |
| username | firstname | lastname | email |
| teacher1 | Teacher | 1 | teacher1@example.com |
| student1 | Student | 1 | student1@example.com |
| student2 | Student | 2 | student2@example.com |
| marker1 | Marker | 1 | marker1@example.com |
| marker2 | Marker | 2 | marker2@example.com |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |
| student2 | C1 | student |
| marker1 | C1 | teacher |
| marker2 | C1 | teacher |
And I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
And I add a "Assignment" to section "1" and I fill the form with:
| Assignment name | Test assignment name |
| Description | Submit your online text |
| assignsubmission_onlinetext_enabled | 1 |
| assignsubmission_file_enabled | 0 |
| Use marking workflow | Yes |
| Use marking allocation | Yes |
| user | course | role |
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |
| student2 | C1 | student |
| marker1 | C1 | teacher |
| marker2 | C1 | teacher |
And the following "activity" exists:
| activity | assign |
| course | C1 |
| name | Test assignment name |
| idnumber | assign |
| description | Submit your online text |
| assignsubmission_onlinetext_enabled | 1 |
| assignsubmission_file_enabled | 0 |
| markingworkflow | 1 |
| markingallocation | 1 |
@javascript
Scenario: Set filters in the grading table and see them in the grading app
Given I log in as "teacher1"
And I am on "Course 1" course homepage
And I follow "Test assignment name"
And I navigate to "View all submissions" in current page administration
And I click on "Grade" "link" in the "Student 1" "table_row"
@ -55,32 +60,8 @@ Feature: In an assignment, teachers can change filters in the grading app
@javascript
Scenario: Set filters in the grading app and see them in the grading table
Given the following "courses" exist:
| fullname | shortname | category | groupmode |
| Course 1 | C1 | 0 | 1 |
And the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | Teacher | 1 | teacher1@example.com |
| student1 | Student | 1 | student1@example.com |
| student2 | Student | 2 | student2@example.com |
| marker1 | Marker | 1 | marker1@example.com |
| marker2 | Marker | 2 | marker2@example.com |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |
| student2 | C1 | student |
| marker1 | C1 | teacher |
| marker2 | C1 | teacher |
And I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
And I add a "Assignment" to section "1" and I fill the form with:
| Assignment name | Test assignment name |
| Description | Submit your online text |
| assignsubmission_onlinetext_enabled | 1 |
| assignsubmission_file_enabled | 0 |
| Use marking workflow | Yes |
| Use marking allocation | Yes |
Given I log in as "teacher1"
And I am on "Course 1" course homepage
And I follow "Test assignment name"
And I navigate to "View all submissions" in current page administration
And I click on "Grade" "link" in the "Student 1" "table_row"

View File

@ -15,15 +15,18 @@ Feature: A user can control their own subscription preferences for a discussion
| user | course | role |
| student1 | C1 | student |
And I log in as "admin"
And I am on "Course 1" course homepage with editing mode on
@javascript
Scenario: An optional forum can have discussions subscribed to
Given 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 |
| Subscription mode | Optional subscription |
Given the following "activity" exists:
| activity | forum |
| course | C1 |
| idnumber | forum1 |
| name | Test forum name |
| intro | Test forum description |
| type | general |
| forcesubscribe | 0 |
And I am on "Course 1" course homepage
And I add a new discussion to "Test forum name" forum with:
| Subject | Test post subject one |
| Message | Test post message one |
@ -62,11 +65,15 @@ Feature: A user can control their own subscription preferences for a discussion
@javascript
Scenario: An automatic subscription forum can have discussions unsubscribed from
Given 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 |
| Subscription mode | Auto subscription |
Given the following "activity" exists:
| activity | forum |
| course | C1 |
| idnumber | forum1 |
| name | Test forum name |
| intro | Test forum description |
| type | general |
| forcesubscribe | 2 |
And I am on "Course 1" course homepage
And I add a new discussion to "Test forum name" forum with:
| Subject | Test post subject one |
| Message | Test post message one |
@ -105,11 +112,15 @@ Feature: A user can control their own subscription preferences for a discussion
@javascript
Scenario: A user does not lose their preferences when a forum is switch from optional to automatic
Given 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 |
| Subscription mode | Optional subscription |
Given the following "activity" exists:
| activity | forum |
| course | C1 |
| idnumber | forum1 |
| name | Test forum name |
| intro | Test forum description |
| type | general |
| forcesubscribe | 0 |
And I am on "Course 1" course homepage
And I add a new discussion to "Test forum name" forum with:
| Subject | Test post subject one |
| Message | Test post message one |
@ -150,11 +161,15 @@ Feature: A user can control their own subscription preferences for a discussion
@javascript
Scenario: A user does not lose their preferences when a forum is switch from optional to automatic
Given 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 |
| Subscription mode | Optional subscription |
Given the following "activity" exists:
| activity | forum |
| course | C1 |
| idnumber | forum1 |
| name | Test forum name |
| intro | Test forum description |
| type | general |
| forcesubscribe | 0 |
And I am on "Course 1" course homepage
And I add a new discussion to "Test forum name" forum with:
| Subject | Test post subject one |
| Message | Test post message one |
@ -194,11 +209,15 @@ Feature: A user can control their own subscription preferences for a discussion
And "Subscribe to this discussion" "checkbox" should exist in the "Test post subject two" "table_row"
Scenario: An optional forum prompts a user to subscribe to a discussion when posting unless they have already chosen not to subscribe
Given 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 |
| Subscription mode | Optional subscription |
Given the following "activity" exists:
| activity | forum |
| course | C1 |
| idnumber | forum1 |
| name | Test forum name |
| intro | Test forum description |
| type | general |
| forcesubscribe | 0 |
And I am on "Course 1" course homepage
And I add a new discussion to "Test forum name" forum with:
| Subject | Test post subject one |
| Message | Test post message one |
@ -230,11 +249,15 @@ Feature: A user can control their own subscription preferences for a discussion
And the field "Discussion subscription" matches value "I don't want to be notified of new posts in this discussion"
Scenario: An automatic forum prompts a user to subscribe to a discussion when posting unless they have already chosen not to subscribe
Given 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 |
| Subscription mode | Auto subscription |
Given the following "activity" exists:
| activity | forum |
| course | C1 |
| idnumber | forum1 |
| name | Test forum name |
| intro | Test forum description |
| type | general |
| forcesubscribe | 2 |
And I am on "Course 1" course homepage
And I add a new discussion to "Test forum name" forum with:
| Subject | Test post subject one |
| Message | Test post message one |
@ -267,6 +290,7 @@ Feature: A user can control their own subscription preferences for a discussion
Scenario: A guest should not be able to subscribe to a discussion
Given I am on site homepage
And I turn 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 |
@ -285,6 +309,7 @@ Feature: A user can control their own subscription preferences for a discussion
Scenario: A user who is not logged in should not be able to subscribe to a discussion
Given I am on site homepage
And I turn 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 |
@ -301,11 +326,15 @@ Feature: A user can control their own subscription preferences for a discussion
And "Unsubscribe from this discussion" "checkbox" should not exist
Scenario: A user can toggle their subscription preferences when viewing a discussion
Given 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 |
| Subscription mode | Optional subscription |
Given the following "activity" exists:
| activity | forum |
| course | C1 |
| idnumber | forum1 |
| name | Test forum name |
| intro | Test forum description |
| type | general |
| forcesubscribe | 0 |
And I am on "Course 1" course homepage
And I add a new discussion to "Test forum name" forum with:
| Subject | Test post subject one |
| Message | Test post message one |

View File

@ -17,19 +17,15 @@ Feature: Viewing the list of cohorts to enrol in a course
@javascript
Scenario: Check the teacher does not see the cohorts field without the proper capabilities
Given I log in as "admin"
Given the following "cohort" exists:
| name | Test cohort name |
| idnumber | 1337 |
| description | Test cohort description |
And I log in as "admin"
And I set the following system permissions of "Teacher" role:
| capability | permission |
| moodle/cohort:manage | Prohibit |
| moodle/cohort:view | Prohibit |
And I navigate to "Users > Accounts >Cohorts" in site administration
And I follow "Add new cohort"
And I set the following fields to these values:
| Name | Test cohort name |
| Context | System |
| Cohort ID | 1337 |
| Description | Test cohort description |
And I press "Save changes"
And I log out
And I log in as "teacher1"
And I am on "Course 1" course homepage
@ -40,16 +36,10 @@ Feature: Viewing the list of cohorts to enrol in a course
@javascript
Scenario: Check we show the cohorts field if there are some present
Given I log in as "admin"
And I navigate to "Users > Accounts >Cohorts" in site administration
And I follow "Add new cohort"
And I set the following fields to these values:
| Name | Test cohort name |
| Context | System |
| Cohort ID | 1337 |
| Description | Test cohort description |
And I press "Save changes"
And I log out
Given the following "cohort" exists:
| name | Test cohort name |
| idnumber | 1337 |
| description | Test cohort description |
And I log in as "teacher1"
And I am on "Course 1" course homepage
And I navigate to course participants