Skip to content

Commit

Permalink
MDL-78158 behat: Behat cleanup and optimisation
Browse files Browse the repository at this point in the history
  • Loading branch information
andelacruz committed Jul 3, 2023
1 parent 9f101a3 commit 09d654b
Show file tree
Hide file tree
Showing 34 changed files with 117 additions and 324 deletions.
6 changes: 3 additions & 3 deletions backup/util/ui/tests/behat/import_course.feature
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ Feature: Import course's contents into another course
Scenario: Import course's contents to another course
Given I log in as "teacher1"
And the following "activities" exist:
| 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 |
| activity | name | course | idnumber |
| data | Test database name | C1 | database1 |
| forum | Test forum name | C1 | forum1 |
And the following "blocks" exist:
| blockname | contextlevel | reference | pagetypepattern | defaultregion |
| comments | Course | C1 | course-view-* | side-pre |
Expand Down
2 changes: 2 additions & 0 deletions backup/util/ui/tests/behat/restore_moodle2_courses.feature
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ Feature: Restore Moodle 2 course backups
And the following "blocks" exist:
| blockname | contextlevel | reference | pagetypepattern | defaultregion |
| activity_modules | Course | C1 | course-view-* | side-pre |
And I log in as "admin"
And I am on "Course 1" course homepage with editing mode on

@javascript
Scenario: Restore a course in another existing course
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ Feature: The activity results block doesn't display student scores for unsupport
| config_gradeformat | Percentages |
| config_nameformat | Display full names |
And I press "Save changes"
When I follow "Test assignment"
And I navigate to "Settings" in current page administration
When I am on the "Test assignment" "assign activity editing" page
And I set the following fields to these values:
| id_grade_modgrade_type | None |
And I press "Save and return to course"
Expand Down
2 changes: 0 additions & 2 deletions blocks/activity_results/tests/behat/defaultsettings.feature
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ Feature: The activity results block can have administrator set defaults
| course | C1 |
| idnumber | 0001 |
| name | Test assignment |
| 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
Expand Down
7 changes: 2 additions & 5 deletions blocks/badges/tests/behat/block_badges_frontpage.feature
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ Feature: Enable Block Badges on the frontpage and view awarded badges
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
And I am on the "Course 1" course page logged in as teacher1
# Issue badge 1 of 2
And I navigate to "Badges > Add a new badge" in current page administration
And I set the following fields to these values:
Expand All @@ -35,7 +34,5 @@ Feature: Enable Block Badges on the frontpage and view awarded badges
And I press "Award badge"
And I set the field "potentialrecipients[]" to "Teacher 1 ([email protected])"
And I press "Award badge"
And I log out
When I log in as "teacher1"
And I am on site homepage
When I am on site homepage
Then I should see "Badge 1" in the "Latest badges" "block"
69 changes: 18 additions & 51 deletions blocks/blog_menu/tests/behat/block_blog_menu_activity.feature
Original file line number Diff line number Diff line change
Expand Up @@ -31,26 +31,21 @@ Feature: Enable Block blog menu in an activity
| 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"
And I am on "Course 1" course homepage
And I follow "Test assignment 1"
Given I am on the "Test assignment 1" "assign activity" page logged in as student1
And I follow "Add a new entry"
When I set the following fields to these values:
| Entry title | S1 First Blog |
| Blog entry body | This is my awesome blog! |
And I press "Save changes"
Then I should see "S1 First Blog"
And I should see "This is my awesome blog!"
And I am on "Course 1" course homepage
And I follow "Test assignment 1"
And I am on the "Test assignment 1" "assign activity" page
And I follow "Blog entries"
And I should see "S1 First Blog"
And I should see "This is my awesome blog!"

Scenario: Students use the blog menu block to view their blogs about the activity
Given I log in as "student1"
And I am on "Course 1" course homepage
And I follow "Test assignment 1"
Given I am on the "Test assignment 1" "assign activity" page logged in as student1
And I follow "Add an entry about this Assignment"
And I set the following fields to these values:
| Entry title | S1 First Blog |
Expand All @@ -59,10 +54,7 @@ Feature: Enable Block blog menu in an activity
And I should see "S1 First Blog"
And I should see "This is my awesome blog about this Assignment!"
And I should see "Associated Assignment: Test assignment 1"
And I log out
And I log in as "student2"
And I am on "Course 1" course homepage
And I follow "Test assignment 1"
And I am on the "Test assignment 1" "assign activity" page logged in as student2
And I follow "Add a new entry"
And I set the following fields to these values:
| Entry title | S2 Second Blog |
Expand All @@ -71,8 +63,7 @@ Feature: Enable Block blog menu in an activity
And I should see "S2 Second Blog"
And I should see "My unrelated blog!"
And I should not see "Associated Assignment: Test assignment 1"
And I am on "Course 1" course homepage
And I follow "Test assignment 1"
And I am on the "Test assignment 1" "assign activity" page
And I follow "Add an entry about this Assignment"
And I set the following fields to these values:
| Entry title | S2 First Blog |
Expand All @@ -81,17 +72,14 @@ Feature: Enable Block blog menu in an activity
And I should see "S2 First Blog"
And I should see "My course blog is better!"
And I should see "Associated Assignment: Test assignment 1"
And I am on "Course 1" course homepage
And I follow "Test assignment 1"
And I am on the "Test assignment 1" "assign activity" page
When I follow "View my entries about this Assignment"
Then I should see "S2 First Blog"
And I should not see "S2 Second Blog"
And I should not see "S1 First Blog"

Scenario: Students use the blog menu block to view all blogs about the assignment
Given I log in as "student1"
And I am on "Course 1" course homepage
And I follow "Test assignment 1"
Given I am on the "Test assignment 1" "assign activity" page logged in as student1
And I follow "Add an entry about this Assignment"
And I set the following fields to these values:
| Entry title | S1 First Blog |
Expand All @@ -100,10 +88,7 @@ Feature: Enable Block blog menu in an activity
And I should see "S1 First Blog"
And I should see "This is my awesome blog about this Assignment!"
And I should see "Associated Assignment: Test assignment 1"
And I log out
And I log in as "student2"
And I am on "Course 1" course homepage
And I follow "Test assignment 1"
And I am on the "Test assignment 1" "assign activity" page logged in as student2
And I follow "Add a new entry"
And I set the following fields to these values:
| Entry title | S2 Second Blog |
Expand All @@ -112,8 +97,7 @@ Feature: Enable Block blog menu in an activity
And I should see "S2 Second Blog"
And I should see "My unrelated blog!"
And I should not see "Associated Assignment: Test assignment 1"
And I am on "Course 1" course homepage
And I follow "Test assignment 1"
And I am on the "Test assignment 1" "assign activity" page
And I follow "Add an entry about this Assignment"
And I set the following fields to these values:
| Entry title | S2 First Blog |
Expand All @@ -122,17 +106,14 @@ Feature: Enable Block blog menu in an activity
And I should see "S2 First Blog"
And I should see "My course blog is better!"
And I should see "Associated Assignment: Test assignment 1"
And I am on "Course 1" course homepage
And I follow "Test assignment 1"
And I am on the "Test assignment 1" "assign activity" page
When I follow "View all entries about this Assignment"
Then I should see "S1 First Blog"
And I should see "S2 First Blog"
And I should not see "S2 Second Blog"

Scenario: Students use the blog menu block to view all their blog entries
Given I log in as "student1"
And I am on "Course 1" course homepage
And I follow "Test assignment 1"
Given I am on the "Test assignment 1" "assign activity" page logged in as student1
And I follow "Add an entry about this Assignment"
And I set the following fields to these values:
| Entry title | S1 First Blog |
Expand All @@ -141,10 +122,7 @@ Feature: Enable Block blog menu in an activity
And I should see "S1 First Blog"
And I should see "This is my awesome blog about this Assignment!"
And I should see "Associated Assignment: Test assignment 1"
And I log out
And I log in as "student2"
And I am on "Course 1" course homepage
And I follow "Test assignment 1"
And I am on the "Test assignment 1" "assign activity" page logged in as student2
And I follow "Add a new entry"
And I set the following fields to these values:
| Entry title | S2 Second Blog |
Expand All @@ -153,8 +131,7 @@ Feature: Enable Block blog menu in an activity
And I should see "S2 Second Blog"
And I should see "My unrelated blog!"
And I should not see "Associated Assignment: Test assignment 1"
And I am on "Course 1" course homepage
And I follow "Test assignment 1"
And I am on the "Test assignment 1" "assign activity" page
And I follow "Add an entry about this Assignment"
And I set the following fields to these values:
| Entry title | S2 First Blog |
Expand All @@ -163,17 +140,14 @@ Feature: Enable Block blog menu in an activity
And I should see "S2 First Blog"
And I should see "My course blog is better!"
And I should see "Associated Assignment: Test assignment 1"
And I am on "Course 1" course homepage
And I follow "Test assignment 1"
And I am on the "Test assignment 1" "assign activity" page
When I follow "Blog entries"
Then I should see "S2 First Blog"
And I should see "S2 Second Blog"
And I should not see "S1 First Blog"

Scenario: Teacher searches for student blogs
Given I log in as "student1"
And I am on "Course 1" course homepage
And I follow "Test assignment 1"
Given I am on the "Test assignment 1" "assign activity" page logged in as student1
And I follow "Add an entry about this Assignment"
And I set the following fields to these values:
| Entry title | S1 First Blog |
Expand All @@ -182,10 +156,7 @@ Feature: Enable Block blog menu in an activity
And I should see "S1 First Blog"
And I should see "This is my awesome blog about this Assignment!"
And I should see "Associated Assignment: Test assignment 1"
And I log out
And I log in as "student2"
And I am on "Course 1" course homepage
And I follow "Test assignment 1"
And I am on the "Test assignment 1" "assign activity" page logged in as student2
And I follow "Add a new entry"
And I set the following fields to these values:
| Entry title | S2 Second Blog |
Expand All @@ -194,8 +165,7 @@ Feature: Enable Block blog menu in an activity
And I should see "S2 Second Blog"
And I should see "My unrelated blog!"
And I should not see "Associated Assignment: Test assignment 1"
And I am on "Course 1" course homepage
And I follow "Test assignment 1"
And I am on the "Test assignment 1" "assign activity" page
And I follow "Add an entry about this Assignment"
And I set the following fields to these values:
| Entry title | S2 First Blog |
Expand All @@ -204,10 +174,7 @@ Feature: Enable Block blog menu in an activity
And I should see "S2 First Blog"
And I should see "My course blog is better!"
And I should see "Associated Assignment: Test assignment 1"
And I log out
When I log in as "teacher1"
And I am on "Course 1" course homepage
And I follow "Test assignment 1"
When I am on the "Test assignment 1" "assign activity" page logged in as teacher1
And I set the field "Search" to "First"
And I press "Search"
Then I should see "S1 First Blog"
Expand Down
35 changes: 10 additions & 25 deletions blocks/blog_menu/tests/behat/block_blog_menu_course.feature
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ Feature: Students can use block blog menu in a course
| blog_menu | Course | C1 | course-view-* | side-pre |

Scenario: Students use the blog menu block to post blogs
Given I log in as "student1"
And I am on "Course 1" course homepage
Given I am on the "Course 1" course page logged in as student1
And I follow "Add a new entry"
When I set the following fields to these values:
| Entry title | S1 First Blog |
Expand All @@ -38,8 +37,7 @@ Feature: Students can use block blog menu in a course
And I should see "This is my awesome blog!"

Scenario: Students use the blog menu block to view their blogs about the course
Given I log in as "student1"
And I am on "Course 1" course homepage
Given I am on the "Course 1" course page logged in as student1
And I follow "Add an entry about this course"
And I set the following fields to these values:
| Entry title | S1 First Blog |
Expand All @@ -48,9 +46,7 @@ Feature: Students can use block blog menu in a course
And I should see "S1 First Blog"
And I should see "This is my awesome blog about this course!"
And I should see "Associated Course: C1"
And I log out
And I log in as "student2"
And I am on "Course 1" course homepage
And I am on the "Course 1" course page logged in as student2
And I follow "Add a new entry"
And I set the following fields to these values:
| Entry title | S2 Second Blog |
Expand All @@ -75,8 +71,7 @@ Feature: Students can use block blog menu in a course
And I should not see "S1 First Blog"

Scenario: Students use the blog menu block to view all blogs about the course
Given I log in as "student1"
And I am on "Course 1" course homepage
Given I am on the "Course 1" course page logged in as student1
And I follow "Add an entry about this course"
And I set the following fields to these values:
| Entry title | S1 First Blog |
Expand All @@ -85,9 +80,7 @@ Feature: Students can use block blog menu in a course
And I should see "S1 First Blog"
And I should see "This is my awesome blog about this course!"
And I should see "Associated Course: C1"
And I log out
And I log in as "student2"
And I am on "Course 1" course homepage
And I am on the "Course 1" course page logged in as student2
And I follow "Add a new entry"
And I set the following fields to these values:
| Entry title | S2 Second Blog |
Expand All @@ -112,8 +105,7 @@ Feature: Students can use block blog menu in a course
And I should not see "S2 Second Blog"

Scenario: Students use the blog menu block to view all their blog entries
Given I log in as "student1"
And I am on "Course 1" course homepage
Given I am on the "Course 1" course page logged in as student1
And I follow "Add an entry about this course"
And I set the following fields to these values:
| Entry title | S1 First Blog |
Expand All @@ -122,9 +114,7 @@ Feature: Students can use block blog menu in a course
And I should see "S1 First Blog"
And I should see "This is my awesome blog about this course!"
And I should see "Associated Course: C1"
And I log out
And I log in as "student2"
And I am on "Course 1" course homepage
And I am on the "Course 1" course page logged in as student2
And I follow "Add a new entry"
And I set the following fields to these values:
| Entry title | S2 Second Blog |
Expand All @@ -149,8 +139,7 @@ Feature: Students can use block blog menu in a course
And I should not see "S1 First Blog"

Scenario: Teacher searches for student blogs
Given I log in as "student1"
And I am on "Course 1" course homepage
Given I am on the "Course 1" course page logged in as student1
And I follow "Add an entry about this course"
And I set the following fields to these values:
| Entry title | S1 First Blog |
Expand All @@ -159,9 +148,7 @@ Feature: Students can use block blog menu in a course
And I should see "S1 First Blog"
And I should see "This is my awesome blog about this course!"
And I should see "Associated Course: C1"
And I log out
And I log in as "student2"
And I am on "Course 1" course homepage
And I am on the "Course 1" course page logged in as student2
And I follow "Add a new entry"
And I set the following fields to these values:
| Entry title | S2 Second Blog |
Expand All @@ -179,9 +166,7 @@ Feature: Students can use block blog menu in a course
And I should see "S2 First Blog"
And I should see "My course blog is better!"
And I should see "Associated Course: C1"
And I log out
When I log in as "teacher1"
And I am on "Course 1" course homepage
When I am on the "Course 1" course page logged in as teacher1
And I set the field "Search" to "First"
And I press "Search"
Then I should see "S1 First Blog"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ Feature: Students can use the recent blog entries block to view recent entries o
| 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"
And I am on "Course 1" course homepage
And I follow "Test assignment 1"
Given I am on the "Test assignment 1" "assign activity" page logged in as student1
And I follow "Add an entry about this Assignment"
When I set the following fields to these values:
| Entry title | S1 First Blog |
Expand All @@ -48,9 +46,7 @@ Feature: Students can use the recent blog entries block to view recent entries o
And I should see "This is my awesome blog!"

Scenario: Students only see a few entries in the recent blog entries block
Given I log in as "student1"
And I am on "Course 1" course homepage
And I follow "Test assignment 1"
Given I am on the "Test assignment 1" "assign activity" page logged in as student1
And I follow "Add an entry about this Assignment"
# Blog 1 of 5
And I set the following fields to these values:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ Feature: Students can use the recent blog entries block to view recent entries o
And the "multilang" filter applies to "content and headings"

Scenario: Students use the recent blog entries block to view blogs
Given I log in as "student1"
And I am on "Course 1" course homepage
Given I am on the "Course 1" course page logged in as student1
And I follow "Add an entry about this course"
When I set the following fields to these values:
| Entry title | S1 First Blog <span lang="RU" class="multilang">RUSSIAN</span><span lang="EN" class="multilang">ENGLISH</span> |
Expand All @@ -39,8 +38,7 @@ Feature: Students can use the recent blog entries block to view recent entries o
And I should see "This is my awesome blog!"

Scenario: Students only see a few entries in the recent blog entries block
Given I log in as "student1"
And I am on "Course 1" course homepage
Given I am on the "Course 1" course page logged in as student1
And I follow "Add an entry about this course"
# Blog 1 of 5
And I set the following fields to these values:
Expand Down
Loading

0 comments on commit 09d654b

Please sign in to comment.