Skip to content

Commit

Permalink
MDL-73648 badges: add Behat generator class for creating badges.
Browse files Browse the repository at this point in the history
  • Loading branch information
paulholden committed May 26, 2023
1 parent 4ed782d commit 12bc873
Show file tree
Hide file tree
Showing 9 changed files with 369 additions and 198 deletions.
81 changes: 30 additions & 51 deletions badges/tests/behat/backpack.feature
@@ -1,4 +1,4 @@
@core @core_badges @_file_upload
@core @core_badges
Feature: Backpack badges
Test the settings to add/update a backpack for a site and user.
I need to verify display backpack in the my profile
Expand Down Expand Up @@ -37,36 +37,21 @@ Feature: Backpack badges

@javascript
Scenario: Verify backback settings
Given I am on homepage
And I log in as "admin"
And I navigate to "Badges > Badges settings" in site administration
And I set the following fields to these values:
| External backpack connection | 1 |
And I press "Save changes"
And I navigate to "Badges > Manage backpacks" in site administration
And I click on "Move up" "link" in the "https://dc.imsglobal.org" "table_row"
And I navigate to "Badges > Add a new badge" in site administration
And I set the following fields to these values:
| Name | Test badge verify backpack |
| Version | v1 |
| Language | English |
| Description | Test 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 set the field "Manager" to "1"
And I press "Save"
And I press "Enable access"
And I press "Continue"
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"
And I log out
When I am on homepage
And I log in as "student1"
Given the following "core_badges > Badge" exists:
| name | Test badge verify backpack |
| version | 1 |
| language | en |
| description | Test badge description |
| image | badges/tests/behat/badge.png |
| imageauthorurl | http://author.example.com |
| imagecaption | Test caption image |
And the following "core_badges > Criteria" exists:
| badge | Test badge verify backpack |
| role | editingteacher |
And the following "core_badges > Issued badge" exists:
| badge | Test badge verify backpack |
| user | student1 |
When I log in as "student1"
And I follow "Preferences" in the user menu
And I follow "Backpack settings"
Then I should see "https://dc.imsglobal.org"
Expand All @@ -82,26 +67,20 @@ Feature: Backpack badges
And I press "Save changes"
And I navigate to "Badges > Manage backpacks" in site administration
And I click on "Move up" "link" in the "https://dc.imsglobal.org" "table_row"
And I navigate to "Badges > Add a new badge" in site administration
And I set the following fields to these values:
| Name | Test badge verify backpack |
| Version | v1 |
| Language | English |
| Description | Test 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 set the field "Manager" to "1"
And I press "Save"
And I press "Enable access"
And I press "Continue"
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"
And I log out
And the following "core_badges > Badge" exists:
| name | Test badge verify backpack |
| version | 1 |
| language | en |
| description | Test badge description |
| image | badges/tests/behat/badge.png |
| imageauthorurl | http://author.example.com |
| imagecaption | Test caption image |
And the following "core_badges > Criteria" exists:
| badge | Test badge verify backpack |
| role | editingteacher |
And the following "core_badges > Issued badge" exists:
| badge | Test badge verify backpack |
| user | student1 |
And the following "setup backpack connected" exist:
| user | externalbackpack |
| student1 | https://dc.imsglobal.org |
Expand Down
60 changes: 27 additions & 33 deletions badges/tests/behat/badge_navigation.feature
@@ -1,4 +1,4 @@
@core @core_badges @_file_upload @javascript
@core @core_badges @javascript
Feature: Test tertiary navigation as various users

Background:
Expand All @@ -15,38 +15,32 @@ Feature: Test tertiary navigation as various users
| 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"
# Create a course badge in our test course.
And the following "core_badges > Badge" exists:
| name | Testing course badge |
| status | inactive |
| type | 2 |
| course | C1 |
| version | 1.1 |
| language | ca |
| description | Testing course badge description |
| image | badges/tests/behat/badge.png |
| imageauthorurl | http://author.example.com |
| imagecaption | Test caption image |
# Create a site badge.
And the following "core_badges > Badge" exists:
| name | Testing site badge |
| status | inactive |
| version | 1.1 |
| language | ca |
| description | Testing site badge description |
| image | badges/tests/behat/badge.png |
| imageauthorurl | http://author.example.com |
| imagecaption | Test caption image |
And the following "core_badges > Criterias" exist:
| badge | role |
| Testing course badge | editingteacher |
| Testing site badge | editingteacher |

Scenario Outline: Check navigation as different users in a course context
Given I log in as "<user>"
Expand Down
18 changes: 8 additions & 10 deletions badges/tests/behat/criteria_activity.feature
@@ -1,4 +1,4 @@
@mod @mod_quiz @core @core_badges @_file_upload @javascript
@mod @mod_quiz @core @core_badges @javascript
Feature: Award badges based on activity completion
In order to ensure a student has learned the material before being marked complete
As a teacher
Expand Down Expand Up @@ -38,15 +38,13 @@ Feature: Award badges based on activity completion
And user "student2" has attempted "Test quiz name" with responses:
| slot | response |
| 1 | False |
And I log in as "teacher1"
And I am on "Course 1" course homepage
And I change window size to "large"
And I navigate to "Badges > Add a new badge" in current page administration
And I set the following fields to these values:
| Name | Course Badge |
| Description | Course badge description |
And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
And I press "Create badge"
And the following "core_badges > Badge" exists:
| name | Course Badge |
| status | 0 |
| type | 2 |
| course | C1 |
| description | Course badge description |
| image | badges/tests/behat/badge.png |

Scenario: Student earns a badge using activity completion, but does not get passing grade
Given I am on the "Course 1" course page logged in as teacher1
Expand Down

0 comments on commit 12bc873

Please sign in to comment.