source: moodle/trunk/fuentes/admin/tool/behat/tests/behat/data_generators.feature @ 136

Last change on this file since 136 was 136, checked in by mabarracus, 4 years ago

Ported code to xenial

File size: 17.9 KB
Line 
1@tool @tool_behat
2Feature: Set up contextual data for tests
3  In order to write tests quickly
4  As a developer
5  I need to fill the database with fixtures
6
7  Scenario: Add a bunch of users
8    Given the following "users" exist:
9      | username  | password  | firstname | lastname |
10      | testuser  | testuser  |  |  |
11      | testuser2 | testuser2 | TestFirstname | TestLastname |
12    And I log in as "testuser"
13    And I log out
14    When I log in as "testuser2"
15    Then I should see "TestFirstname"
16
17  @javascript
18  Scenario: Add a bunch of courses and categories
19    Given the following "categories" exist:
20      | name | category | idnumber |
21      | Cat 1 | 0 | CAT1 |
22      | Cat 2 | CAT1 | CAT2 |
23      | Cat 3 | CAT1 | CAT3 |
24    And the following "courses" exist:
25      | fullname | shortname | category |
26      | Course 1 | COURSE1 | CAT3 |
27      | Course 2 | COURSE2 | CAT3 |
28      | Course 3 | COURSE3 | 0 |
29    When I log in as "admin"
30    Then I should see "Course 1"
31    And I should see "Course 2"
32    And I should see "Course 3"
33    And I go to the courses management page
34    And I follow "Cat 1"
35    And I should see "Cat 2"
36    And I should see "Cat 3"
37    And I follow "Cat 3"
38    And I should see "Course 1"
39    And I should see "Course 2"
40    And I follow "Cat 2"
41    And I should see "No courses in this category"
42    And I follow "Miscellaneous"
43    And I should see "Course 3"
44
45  @javascript
46  Scenario: Add a bunch of groups and groupings
47    Given the following "courses" exist:
48      | fullname | shortname |
49      | Course 1 | C1 |
50    And the following "groups" exist:
51      | name | course | idnumber |
52      | Group 1 | C1 | G1 |
53      | Group 2 | C1 | G2 |
54    And the following "groupings" exist:
55      | name | course | idnumber |
56      | Grouping 1 | C1 | GG1 |
57      | Grouping 2 | C1 | GG2 |
58    When I log in as "admin"
59    And I follow "Course 1"
60    And I expand "Users" node
61    And I follow "Groups"
62    Then I should see "Group 1"
63    And I should see "Group 2"
64    And I follow "Groupings"
65    And I should see "Grouping 1"
66    And I should see "Grouping 2"
67
68  @javascript
69  Scenario: Role overrides
70    Given the following "users" exist:
71      | username | firstname | lastname | email |
72      | teacher1 | Teacher | 1 | teacher1@asd.com |
73      | student1 | Student | 1 | student1@asd.com |
74    And the following "categories" exist:
75      | name | category | idnumber |
76      | Cat 1 | 0 | CAT1 |
77    And the following "courses" exist:
78      | fullname | shortname |
79      | Course 1 | C1 |
80    And the following "course enrolments" exist:
81      | user | course | role |
82      | student1 | C1 | student |
83      | teacher1 | C1 | editingteacher |
84    And the following "permission overrides" exist:
85      | capability | permission | role | contextlevel | reference |
86      | mod/forum:editanypost | Allow | student | Course | C1 |
87      | mod/forum:replynews | Prevent | editingteacher | Course | C1 |
88    When I log in as "admin"
89    And I follow "Course 1"
90    And I expand "Users" node
91    And I follow "Permissions"
92    And I set the field "Advanced role override" to "Student (1)"
93    Then "mod/forum:editanypost" capability has "Allow" permission
94    And I press "Cancel"
95    And I set the field "Advanced role override" to "Teacher (1)"
96    And "mod/forum:replynews" capability has "Prevent" permission
97    And I press "Cancel"
98
99  Scenario: Add course enrolments
100    Given the following "users" exist:
101      | username | firstname | lastname | email |
102      | student1 | Student | 1 | student1@asd.com |
103    And the following "courses" exist:
104      | fullname | shortname | format |
105      | Course 1 | C1 | topics |
106    And the following "course enrolments" exist:
107      | user | course | role |
108      | student1 | C1 | student |
109    When I log in as "student1"
110    And I follow "Course 1"
111    Then I should see "Topic 1"
112
113  Scenario: Add role assigns
114    Given the following "roles" exist:
115      | name                   | shortname | description      | archetype      |
116      | Custom editing teacher | custom1   | My custom role 1 | editingteacher |
117      | Custom student         | custom2   |                  |                |
118    And the following "users" exist:
119      | username | firstname | lastname | email |
120      | user1 | User | 1 | user1@moodlemoodle.com |
121      | user2 | User | 2 | user2@moodlemoodle.com |
122      | user3 | User | 3 | user3@moodlemoodle.com |
123      | user4 | User | 4 | user4@moodlemoodle.com |
124      | user5 | User | 5 | user5@moodlemoodle.com |
125    And the following "categories" exist:
126      | name | category | idnumber |
127      | Cat 1 | 0 | CAT1 |
128    And the following "courses" exist:
129      | fullname | shortname | category |
130      | Course 1 | C1 | CAT1 |
131    And the following "course enrolments" exist:
132      | user | course | role |
133      | user4 | C1 | custom1 |
134    And the following "role assigns" exist:
135      | user  | role           | contextlevel | reference |
136      | user1 | manager        | System       |           |
137      | user2 | editingteacher | Category     | CAT1      |
138      | user3 | editingteacher | Course       | C1        |
139      | user5 | custom2        | System       |           |
140    When I log in as "user1"
141    Then I should see "Front page settings"
142    And I log out
143    And I log in as "user2"
144    And I follow "Course 1"
145    And I should see "Turn editing on"
146    And I log out
147    And I log in as "user3"
148    And I follow "Course 1"
149    And I should see "Turn editing on"
150    And I log out
151    And I log in as "user4"
152    And I follow "Course 1"
153    And I should see "Turn editing on"
154    And I log out
155    And I log in as "user5"
156    And I should see "You are logged in as"
157    And I follow "Course 1"
158    And I should see "You can not enrol yourself in this course."
159
160  Scenario: Add modules
161    Given the following "courses" exist:
162      | fullname | shortname |
163      | Course 1 | C1 |
164    And the following "activities" exist:
165      | activity   | name                   | intro                         | course | idnumber    |
166      | assign     | Test assignment name   | Test assignment description   | C1     | assign1     |
167      | assignment | Test assignment22 name | Test assignment22 description | C1     | assignment1 |
168      | book       | Test book name         | Test book description         | C1     | book1       |
169      | chat       | Test chat name         | Test chat description         | C1     | chat1       |
170      | choice     | Test choice name       | Test choice description       | C1     | choice1     |
171      | data       | Test database name     | Test database description     | C1     | data1       |
172      | feedback   | Test feedback name     | Test feedback description     | C1     | feedback1   |
173      | folder     | Test folder name       | Test folder description       | C1     | folder1     |
174      | forum      | Test forum name        | Test forum description        | C1     | forum1      |
175      | glossary   | Test glossary name     | Test glossary description     | C1     | glossary1   |
176      | imscp      | Test imscp name        | Test imscp description        | C1     | imscp1      |
177      | label      | Test label name        | Test label description        | C1     | label1      |
178      | lesson     | Test lesson name       | Test lesson description       | C1     | lesson1     |
179      | lti        | Test lti name          | Test lti description          | C1     | lti1        |
180      | page       | Test page name         | Test page description         | C1     | page1       |
181      | quiz       | Test quiz name         | Test quiz description         | C1     | quiz1       |
182      | resource   | Test resource name     | Test resource description     | C1     | resource1   |
183      | scorm      | Test scorm name        | Test scorm description        | C1     | scorm1      |
184      | survey     | Test survey name       | Test survey description       | C1     | survey1     |
185      | url        | Test url name          | Test url description          | C1     | url1        |
186      | wiki       | Test wiki name         | Test wiki description         | C1     | wiki1       |
187      | workshop   | Test workshop name     | Test workshop description     | C1     | workshop1   |
188    And the following "scales" exist:
189      | name | scale |
190      | Test Scale 1 | Disappointing, Good, Very good, Excellent |
191    And the following "activities" exist:
192      | activity   | name                            | intro                         | course | idnumber    | grade |
193      | assign     | Test assignment name with scale | Test assignment description   | C1     | assign1     | Test Scale 1 |
194    When I log in as "admin"
195    And I follow "Course 1"
196    Then I should see "Test assignment name"
197    # Assignment 2.2 module type is disabled by default
198    # And I should see "Test assignment22 name"
199    And I should see "Test book name"
200    And I should see "Test chat name"
201    And I should see "Test choice name"
202    And I should see "Test database name"
203    # Feedback module type is disabled by default
204    # And I should see "Test feedback name"
205    And I should see "Test folder name"
206    And I should see "Test forum name"
207    And I should see "Test glossary name"
208    And I should see "Test imscp name"
209    # We don't see label name, we see only description:
210    And I should see "Test label description"
211    And I should see "Test lesson name"
212    And I should see "Test lti name"
213    And I should see "Test page name"
214    And I should see "Test quiz name"
215    And I should see "Test resource name"
216    And I should see "Test scorm name"
217    And I should see "Test survey name"
218    And I should see "Test url name"
219    And I should see "Test wiki name"
220    And I should see "Test workshop name"
221    And I follow "Test assignment name"
222    And I should see "Test assignment description"
223    And I follow "C1"
224    And I follow "Test assignment name with scale"
225    And I follow "Edit settings"
226    And the field "Type" matches value "Scale"
227
228  @javascript
229  Scenario: Add relations between users and groups
230    Given the following "users" exist:
231      | username | firstname | lastname | email |
232      | student1 | Student | 1 | student1@asd.com |
233      | student2 | Student | 2 | student2@asd.com |
234    And the following "courses" exist:
235      | fullname | shortname |
236      | Course 1 | C1 |
237    And the following "groups" exist:
238      | name | course | idnumber |
239      | Group 1 | C1 | G1 |
240      | Group 2 | C1 | G2 |
241    And the following "groupings" exist:
242      | name | course | idnumber |
243      | Grouping 1 | C1 | GG1 |
244    And the following "course enrolments" exist:
245      | user | course | role |
246      | student1 | C1 | student |
247      | student2 | C1 | student |
248    And the following "group members" exist:
249      | user | group |
250      | student1 | G1 |
251      | student2 | G2 |
252    And the following "grouping groups" exist:
253      | grouping | group |
254      | GG1 | G1 |
255    When I log in as "admin"
256    And I follow "Course 1"
257    And I expand "Users" node
258    And I follow "Groups"
259    Then the "groups" select box should contain "Group 1 (1)"
260    And the "groups" select box should contain "Group 2 (1)"
261    And I set the field "groups" to "Group 1 (1)"
262    And the "members" select box should contain "Student 1"
263    And I set the field "groups" to "Group 2 (1)"
264    And the "members" select box should contain "Student 2"
265
266  Scenario: Add cohorts and cohort members with data generator
267    Given the following "categories" exist:
268      | name  | category | idnumber |
269      | Cat 1 | 0        | CAT1     |
270    And the following "users" exist:
271      | username | firstname | lastname | email |
272      | student1 | Student | 1 | student1@asd.com |
273      | student2 | Student | 2 | student2@asd.com |
274    And the following "cohorts" exist:
275      | name            | idnumber |
276      | System cohort A | CHSA     |
277    And the following "cohorts" exist:
278      | name                 | idnumber | contextlevel | reference |
279      | System cohort B      | CHSB     | System       |           |
280      | Cohort in category   | CHC      | Category     | CAT1      |
281      | Empty cohort         | CHE      | Category     | CAT1      |
282    And the following "cohort members" exist:
283      | user     | cohort |
284      | student1 | CHSA   |
285      | student2 | CHSB   |
286      | student1 | CHSB   |
287      | student1 | CHC    |
288    When I log in as "admin"
289    And I navigate to "Cohorts" node in "Site administration > Users > Accounts"
290    Then the following should exist in the "cohorts" table:
291      | Name            | Cohort size |
292      | System cohort A | 1           |
293      | System cohort B | 2           |
294    And I should not see "Cohort in category"
295    And I follow "Courses"
296    And I follow "Cat 1"
297    And I follow "Cohorts"
298    And I should not see "System cohort"
299    And the following should exist in the "cohorts" table:
300      | Name               | Cohort size |
301      | Cohort in category | 1           |
302      | Empty cohort       | 0           |
303
304  Scenario: Add grade categories with data generator
305    Given the following "courses" exist:
306      | fullname | shortname |
307      | Course 1 | C1 |
308    And the following "grade categories" exist:
309      | fullname | course |
310      | Grade category 1 | C1 |
311    And the following "grade categories" exist:
312      | fullname | course | gradecategory |
313      | Grade sub category 2 | C1 | Grade category 1 |
314    When I log in as "admin"
315    And I follow "Courses"
316    And I follow "Course 1"
317    And I navigate to "Grades" node in "Course administration"
318    Then I should see "Grade category 1"
319    And I should see "Grade sub category 2"
320
321  Scenario: Add a bunch of grade items
322    Given the following "courses" exist:
323      | fullname | shortname |
324      | Course 1 | C1 |
325    And the following "grade categories" exist:
326      | fullname | course |
327      | Grade category 1 | C1 |
328    And the following "grade categories" exist:
329      | fullname | course | gradecategory |
330      | Grade sub category 2 | C1 | Grade category 1 |
331    And the following "grade items" exist:
332      | itemname    | course |
333      | Test Grade Item 1 | C1 |
334    And the following "grade items" exist:
335      | itemname    | course | gradecategory |
336      | Test Grade Item 2 | C1 | Grade category 1 |
337      | Test Grade Item 3 | C1 | Grade sub category 2 |
338    When I log in as "admin"
339    And I follow "Course 1"
340    And I follow "Grades"
341    And I expand "Setup" node
342    And I follow "Categories and items"
343    Then I should see "Test Grade Item 1"
344    And I follow "Edit   Test Grade Item 1"
345    And I expand all fieldsets
346    And I should see "Course 1"
347    And I press "Cancel"
348    And I should see "Grade category 1"
349    And I should see "Test Grade Item 2"
350    And I follow "Edit   Test Grade Item 2"
351    And I expand all fieldsets
352    And I should see "Grade category 1"
353    And I press "Cancel"
354    And I should see "Grade sub category 2"
355    And I should see "Test Grade Item 3"
356    And I follow "Edit   Test Grade Item 3"
357    And I expand all fieldsets
358    And I should see "Grade sub category 2"
359    And I press "Cancel"
360
361  Scenario: Add a bunch of scales
362    Given the following "courses" exist:
363      | fullname | shortname |
364      | Course 1 | C1 |
365    And the following "scales" exist:
366      | name | scale |
367      | Test Scale 1 | Disappointing, Good, Very good, Excellent |
368    When I log in as "admin"
369    And I follow "Course 1"
370    And I follow "Grades"
371    And I follow "Scales"
372    Then I should see "Test Scale 1"
373    And I should see "Disappointing,  Good,  Very good,  Excellent"
374
375  Scenario: Add a bunch of outcomes
376    Given the following "courses" exist:
377      | fullname | shortname |
378      | Course 1 | C1        |
379    And the following "scales" exist:
380      | name | scale |
381      | Test Scale 1 | Disappointing, Good, Very good, Excellent |
382    And the following "grade outcomes" exist:
383      | fullname        | shortname | scale        |
384      | Grade outcome 1 | OT1       | Test Scale 1 |
385    And the following "grade outcomes" exist:
386      | fullname        | shortname | course | scale        |
387      | Grade outcome 2 | OT2       | C1     | Test Scale 1 |
388    When I log in as "admin"
389    And I set the following administration settings values:
390      | Enable outcomes | 1 |
391    And I follow "Home"
392    And I follow "Course 1"
393    And I follow "Outcomes"
394    Then I should see "Grade outcome 1" in the "#addoutcomes" "css_element"
395    And I should see "Grade outcome 2" in the "#removeoutcomes" "css_element"
396    And I follow "Edit outcomes"
397    And the following should exist in the "generaltable" table:
398      | Full name       | Short name | Scale        |
399      | Grade outcome 2 | OT2        | Test Scale 1 |
400
401  Scenario: Add a bunch of outcome grade items
402    Given the following "courses" exist:
403      | fullname | shortname |
404      | Course 1 | C1        |
405    And the following "scales" exist:
406      | name         | scale                                     |
407      | Test Scale 1 | Disappointing, Good, Very good, Excellent |
408    And the following "grade outcomes" exist:
409      | fullname        | shortname | course | scale        |
410      | Grade outcome 1 | OT1       | C1     | Test Scale 1 |
411    And the following "grade categories" exist:
412      | fullname         | course |
413      | Grade category 1 | C1     |
414     And the following "grade items" exist:
415       | itemname                  | course | outcome | gradecategory    |
416       | Test Outcome Grade Item 1 | C1     | OT1     | Grade category 1 |
417    When I log in as "admin"
418    And I set the following administration settings values:
419      | Enable outcomes | 1 |
420    And I follow "Home"
421    And I follow "Course 1"
422    And I follow "Grades"
423    And I expand "Setup" node
424    And I follow "Categories and items"
425    Then I should see "Test Outcome Grade Item 1"
426    And I follow "Edit   Test Outcome Grade Item 1"
427    And the field "Outcome" matches value "Grade outcome 1"
428    And I expand all fieldsets
429    And "//div[contains(@class, 'fitem')]/div[contains(@class, 'fitemtitle')]/div[contains(@class, fstaticlabel) and contains(., 'Grade category')]/../../div[contains(@class, 'felement') and contains(., 'Grade category 1')]" "xpath_element" should exist
430    And I press "Cancel"
Note: See TracBrowser for help on using the repository browser.