147 console.log ('z '+JSON.stringify(z)); |
147 console.log ('z '+JSON.stringify(z)); |
148 }); |
148 }); |
149 }));*/ |
149 }));*/ |
150 }); |
150 }); |
151 |
151 |
152 suite ('setting settings to test values', function () { |
152 suite ('setting settings to test-values', function () { |
153 test_page_loading ('/settings/', 'Settings'); |
153 test_page_loading ('/settings/', 'Settings'); |
154 test_fill_settings (t); |
154 test_fill_settings (t); |
155 test_val ('#id_workspace_name', t['#id_workspace_name']); |
155 test_val ('#id_workspace_name', t['#id_workspace_name']); |
156 test ('Save test settings ', dsl (function () { |
156 test ('Save test settings ', dsl (function () { |
157 elt ('#settings input[type="submit"]').click (); |
157 elt ('#settings input[type="submit"]').click (); |
258 test_count ('select#id_format option', 3); |
258 test_count ('select#id_format option', 3); |
259 test_text ('select#id_format option:eq(0)[value="markdown"][selected]', 'markdown', non_visible); |
259 test_text ('select#id_format option:eq(0)[value="markdown"][selected]', 'markdown', non_visible); |
260 test_text ('select#id_format option:eq(1)[value="rst"]', 'rst', non_visible); |
260 test_text ('select#id_format option:eq(1)[value="rst"]', 'rst', non_visible); |
261 test_text ('select#id_format option:eq(2)[value="html"]', 'html', non_visible); |
261 test_text ('select#id_format option:eq(2)[value="html"]', 'html', non_visible); |
262 test_count ('#markItUpId_content li', 20); // How many buttons are in the WYSIWYG editor toolbar ? |
262 test_count ('#markItUpId_content li', 20); // How many buttons are in the WYSIWYG editor toolbar ? |
|
263 test_unlogged_footer (); |
|
264 |
263 test ('submit empty fields', dsl(function () { |
265 test ('submit empty fields', dsl(function () { |
264 elt ('#text input[type="submit"]').click (); |
266 elt ('#text input[type="submit"]').click (); |
265 browser.waitForPageLoad (); |
267 browser.waitForPageLoad (); |
266 })); |
268 })); |
267 test_count ('div.help_text span.error-text', 2); |
269 test_count ('div.help_text span.error-text', 2); |
268 test_form_field ('text div.error', 'id_title', 'text', 0, 'Title', true); |
270 test_form_field ('text div.error', 'id_title', 'text', 0, 'Title', true); |
269 test_form_field ('text div.error', 'id_content', 'textarea', 2, 'Content', true); |
271 test_form_field ('text div.error', 'id_content', 'textarea', 1, 'Content', true); |
270 |
|
271 test_unlogged_footer (); |
|
272 }); |
272 }); |
273 |
273 |
274 suite ('upload text page conformity', function () { |
274 suite ('upload text page conformity', function () { |
275 test_page_loading ('/create/upload/', 'Upload a text - '+t['#id_workspace_name']); |
275 test_page_loading ('/create/upload/', 'Upload a text - '+t['#id_workspace_name']); |
276 test_logged_header (w.USER_ADMIN); |
276 test_logged_header (w.USER_ADMIN); |
281 test_text ('#text ul.sub_list:eq(0) a:eq(2)[href="/create/import/"]', 'Import a co-mented text'); |
281 test_text ('#text ul.sub_list:eq(0) a:eq(2)[href="/create/import/"]', 'Import a co-mented text'); |
282 test_count ('#text form[action="."]:eq(0) :input', 6); |
282 test_count ('#text form[action="."]:eq(0) :input', 6); |
283 test_form_field ('text', 'id_title', 'text', 0, 'Title'); |
283 test_form_field ('text', 'id_title', 'text', 0, 'Title'); |
284 test_form_field ('text', 'id_format', 'select', 1, 'Format', true); |
284 test_form_field ('text', 'id_format', 'select', 1, 'Format', true); |
285 test_form_field ('text', 'id_tags', 'text', 2, 'Tags'); |
285 test_form_field ('text', 'id_tags', 'text', 2, 'Tags'); |
286 test_form_field ('text', 'id_file', 'file', 3, 'Upload file (optional)'); |
286 test_form_field ('text', 'id_file', 'file', 3, 'Upload file'); |
287 test_val ('#text :input:eq(4)[type=submit]', 'Save'); |
287 test_val ('#text :input:eq(4)[type=submit]', 'Save'); |
288 test_val ('#text :input:eq(5)#cancel_button[type=button]', 'Cancel'); |
288 test_val ('#text :input:eq(5)#cancel_button[type=button]', 'Cancel'); |
289 test_count ('select#id_format option', 3); |
289 test_count ('select#id_format option', 3); |
290 test_text ('select#id_format option:eq(0)[value="markdown"][selected]', 'markdown', non_visible); |
290 test_text ('select#id_format option:eq(0)[value="markdown"][selected]', 'markdown', non_visible); |
291 test_text ('select#id_format option:eq(1)[value="rst"]', 'rst', non_visible); |
291 test_text ('select#id_format option:eq(1)[value="rst"]', 'rst', non_visible); |
292 test_text ('select#id_format option:eq(2)[value="html"]', 'html', non_visible); |
292 test_text ('select#id_format option:eq(2)[value="html"]', 'html', non_visible); |
293 test_unlogged_footer (); |
293 test_unlogged_footer (); |
|
294 |
|
295 test ('submit empty fields', dsl(function () { |
|
296 elt ('#text input[type="submit"]').click (); |
|
297 browser.waitForPageLoad (); |
|
298 })); |
|
299 test_count ('div.help_text span.error-text', 1); |
|
300 test_form_field ('text div.error', 'id_file', 'file', 0, 'Upload file'); |
|
301 test_match ('#text div.help_text:eq(3) span.error-text:eq(0)', /You should specify a file to upload/m); |
294 }); |
302 }); |
295 |
303 |
296 suite ('import a co-mented text page conformity', function () { |
304 suite ('import a co-mented text page conformity', function () { |
297 test_page_loading ('/create/import/', 'Import a co-mented text - '+t['#id_workspace_name']); |
305 test_page_loading ('/create/import/', 'Import a co-mented text - '+t['#id_workspace_name']); |
298 test_logged_header (w.USER_ADMIN); |
306 test_logged_header (w.USER_ADMIN); |
304 test_count ('#text form[action="."]:eq(0) :input', 3); |
312 test_count ('#text form[action="."]:eq(0) :input', 3); |
305 test_form_field ('text', 'id_file', 'file', 0, 'Upload XML file', true); |
313 test_form_field ('text', 'id_file', 'file', 0, 'Upload XML file', true); |
306 test_val ('#text :input:eq(1)[type=submit]', 'Save'); |
314 test_val ('#text :input:eq(1)[type=submit]', 'Save'); |
307 test_val ('#text :input:eq(2)#cancel_button[type=button]', 'Cancel'); |
315 test_val ('#text :input:eq(2)#cancel_button[type=button]', 'Cancel'); |
308 test_unlogged_footer (); |
316 test_unlogged_footer (); |
|
317 |
|
318 test ('submit empty fields', dsl(function () { |
|
319 elt ('#text input[type="submit"]').click (); |
|
320 browser.waitForPageLoad (); |
|
321 })); |
|
322 test_count ('div.help_text span.error-text', 1); |
|
323 test_form_field ('text div.error', 'id_file', 'file', 0, 'Upload XML file', true); |
|
324 test_match ('#text div.help_text:eq(0) span.error-text:eq(0)', /You should specify a file to upload/m); |
309 }); |
325 }); |
310 |
326 |
311 suite ('edit profile page conformity', function () { |
327 suite ('edit profile page conformity', function () { |
312 test_page_loading ('/profile/', 'Your profile [(]'+w.USER_ADMIN+'[)]\n - '+t['#id_workspace_name']); |
328 test_page_loading ('/profile/', 'Your profile [(]'+w.USER_ADMIN+'[)]\n - '+t['#id_workspace_name']); |
313 test_logged_header (w.USER_ADMIN, no_tagline); |
329 test_logged_header (w.USER_ADMIN, no_tagline); |
410 test_text ('select#id_role option:eq(4)[value="4"]', 'Commentator', non_visible); |
426 test_text ('select#id_role option:eq(4)[value="4"]', 'Commentator', non_visible); |
411 test_text ('select#id_role option:eq(5)[value="5"]', 'Observer', non_visible); |
427 test_text ('select#id_role option:eq(5)[value="5"]', 'Observer', non_visible); |
412 test_val ('#user :input:eq(6)[type=submit]', 'Add user'); |
428 test_val ('#user :input:eq(6)[type=submit]', 'Add user'); |
413 test_val ('#user :input:eq(7)#cancel_button[type=button]', 'Cancel'); |
429 test_val ('#user :input:eq(7)#cancel_button[type=button]', 'Cancel'); |
414 test_unlogged_footer (); |
430 test_unlogged_footer (); |
|
431 |
|
432 test ('submit empty fields', dsl(function () { |
|
433 elt ('#user input[type="submit"]').click (); |
|
434 browser.waitForPageLoad (); |
|
435 })); |
|
436 test_count ('div.help_text span.error-text', 1); |
|
437 test_form_field ('user div.error', 'id_email', 'text', 0, 'E-mail address', true); |
|
438 test_match ('#user div.help_text:eq(0) span.error-text:eq(0)', /This field is required/m); |
415 // X TOTEST add user (pending) |
439 // X TOTEST add user (pending) |
416 }); |
440 }); |
417 |
441 |
418 suite ('add users in bulk page conformity', function () { |
442 suite ('add users in bulk page conformity', function () { |
419 test_page_loading ('/user/mass-add/', 'Add users in bulk\n - '+t['#id_workspace_name']); |
443 test_page_loading ('/user/mass-add/', 'Add users in bulk\n - '+t['#id_workspace_name']); |
436 test_text ('select#id_role option:eq(5)[value="5"]', 'Observer', non_visible); |
460 test_text ('select#id_role option:eq(5)[value="5"]', 'Observer', non_visible); |
437 test_val ('#user :input:eq(4)[type=submit]', 'Add users'); |
461 test_val ('#user :input:eq(4)[type=submit]', 'Add users'); |
438 test_val ('#user :input:eq(5)#cancel_button[type=button]', 'Cancel'); |
462 test_val ('#user :input:eq(5)#cancel_button[type=button]', 'Cancel'); |
439 // X TOTEST add users (pending) -> can't be deleted |
463 // X TOTEST add users (pending) -> can't be deleted |
440 test_unlogged_footer (); |
464 test_unlogged_footer (); |
|
465 |
|
466 test ('submit empty fields', dsl(function () { |
|
467 elt ('#user input[type="submit"]').click (); |
|
468 browser.waitForPageLoad (); |
|
469 })); |
|
470 test_count ('div.help_text span.error-text', 1); |
|
471 test_form_field ('user div.error', 'id_email', 'textarea', 0, 'Emails', true); |
|
472 test_match ('#user div.help_text:eq(0) span.error-text:eq(0)', /This field is required/m); |
441 }); |
473 }); |
442 |
474 |
443 suite ('settings page conformity', function () { |
475 suite ('settings page conformity', function () { |
444 test_page_loading ('/settings/', 'Settings - '+t['#id_workspace_name']); |
476 test_page_loading ('/settings/', 'Settings - '+t['#id_workspace_name']); |
445 test_logged_header (w.USER_ADMIN); |
477 test_logged_header (w.USER_ADMIN); |
498 // X TOTEST que si on reclique l'adresse est changée |
530 // X TOTEST que si on reclique l'adresse est changée |
499 |
531 |
500 test_unlogged_footer (); |
532 test_unlogged_footer (); |
501 }); |
533 }); |
502 |
534 |
|
535 // vérifier les valeurs de settings sauvées |
|
536 // Tester les champs obligatoires |
503 // Tester les créations de textes |
537 // Tester les créations de textes |
504 // Tester les champs obligatoires |
|
505 // Tester les liens masqués des textes listés si bien créés |
538 // Tester les liens masqués des textes listés si bien créés |
506 // Tester suppression de text |
539 // Tester suppression de text |
507 // Tester bulk actions sur les textes |
540 // Tester bulk actions sur les textes |
508 |
541 |
509 // tester l'affichage d'un texte |
542 // tester l'affichage d'un texte |
694 /** Test Django form field presence |
727 /** Test Django form field presence |
695 */ |
728 */ |
696 function test_form_field (form_id, field_id, type, position, label, mandatory) { |
729 function test_form_field (form_id, field_id, type, position, label, mandatory) { |
697 test ('has a '+label+' form field', dsl(function () { |
730 test ('has a '+label+' form field', dsl(function () { |
698 var s = ''; |
731 var s = ''; |
|
732 |
699 switch (type) { |
733 switch (type) { |
700 case 'textarea':s = 'textarea#'+field_id; break; |
734 case 'textarea':s = 'textarea#'+field_id; break; |
701 case 'select': s = 'select#'+field_id; break; |
735 case 'select': s = 'select#'+field_id; break; |
702 default: s = 'input#'+field_id+'[type="'+type+'"]'; |
736 default: s = 'input#'+field_id+'[type="'+type+'"]'; |
703 } |
737 } |
704 // var s = type == 'textarea' ? 'textarea#'+field_id : 'input#'+field_id+'[type='+type+']'; |
738 |
705 expect (elt (s).val ()).toBeDefined (); |
739 expect (elt (s).val ()).toBeDefined (); |
706 expect (elt ('#'+form_id+' :input:eq('+position+')#'+field_id).val ()).toBeDefined (); |
740 expect (elt ('#'+form_id+' :input:eq('+position+')#'+field_id).val ()).toBeDefined (); |
707 expect (elt ('label[for='+field_id+']').text ()).toBe (label); |
741 expect (elt ('label[for='+field_id+']').text ()).toBe (label); |
708 |
742 |
709 if (mandatory) |
743 if (mandatory) |