Commit | Line | Data |
---|---|---|
5076b961 MG |
1 | @core @core_cohort @_file_upload |
2 | Feature: 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" | |
17 | And I navigate to "Cohorts" node in "Site administration > Users > Accounts" | |
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 | | |
fbb250f8 MG |
45 | And the "class" attribute of "cohort name 1" "table_row" should not contain "dimmed_text" |
46 | And the "class" attribute of "cohort name 2" "table_row" should not contain "dimmed_text" | |
47 | And the "class" attribute of "cohort name 3" "table_row" should contain "dimmed_text" | |
48 | And the "class" attribute of "cohort name 4" "table_row" should not contain "dimmed_text" | |
49 | And the "class" attribute of "cohort name 5" "table_row" should contain "dimmed_text" | |
50 | And the "class" attribute of "cohort name 6" "table_row" should not contain "dimmed_text" | |
5076b961 MG |
51 | |
52 | @javascript | |
53 | Scenario: Upload cohorts with default category context as admin | |
54 | When I log in as "admin" | |
55 | And I navigate to "Cohorts" node in "Site administration > Users > Accounts" | |
56 | And I follow "Upload cohorts" | |
57 | And I upload "cohort/tests/fixtures/uploadcohorts1.csv" file to "File" filemanager | |
58 | And I set the field "Default context" to "Cat 1 / Cat 3" | |
59 | And I click on "Preview" "button" | |
60 | Then the following should exist in the "previewuploadedcohorts" table: | |
61 | | name | idnumber | description | Context | Status | | |
62 | | cohort name 1 | cohortid1 | first description | Cat 3 | | | |
63 | | cohort name 2 | cohortid2 | | Cat 3 | | | |
64 | | cohort name 3 | cohortid3 | | Miscellaneous | | | |
65 | | cohort name 4 | cohortid4 | | Cat 1 | | | |
66 | | cohort name 5 | cohortid5 | | Cat 2 | | | |
67 | | cohort name 6 | cohortid6 | | Cat 3 | | | |
68 | And I press "Upload cohorts" | |
69 | And I should see "Uploaded 6 cohorts" | |
70 | And I press "Continue" | |
71 | And I should see "Category: Cat 3: available cohorts (3)" | |
72 | And I navigate to "Cohorts" node in "Site administration > Users > Accounts" | |
73 | And I follow "All cohorts" | |
74 | And the following should exist in the "cohorts" table: | |
75 | | Category | Name | Cohort ID | Description | Cohort size | Source | | |
76 | | Cat 3 | cohort name 1 | cohortid1 | first description | 0 | Created manually | | |
77 | | Cat 3 | cohort name 2 | cohortid2 | | 0 | Created manually | | |
78 | | Miscellaneous | cohort name 3 | cohortid3 | | 0 | Created manually | | |
79 | | Cat 1 | cohort name 4 | cohortid4 | | 0 | Created manually | | |
80 | | Cat 2 | cohort name 5 | cohortid5 | | 0 | Created manually | | |
81 | | Cat 3 | cohort name 6 | cohortid6 | | 0 | Created manually | | |
82 | ||
83 | @javascript | |
84 | Scenario: Upload cohorts with default category context as manager | |
85 | Given the following "users" exist: | |
86 | | username | firstname | lastname | email | | |
87 | | user1 | User | 1 | user1@moodlemoodle.com | | |
88 | And the following "role assigns" exist: | |
89 | | user | role | contextlevel | reference | | |
90 | | user1 | manager | Category | CAT1 | | |
91 | When I log in as "user1" | |
92 | And I follow "Courses" | |
93 | And I follow "Cat 1" | |
94 | And I navigate to "Cohorts" node in "Category: Cat 1" | |
95 | And I follow "Upload cohorts" | |
96 | And I upload "cohort/tests/fixtures/uploadcohorts1.csv" file to "File" filemanager | |
97 | And I click on "Preview" "button" | |
98 | Then the following should exist in the "previewuploadedcohorts" table: | |
99 | | name | idnumber | description | Context | Status | | |
100 | | cohort name 1 | cohortid1 | first description | Cat 1 | | | |
101 | | cohort name 2 | cohortid2 | | Cat 1 | | | |
102 | | 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. | | |
103 | | cohort name 4 | cohortid4 | | Cat 1 | | | |
104 | | 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. | | |
105 | | cohort name 6 | cohortid6 | | Cat 3 | | | |
106 | And I press "Upload cohorts" | |
107 | And I should see "Uploaded 6 cohorts" | |
108 | ||
109 | @javascript | |
110 | Scenario: Upload cohorts with conflicting id number | |
111 | Given the following "cohorts" exist: | |
112 | | name | idnumber | | |
113 | | Cohort | cohortid2 | | |
114 | When I log in as "admin" | |
115 | And I navigate to "Cohorts" node in "Site administration > Users > Accounts" | |
116 | And I follow "Upload cohorts" | |
117 | And I upload "cohort/tests/fixtures/uploadcohorts1.csv" file to "File" filemanager | |
118 | And I click on "Preview" "button" | |
119 | Then I should see "Errors were found in CSV data. See details below." | |
120 | Then the following should exist in the "previewuploadedcohorts" table: | |
121 | | name | idnumber | description | Context | Status | | |
122 | | cohort name 1 | cohortid1 | first description | System | | | |
123 | | cohort name 2 | cohortid2 | | System | Cohort with the same ID number already exists | | |
124 | | cohort name 3 | cohortid3 | | Miscellaneous | | | |
125 | | cohort name 4 | cohortid4 | | Cat 1 | | | |
126 | | cohort name 5 | cohortid5 | | Cat 2 | | | |
127 | | cohort name 6 | cohortid6 | | Cat 3 | | | |
128 | And "Upload cohorts" "button" should not exist | |
129 | ||
130 | @javascript | |
131 | Scenario: Upload cohorts with different ways of specifying context | |
132 | When I log in as "admin" | |
133 | And I navigate to "Cohorts" node in "Site administration > Users > Accounts" | |
134 | And I follow "Upload cohorts" | |
135 | And I upload "cohort/tests/fixtures/uploadcohorts2.csv" file to "File" filemanager | |
136 | And I click on "Preview" "button" | |
137 | Then the following should exist in the "previewuploadedcohorts" table: | |
138 | | name | idnumber | description | Context | Status | | |
139 | | Specify category as name | cohortid1 | | Miscellaneous | | | |
140 | | Specify category as idnumber | cohortid2 | | Cat 1 | | | |
141 | | Specify category as id | cohortid3 | | Miscellaneous | | | |
142 | | Specify category as path | cohortid4 | | Cat 3 | | | |
143 | | Specify category_id | cohortid5 | | Miscellaneous | | | |
144 | | Specify category_idnumber | cohortid6 | | Cat 1 | | | |
145 | | Specify category_path | cohortid7 | | Cat 3 | | | |
146 | And I should not see "not found or you" | |
147 | And I press "Upload cohorts" | |
148 | And I should see "Uploaded 7 cohorts" | |
149 | And I press "Continue" | |
150 | And I follow "Upload cohorts" | |
151 | And I upload "cohort/tests/fixtures/uploadcohorts3.csv" file to "File" filemanager | |
152 | And I click on "Preview" "button" | |
153 | And the following should exist in the "previewuploadedcohorts" table: | |
154 | | name | idnumber | description | Context | Status | | |
155 | | Specify context as id (system) | cohortid8 | | System | | | |
156 | | Specify context as name (system) | cohortid9 | | System | | | |
157 | | Specify context as category name only | cohortid10 | | Cat 1 | | | |
158 | | Specify context as category path | cohortid12 | | Cat 3 | | | |
159 | | Specify context as category idnumber | cohortid13 | | Cat 2 | | | |
160 | And I should not see "not found or you" | |
161 | And I press "Upload cohorts" | |
162 | And I should see "Uploaded 5 cohorts" |