MDL-64506 phpunit: Update unit tests to use classic
[moodle.git] / cohort / tests / behat / upload_cohorts.feature
CommitLineData
5076b961
MG
1@core @core_cohort @_file_upload
2Feature: A privileged user can create cohorts using a CSV file
3 In order to create cohorts using a CSV file
4 As an admin
5 I need to be able to upload a CSV file and navigate through the upload process
6
7 Background:
8 Given the following "categories" exist:
9 | name | category | idnumber |
10 | Cat 1 | 0 | CAT1 |
11 | Cat 2 | 0 | CAT2 |
12 | Cat 3 | CAT1 | CAT3 |
13
14 @javascript
15 Scenario: Upload cohorts with default System context as admin
16 When I log in as "admin"
02fda279 17 And I navigate to "Users > Accounts >Cohorts" in site administration
5076b961
MG
18 And I follow "Upload cohorts"
19 And I upload "cohort/tests/fixtures/uploadcohorts1.csv" file to "File" filemanager
20 And I click on "Preview" "button"
21 Then the following should exist in the "previewuploadedcohorts" table:
fbb250f8
MG
22 | name | idnumber | description | Context | visible | Status |
23 | cohort name 1 | cohortid1 | first description | System | 1 | |
24 | cohort name 2 | cohortid2 | | System | 1 | |
25 | cohort name 3 | cohortid3 | | Miscellaneous | 0 | |
26 | cohort name 4 | cohortid4 | | Cat 1 | 1 | |
27 | cohort name 5 | cohortid5 | | Cat 2 | 0 | |
28 | cohort name 6 | cohortid6 | | Cat 3 | 1 | |
5076b961
MG
29 And I press "Upload cohorts"
30 And I should see "Uploaded 6 cohorts"
31 And I press "Continue"
32 And the following should exist in the "cohorts" table:
33 | Name | Cohort ID | Description | Cohort size | Source |
34 | cohort name 1 | cohortid1 | first description | 0 | Created manually |
35 | cohort name 2 | cohortid2 | | 0 | Created manually |
36 And I follow "All cohorts"
37 And the following should exist in the "cohorts" table:
38 | Category | Name | Cohort ID | Description | Cohort size | Source |
39 | System | cohort name 1 | cohortid1 | first description | 0 | Created manually |
40 | System | cohort name 2 | cohortid2 | | 0 | Created manually |
41 | Miscellaneous | cohort name 3 | cohortid3 | | 0 | Created manually |
42 | Cat 1 | cohort name 4 | cohortid4 | | 0 | Created manually |
43 | Cat 2 | cohort name 5 | cohortid5 | | 0 | Created manually |
44 | Cat 3 | cohort name 6 | cohortid6 | | 0 | Created manually |
5c572128
FM
45 And ".dimmed_text" "css_element" should not exist in the "cohort name 1" "table_row"
46 And ".dimmed_text" "css_element" should not exist in the "cohort name 2" "table_row"
47 And ".dimmed_text" "css_element" should exist in the "cohort name 3" "table_row"
fbb250f8 48 And the "class" attribute of "cohort name 3" "table_row" should contain "dimmed_text"
5c572128 49 And ".dimmed_text" "css_element" should not exist in the "cohort name 4" "table_row"
fbb250f8 50 And the "class" attribute of "cohort name 5" "table_row" should contain "dimmed_text"
5c572128 51 And ".dimmed_text" "css_element" should not exist in the "cohort name 6" "table_row"
5076b961 52
88cb8b78 53 @javascript @_file_upload
5076b961
MG
54 Scenario: Upload cohorts with default category context as admin
55 When I log in as "admin"
02fda279 56 And I navigate to "Users > Accounts >Cohorts" in site administration
5076b961
MG
57 And I follow "Upload cohorts"
58 And I upload "cohort/tests/fixtures/uploadcohorts1.csv" file to "File" filemanager
59 And I set the field "Default context" to "Cat 1 / Cat 3"
60 And I click on "Preview" "button"
61 Then the following should exist in the "previewuploadedcohorts" table:
62 | name | idnumber | description | Context | Status |
63 | cohort name 1 | cohortid1 | first description | Cat 3 | |
64 | cohort name 2 | cohortid2 | | Cat 3 | |
65 | cohort name 3 | cohortid3 | | Miscellaneous | |
66 | cohort name 4 | cohortid4 | | Cat 1 | |
67 | cohort name 5 | cohortid5 | | Cat 2 | |
68 | cohort name 6 | cohortid6 | | Cat 3 | |
69 And I press "Upload cohorts"
70 And I should see "Uploaded 6 cohorts"
71 And I press "Continue"
72 And I should see "Category: Cat 3: available cohorts (3)"
02fda279 73 And I navigate to "Users > Accounts >Cohorts" in site administration
5076b961
MG
74 And I follow "All cohorts"
75 And the following should exist in the "cohorts" table:
76 | Category | Name | Cohort ID | Description | Cohort size | Source |
77 | Cat 3 | cohort name 1 | cohortid1 | first description | 0 | Created manually |
78 | Cat 3 | cohort name 2 | cohortid2 | | 0 | Created manually |
79 | Miscellaneous | cohort name 3 | cohortid3 | | 0 | Created manually |
80 | Cat 1 | cohort name 4 | cohortid4 | | 0 | Created manually |
81 | Cat 2 | cohort name 5 | cohortid5 | | 0 | Created manually |
82 | Cat 3 | cohort name 6 | cohortid6 | | 0 | Created manually |
83
88cb8b78 84 @javascript @_file_upload
5076b961
MG
85 Scenario: Upload cohorts with default category context as manager
86 Given the following "users" exist:
87 | username | firstname | lastname | email |
0fe86bbd 88 | user1 | User | 1 | user1@example.com |
5076b961
MG
89 And the following "role assigns" exist:
90 | user | role | contextlevel | reference |
91 | user1 | manager | Category | CAT1 |
92 When I log in as "user1"
e5287f9b 93 And I am on course index
5076b961 94 And I follow "Cat 1"
e5287f9b 95 And I navigate to "Cohorts" in current page administration
5076b961
MG
96 And I follow "Upload cohorts"
97 And I upload "cohort/tests/fixtures/uploadcohorts1.csv" file to "File" filemanager
98 And I click on "Preview" "button"
99 Then the following should exist in the "previewuploadedcohorts" table:
100 | name | idnumber | description | Context | Status |
101 | cohort name 1 | cohortid1 | first description | Cat 1 | |
102 | cohort name 2 | cohortid2 | | Cat 1 | |
103 | cohort name 3 | cohortid3 | | Cat 1 | Category Miscellaneous not found or you don't have permission to create a cohort there. The default context will be used. |
104 | cohort name 4 | cohortid4 | | Cat 1 | |
105 | cohort name 5 | cohortid5 | | Cat 1 | Category CAT2 not found or you don't have permission to create a cohort there. The default context will be used. |
106 | cohort name 6 | cohortid6 | | Cat 3 | |
107 And I press "Upload cohorts"
108 And I should see "Uploaded 6 cohorts"
109
88cb8b78 110 @javascript @_file_upload
5076b961
MG
111 Scenario: Upload cohorts with conflicting id number
112 Given the following "cohorts" exist:
113 | name | idnumber |
114 | Cohort | cohortid2 |
115 When I log in as "admin"
02fda279 116 And I navigate to "Users > Accounts >Cohorts" in site administration
5076b961
MG
117 And I follow "Upload cohorts"
118 And I upload "cohort/tests/fixtures/uploadcohorts1.csv" file to "File" filemanager
119 And I click on "Preview" "button"
120 Then I should see "Errors were found in CSV data. See details below."
121 Then the following should exist in the "previewuploadedcohorts" table:
122 | name | idnumber | description | Context | Status |
123 | cohort name 1 | cohortid1 | first description | System | |
124 | cohort name 2 | cohortid2 | | System | Cohort with the same ID number already exists |
125 | cohort name 3 | cohortid3 | | Miscellaneous | |
126 | cohort name 4 | cohortid4 | | Cat 1 | |
127 | cohort name 5 | cohortid5 | | Cat 2 | |
128 | cohort name 6 | cohortid6 | | Cat 3 | |
129 And "Upload cohorts" "button" should not exist
130
88cb8b78 131 @javascript @_file_upload
5076b961
MG
132 Scenario: Upload cohorts with different ways of specifying context
133 When I log in as "admin"
02fda279 134 And I navigate to "Users > Accounts >Cohorts" in site administration
5076b961
MG
135 And I follow "Upload cohorts"
136 And I upload "cohort/tests/fixtures/uploadcohorts2.csv" file to "File" filemanager
137 And I click on "Preview" "button"
138 Then the following should exist in the "previewuploadedcohorts" table:
139 | name | idnumber | description | Context | Status |
140 | Specify category as name | cohortid1 | | Miscellaneous | |
141 | Specify category as idnumber | cohortid2 | | Cat 1 | |
142 | Specify category as id | cohortid3 | | Miscellaneous | |
143 | Specify category as path | cohortid4 | | Cat 3 | |
144 | Specify category_id | cohortid5 | | Miscellaneous | |
145 | Specify category_idnumber | cohortid6 | | Cat 1 | |
146 | Specify category_path | cohortid7 | | Cat 3 | |
147 And I should not see "not found or you"
148 And I press "Upload cohorts"
149 And I should see "Uploaded 7 cohorts"
150 And I press "Continue"
151 And I follow "Upload cohorts"
152 And I upload "cohort/tests/fixtures/uploadcohorts3.csv" file to "File" filemanager
153 And I click on "Preview" "button"
154 And the following should exist in the "previewuploadedcohorts" table:
155 | name | idnumber | description | Context | Status |
156 | Specify context as id (system) | cohortid8 | | System | |
157 | Specify context as name (system) | cohortid9 | | System | |
158 | Specify context as category name only | cohortid10 | | Cat 1 | |
159 | Specify context as category path | cohortid12 | | Cat 3 | |
160 | Specify context as category idnumber | cohortid13 | | Cat 2 | |
161 And I should not see "not found or you"
162 And I press "Upload cohorts"
163 And I should see "Uploaded 5 cohorts"
88cb8b78
SA
164
165 @javascript @_file_upload
166 Scenario: Upload cohorts with theme
167 When I log in as "admin"
02fda279 168 And I navigate to "Users > Accounts >Cohorts" in site administration
88cb8b78
SA
169 And I follow "Upload cohorts"
170 And I upload "cohort/tests/fixtures/uploadcohorts4.csv" file to "File" filemanager
171 And I click on "Preview" "button"
172 Then the following should exist in the "previewuploadedcohorts" table:
e00f1c66
MM
173 | name | idnumber | description | Context | visible | theme | Status |
174 | cohort name 1 | cohortid1 | first description | System | 1 | boost | |
175 | cohort name 2 | cohortid2 | | System | 1 | | |
176 | cohort name 3 | cohortid3 | | Miscellaneous | 0 | boost | |
177 | cohort name 4 | cohortid4 | | Cat 1 | 1 | classic | |
178 | cohort name 5 | cohortid5 | | Cat 2 | 0 | | |
179 | cohort name 6 | cohortid6 | | Cat 3 | 1 | classic | |
88cb8b78
SA
180 And I press "Upload cohorts"
181 And I should see "Uploaded 6 cohorts"
182 And I press "Continue"
183 And the following should exist in the "cohorts" table:
184 | Name | Cohort ID | Description | Cohort size | Source |
185 | cohort name 1 | cohortid1 | first description | 0 | Created manually |
186 | cohort name 2 | cohortid2 | | 0 | Created manually |
187 And I follow "All cohorts"
188 And the following should exist in the "cohorts" table:
189 | Category | Name | Cohort ID | Description | Cohort size | Source |
190 | System | cohort name 1 | cohortid1 | first description | 0 | Created manually |
191 | System | cohort name 2 | cohortid2 | | 0 | Created manually |
192 | Miscellaneous | cohort name 3 | cohortid3 | | 0 | Created manually |
193 | Cat 1 | cohort name 4 | cohortid4 | | 0 | Created manually |
194 | Cat 2 | cohort name 5 | cohortid5 | | 0 | Created manually |
195 | Cat 3 | cohort name 6 | cohortid6 | | 0 | Created manually |