Skip to content

Commit

Permalink
MDL-72354 badges: Fix behat tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sarjona committed Jul 19, 2024
1 parent 879901e commit 1a74342
Showing 1 changed file with 26 additions and 22 deletions.
48 changes: 26 additions & 22 deletions badges/tests/behat/view_badge.feature
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,27 @@ Feature: Display badges
| username | firstname | lastname | email |
| student1 | Student | 1 | student1@example.com |
# Create system badge and define a criterion.
Given the following "core_badges > Badge" exists:
| name | Testing system badge |
| description | Testing system badge description |
| image | badges/tests/behat/badge.png |
| version | 1.1 |
| status | 0 |
| type | 1 |
| language | ca |
And the following "core_badges > Criteria" exists:
| badge | Testing system badge |
| role | editingteacher |
And the following "core_badges > Badge" exists:
| name | Testing system badge |
| status | inactive |
| version | 1.1 |
| language | ca |
| description | Testing system badge description |
| image | badges/tests/behat/badge.png |
| imageauthorurl | http://author.example.com |
| imagecaption | My caption image |
And the following "core_badges > Criterias" exist:
| badge | role |
| Testing system badge | editingteacher |
And I log in as "admin"
And I navigate to "Badges > Manage badges" in site administration
And I follow "Testing system badge"
And I select "Criteria" from the "jump" singleselect

Scenario: Display badge without expired date
# Enable the badge.
Given I press "Enable access"
Given I press "Enable access" action in the "Testing system badge" report row
And I click on "Enable" "button" in the "Confirm" "dialogue"
# Award badge to student1.
And I select "Recipients (0)" from the "jump" singleselect
And I press "Award badge"
When I press "Award badge" action in the "Testing system badge" report row
And I set the field "potentialrecipients[]" to "Student 1 ([email protected])"
And I press "Award badge"
# Check badge details are displayed.
Expand All @@ -49,7 +47,9 @@ Feature: Display badges

Scenario: Display badge with ALL criteria
# Add another criterion and enable the badge.
Given I set the field "type" to "Profile completion"
Given I follow "Testing system badge"
And I select "Criteria" from the "jump" singleselect
And I set the field "type" to "Profile completion"
And I set the field "id_field_firstname" to "1"
And I press "Save"
And I press "Enable access"
Expand All @@ -63,7 +63,7 @@ Feature: Display badges
And I navigate to "Badges > Manage badges" in site administration
And I follow "Testing system badge"
And I select "Recipients (1)" from the "jump" singleselect
And I press "View issued badge" action in the "Student 1" report row
When I press "View issued badge" action in the "Student 1" report row
Then I should see "Awarded to Student 1"
And I should see "Complete ALL of the listed requirements."
And I should see "This badge has to be awarded by a user with the following role:"
Expand All @@ -76,15 +76,17 @@ Feature: Display badges

Scenario: Display badge with ANY criteria
# Add another criterion and enable the badge.
Given I set the field "type" to "Profile completion"
Given I follow "Testing system badge"
And I select "Criteria" from the "jump" singleselect
And I set the field "type" to "Profile completion"
And I set the field "id_field_firstname" to "1"
And I press "Save"
And I set the field "update" to "2"
And I press "Enable access"
And I click on "Enable" "button" in the "Confirm" "dialogue"
# Check badge details are displayed.
And I select "Recipients (2)" from the "jump" singleselect
And I press "View issued badge" action in the "Student 1" report row
When I press "View issued badge" action in the "Student 1" report row
Then I should see "Awarded to Student 1"
And I should see "Complete ANY of the listed requirements."
And I should see "This badge has to be awarded by a user with the following role:"
Expand All @@ -97,7 +99,8 @@ Feature: Display badges

Scenario: Display badge with expiration date but not expired yet
# Set expired date to badge (future date).
Given I select "Edit details" from the "jump" singleselect
Given I press "Edit" action in the "Testing system badge" report row
And I expand all fieldsets
When I click on "Relative date" "radio"
And I set the field "expireperiod[number]" to "1"
And I press "Save changes"
Expand All @@ -120,7 +123,8 @@ Feature: Display badges

Scenario: Display expired badge
# Set expired date to badge (relative date 1 seconds after the date of issue it).
Given I select "Edit details" from the "jump" singleselect
Given I press "Edit" action in the "Testing system badge" report row
And I expand all fieldsets
When I click on "Relative date" "radio"
And I set the field "expireperiod[timeunit]" to "1"
And I set the field "expireperiod[number]" to "1"
Expand Down

0 comments on commit 1a74342

Please sign in to comment.