MDL-43738 behat: Updating steps definitions and deprecating methods
[moodle.git] / badges / tests / behat / award_badge.feature
CommitLineData
561e9bb9 1@core @core_badges @_file_upload
27806552
YB
2Feature: Award badges
3 In order to award badges to users for their achievements
4 As an admin
5 I need to add criteria to badges in the system
6
27806552 7 @javascript
844d74d7 8 Scenario: Award profile badge
d1e55a47
DM
9 Given I log in as "admin"
10 And I expand "Site administration" node
27806552
YB
11 And I expand "Badges" node
12 And I follow "Add a new badge"
13 And I fill the moodle form with:
844d74d7 14 | Name | Profile Badge |
27806552
YB
15 | Description | Test badge description |
16 | issuername | Test Badge Site |
17 | issuercontact | testuser@test-badge-site.com |
07622451 18 And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
27806552
YB
19 And I press "Create badge"
20 And I select "Profile completion" from "type"
27806552
YB
21 And I check "First name"
22 And I check "Email address"
844d74d7 23 And I check "Phone"
27806552
YB
24 When I press "Save"
25 Then I should see "Profile completion"
26 And I should see "First name"
27 And I should see "Email address"
28 And I should not see "Criteria for this badge have not been set up yet."
844d74d7
JM
29 And I press "Enable access"
30 And I press "Continue"
31 And I expand "My profile settings" node
32 And I follow "Edit profile"
33 And I expand all fieldsets
34 And I fill in "Phone" with "123456789"
35 And I press "Update profile"
36 And I follow "My badges"
37 Then I should see "Profile Badge"
38 And I should not see "There are no badges available."
27806552
YB
39
40 @javascript
844d74d7
JM
41 Scenario: Award site badge
42 Given the following "users" exists:
43 | username | firstname | lastname | email |
44 | teacher | teacher | 1 | teacher1@asd.com |
45 | student | student | 1 | student1@asd.com |
d1e55a47 46 And I log in as "admin"
844d74d7 47 And I expand "Site administration" node
27806552
YB
48 And I expand "Badges" node
49 And I follow "Add a new badge"
50 And I fill the moodle form with:
844d74d7
JM
51 | Name | Site Badge |
52 | Description | Site badge description |
53 | issuername | Tester of site badge |
07622451 54 And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
27806552 55 And I press "Create badge"
844d74d7
JM
56 And I select "Manual issue by role" from "type"
57 And I check "Teacher"
27806552
YB
58 And I press "Save"
59 And I press "Enable access"
60 And I press "Continue"
844d74d7
JM
61 And I follow "Recipients (0)"
62 And I press "Award badge"
63 And I select "teacher 1 (teacher1@asd.com)" from "potentialrecipients[]"
64 And I press "Award badge"
65 And I select "student 1 (student1@asd.com)" from "potentialrecipients[]"
66 And I press "Award badge"
67 When I follow "Site Badge"
68 Then I should see "Recipients (2)"
69 And I log out
70 And I log in as "student"
71 And I expand "My profile" node
72 And I follow "My badges"
73 Then I should see "Site Badge"
68c13c68
JM
74
75 @javascript
76 Scenario: Award course badge
77 Given the following "users" exists:
78 | username | firstname | lastname | email |
79 | teacher1 | Teacher | 1 | teacher1@asd.com |
80 | student1 | Student | 1 | student1@asd.com |
81 | student2 | Student | 2 | student2@asd.com |
82 And the following "courses" exists:
83 | fullname | shortname | category | groupmode |
84 | Course 1 | C1 | 0 | 1 |
85 And the following "course enrolments" exists:
86 | user | course | role |
87 | teacher1 | C1 | editingteacher |
88 | student1 | C1 | student |
89 | student2 | C1 | student |
68c13c68
JM
90 And I log in as "teacher1"
91 And I follow "Course 1"
92 And I click on "//span[text()='Badges']" "xpath_element" in the "Administration" "block"
93 And I follow "Add a new badge"
94 And I fill the moodle form with:
95 | Name | Course Badge |
96 | Description | Course badge description |
97 | issuername | Tester of course badge |
07622451 98 And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
68c13c68
JM
99 And I press "Create badge"
100 And I select "Manual issue by role" from "type"
101 And I check "Teacher"
102 And I press "Save"
103 And I press "Enable access"
104 And I press "Continue"
105 And I follow "Recipients (0)"
106 And I press "Award badge"
107 And I select "Student 2 (student2@asd.com)" from "potentialrecipients[]"
108 And I press "Award badge"
109 And I select "Student 1 (student1@asd.com)" from "potentialrecipients[]"
110 When I press "Award badge"
111 And I follow "Course Badge"
112 Then I should see "Recipients (2)"
113 And I log out
114 And I log in as "student1"
115 And I follow "Course 1"
116 And I expand "My profile" node
117 And I follow "My badges"
066ef320
JM
118 Then I should see "Course Badge"
119
120 @javascript
121 Scenario: Award badge on activity completion
122 Given the following "courses" exists:
123 | fullname | shortname | category |
124 | Course 1 | C1 | 0 |
125 And the following "users" exists:
126 | username | firstname | lastname | email |
127 | teacher1 | Teacher | Frist | teacher1@asd.com |
128 | student1 | Student | First | student1@asd.com |
129 And the following "course enrolments" exists:
130 | user | course | role |
131 | teacher1 | C1 | editingteacher |
132 | student1 | C1 | student |
066ef320
JM
133 And I log in as "admin"
134 And I set the following administration settings values:
135 | Enable completion tracking | 1 |
136 And I follow "Home"
137 And I follow "Course 1"
138 And I follow "Edit settings"
139 And I fill the moodle form with:
140 | Enable completion tracking | Yes |
141 And I press "Save changes"
142 And I turn editing mode on
143 And I add a "Assignment" to section "1" and I fill the form with:
144 | Assignment name | Test assignment name |
145 | Description | Submit your online text |
146 And I log out
147 And I log in as "teacher1"
148 And I follow "Course 1"
149 And I click on "//span[text()='Badges']" "xpath_element" in the "Administration" "block"
150 And I follow "Add a new badge"
151 And I fill the moodle form with:
152 | Name | Course Badge |
153 | Description | Course badge description |
154 | issuername | Tester of course badge |
07622451 155 And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
066ef320
JM
156 And I press "Create badge"
157 And I select "Activity completion" from "type"
158 And I check "Test assignment name"
159 And I press "Save"
160 And I press "Enable access"
161 When I press "Continue"
162 And I log out
163 And I log in as "student1"
164 And I follow "Course 1"
165 And I expand "My profile" node
166 And I follow "My badges"
167 Then I should see "There are no badges available."
168 And I follow "Home"
169 And I follow "Course 1"
170 And I press "Mark as complete: Test assignment name"
171 And I expand "My profile" node
172 And I follow "My badges"
173 Then I should see "Course Badge"
174
175 @javascript
176 Scenario: Award badge on course completion
177 Given the following "courses" exists:
178 | fullname | shortname | category |
179 | Course 1 | C1 | 0 |
180 And the following "users" exists:
181 | username | firstname | lastname | email |
182 | teacher1 | Teacher | Frist | teacher1@asd.com |
183 | student1 | Student | First | student1@asd.com |
184 And the following "course enrolments" exists:
185 | user | course | role |
186 | teacher1 | C1 | editingteacher |
187 | student1 | C1 | student |
066ef320
JM
188 And I log in as "admin"
189 And I set the following administration settings values:
190 | Enable completion tracking | 1 |
191 And I follow "Home"
192 And I follow "Course 1"
193 And I follow "Edit settings"
194 And I fill the moodle form with:
195 | Enable completion tracking | Yes |
196 And I press "Save changes"
197 And I turn editing mode on
198 And I add a "Assignment" to section "1" and I fill the form with:
199 | Assignment name | Test assignment name |
200 | Description | Submit your online text |
201 | assignsubmission_onlinetext_enabled | 1 |
202 And I follow "Course completion"
203 And I select "2" from "id_overall_aggregation"
204 And I click on "Condition: Activity completion" "link"
205 And I check "Assign - Test assignment name"
206 And I press "Save changes"
207 And I log out
208 And I log in as "teacher1"
209 And I follow "Course 1"
210 And I click on "//span[text()='Badges']" "xpath_element" in the "Administration" "block"
211 And I follow "Add a new badge"
212 And I fill the moodle form with:
213 | Name | Course Badge |
214 | Description | Course badge description |
215 | issuername | Tester of course badge |
07622451 216 And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
066ef320
JM
217 And I press "Create badge"
218 And I select "Course completion" from "type"
219 And I fill the moodle form with:
220 | grade_2 | 0 |
221 And I press "Save"
222 And I press "Enable access"
223 When I press "Continue"
224 And I log out
225 And I log in as "student1"
226 And I follow "Course 1"
227 And I expand "My profile" node
228 And I follow "My badges"
229 Then I should see "There are no badges available."
230 And I follow "Home"
231 And I follow "Course 1"
232 And I press "Mark as complete: Test assignment name"
233 And I log out
234 And I log in as "admin"
235 # We can't wait for cron to happen, so the admin manually triggers it.
236 And I trigger cron
237 # The admin needs to trigger cron twice to see the completion status as completed.
b71419ae
DM
238 # We wait more than 1 minute because of the next cron run scheduled time.
239 And I wait "61" seconds
066ef320
JM
240 And I trigger cron
241 # Finally the admin goes back to homepage to continue the user story.
242 And I am on homepage
243 And I log out
244 And I log in as "student1"
245 And I expand "My profile" node
246 And I follow "My badges"
a57263d1 247 Then I should see "Course Badge"