Skip to content

Commit

Permalink
MDL-78158 Behat: Use data generators to add blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
andelacruz committed Jul 3, 2023
1 parent 8dbb618 commit 9f101a3
Show file tree
Hide file tree
Showing 62 changed files with 381 additions and 332 deletions.
8 changes: 4 additions & 4 deletions backup/util/ui/tests/behat/import_course.feature
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ Feature: Import course's contents into another course
| activity | name | intro | course | idnumber | section |
| data | Test database name | Test database description | C1 | database1 | 2 |
| forum | Test forum name | Test forum name description | C1 | forum1 | 1 |
And I am on "Course 1" course homepage with editing mode on
And I add the "Comments" block
And I add the "Recent blog entries" block
And I turn editing mode off
And the following "blocks" exist:
| blockname | contextlevel | reference | pagetypepattern | defaultregion |
| comments | Course | C1 | course-view-* | side-pre |
| blog_recent | Course | C1 | course-view-* | side-pre |
When I import "Course 1" course into "Course 2" course using this options:
Then I should see "Test database name"
And I should see "Test forum name"
Expand Down
6 changes: 3 additions & 3 deletions backup/util/ui/tests/behat/restore_moodle2_courses.feature
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ Feature: Restore Moodle 2 course backups
| 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 the "Activities" block
And the following "blocks" exist:
| blockname | contextlevel | reference | pagetypepattern | defaultregion |
| activity_modules | Course | C1 | course-view-* | side-pre |

@javascript
Scenario: Restore a course in another existing course
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ Feature: The activity results block doesn't display student scores for unsupport
Given the following "activities" exist:
| activity | name | intro | course | section | idnumber | assignsubmission_file_enabled |
| assign | Test assignment | Offline text | C1 | 1 | assign1 | 0 |
And the following "blocks" exist:
| blockname | contextlevel | reference | pagetypepattern | defaultregion |
| activity_results | Course | C1 | course-view-* | side-pre |
And I am on "Course 1" course homepage
And I add the "Activity results" block
And I configure the "Activity results" block
And I set the following fields to these values:
| config_showbest | 1 |
Expand Down
4 changes: 3 additions & 1 deletion blocks/activity_results/tests/behat/defaultsettings.feature
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,10 @@ Feature: The activity results block can have administrator set defaults
| config_showbest_locked | 1 | block_activity_results |
| config_showworst | 0 | block_activity_results |
| config_showworst_locked | 1 | block_activity_results |
And the following "blocks" exist:
| blockname | contextlevel | reference | pagetypepattern | defaultregion |
| activity_results | Course | C1 | course-view-* | side-pre |
And I am on "Course 1" course homepage
And I add the "Activity results" block
When I configure the "Activity results" block
And the following fields match these values:
| config_showbest | 0 |
Expand Down
8 changes: 3 additions & 5 deletions blocks/badges/tests/behat/block_badges_frontpage.feature
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@ Feature: Enable Block Badges on the frontpage and view awarded badges
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
And I log in as "admin"
And I am on site homepage
And I turn editing mode on
And I add the "Latest badges" block
And I log out
And the following "blocks" exist:
| blockname | contextlevel | reference | pagetypepattern | defaultregion |
| badges | System | 1 | site-index | side-pre |
And I log in as "teacher1"
And I am on "Course 1" course homepage
# Issue badge 1 of 2
Expand Down
8 changes: 3 additions & 5 deletions blocks/blog_menu/tests/behat/block_blog_menu_activity.feature
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,9 @@ Feature: Enable Block blog menu in an activity
| idnumber | 0001 |
| section | 1 |
| assignsubmission_file_enabled | 0 |
And I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
And I follow "Test assignment 1"
And I add the "Blog menu" block
And I log out
And the following "blocks" exist:
| blockname | contextlevel | reference | pagetypepattern | defaultregion |
| blog_menu | Activity module | 0001 | mod-assign-view | side-pre |

Scenario: Students use the blog menu block to post blogs
Given I log in as "student1"
Expand Down
7 changes: 3 additions & 4 deletions blocks/blog_menu/tests/behat/block_blog_menu_course.feature
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@ Feature: Students can use block blog menu in a course
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |
| student2 | C1 | student |
And I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
And I add the "Blog menu" block
And I log out
And the following "blocks" exist:
| blockname | contextlevel | reference | pagetypepattern | defaultregion |
| blog_menu | Course | C1 | course-view-* | side-pre |

Scenario: Students use the blog menu block to post blogs
Given I log in as "student1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@ Feature: Enable Block blog menu on the frontpage
Given the following "users" exist:
| username | firstname | lastname | email | idnumber |
| student1 | Student | 1 | student1@example.com | S1 |
And I log in as "admin"
And I am on site homepage
And I turn editing mode on
And I add the "Blog menu" block
And I log out
And the following "blocks" exist:
| blockname | contextlevel | reference | pagetypepattern | defaultregion |
| blog_menu | System | 1 | site-index | side-pre |

Scenario: Students use the blog menu block to post blogs
Given I log in as "student1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,10 @@ Feature: Students can use the recent blog entries block to view recent entries o
| intro | Offline text |
| section | 1 |
| assignsubmission_file_enabled | 0 |
And I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
And I follow "Test assignment 1"
And I add the "Blog menu" block
And I add the "Recent blog entries" block
And I log out
And the following "blocks" exist:
| blockname | contextlevel | reference | pagetypepattern | defaultregion |
| blog_menu | Activity module | 0001 | mod-assign-view | side-pre |
| blog_recent | Activity module | 0001 | mod-assign-view | side-pre |

Scenario: Students use the recent blog entries block to view blogs
Given I log in as "student1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,12 @@ Feature: Students can use the recent blog entries block to view recent entries o
| user | course | role |
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |
And the following "blocks" exist:
| blockname | contextlevel | reference | pagetypepattern | defaultregion |
| blog_menu | Course | C1 | course-view-* | side-pre |
| blog_recent | Course | C1 | course-view-* | side-pre |
And the "multilang" filter is "on"
And the "multilang" filter applies to "content and headings"
And I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
And I add the "Blog menu" block
And I add the "Recent blog entries" block
And I log out

Scenario: Students use the recent blog entries block to view blogs
Given I log in as "student1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ Feature: Feature: Students can use the recent blog entries block to view recent
Given the following "users" exist:
| username | firstname | lastname | email | idnumber |
| student1 | Student | 1 | student1@example.com | S1 |
And the following "blocks" exist:
| blockname | contextlevel | reference | pagetypepattern | defaultregion |
| blog_recent | System | 1 | site-index | side-pre |
And the following config values are set as admin:
| unaddableblocks | | theme_boost|
And I log in as "admin"
And I am on site homepage
And I turn editing mode on
And I add the "Recent blog entries" block
And the following config values are set as admin:
| unaddableblocks | | theme_boost|
# TODO MDL-57120 site "Blogs" link not accessible without navigation block.
And I add the "Navigation" block if not present
And I log out
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,10 @@ Feature: Enable the calendar block in a course and test it's functionality

@javascript
Scenario: View a user event in the calendar block
Given I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
And I add the "Calendar" block
Given the following "blocks" exist:
| blockname | contextlevel | reference | pagetypepattern | defaultregion |
| calendar_month | Course | C1 | course-view-* | side-pre |
And I log in as "teacher1"
And I create a calendar event with form data:
| id_eventtype | User |
| id_name | User Event |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ Feature: Enable the calendar block on the site front page
Given the following "users" exist:
| username | firstname | lastname | email | idnumber |
| student1 | Student | 1 | student1@example.com | S1 |
And the following "blocks" exist:
| blockname | contextlevel | reference | pagetypepattern | defaultregion |
| calendar_month | System | 1 | site-index | side-pre |
And I log in as "admin"
And I am on site homepage
And I turn editing mode on
And I add the "Calendar" block
And I create a calendar event with form data:
| id_eventtype | Site |
| id_name | Site Event |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ Feature: View a site event on the frontpage
Given the following "users" exist:
| username | firstname | lastname | email | idnumber |
| teacher1 | Teacher | 1 | teacher1@example.com | T1 |
And the following "blocks" exist:
| blockname | contextlevel | reference | pagetypepattern | defaultregion |
| calendar_upcoming | System | 1 | site-index | side-pre |

@javascript
Scenario: View a site event in the upcoming events block on the frontpage
Given I log in as "admin"
And I create a calendar event with form data:
| id_eventtype | Site |
| id_name | My Site Event |
And I am on site homepage
And I turn editing mode on
And I add the "Upcoming events" block
And I log out
When I log in as "teacher1"
And I am on site homepage
Expand Down
7 changes: 3 additions & 4 deletions blocks/comments/tests/behat/add_comment.feature
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@ Feature: Add a comment to the comments block
| 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 the "Comments" block
And I log out
And the following "blocks" exist:
| blockname | contextlevel | reference | pagetypepattern | defaultregion |
| comments | Course | C1 | course-view-* | side-pre |
And I log in as "student1"
And I am on "Course 1" course homepage

Expand Down
4 changes: 3 additions & 1 deletion blocks/comments/tests/behat/block_comment_activity.feature
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@ Feature: Enable Block comments on an activity page and view comments
And the following "activities" exist:
| activity | course | idnumber | name | intro |
| page | C1 | page1 | Test page name | Test page description |
And the following "blocks" exist:
| blockname | contextlevel | reference | pagetypepattern | defaultregion |
| comments | Activity module | page1 | mod-page-* | side-pre |
And I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
And I follow "Test page name"
And I add the "Comments" block
And I follow "Show comments"
And I add "I'm a comment from the teacher" comment to comments block
And I log out
Expand Down
4 changes: 3 additions & 1 deletion blocks/comments/tests/behat/block_comment_course.feature
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ Feature: Enable Block comments on a course page and view comments
| user | course | role |
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |
And the following "blocks" exist:
| blockname | contextlevel | reference | pagetypepattern | defaultregion |
| comments | Course | C1 | course-view-* | side-pre |
And I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
And I add the "Comments" block
And I follow "Show comments"
And I add "I'm a comment from the teacher" comment to comments block
And I log out
Expand Down
5 changes: 3 additions & 2 deletions blocks/comments/tests/behat/block_comment_frontpage.feature
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ Feature: Enable Block comments on the frontpage and view comments
Given the following "users" exist:
| username | firstname | lastname | email | idnumber |
| teacher1 | Teacher | 1 | teacher1@example.com | T1 |
And the following "blocks" exist:
| blockname | contextlevel | reference | pagetypepattern | defaultregion |
| comments | System | 1 | site-index | side-pre |
And I log in as "admin"
And I am on site homepage
And I turn editing mode on
And I add the "Comments" block
And I follow "Show comments"
And I add "I'm a comment from admin" comment to comments block
And I log out
Expand Down
7 changes: 3 additions & 4 deletions blocks/comments/tests/behat/delete_comment.feature
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@ Feature: Delete comment block messages
| 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 the "Comments" block
And I log out
And the following "blocks" exist:
| blockname | contextlevel | reference | pagetypepattern | defaultregion |
| comments | Course | C1 | course-view-* | side-pre |
And I log in as "student1"
And I am on "Course 1" course homepage
And I add "Comment from student1" comment to comments block
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@ Feature: Enable Block Completion in a course using manual completion by others
| teacher1 | C1 | editingteacher |
| teacher2 | C1 | teacher |
| student1 | C1 | student |
And the following "blocks" exist:
| blockname | contextlevel | reference | pagetypepattern | defaultregion |
| completionstatus | Course | C1 | course-view-* | side-pre |

Scenario: Add the block to a the course and mark a student complete.
Given I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
And I add the "Course completion status" block
And I navigate to "Course completion" in current page administration
And I expand all fieldsets
And I set the following fields to these values:
Expand Down Expand Up @@ -55,7 +57,6 @@ Feature: Enable Block Completion in a course using manual completion by others
Scenario: Add the block to a the course and require multiple roles to mark a student complete.
Given I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
And I add the "Course completion status" block
And I navigate to "Course completion" in current page administration
And I expand all fieldsets
And I set the following fields to these values:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ Feature: Enable Block Completion in a course using manual self completion
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |
And I enable "selfcompletion" "block" plugin
And the following "blocks" exist:
| blockname | contextlevel | reference | pagetypepattern | defaultregion |
| completionstatus | Course | C1 | course-view-* | side-pre |
| selfcompletion | Course | C1 | course-view-* | side-pre |
And I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
And I add the "Course completion status" block
And I add the "Self completion" block
And I navigate to "Course completion" in current page administration
And I expand all fieldsets
And I set the following fields to these values:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@ Feature: Course summary block used in a course
| student1 | C101 | student |
| teacher1 | C101 | editingteacher |
And I enable "course_summary" "block" plugin
And I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
And I add the "Course/site summary" block
And I log out
And the following "blocks" exist:
| blockname | contextlevel | reference | pagetypepattern | defaultregion |
| course_summary | Course | C101 | course-view-* | side-pre |

Scenario: Student can view course summary
When I log in as "student1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ Feature: Course summary block used on the frontpage
Background:
Given I log in as "admin"
And I enable "course_summary" "block" plugin
And the following "blocks" exist:
| blockname | contextlevel | reference | pagetypepattern | defaultregion |
| course_summary | System | 1 | site-index | side-pre |
And I am on site homepage
And I turn editing mode on
And I add the "Course/site summary" block
And I navigate to "Site home > Site home settings" in site administration
And I set the following fields to these values:
| summary | Proved the summary block works! |
Expand Down
11 changes: 4 additions & 7 deletions blocks/login/tests/behat/login_block.feature
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,16 @@ Feature: Login from a block
Given the following "users" exist:
| username | password | firstname | lastname | email |
| testuser | testpass | Test | User | student1@example.com |
And I log in as "admin"
And I am on site homepage
And I turn editing mode on
And I add the "Login" block
And the following "blocks" exist:
| blockname | contextlevel | reference | pagetypepattern | defaultregion |
| login | System | 1 | site-index | side-pre |

Scenario: Login block visible to non-logged in users
Given I log out
When I am on homepage
Then "Login" "block" should exist

Scenario: Login as student through login block
Given I log out
And I am on homepage
Given I am on homepage
When I set the field "Username" to "testuser"
And I set the field "Password" to "testpass"
And I click on "Log in" "button" in the "Login" "block"
Expand Down
Loading

0 comments on commit 9f101a3

Please sign in to comment.