Skip to content

Commit

Permalink
MDL-72904 core_badges: Update behat tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Dias committed Dec 23, 2021
1 parent 96dd6c9 commit 6d5ab22
Show file tree
Hide file tree
Showing 13 changed files with 507 additions and 41 deletions.
15 changes: 6 additions & 9 deletions badges/tests/behat/add_badge.feature
Expand Up @@ -40,12 +40,11 @@ Feature: Add badges to the system
And I should see "Alignments (0)"
And I should not see "Create badge"
And I should not see "Issuer details"
And I follow "Overview"
And I select "Overview" from the "jump" singleselect
And I should see "Issuer details"
And I should see "Test Badge Site"
And I should see "testuser@example.com"
And I navigate to "Badges > Manage badges" in site administration
And I should see "Number of badges available: 1"
And I should not see "There are no badges available."

@javascript @_file_upload
Expand All @@ -62,7 +61,6 @@ Feature: Add badges to the system
And I press "Create badge"
And I wait until the page is ready
And I navigate to "Badges > Manage badges" in site administration
And I should see "Number of badges available: 1"
And I press "Add a new badge"
And I set the following fields to these values:
| Name | Test Badge 2 |
Expand All @@ -73,7 +71,7 @@ Feature: Add badges to the system
| Image caption | Test caption image |
And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
And I press "Create badge"
And I follow "Related badges (0)"
And I select "Related badges (0)" from the "jump" singleselect
And I should see "This badge does not have any related badges."
And I press "Add related badge"
And I follow "Related badges"
Expand All @@ -97,7 +95,7 @@ Feature: Add badges to the system
When I press "Create badge"
Then I should see "Edit details"
And I should see "Endorsement"
And I follow "Endorsement"
And I select "Endorsement" from the "jump" singleselect
And I set the following fields to these values:
| Endorser name | Endorser |
| Email | endorsement@example.com |
Expand All @@ -121,7 +119,7 @@ Feature: Add badges to the system
When I press "Create badge"
Then I should see "Test Badge"
And I should see "Endorsement"
And I follow "Alignments (0)"
And I select "Alignments (0)" from the "jump" singleselect
And I should see "This badge does not have any external skills or standards specified."
And I press "Add external skill or standard"
And I set the following fields to these values:
Expand Down Expand Up @@ -158,7 +156,6 @@ Feature: Add badges to the system
And I should see "Alignments (0)"
And I should not see "Create badge"
And I navigate to "Badges > Manage badges" in site administration
And I should see "Number of badges available: 1"
And I should not see "There are no badges available."
# See buttons from the "Site badges" page.
And I am on homepage
Expand All @@ -183,14 +180,14 @@ Feature: Add badges to the system
| Image caption | Test caption image |
And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
And I press "Create badge"
When I follow "Edit details"
When I select "Edit details" from the "jump" singleselect
And I should see "Test badge with 'apostrophe' and other friends (&@#)"
And I should not see "Issuer details"
And I set the following fields to these values:
| Name | Test badge renamed |
| Version | secondversion |
And I press "Save changes"
And I follow "Overview"
And I select "Overview" from the "jump" singleselect
Then I should not see "Test badge with 'apostrophe' and other friends (&@#)"
And I should not see "firstversion"
And I should see "Test badge renamed"
Expand Down
20 changes: 10 additions & 10 deletions badges/tests/behat/award_badge.feature
Expand Up @@ -63,15 +63,15 @@ Feature: Award badges
And I am on "Course 1" course homepage
And I navigate to "Badges > Manage badges" in current page administration
And I follow "Course Badge 1"
And I follow "Recipients (0)"
And I select "Recipients (0)" from the "jump" singleselect
And I press "Award badge"
# Award course badge 1 to student 1.
And I set the field "potentialrecipients[]" to "Student 1 (student1@example.com)"
When I press "Award badge"
And I am on "Course 1" course homepage
And I navigate to "Badges > Manage badges" in current page administration
And I follow "Course Badge 1"
And I follow "Recipients (1)"
And I select "Recipients (1)" from the "jump" singleselect
Then I should see "Recipients (1)"
And I log out
# Student 1 should have both badges.
Expand Down Expand Up @@ -152,7 +152,7 @@ Feature: Award badges
And I press "Save"
And I press "Enable access"
And I press "Continue"
And I follow "Recipients (0)"
And I select "Recipients (0)" from the "jump" singleselect
And I press "Award badge"
And I set the field "potentialrecipients[]" to "Teacher 1 (teacher1@example.com)"
And I press "Award badge"
Expand Down Expand Up @@ -181,7 +181,7 @@ Feature: Award badges
And I press "Save"
And I press "Enable access"
And I press "Continue"
And I follow "Recipients (0)"
And I select "Recipients (0)" from the "jump" singleselect
And I press "Award badge"
And I set the field "potentialrecipients[]" to "Student 2 (student2@example.com)"
And I press "Award badge"
Expand Down Expand Up @@ -284,15 +284,15 @@ Feature: Award badges
And I press "Save"
And I press "Enable access"
And I press "Continue"
And I follow "Recipients (0)"
And I select "Recipients (0)" from the "jump" singleselect
And I press "Award badge"
# Award course badge 1 to student 1.
And I set the field "potentialrecipients[]" to "Student 1 (student1@example.com)"
When I press "Award badge"
And I am on "Course 1" course homepage
And I navigate to "Badges > Manage badges" in current page administration
And I follow "Course Badge 1"
And I follow "Recipients (1)"
And I select "Recipients (1)" from the "jump" singleselect
Then I should see "Recipients (1)"
# Add course badge 2.
And I am on "Course 1" course homepage
Expand All @@ -310,15 +310,15 @@ Feature: Award badges
And I press "Save"
And I press "Enable access"
And I press "Continue"
And I follow "Recipients (0)"
And I select "Recipients (0)" from the "jump" singleselect
And I press "Award badge"
# Award course badge 2 to student 2.
And I set the field "potentialrecipients[]" to "Student 2 (student2@example.com)"
When I press "Award badge"
And I am on "Course 1" course homepage
And I navigate to "Badges > Manage badges" in current page administration
And I follow "Course Badge 2"
And I follow "Recipients (1)"
And I select "Recipients (1)" from the "jump" singleselect
Then I should see "Recipients (1)"
And I log out
And I trigger cron
Expand Down Expand Up @@ -351,7 +351,7 @@ Feature: Award badges
And I press "Save"
And I press "Enable access"
And I press "Continue"
And I follow "Recipients (0)"
And I select "Recipients (0)" from the "jump" singleselect
And I press "Award badge"
And I set the field "potentialrecipients[]" to "Student 2 (student2@example.com)"
And I press "Award badge"
Expand All @@ -361,7 +361,7 @@ Feature: Award badges
And I navigate to "Badges > Manage badges" in current page administration
And I follow "Course Badge"
Then I should see "Recipients (2)"
And I follow "Recipients (2)"
And I select "Recipients (2)" from the "jump" singleselect
And I press "Award badge"
And I set the field "existingrecipients[]" to "Student 2 (student2@example.com)"
And I press "Revoke badge"
Expand Down
4 changes: 2 additions & 2 deletions badges/tests/behat/backpack.feature
Expand Up @@ -60,7 +60,7 @@ Feature: Backpack badges
And I press "Save"
And I press "Enable access"
And I press "Continue"
And I follow "Recipients (0)"
And I select "Recipients (0)" from the "jump" singleselect
And I press "Award badge"
And I set the field "potentialrecipients[]" to "Student 1 (student1@example.com)"
And I press "Award badge"
Expand Down Expand Up @@ -97,7 +97,7 @@ Feature: Backpack badges
And I press "Save"
And I press "Enable access"
And I press "Continue"
And I follow "Recipients (0)"
And I select "Recipients (0)" from the "jump" singleselect
And I press "Award badge"
And I set the field "potentialrecipients[]" to "Student 1 (student1@example.com)"
And I press "Award badge"
Expand Down
147 changes: 147 additions & 0 deletions badges/tests/behat/badge_navigation.feature
@@ -0,0 +1,147 @@
@core @core_badges @_file_upload @javascript
Feature: Test tertiary navigation as various users

Background:
Given the following "users" exist:
| username | firstname | lastname | email |
| student1 | Student | 1 | student1@example.com |
| teacher | Teacher | 1 | teacher@example.com |
| nonediting | Nonediting | 1 | nonediting@example.com |
And the following "courses" exist:
| fullname | shortname | format | enablecompletion |
| Course 1 | C1 | topics | 1 |
And the following "course enrolments" exist:
| user | course | role |
| teacher | C1 | editingteacher |
| student1 | C1 | student |
| nonediting | C1 | teacher |
# Create system badge and define a criterion.
And I log in as "admin"
And I am on "Course 1" course homepage
And I navigate to "Badges > Add a new badge" in current page administration
And I set the following fields to these values:
| Name | Testing course badge |
| Version | 1.1 |
| Language | Catalan |
| Description | Testing course badge description |
| Image author | http://author.example.com |
| Image caption | Test caption image |
And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
And I press "Create badge"
And I set the field "type" to "Manual issue by role"
And I expand all fieldsets
And I set the field "Teacher" to "1"
And I press "Save"
And I am on site homepage
And I navigate to "Badges > Add a new badge" in site administration
And I set the following fields to these values:
| Name | Testing site badge |
| Version | 1.1 |
| Language | Catalan |
| Description | Testing site badge description |
| Image author | http://author.example.com |
| Image caption | Test caption image |
And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
And I press "Create badge"
And I set the field "type" to "Manual issue by role"
And I expand all fieldsets
And I set the field "Teacher" to "1"
And I press "Save"

Scenario Outline: Check navigation as different users in a course context
Given I log in as "<user>"
And I am on "Course 1" course homepage
When I navigate to "Badges" in current page administration
Then "Manage badges" "button" should exist
And "Add a new badge" "button" <createbutton>
And I should see "<activetab>" is active in secondary navigation
And I click on "Manage badges" "button"
And "Manage badges" "button" should not exist
And "Back" "button" should exist
And "Add a new badge" "button" <createbutton>
And I should see "<activetab>" is active in secondary navigation
And I click on "Back" "button"
And "Back" "button" should not exist
And "Manage badges" "button" should exist
And "Add a new badge" "button" <createbutton>
And I should see "<activetab>" is active in secondary navigation
And I click on "Manage badges" "button"
And I click on "Testing course badge" "link"
And "Manage badges" "button" should not exist
And "Add a new badge" "button" should not exist
And "Back" "button" should exist
And I should see "<activetab>" is active in secondary navigation
And I click on "Back" "button"
And "Back" "button" should exist
And "Manage badges" "button" should not exist
And "Add a new badge" "button" <createbutton>
And I should see "<activetab>" is active in secondary navigation

Examples:
| user | createbutton | activetab |
| admin | should exist | More |
| teacher | should exist | More |
| nonediting | should not exist | Badges |

Scenario: Check navigation as a student
Given I log in as "student1"
And I am on "Course 1" course homepage
When I navigate to "Badges" in current page administration
Then "Back" "button" should not exist
And "Manage badges" "button" should not exist
And "Add a new badge" "button" should not exist
And I should see "Badges" is active in secondary navigation

Scenario: Check navigation as an admin in a site context
Given I log in as "admin"
When I navigate to "Badges > Manage badges" in site administration
Then "Manage badges" "button" should not exist
And "Add a new badge" "button" should exist
And I should see "Site administration" is active in secondary navigation
And I click on "Testing site badge" "link"
And "Manage badges" "button" should not exist
And "Add a new badge" "button" should not exist
And "Back" "button" should exist
And I should see "Site administration" is active in secondary navigation
And I click on "Back" "button"
And "Back" "button" should not exist
And "Manage badges" "button" should not exist
And "Add a new badge" "button" should exist

Scenario Outline: Check secondary navigation highlights after tertiary nav jumps in site admin
Given I log in as "admin"
And I navigate to "Badges > Manage badges" in site administration
And I click on "Testing site badge" "link"
When I select "<option>" from the "jump" singleselect
Then I should see "Site administration" is active in secondary navigation

Examples:
| option |
| Overview |
| Edit details |
| Criteria |
| Message |
| Recipients (0) |
| Endorsement |
| Related badges (0) |
| Alignments (0) |

Scenario Outline: Check secondary navigation highlights after tertiary nav jumps in course as admin
Given I log in as "admin"
And I am on "Course 1" course homepage
And I navigate to "Badges" in current page administration
And I click on "Manage badges" "button"
And I click on "Testing course badge" "link"
When I select "<option>" from the "jump" singleselect
Then I should see "More" is active in secondary navigation

Examples:
| option |
| Overview |
| Edit details |
| Criteria |
| Message |
| Recipients (0) |
| Endorsement |
| Related badges (0) |
| Alignments (0) |
8 changes: 4 additions & 4 deletions badges/tests/behat/criteria_cohort.feature
Expand Up @@ -146,7 +146,7 @@ Feature: Award badges based on cohort
And I press "Save"
When I press "Enable access"
And I press "Continue"
And I follow "Recipients (0)"
And I select "Recipients (0)" from the "jump" singleselect
And I press "Award badge"
And I set the field "potentialrecipients[]" to "First User (first@example.com)"
And I press "Award badge"
Expand Down Expand Up @@ -198,7 +198,7 @@ Feature: Award badges based on cohort
And I set the field "update" to "Any"
When I press "Enable access"
And I press "Continue"
And I follow "Recipients (1)"
And I select "Recipients (1)" from the "jump" singleselect
And I press "Award badge"
And I set the field "potentialrecipients[]" to "First User (first@example.com)"
And I press "Award badge"
Expand Down Expand Up @@ -255,7 +255,7 @@ Feature: Award badges based on cohort
And I set the field "update" to "Any"
When I press "Enable access"
And I press "Continue"
And I follow "Recipients (1)"
And I select "Recipients (1)" from the "jump" singleselect
And I press "Award badge"
And I set the field "potentialrecipients[]" to "First User (first@example.com)"
And I press "Award badge"
Expand Down Expand Up @@ -314,7 +314,7 @@ Feature: Award badges based on cohort
And I set the field "update" to "All"
When I press "Enable access"
And I press "Continue"
And I follow "Recipients (0)"
And I select "Recipients (0)" from the "jump" singleselect
And I press "Award badge"
And I set the field "potentialrecipients[]" to "First User (first@example.com)"
And I press "Award badge"
Expand Down

0 comments on commit 6d5ab22

Please sign in to comment.