Skip to content

Commit

Permalink
MDL-70152 behat: Forum behat generators use UI
Browse files Browse the repository at this point in the history
Behat cleanup and optimisation
  • Loading branch information
andelacruz committed May 29, 2023
1 parent 640db57 commit c95ef35
Show file tree
Hide file tree
Showing 80 changed files with 471 additions and 1,017 deletions.
8 changes: 2 additions & 6 deletions admin/tool/behat/tests/behat/edit_permissions.feature
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,12 @@ Feature: Edit capabilities
And "mod/forum:addquestion" capability has "Allow" permission

Scenario: Module capabilities overrides
Given I log in as "teacher1"
And the following "activity" exists:
Given the following "activity" exists:
| activity | forum |
| course | C1 |
| idnumber | 00001 |
| name | I'm the name |
| intro | I'm the introduction |
| section | 1 |
And I am on "Course 1" course homepage with editing mode on
And I follow "I'm the name"
And I am on the "I'm the name" "forum activity" page logged in as teacher1
And I navigate to "Permissions" in current page administration
And I override the system permissions of "Student" role with:
| mod/forum:deleteanypost | Prohibit |
Expand Down
1 change: 0 additions & 1 deletion admin/tool/usertours/tests/behat/tour_filter.feature
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ Feature: Apply tour filters to a tour
| wiki | C1 | Test wiki name | First page | collaborative | | | |
| forum | C2 | Test forum name | | | 001 | Test forum description | general |
And I log in as "admin"
And I am on "Course 1" course homepage with editing mode on
And I add a new user tour with:
| Name | Wiki tour |
| Description | A tour with both matches |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,21 +58,18 @@ Feature: availability_completion
@javascript
Scenario: Test completion and course cache rebuild
Given the following "activities" exist:
| activity | name | intro | course | idnumber |
| forum | forum 1 | forum 1 | C1 | forum1 |
And I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
And I open "forum 1" actions menu
And I click on "Edit settings" "link" in the "forum 1" activity
| activity | name | course | idnumber |
| forum | forum 1 | C1 | forum1 |
And the following forum discussions exist in course "Course 1":
| user | forum | name | message |
| student1 | forum 1 | Forum posst 1 | This is the body |
And I am on the "forum 1" "forum activity editing" page logged in as teacher1
And I set the following fields to these values:
| Completion tracking | Show activity as complete when conditions are met |
| completionview | 1 |
| completionpostsenabled | 1 |
| completionposts | 2 |
And I press "Save and return to course"
And I add a new discussion to "forum 1" forum with:
| Subject | Forum post 1 |
| Message | This is the body |
And I am on "Course 1" course homepage with editing mode on
And I add a "Page" to section "2"
And I set the following fields to these values:
Expand All @@ -87,25 +84,18 @@ Feature: availability_completion
| Required completion status | must be marked complete |
| cm | forum 1 |
And I press "Save and return to course"
And I log out
And I log in as "student1"
When I am on "Course 1" course homepage
When I am on the "Course 1" course page logged in as student1
# Page 2 should not appear yet.
Then I should not see "Page 2" in the "region-main" "region"
And I click on "forum 1" "link" in the "region-main" "region"
# Page 2 should not appear yet.
And I should not see "Page 2" in the "region-main" "region"
And I log out
And I log in as "teacher1"
And I am on "Course 1" course homepage
And I am on the "forum 1" "forum activity editing" page
And I am on the "forum 1" "forum activity editing" page logged in as teacher1
And I expand all fieldsets
And I set the following fields to these values:
| completionpostsenabled | 0 |
And I press "Save and display"
And I log out
And I log in as "student1"
And I am on "Course 1" course homepage
And I am on the "Course 1" course page logged in as student1
And I click on "forum 1" "link" in the "region-main" "region"
And I am on "Course 1" course homepage
And I should see "Page 2" in the "region-main" "region"
10 changes: 2 additions & 8 deletions availability/tests/behat/edit_availability.feature
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ Feature: edit_availability
And the following "activity" exists:
| activity | forum |
| course | C1 |
| section | 1 |
| name | MyForum |
| intro | x |

Scenario: Confirm the 'enable availability' option is working
Given the following config values are set as admin:
Expand Down Expand Up @@ -184,9 +182,7 @@ Feature: edit_availability
# Button does not exist when conditional access restrictions are turned off.
Given the following config values are set as admin:
| enableavailability | 0 |
And I log in as "admin"
And I am on "Course 1" course homepage with editing mode on
And I am on the "MyForum" "forum activity editing" page
And I am on the "MyForum" "forum activity editing" page logged in as admin
When I expand all fieldsets
Then "Add group/grouping access restriction" "button" should not exist

Expand All @@ -196,9 +192,7 @@ Feature: edit_availability
Given the following "groupings" exist:
| name | course | idnumber |
| GX1 | C1 | GXI1 |
And I log in as "admin"
And I am on "Course 1" course homepage with editing mode on
And I am on the "MyForum" "forum activity editing" page
And I am on the "MyForum" "forum activity editing" page logged in as admin
When I expand all fieldsets
Then the "Add group/grouping access restriction" "button" should be disabled

Expand Down
44 changes: 10 additions & 34 deletions backup/util/ui/tests/behat/restore_moodle2_courses.feature
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,13 @@ Feature: Restore Moodle 2 course backups
| Course 3 | C3 | 0 | topics | 2 | 0 |
| Course 4 | C4 | 0 | topics | 20 | 0 |
And the following "activities" exist:
| activity | course | idnumber | name | intro | section | externalurl |
| assign | C3 | assign1 | Test assign name | Assign description | 1 | |
| data | C3 | data1 | Test database name | Database description | 2 | |
| forum | C1 | 0001 | Test forum name | Test forum description | 1 | |
| url | C1 | url1 | Test URL name | Test URL description | 3 | http://www.moodle.org |
| activity | course | idnumber | name | intro | section | externalurl |
| assign | C3 | assign1 | Test assign name | Assign description | 1 | |
| data | C3 | data1 | Test database name | Database description | 2 | |
| forum | C1 | 0001 | Test forum name | | 1 | |
| url | C1 | url1 | Test URL name | Test URL description | 3 | http://www.moodle.org |
And I log in as "admin"
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 the "Activities" block

@javascript
Expand Down Expand Up @@ -69,7 +66,6 @@ Feature: Restore Moodle 2 course backups
| course | C1 |
| section | 1 |
| name | Test forum post backup name |
| intro | Test forum post backup description |
And I am on the "Course 1" "restore" page
And I merge "test_backup.mbz" backup into the current course after deleting it's contents using this options:
| Schema | Section 3 | 0 |
Expand Down Expand Up @@ -112,11 +108,7 @@ Feature: Restore Moodle 2 course backups

@javascript
Scenario: Restore a backup in an existing course retaining the backup course settings
Given I add a "URL" to section "3" and I fill the form with:
| Name | Test URL name |
| Description | Test URL description |
| id_externalurl | http://www.moodle.org |
And I hide section "3"
Given I hide section "3"
And I hide section "7"
When I backup "Course 1" course using this options:
| Confirmation | Filename | test_backup.mbz |
Expand All @@ -138,11 +130,7 @@ Feature: Restore Moodle 2 course backups

@javascript
Scenario: Restore a backup in an existing course keeping the target course settings
Given I add a "URL" to section "3" and I fill the form with:
| Name | Test URL name |
| Description | Test URL description |
| id_externalurl | http://www.moodle.org |
And I hide section "3"
Given I hide section "3"
And I hide section "7"
When I backup "Course 1" course using this options:
| Confirmation | Filename | test_backup.mbz |
Expand All @@ -164,11 +152,7 @@ Feature: Restore Moodle 2 course backups

@javascript
Scenario: Restore a backup in an existing course deleting contents and retaining the backup course settings
Given I add a "URL" to section "3" and I fill the form with:
| Name | Test URL name |
| Description | Test URL description |
| id_externalurl | http://www.moodle.org |
And I hide section "3"
Given I hide section "3"
And I hide section "7"
When I backup "Course 1" course using this options:
| Initial | Include enrolled users | 0 |
Expand All @@ -192,11 +176,7 @@ Feature: Restore Moodle 2 course backups

@javascript
Scenario: Restore a backup in an existing course deleting contents and keeping the current course settings
Given I add a "URL" to section "3" and I fill the form with:
| Name | Test URL name |
| Description | Test URL description |
| id_externalurl | http://www.moodle.org |
And I hide section "3"
Given I hide section "3"
And I hide section "7"
When I backup "Course 1" course using this options:
| Initial | Include enrolled users | 0 |
Expand All @@ -220,11 +200,7 @@ Feature: Restore Moodle 2 course backups

@javascript
Scenario: Restore a backup in an existing course deleting contents decreasing the number of sections
Given I add a "URL" to section "3" and I fill the form with:
| Name | Test URL name |
| Description | Test URL description |
| id_externalurl | http://www.moodle.org |
And I hide section "3"
Given I hide section "3"
And I hide section "7"
When I backup "Course 1" course using this options:
| Initial | Include enrolled users | 0 |
Expand Down
17 changes: 6 additions & 11 deletions blocks/navigation/tests/behat/participants_link.feature
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,15 @@ Feature: Displaying the link to the Participants page

@javascript
Scenario: Course participants link is displayed to users depending on role permissions settings
And I log in as "admin"
And I am on "Course1" 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 am on the "Course1" "enrolment methods" page
Given the following "activities" exist:
| activity | course | name |
| forum | C1 | Test forum name |
And I am on the "Course1" "enrolment methods" page logged in as admin
And I click on "Edit" "link" in the "Guest access" "table_row"
And I set the following fields to these values:
| Allow guest access | Yes |
And I press "Save changes"
And I log out
When I log in as "guest"
And I am on "Course1" course homepage
When I am on the "Course1" course page logged in as guest
Then I should not see "Participants" in the "Navigation" "block"
And I am on the "Test forum name" "forum activity" page
And I should not see "Participants" in the "Navigation" "block"
Expand All @@ -60,8 +56,7 @@ Feature: Displaying the link to the Participants page
And I set the following system permissions of "Guest" role:
| capability | permission |
| moodle/course:viewparticipants | Allow |
And I log in as "guest"
And I am on "Course1" course homepage
And I am on the "Course1" course page logged in as guest
And I should see "Participants" in the "Navigation" "block"
And I am on the "Test forum name" "forum activity" page
And I should see "Participants" in the "Navigation" "block"
Expand Down
Loading

0 comments on commit c95ef35

Please sign in to comment.