|
1 |
|
2 // " Vim settings |
|
3 // set tabstop=4 " number of spaces in a tab |
|
4 // set softtabstop=4 " as above |
|
5 // set shiftwidth=4 " as above |
|
6 |
|
7 var k = __karma__.config, |
|
8 test_ = JSON.parse (k.t, new Function (['k','v'], k.r)), // revive helper functions sent from Karma |
|
9 t = {'text_nb': 0, 'user_nb': 4}; |
|
10 |
|
11 const non_visible = false, |
|
12 no_tagline = false, |
|
13 c = { |
|
14 '#id_workspace_name': 'Test workspace name', |
|
15 '#id_workspace_tagline': 'Test workspace tagline', |
|
16 '#id_workspace_registration': 'on', // registration |
|
17 '#id_workspace_registration_moderation':'on', // registration moderation |
|
18 '#id_workspace_role_model': 'generic', |
|
19 '#id_workspace_category_1': 'ws_cat_1', |
|
20 '#id_workspace_category_2': 'ws_cat_2', |
|
21 '#id_workspace_category_3': 'ws_cat_3', |
|
22 '#id_workspace_category_4': 'ws_cat_4', |
|
23 '#id_workspace_category_5': 'ws_cat_5', |
|
24 '#id_custom_css': "h2 { font-family: Test_Sopinspace !important; }", |
|
25 '#id_custom_font': 'Test_Sopinspace_custom_font', |
|
26 '#id_custom_titles_font': 'Test_Sopinspace_custom_titles_font', |
|
27 'texts': [ |
|
28 { |
|
29 '#id_title': 'Text One Sopinspace-Test éléguant', |
|
30 '#id_format': 'markdown', |
|
31 '#id_content': 'Contenu du premier texte.\nSur plusieurs lignes\nPour tester un cas réaliste', |
|
32 '#id_tags': 'test_text, Text Premier' |
|
33 }, |
|
34 { |
|
35 '#id_title': 'Text Two Sopinspace-Test éléguant', |
|
36 '#id_format': 'rst', |
|
37 '#id_content': 'Contenu du deuxième texte.\nSur plusieurs lignes aussi\nPour tester un cas réaliste', |
|
38 '#id_tags': 'test_text, Text Second' |
|
39 }, |
|
40 { |
|
41 '#id_title': 'Text Three Sopinspace-Test éléguant', |
|
42 '#id_format': 'html', |
|
43 '#id_content': 'Contenu du troisième texte.<br/>Sur <b>plusieurs</b> lignes<br/>', |
|
44 '#id_tags': 'test_text, Text Troisième' |
|
45 } |
|
46 ] |
|
47 }; |
|
48 |
|
49 suite ('comt logged admin', function () { |
|
50 |
|
51 this.timeout(20000); |
|
52 |
|
53 suite ('logs as an admin', function () { |
|
54 test ('logs an admin in', dsl(function () { |
|
55 browser.navigateTo ('/'); |
|
56 input ('#id_username').enter (k.w.USER_ADMIN); |
|
57 input ('#id_password').enter (k.w.PASS_ADMIN); |
|
58 test_.elt ('#login input[type=submit]').click (); |
|
59 browser.waitForPageLoad (); // Must be done here in this test() block |
|
60 browser.navigateTo ('/'); |
|
61 expect (element ('title').text ()).toMatch (/Dashboard/m); |
|
62 })); |
|
63 }); |
|
64 |
|
65 suite ('setting settings to test-values', function () { |
|
66 test_.page_loading ('/settings/', 'Settings'); |
|
67 test_fill_settings (c); |
|
68 test_.val ('#id_workspace_name', c['#id_workspace_name']); |
|
69 test_.submit ('#settings input[type="submit"]'); |
|
70 test_.page_loading ('/settings/', 'Settings'); |
|
71 test_.text ('#content h1.main_title a[href="/"]', c['#id_workspace_name']); |
|
72 test_.page_loading ('/settings/design/', 'Settings'); |
|
73 test_fill_design (c); |
|
74 test_.submit ('#settings input[type="submit"]'); |
|
75 }); |
|
76 |
|
77 suite ('admin dashboard page conformity', function () { |
|
78 test_.page_loading ('/', 'Dashboard\n - '+c['#id_workspace_name']); |
|
79 test_logged_header (k.w.USER_ADMIN); |
|
80 test_default_tabs (t.text_nb, t.user_nb); |
|
81 test_.count ('table.dash_table', 5); |
|
82 test_.text ('table.dash_table th:eq(0)', 'Actions'); |
|
83 test_.match ('table.dash_table:eq(0) a:eq(0)[href="/create/content/"]', /\sCreate a text/); |
|
84 test_.text ('table.dash_table:eq(0) a:eq(1).tip[href="#"]', '\xa0'); |
|
85 test_.match ('table.dash_table:eq(0) a:eq(2)[href="/create/upload/"]', /\sUpload a text/); |
|
86 test_.text ('table.dash_table:eq(0) a:eq(3).tip[href="#"]', '\xa0'); |
|
87 test_.match ('table.dash_table:eq(0) a:eq(4)[href="/create/import/"]', /\sImport a co-mented text/); |
|
88 test_.text ('table.dash_table:eq(0) a:eq(5).tip[href="#"]', '\xa0'); |
|
89 test_.match ('table.dash_table:eq(0) a:eq(6)[href="/user/add/"]', /\sInvite user/); |
|
90 test_.match ('table.dash_table:eq(0) a:eq(7)[href="/profile/"]', /\sEdit your profile/); |
|
91 test_.match ('table.dash_table:eq(0) a:eq(8)[href="/text/"]', /\sView text list/); |
|
92 test_.match ('table.dash_table:eq(0) a:eq(9)[href="/settings/"]', /\sConfigure workspace/); |
|
93 test_.text ('table.dash_table th:eq(1)', 'Recent texts (all)'); |
|
94 test_.text ('table.dash_table:eq(1) a:eq(0)[href="/text/"]', 'all'); |
|
95 test_.text ('table.dash_table th:eq(2)', 'Recent comments'); |
|
96 test_.match ('table.dash_table th:eq(3)', /^Workspace activity\n\s+\(month\/week\/24 hours\)$/m); |
|
97 test_.text ('table.dash_table:eq(3) a:eq(0)[href="?span=month"]', 'month'); |
|
98 test_.text ('table.dash_table:eq(3) a:eq(1)[href="?span=day"]', '24 hours'); |
|
99 test_.text ('table.dash_table th:eq(4) span.em', 'Activities'); |
|
100 test_unlogged_footer (); |
|
101 }); |
|
102 |
|
103 suite ('empty texts list page conformity', function () { |
|
104 test_.page_loading ('/text/', 'Texts\n - '+c['#id_workspace_name']); |
|
105 test_logged_header (k.w.USER_ADMIN); |
|
106 test_default_tabs (t.text_nb, t.user_nb); |
|
107 test_.count ('#text ul.sub_list:eq(0) a', 3); |
|
108 test_.text ('#text ul.sub_list:eq(0) a:eq(0)[href="/create/content/"]', 'Create a text'); |
|
109 test_.text ('#text ul.sub_list:eq(0) a:eq(1)[href="/create/upload/"]', 'Upload a text'); |
|
110 test_.text ('#text ul.sub_list:eq(0) a:eq(2)[href="/create/import/"]', 'Import a co-mented text'); |
|
111 test_.match ('#text', /No texts yet/m); |
|
112 test_.count ('#texts_form :input', 0); |
|
113 }); |
|
114 |
|
115 suite ('create a text page conformity', function () { |
|
116 test_.page_loading ('/create/content/', 'Create a text - '+c['#id_workspace_name']); |
|
117 test_logged_header (k.w.USER_ADMIN); |
|
118 test_default_tabs (t.text_nb, t.user_nb); |
|
119 test_.count ('#text ul.sub_list:eq(0) a', 3); |
|
120 test_.text ('#text ul.sub_list:eq(0) a:eq(0)[href="/text/"]', 'Text list'); |
|
121 test_.text ('#text ul.sub_list:eq(0) a:eq(1)[href="/create/upload/"]', 'Upload a text'); |
|
122 test_.text ('#text ul.sub_list:eq(0) a:eq(2)[href="/create/import/"]', 'Import a co-mented text'); |
|
123 test_.count ('#text form[action="."]:eq(0) :input', 6); |
|
124 test_.field ('text', 'id_title', 'text', 0, 'Title', true); |
|
125 test_.field ('text', 'id_format', 'select', 1, 'Format', true); |
|
126 test_.field ('text', 'id_content', 'textarea', 2, 'Content', true); |
|
127 test_.field ('text', 'id_tags', 'text', 3, 'Tags'); |
|
128 test_.val ('#text :input:eq(4)[type=submit]', 'Save'); |
|
129 test_.val ('#text :input:eq(5)#cancel_button[type=button]', 'Cancel'); |
|
130 test_.count ('select#id_format option', 3); |
|
131 test_.text ('select#id_format option:eq(0)[value="markdown"][selected]', 'markdown', non_visible); |
|
132 test_.text ('select#id_format option:eq(1)[value="rst"]', 'rst', non_visible); |
|
133 test_.text ('select#id_format option:eq(2)[value="html"]', 'html', non_visible); |
|
134 test_.count ('.markdown #markItUpId_content li', 20); // How many buttons in the WYSIWYG editor toolbar ? |
|
135 test_unlogged_footer (); |
|
136 test_.submit('#text input[type="submit"]'); |
|
137 test_.count ('div.help_text span.error-text', 2); |
|
138 test_.field ('text div.error', 'id_title', 'text', 0, 'Title', true); |
|
139 test_.field ('text div.error', 'id_content', 'textarea', 1, 'Content', true); |
|
140 }); |
|
141 |
|
142 suite ('upload text page conformity', function () { |
|
143 test_.page_loading ('/create/upload/', 'Upload a text - '+c['#id_workspace_name']); |
|
144 test_logged_header (k.w.USER_ADMIN); |
|
145 test_default_tabs (t.text_nb, t.user_nb); |
|
146 test_.count ('#text ul.sub_list:eq(0) a', 3); |
|
147 test_.text ('#text ul.sub_list:eq(0) a:eq(0)[href="/text/"]', 'Text list'); |
|
148 test_.text ('#text ul.sub_list:eq(0) a:eq(1)[href="/create/content/"]', 'Create a text'); |
|
149 test_.text ('#text ul.sub_list:eq(0) a:eq(2)[href="/create/import/"]', 'Import a co-mented text'); |
|
150 test_.count ('#text form[action="."]:eq(0) :input', 6); |
|
151 test_.field ('text', 'id_title', 'text', 0, 'Title'); |
|
152 test_.field ('text', 'id_format', 'select', 1, 'Format', true); |
|
153 test_.field ('text', 'id_tags', 'text', 2, 'Tags'); |
|
154 test_.field ('text', 'id_file', 'file', 3, 'Upload file'); |
|
155 test_.val ('#text :input:eq(4)[type=submit]', 'Save'); |
|
156 test_.val ('#text :input:eq(5)#cancel_button[type=button]', 'Cancel'); |
|
157 test_.count ('select#id_format option', 3); |
|
158 test_.text ('select#id_format option:eq(0)[value="markdown"][selected]', 'markdown', non_visible); |
|
159 test_.text ('select#id_format option:eq(1)[value="rst"]', 'rst', non_visible); |
|
160 test_.text ('select#id_format option:eq(2)[value="html"]', 'html', non_visible); |
|
161 test_unlogged_footer (); |
|
162 test_.submit('#text input[type="submit"]'); |
|
163 test_.count ('div.help_text span.error-text', 1); |
|
164 test_.field ('text div.error', 'id_file', 'file', 0, 'Upload file'); |
|
165 test_.match ('#text div.help_text:eq(3) span.error-text:eq(0)', /You should specify a file to upload/m); |
|
166 }); |
|
167 |
|
168 suite ('import a co-mented text page conformity', function () { |
|
169 test_.page_loading ('/create/import/', 'Import a co-mented text - '+c['#id_workspace_name']); |
|
170 test_logged_header (k.w.USER_ADMIN); |
|
171 test_default_tabs (t.text_nb, t.user_nb); |
|
172 test_.count ('#text ul.sub_list:eq(0) a', 3); |
|
173 test_.text ('#text ul.sub_list:eq(0) a:eq(0)[href="/text/"]', 'Text list'); |
|
174 test_.text ('#text ul.sub_list:eq(0) a:eq(1)[href="/create/content/"]', 'Create a text'); |
|
175 test_.text ('#text ul.sub_list:eq(0) a:eq(2)[href="/create/upload/"]', 'Upload a text'); |
|
176 test_.count ('#text form[action="."]:eq(0) :input', 3); |
|
177 test_.field ('text', 'id_file', 'file', 0, 'Upload XML file', true); |
|
178 test_.val ('#text :input:eq(1)[type=submit]', 'Save'); |
|
179 test_.val ('#text :input:eq(2)#cancel_button[type=button]', 'Cancel'); |
|
180 test_unlogged_footer (); |
|
181 test_.submit('#text input[type="submit"]'); |
|
182 test_.count ('div.help_text span.error-text', 1); |
|
183 test_.field ('text div.error', 'id_file', 'file', 0, 'Upload XML file', true); |
|
184 test_.match ('#text div.help_text:eq(0) span.error-text:eq(0)', /You should specify a file to upload/m); |
|
185 }); |
|
186 |
|
187 suite ('create texts', function () { |
|
188 /* 'texts': [ |
|
189 { |
|
190 '#id_title': 'Text One Sopinspace-Test éléguant', |
|
191 '#id_format': 'markdown', |
|
192 '#id_content': 'Contenu du premier texte.\nSur plusieurs lignes\nPour tester un cas réaliste', |
|
193 '#id_tags': 'test_.text, Text Premier' |
|
194 },*/ |
|
195 test_.page_loading ('/create/content/', 'Create a text - '+c['#id_workspace_name']); |
|
196 test ('test creation', dsl(function () { |
|
197 dropdownlist ('#id_format').option (c['texts'][0]['#id_format']); |
|
198 })); |
|
199 test_.fill_field ('#id_title', c['texts'][0]); |
|
200 test_.fill_field ('#id_content', c['texts'][0]); |
|
201 test_.fill_field ('#id_tags', c['texts'][0]); |
|
202 test_.val ('#id_title', 'Text One Sopinspace-Test éléguant'); |
|
203 //test_.pause (); |
|
204 //test_.submit ('#save_button'); |
|
205 //t.text_nb++; |
|
206 }); |
|
207 // insert here text creation |
|
208 // create successively : a markdown text, a html and a rst one |
|
209 // with tags |
|
210 |
|
211 // check that public texts still work while unlogged |
|
212 // check that non public texts are unavailable |
|
213 // Are the public texts displayed in the login page ? |
|
214 |
|
215 // vérifier les valeurs de settings sauvées |
|
216 // Tester les liens masqués des textes listés si bien créés |
|
217 // Tester suppression de text |
|
218 // Tester bulk actions sur les textes |
|
219 |
|
220 // tester l'affichage d'un texte |
|
221 // tester que : #textcontainer.custom h1 font: Test_Sopinspace_custom_titles_font |
|
222 // tester que si Text preferences -> custom -> #textcontainer.custom font: Test_Sopinspace_custom_font |
|
223 // #textcontainer #add_comment_btn span -> #textcontainer font-family: Test_Sopinspace |
|
224 |
|
225 suite.skip ('texts list page conformity', function () { |
|
226 test_.page_loading ('/text/', 'Texts\n - '+c['#id_workspace_name']); |
|
227 test_logged_header (k.w.USER_ADMIN); |
|
228 test_default_tabs (t.text_nb, t.user_nb); |
|
229 test_.count ('#text ul.sub_list:eq(0) a', 3); |
|
230 test_.text ('#text ul.sub_list:eq(0) a:eq(0)[href="/create/content/"]', 'Create a text'); |
|
231 test_.text ('#text ul.sub_list:eq(0) a:eq(1)[href="/create/upload/"]', 'Upload a text'); |
|
232 test_.text ('#text ul.sub_list:eq(0) a:eq(2)[href="/create/import/"]', 'Import a co-mented text'); |
|
233 // TOTEST : filter by tag |
|
234 test_.count ('form#filter_form[action="."] :input', 1); |
|
235 test_.text ('select#tag_selected option:eq(0)[selected][value="0"]', '- All -', non_visible); |
|
236 test_.count ('#texts_form :input', 3 + t.text_nb % 10); |
|
237 test_.match ('#paginator', new RegExp ('\\s\\d+-\\d+ of '+t.text_nb+'\\s','m')); |
|
238 // TOTEST : pagination |
|
239 // TOTEST : Bulk Actions -> Apply does enable |
|
240 test_.text ('select#bulk_actions option:eq(0)[selected][value="-1"]', 'Bulk Actions', non_visible); |
|
241 test_.text ('select#bulk_actions option:eq(1)[value="delete"]', 'Delete', non_visible); |
|
242 test_.val ('form#texts_form input#apply[type=button][disabled]', 'Apply'); |
|
243 test_.count ('table.large_table:eq(1) th', 6); |
|
244 test_.val ('table.large_table:eq(1) th:eq(0) input#all_check[type="checkbox"]', 'on'); |
|
245 test_.text ('table.large_table:eq(1) th:eq(1) a[href="?order=title"]', 'Text'); |
|
246 test_.text ('table.large_table:eq(1) th:eq(2)', 'Author'); |
|
247 test_.text ('table.large_table:eq(1) th:eq(3) a[href="?order=-modified"]', 'Modified'); |
|
248 test_.text ('table.large_table:eq(1) th:eq(4)', '# comments'); |
|
249 test_.text ('table.large_table:eq(1) th:eq(5)', 'Last week activity'); |
|
250 test_unlogged_footer (); |
|
251 }); |
|
252 |
|
253 suite ('edit profile page conformity', function () { |
|
254 test_.page_loading ('/profile/', 'Your profile [(]'+k.w.USER_ADMIN+'[)]\n - '+c['#id_workspace_name']); |
|
255 test_logged_header (k.w.USER_ADMIN, no_tagline); |
|
256 test_.count ('#content ul.sub_list:eq(0) a', 1); |
|
257 test_.text ('#content ul.sub_list:eq(0) a:eq(0)[href="/profile-pw/"]', 'Password'); |
|
258 test_.count ('form#profile[action="."]:eq(0) :input', 5); |
|
259 test_.field ('profile', 'id_email', 'text', 0, 'E-mail address', true); |
|
260 test_.field ('profile', 'id_first_name','text', 1, 'First name'); |
|
261 test_.field ('profile', 'id_last_name', 'text', 2, 'Last name'); |
|
262 test_.field ('profile', 'id_tags', 'text', 3, 'Tags'); |
|
263 test_.val ('#profile :input:eq(4)[type=submit]', 'Save'); |
|
264 test_unlogged_footer (); |
|
265 }); |
|
266 |
|
267 suite ('edit password page conformity', function () { |
|
268 test_.page_loading ('/profile-pw/', 'Your profile [(]'+k.w.USER_ADMIN+'[)]\n - '+c['#id_workspace_name']); |
|
269 test_logged_header (k.w.USER_ADMIN, no_tagline); |
|
270 test_.count ('#content ul.sub_list:eq(0) a', 1); |
|
271 test_.text ('#content ul.sub_list:eq(0) a:eq(0)[href="/profile/"]', 'Profile'); |
|
272 test_.count ('form#profile[action="."]:eq(0) :input', 4); |
|
273 test_.field ('profile', 'id_old_password', 'password', 0, 'Old password', true); |
|
274 test_.field ('profile', 'id_new_password1', 'password', 1, 'New password', true); |
|
275 test_.field ('profile', 'id_new_password2', 'password', 2, 'New password confirmation', true); |
|
276 test_.val ('#profile :input:eq(3)[type=submit]', 'Save'); |
|
277 test_unlogged_footer (); |
|
278 }); |
|
279 |
|
280 suite ('people list page conformity', function () { |
|
281 test_.page_loading ('/user/', 'People\' list\n - '+c['#id_workspace_name']); |
|
282 test_logged_header (k.w.USER_ADMIN); |
|
283 test_default_tabs (t.text_nb, t.user_nb); |
|
284 test_.count ('#user ul.sub_list:eq(0) a', 2); |
|
285 test_.text ('#user ul.sub_list:eq(0) a:eq(0)[href="/user/add/"]', 'Add a new user'); |
|
286 test_.text ('#user ul.sub_list:eq(0) a:eq(1)[href="/user/mass-add/"]', 'Add users in bulk'); |
|
287 // TOTEST : filter by tag -> commentator user should be tagged commentator (to change in fixture) |
|
288 test_.count ('form#filter_form[action="."] :input', 1); |
|
289 test_.text ('#filter_form a[href="?display=1"]', 'Display suspended users'); |
|
290 test_.text ('select#tag_selected option:eq(0)[selected][value="0"]', '- All -', non_visible); |
|
291 // TOTEST : pagination |
|
292 // TOTEST : Bulk Actions -> Apply does enable |
|
293 // TOTEST display suspended users |
|
294 test_.text ('select#bulk_actions option:eq(0)[selected][value="-1"]', '- Bulk Actions -', non_visible); |
|
295 test_.text ('select#bulk_actions option:eq(1)[value="disable"]', 'Suspend access', non_visible); |
|
296 test_.text ('select#bulk_actions option:eq(2)[value="enable"]', 'Enable access', non_visible); |
|
297 test_.text ('select#bulk_actions option:eq(3)[value="role_1"]', 'Change role to Manager', non_visible); |
|
298 test_.text ('select#bulk_actions option:eq(4)[value="role_2"]', 'Change role to Editor', non_visible); |
|
299 test_.text ('select#bulk_actions option:eq(5)[value="role_3"]', 'Change role to Moderator', non_visible); |
|
300 test_.text ('select#bulk_actions option:eq(6)[value="role_4"]', 'Change role to Commentator', non_visible); |
|
301 test_.text ('select#bulk_actions option:eq(7)[value="role_5"]', 'Change role to Observer', non_visible); |
|
302 test_.val ('form#user_form input#apply[type=button][disabled]', 'Apply'); |
|
303 test_.count ('table.large_table:eq(1) th', 6); |
|
304 test_.val ('table.large_table:eq(1) th:eq(0) input#all_check[type="checkbox"]', 'on'); |
|
305 test_.text ('table.large_table:eq(1) th:eq(1) a[href="?order=user__username"]', 'User'); |
|
306 test_.text ('table.large_table:eq(1) th:eq(2) a[href="?order=user__email"]', 'Email'); |
|
307 test_.text ('table.large_table:eq(1) th:eq(3) a[href="?order=-user__date_joined"]', 'Date joined'); |
|
308 test_.text ('table.large_table:eq(1) th:eq(4) a[href="?order=role__name"]', 'Role'); |
|
309 test_.text ('table.large_table:eq(1) th:eq(5)', 'Last week activity'); |
|
310 test_.text ('table.large_table:eq(1) tr:last a[href="/user/-/edit/"]', 'Anonymous users'); |
|
311 test_.text ('table.large_table:eq(1) a.main_object_title[href="/profile/"]', k.w.USER_ADMIN); |
|
312 test_.text ('table.large_table:eq(1) div.hidden-user-actions a[href="/profile/"]', 'Your profile'); |
|
313 // TOTEST roles of users |
|
314 test_unlogged_footer (); |
|
315 }); |
|
316 |
|
317 suite ('check user number', function () { |
|
318 test_.page_loading ('/user/?display=1', 'People\' list\n - '+c['#id_workspace_name']); |
|
319 test_.count ('#user_form :input', 6 + (t.user_nb % 10) * 2); |
|
320 test_.match ('#paginator', new RegExp ('\\s\\d+-\\d+ of '+t.user_nb+'\\s','m')); |
|
321 }); |
|
322 |
|
323 suite ('add a user page conformity', function () { |
|
324 test_.page_loading ('/user/add/', 'Add a new user\n - '+c['#id_workspace_name']); |
|
325 test_logged_header (k.w.USER_ADMIN); |
|
326 test_default_tabs (t.text_nb, t.user_nb); |
|
327 test_.count ('#user ul.sub_list:eq(0) a', 2); |
|
328 test_.text ('#user ul.sub_list:eq(0) a:eq(0)[href="/user/"]', 'Users\' list'); |
|
329 test_.text ('#user ul.sub_list:eq(0) a:eq(1)[href="/user/mass-add/"]', 'Add users in bulk'); |
|
330 test_.count ('#user form[action="."]:eq(0) :input', 8); |
|
331 test_.field ('user', 'id_email', 'text', 0, 'E-mail address', true); |
|
332 test_.field ('user', 'id_first_name', 'text', 1, 'First name'); |
|
333 test_.field ('user', 'id_last_name', 'text', 2, 'Last name'); |
|
334 test_.field ('user', 'id_tags', 'text', 3, 'Tags'); |
|
335 test_.field ('user', 'id_role', 'select', 4, 'Workspace level role'); |
|
336 test_.field ('user', 'id_note', 'textarea', 5, 'Note'); |
|
337 test_.count ('select#id_role option', 6); |
|
338 test_.text ('select#id_role option:eq(0)[value][selected]', '---------', non_visible); |
|
339 test_.text ('select#id_role option:eq(1)[value="1"]', 'Manager', non_visible); |
|
340 test_.text ('select#id_role option:eq(2)[value="2"]', 'Editor', non_visible); |
|
341 test_.text ('select#id_role option:eq(3)[value="3"]', 'Moderator', non_visible); |
|
342 test_.text ('select#id_role option:eq(4)[value="4"]', 'Commentator', non_visible); |
|
343 test_.text ('select#id_role option:eq(5)[value="5"]', 'Observer', non_visible); |
|
344 test_.val ('#user :input:eq(6)[type=submit]', 'Add user'); |
|
345 test_.val ('#user :input:eq(7)#cancel_button[type=button]', 'Cancel'); |
|
346 test_unlogged_footer (); |
|
347 test_.submit('#user input[type="submit"]'); |
|
348 test_.count ('div.help_text span.error-text', 1); |
|
349 test_.field ('user div.error', 'id_email', 'text', 0, 'E-mail address', true); |
|
350 test_.match ('#user div.help_text:eq(0) span.error-text:eq(0)', /This field is required/m); |
|
351 // X TOTEST add user (pending) |
|
352 }); |
|
353 |
|
354 suite ('add-users-in-bulk page conformity', function () { |
|
355 test_.page_loading ('/user/mass-add/', 'Add users in bulk\n - '+c['#id_workspace_name']); |
|
356 test_logged_header (k.w.USER_ADMIN); |
|
357 test_default_tabs (t.text_nb, t.user_nb); |
|
358 test_.count ('#user ul.sub_list:eq(0) a', 2); |
|
359 test_.text ('#user ul.sub_list:eq(0) a:eq(0)[href="/user/"]', 'Users\' list'); |
|
360 test_.text ('#user ul.sub_list:eq(0) a:eq(1)[href="/user/add/"]', 'Add a new user'); |
|
361 test_.count ('#user form[action="."]:eq(0) :input', 6); |
|
362 test_.field ('user', 'id_email', 'textarea', 0, 'Emails', true); |
|
363 test_.field ('user', 'id_tags', 'text', 1, 'Tags'); |
|
364 test_.field ('user', 'id_role', 'select', 2, 'Workspace level role'); |
|
365 test_.field ('user', 'id_note', 'textarea', 3, 'Note'); |
|
366 test_.count ('select#id_role option', 6); |
|
367 test_.text ('select#id_role option:eq(0)[value][selected]', '---------', non_visible); |
|
368 test_.text ('select#id_role option:eq(1)[value="1"]', 'Manager', non_visible); |
|
369 test_.text ('select#id_role option:eq(2)[value="2"]', 'Editor', non_visible); |
|
370 test_.text ('select#id_role option:eq(3)[value="3"]', 'Moderator', non_visible); |
|
371 test_.text ('select#id_role option:eq(4)[value="4"]', 'Commentator', non_visible); |
|
372 test_.text ('select#id_role option:eq(5)[value="5"]', 'Observer', non_visible); |
|
373 test_.val ('#user :input:eq(4)[type=submit]', 'Add users'); |
|
374 test_.val ('#user :input:eq(5)#cancel_button[type=button]', 'Cancel'); |
|
375 // X TOTEST add users (pending) -> can't be deleted |
|
376 test_unlogged_footer (); |
|
377 test_.submit('#user input[type="submit"]'); |
|
378 test_.count ('div.help_text span.error-text', 1); |
|
379 test_.field ('user div.error', 'id_email', 'textarea', 0, 'Emails', true); |
|
380 test_.match ('#user div.help_text:eq(0) span.error-text:eq(0)', /This field is required/m); |
|
381 }); |
|
382 |
|
383 suite ('settings page conformity', function () { |
|
384 test_.page_loading ('/settings/', 'Settings - '+c['#id_workspace_name']); |
|
385 test_logged_header (k.w.USER_ADMIN); |
|
386 test_default_tabs (t.text_nb, t.user_nb); |
|
387 test_.count ('#settings ul.sub_list:eq(0) a', 1); |
|
388 test_.text ('#settings ul.sub_list:eq(0) a:eq(0)[href="/settings/design/"]', 'Appearance'); |
|
389 test_.count ('#settings form[action="."]:eq(0) :input', 12); |
|
390 test_.field ('settings', 'id_workspace_name', 'text', 0, 'Workspace name'); |
|
391 test_.field ('settings', 'id_workspace_tagline', 'text', 1, 'Workspace tagline'); |
|
392 test_.field ('settings', 'id_workspace_registration', 'checkbox', 2, 'Workspace registration'); |
|
393 test_.field ('settings', 'id_workspace_registration_moderation', 'checkbox', 3, 'Workspace registration moderation'); |
|
394 test_.field ('settings', 'id_workspace_role_model', 'select', 4, 'Role model'); |
|
395 test_.text ('select#id_workspace_role_model option:eq(0)[selected][value="generic"]', 'Generic', non_visible); |
|
396 test_.text ('select#id_workspace_role_model option:eq(1)[value="teacher"]', 'Class (education)', non_visible); |
|
397 test_.field ('settings', 'id_workspace_category_1', 'text', 5, 'Label for the first category of comments'); |
|
398 test_.field ('settings', 'id_workspace_category_2', 'text', 6, 'Label for the second category of comments'); |
|
399 test_.field ('settings', 'id_workspace_category_3', 'text', 7, 'Label for the third category of comments'); |
|
400 test_.field ('settings', 'id_workspace_category_4', 'text', 8, 'Label for the fourth category of comments'); |
|
401 test_.field ('settings', 'id_workspace_category_5', 'text', 9, 'Label for the fifth category of comments'); |
|
402 test_.val ('#settings :input:eq(10)[type=submit]', 'Save'); |
|
403 test_.val ('#settings :input:eq(11)#cancel_button[type=button]', 'Cancel'); |
|
404 // TOTEST Workspace registration feature (with newly accessible page) |
|
405 test_unlogged_footer (); |
|
406 }); |
|
407 |
|
408 suite ('settings design page conformity', function () { |
|
409 test_.page_loading ('/settings/design/', 'Settings - '+c['#id_workspace_name']); |
|
410 test_logged_header (k.w.USER_ADMIN); |
|
411 test_default_tabs (t.text_nb, t.user_nb); |
|
412 test_.count ('#settings ul.sub_list:eq(0) a', 1); |
|
413 test_.text ('#settings ul.sub_list:eq(0) a:eq(0)[href="/settings/"]', 'General'); |
|
414 test_.count ('#settings form[action="."]:eq(0) :input', 7); |
|
415 test_.field ('settings', 'id_workspace_logo_file', 'file', 0, 'Workspace logo'); |
|
416 test_.field ('settings', 'id_custom_css', 'textarea', 1, 'Custom CSS rules'); |
|
417 test_.field ('settings', 'id_custom_font', 'text', 2, 'Custom font'); |
|
418 test_.field ('settings', 'id_custom_titles_font', 'text', 3, 'Custom font for titles'); |
|
419 test_.val ('#settings :input:eq(4)[type=submit]', 'Save'); |
|
420 test_.val ('#settings :input:eq(5)#cancel_button[type=button]', 'Cancel'); |
|
421 test_.val ('#settings :input:eq(6)#delete_logo_button[type=submit]', 'Delete logo'); |
|
422 test_unlogged_footer (); |
|
423 }); |
|
424 |
|
425 suite ('followup page conformity', function () { |
|
426 test_.page_loading ('/followup/', 'Followup\n - '+c['#id_workspace_name']); |
|
427 test_logged_header (k.w.USER_ADMIN); |
|
428 test_default_tabs (t.text_nb, t.user_nb); |
|
429 test_.text ('#followup a:eq(0)[href="/help/#public_private_feed"]', '?'); |
|
430 test_.match ('#followup a:eq(1)[href$="/feed/"]', new RegExp (k.w.WORKSPACE_URL+'feed/', 'm')); |
|
431 test_.text ('#followup a:eq(2)[href="/help/#public_private_feed"]', '?'); |
|
432 test_.count ('form#followup_form[action="."] :input', 3); |
|
433 test_.val ('form#followup_form input[type=submit]', '(Activate private feed|Reset private feed url)'); |
|
434 test_.val ('form#followup_form input#workspace_notify_check[type=checkbox]', 'on'); |
|
435 test_.val ('form#followup_form input#own_notify_check[type=checkbox]', 'on'); |
|
436 |
|
437 // X TOTEST qu'une fois cliqué, le bouton a le nvo label, et qu'une adresse est disponible |
|
438 // X TOTEST que si on reclique l'adresse est changée |
|
439 |
|
440 test_unlogged_footer (); |
|
441 }); |
|
442 |
|
443 }); |
|
444 |
|
445 function test_default_tabs (text_nb, user_nb) { |
|
446 test_.count ('#main-tabs a', 5); |
|
447 test_.text ('#main-tabs li:nth-of-type(1) a[href="/"]', 'Dashboard'); |
|
448 test_.match ('#main-tabs li:nth-of-type(2) a[href="/text/"]', /^Texts \(\d+\) $/); |
|
449 test_.match ('#main-tabs li:nth-of-type(3) a[href="/user/"]', /^People \(\d+\)$/); |
|
450 test_.text ('#main-tabs li:nth-of-type(4) a[href="/settings/"]', 'Settings'); |
|
451 test_.text ('#main-tabs li:nth-of-type(5) a[href="/followup/"]', 'Followup'); |
|
452 test_.match ('#main-tabs a[href="/text/"]', new RegExp ('^Texts\\s*\\('+text_nb+'\\)\\s*$')); |
|
453 test_.match ('#main-tabs a[href="/user/"]', new RegExp ('^People\\s*\\('+user_nb+'\\)\\s*$')); |
|
454 } |
|
455 |
|
456 function test_logged_header (username, is_tagline) { |
|
457 is_tagline = typeof is_tagline == 'undefined' ? true : is_tagline; |
|
458 |
|
459 test_.text ('#header_controls b', username) |
|
460 test_.count ('#header_controls a', 6); |
|
461 test_.text ('#header_controls a:nth-of-type(1)[href="/"]', 'Home'); |
|
462 test_.text ('#header_controls a:nth-of-type(2)[href="/create/content/"]', 'Create a text'); |
|
463 test_.text ('#header_controls a:nth-of-type(3)[href="/create/upload/"]', 'Upload a text'); |
|
464 test_.text ('#header_controls a:nth-of-type(4)[href="/create/import/"]', 'Import a co-mented text'); |
|
465 test_.text ('#header_controls a:nth-of-type(5)[href="/profile/"]', 'Profile'); |
|
466 test_.text ('#header_controls a:nth-of-type(6)[href="/logout/"]', 'Logout'); |
|
467 test_.text ('#content h1.main_title a[href="/"]', c['#id_workspace_name']); |
|
468 |
|
469 if (is_tagline) { |
|
470 test_.match ('#content h1.main_title + div', new RegExp (c['#id_workspace_tagline'], 'm')); |
|
471 } |
|
472 } |
|
473 |
|
474 function test_fill_settings (s) { |
|
475 test_.fill_field ('#id_workspace_name', s); |
|
476 test_.fill_field ('#id_workspace_tagline', s); |
|
477 test_.fill_field ('#id_workspace_registration', s); |
|
478 test_.fill_field ('#id_workspace_registration_moderation', s); |
|
479 test_.fill_field ('#id_workspace_role_model', s); |
|
480 test_.fill_field ('#id_workspace_category_1', s); |
|
481 test_.fill_field ('#id_workspace_category_2', s); |
|
482 test_.fill_field ('#id_workspace_category_3', s); |
|
483 test_.fill_field ('#id_workspace_category_4', s); |
|
484 test_.fill_field ('#id_workspace_category_5', s); |
|
485 } |
|
486 |
|
487 function test_fill_design (s) { |
|
488 test_.fill_field ('#id_custom_css', s); |
|
489 test_.fill_field ('#id_custom_font', s); |
|
490 test_.fill_field ('#id_custom_titles_font', s); |
|
491 } |