src/cm/scripts/test-suite/tests/tests.js
changeset 614 61408993f361
parent 613 a0b695aace0a
child 617 73d293d9cf76
equal deleted inserted replaced
611:fa66f4bb1563 614:61408993f361
    21 	'#id_workspace_category_1':	'ws_cat_1',
    21 	'#id_workspace_category_1':	'ws_cat_1',
    22 	'#id_workspace_category_2':	'ws_cat_2',
    22 	'#id_workspace_category_2':	'ws_cat_2',
    23 	'#id_workspace_category_3':	'ws_cat_3',
    23 	'#id_workspace_category_3':	'ws_cat_3',
    24 	'#id_workspace_category_4':	'ws_cat_4',
    24 	'#id_workspace_category_4':	'ws_cat_4',
    25 	'#id_workspace_category_5':	'ws_cat_5',
    25 	'#id_workspace_category_5':	'ws_cat_5',
    26 	'#id_custom_css': ".voted {\n  color: #008000;\n}\n\n.rejected, .fallen, .withdrawn {\n  color: #ff0000;\n}\n\ndiv.frame {\n  border: 1px solid #000;\n  padding: 5px;\n}\n\ndiv.frame .title {\n  font-weight: bold;\n  text-align: center; font-color:purple; \n}",
    26 	'#id_custom_css': "h2 {  font-family: Test_Sopinspace !important; }",
    27 	'#id_custom_font': 'Ubuntu',
    27 	'#id_custom_font': 'Test_Sopinspace_custom_font',
    28 	'#id_custom_titles_font': 'Ubuntu Monospaced',
    28 	'#id_custom_titles_font': 'Test_Sopinspace_custom_titles_font',
    29 };
    29 };
    30 
    30 
    31 
    31 
    32 suite ('comt', function () {
    32 suite ('comt', function () {
    33 
    33 
    58 		test_page_loading ('/help/', 'Help');
    58 		test_page_loading ('/help/', 'Help');
    59 		test_unlogged_header ();
    59 		test_unlogged_header ();
    60 		test_unlogged_footer ();
    60 		test_unlogged_footer ();
    61 	});
    61 	});
    62 
    62 
       
    63 	suite ('contact page mandatory field test', function () {
       
    64 		test_page_loading ('/contact/', 'Contact');
       
    65 
       
    66 		test ('submit empty fields', dsl(function () {
       
    67 			elt ('#profile input[type="submit"]').click ();
       
    68 			browser.waitForPageLoad ();
       
    69 		}));
       
    70 		test_count ('div.help_text span.error-text', 4);
       
    71 		test_form_field ('profile div.error', 'id_name', 'text', 0, 'Your name', true); // the field id_name is…
       
    72 		test_form_field ('profile div.error', 'id_email', 'text', 1, 'Your email address', true);
       
    73 		test_form_field ('profile div.error', 'id_title', 'text', 2, 'Subject of the message', true);
       
    74 		test_form_field ('profile div.error', 'id_body', 'textarea', 3, 'Body of the message', true);
       
    75 		test_form_field ('profile', 'id_copy', 'checkbox', 4, 'Send me a copy of the email', false);
       
    76 	});
       
    77 
    63 	suite ('reset password page conformity', function () {
    78 	suite ('reset password page conformity', function () {
    64 		test_page_loading ('/password_reset/', 'Reset my password');
    79 		test_page_loading ('/password_reset/', 'Reset my password');
    65 		test_unlogged_header ();
    80 		test_unlogged_header ();
    66 		test_val	('form#profile[action="."]');
    81 		test_val	('form#profile[action="."]');
    67 		test_count	('form#profile :input', 3);
    82 		test_count	('form#profile :input', 3);
    68 		test_form_field ('profile', 'id_email', 'text', 1, 'E-mail', true);
    83 		test_form_field ('profile', 'id_email', 'text', 1, 'E-mail', true);
    69 		test_val	('#profile input[type=submit]', 'Reset my password');
    84 		test_val	('#profile input[type=submit]', 'Reset my password');
    70 		test_unlogged_footer ();
    85 		test_unlogged_footer ();
       
    86 
       
    87 		test ('submit empty fields', dsl(function () {
       
    88 			elt ('#profile input[type="submit"]').click ();
       
    89 			browser.waitForPageLoad ();
       
    90 		}));
       
    91 
       
    92 		test_count ('div.help_text span.error-text', 1);
       
    93 		test_form_field ('profile div.error', 'id_email', 'text', 0, 'E-mail', true);
    71 	});
    94 	});
    72 
    95 
    73 	suite ('login page conformity', function () {
    96 	suite ('login page conformity', function () {
    74 		test_page_loading ('/', 'Home');
    97 		test_page_loading ('/', 'Home');
    75 		test_unlogged_header ();
    98 		test_unlogged_header ();
    76 		test_val	('form#login[action="/login/"]');
    99 		test_val	('form#login[action="/login/"]');
    77 		test_count	('form#login[action="/login/"] :input', 3);
   100 		test_count	('form#login[action="/login/"] :input', 3);
    78 		test_form_field ('login', 'id_username', 'text', 0, 'Username', true);
   101 		test_form_field ('login', 'id_username', 'text', 0, 'Username', true);
    79 		test_form_field ('login', 'id_password', 'password', 1, 'Password', true);
   102 		test_form_field ('login', 'id_password', 'password', 1, 'Password', true);
    80 		test_val ('form#login input[type=submit]', 'Login');
   103 		test_val	('form#login input[type=submit]', 'Login');
    81 		test_text	('form#login a[href="/password_reset/"]', 'Forgot password?');
   104 		test_text	('form#login a[href="/password_reset/"]', 'Forgot password?');
    82 		test_unlogged_footer ();
   105 		test_unlogged_footer ();
    83 		// test_i18n ();
   106 		// test_i18n ();
    84 		test		('logs an admin in', dsl(function () {
   107 
       
   108 		test ('get back to / to avoid bugging next page load', dsl(function () {
       
   109 			browser.navigateTo ('/');
       
   110 		}));
       
   111 		test_page_loading ('/login/', 'Login');
       
   112 		test ('submit empty fields', dsl(function () {
       
   113 			elt ('#login input[type="submit"]').click ();
       
   114 			browser.waitForPageLoad ();
       
   115 		}));
       
   116 		test_form_field ('login div.error', 'id_username', 'text', 0, 'Username', true);
       
   117 		test_form_field ('login div.error', 'id_password', 'password', 1, 'Password', true);
       
   118 		test ('logs an admin in', dsl(function () {
    85 			input ('#id_username').enter (w.USER_ADMIN);
   119 			input ('#id_username').enter (w.USER_ADMIN);
    86 			input ('#id_password').enter (w.PASS_ADMIN);
   120 			input ('#id_password').enter (w.PASS_ADMIN);
    87 			elt ('#login input[type=submit]').click ();
   121 			elt ('#login input[type=submit]').click ();
    88 			// Must be done here in this test() block
   122 			// Must be done here in this test() block
    89 			browser.waitForPageLoad ();
   123 			browser.waitForPageLoad ();
   113 				console.log ('z '+JSON.stringify(z));
   147 				console.log ('z '+JSON.stringify(z));
   114 			});
   148 			});
   115 		}));*/
   149 		}));*/
   116     });
   150     });
   117 
   151 
   118 	suite ('setting settings to test values', function () {
   152 	suite ('setting settings to test-values', function () {
   119 		test_page_loading ('/settings/', 'Settings');
   153 		test_page_loading ('/settings/', 'Settings');
   120 		test_fill_settings (t);
   154 		test_fill_settings (t);
   121 		test_val ('#id_workspace_name', t['#id_workspace_name']);
   155 		test_val ('#id_workspace_name', t['#id_workspace_name']);
   122 		test ('Save test settings ', dsl (function () {
   156 		test ('Save test settings ', dsl (function () {
   123 			elt ('#settings input[type="submit"]').click ();
   157 			elt ('#settings input[type="submit"]').click ();
   213         test_count  ('#text ul.sub_list:eq(0) a', 3);
   247         test_count  ('#text ul.sub_list:eq(0) a', 3);
   214         test_text   ('#text ul.sub_list:eq(0) a:eq(0)[href="/text/"]', 'Text list');
   248         test_text   ('#text ul.sub_list:eq(0) a:eq(0)[href="/text/"]', 'Text list');
   215         test_text   ('#text ul.sub_list:eq(0) a:eq(1)[href="/create/upload/"]', 'Upload a text');
   249         test_text   ('#text ul.sub_list:eq(0) a:eq(1)[href="/create/upload/"]', 'Upload a text');
   216         test_text   ('#text ul.sub_list:eq(0) a:eq(2)[href="/create/import/"]', 'Import a co-mented text');
   250         test_text   ('#text ul.sub_list:eq(0) a:eq(2)[href="/create/import/"]', 'Import a co-mented text');
   217         test_count  ('#text form[action="."]:eq(0) :input', 6);
   251         test_count  ('#text form[action="."]:eq(0) :input', 6);
   218 		test_form_field ('text', 'id_title',		'text', 0, 'Title', true);
   252 		test_form_field ('text', 'id_title',	'text', 0, 'Title', true);
   219 		test_form_field ('text', 'id_format',		'select', 1, 'Format', true);
   253 		test_form_field ('text', 'id_format',	'select', 1, 'Format', true);
   220 		test_form_field ('text', 'id_content',		'textarea', 2, 'Content', true);
   254 		test_form_field ('text', 'id_content',	'textarea', 2, 'Content', true);
   221 		test_form_field ('text', 'id_tags',			'text', 3, 'Tags');
   255 		test_form_field ('text', 'id_tags',		'text', 3, 'Tags');
   222 		test_val	('#text :input:eq(4)[type=submit]', 'Save');
   256 		test_val	('#text :input:eq(4)[type=submit]', 'Save');
   223 		test_val	('#text :input:eq(5)#cancel_button[type=button]', 'Cancel');
   257 		test_val	('#text :input:eq(5)#cancel_button[type=button]', 'Cancel');
   224 		test_count	('select#id_format option', 3);
   258 		test_count	('select#id_format option', 3);
   225         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);
   226         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);
   227         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);
   228 		test_count	('#markItUpId_content li', 20);
   262 		test_count	('#markItUpId_content li', 20); // How many buttons are in the WYSIWYG editor toolbar ?
   229         test_unlogged_footer ();
   263         test_unlogged_footer ();
       
   264 
       
   265 		test ('submit empty fields', dsl(function () {
       
   266 			elt ('#text input[type="submit"]').click ();
       
   267 			browser.waitForPageLoad ();
       
   268 		}));
       
   269 		test_count ('div.help_text span.error-text', 2);
       
   270 		test_form_field ('text div.error', 'id_title',		'text', 0, 'Title', true);
       
   271 		test_form_field ('text div.error', 'id_content',	'textarea', 1, 'Content', true);
   230     });
   272     });
   231 
   273 
   232 	suite ('upload text page conformity', function () {
   274 	suite ('upload text page conformity', function () {
   233         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']);
   234 		test_logged_header	(w.USER_ADMIN);
   276 		test_logged_header	(w.USER_ADMIN);
   236         test_count  ('#text ul.sub_list:eq(0) a', 3);
   278         test_count  ('#text ul.sub_list:eq(0) a', 3);
   237         test_text   ('#text ul.sub_list:eq(0) a:eq(0)[href="/text/"]', 'Text list');
   279         test_text   ('#text ul.sub_list:eq(0) a:eq(0)[href="/text/"]', 'Text list');
   238         test_text   ('#text ul.sub_list:eq(0) a:eq(1)[href="/create/content/"]', 'Create a text');
   280         test_text   ('#text ul.sub_list:eq(0) a:eq(1)[href="/create/content/"]', 'Create a text');
   239         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');
   240         test_count  ('#text form[action="."]:eq(0) :input', 6);
   282         test_count  ('#text form[action="."]:eq(0) :input', 6);
   241 		test_form_field ('text', 'id_title',		'text', 0, 'Title');
   283 		test_form_field ('text', 'id_title',	'text', 0, 'Title');
   242 		test_form_field ('text', 'id_format',		'select', 1, 'Format', true);
   284 		test_form_field ('text', 'id_format',	'select', 1, 'Format', true);
   243 		test_form_field ('text', 'id_tags',			'text', 2, 'Tags');
   285 		test_form_field ('text', 'id_tags',		'text', 2, 'Tags');
   244 		test_form_field ('text', 'id_file',			'file', 3, 'Upload file (optional)');
   286 		test_form_field ('text', 'id_file',		'file', 3, 'Upload file');
   245 		test_val	('#text :input:eq(4)[type=submit]', 'Save');
   287 		test_val	('#text :input:eq(4)[type=submit]', 'Save');
   246 		test_val	('#text :input:eq(5)#cancel_button[type=button]', 'Cancel');
   288 		test_val	('#text :input:eq(5)#cancel_button[type=button]', 'Cancel');
   247 		test_count	('select#id_format option', 3);
   289 		test_count	('select#id_format option', 3);
   248         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);
   249         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);
   250         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);
   251         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);
   252     });
   302     });
   253 
   303 
   254 	suite ('import a co-mented text page conformity', function () {
   304 	suite ('import a co-mented text page conformity', function () {
   255         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']);
   256 		test_logged_header	(w.USER_ADMIN);
   306 		test_logged_header	(w.USER_ADMIN);
   262         test_count  ('#text form[action="."]:eq(0) :input', 3);
   312         test_count  ('#text form[action="."]:eq(0) :input', 3);
   263 		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);
   264 		test_val	('#text :input:eq(1)[type=submit]', 'Save');
   314 		test_val	('#text :input:eq(1)[type=submit]', 'Save');
   265 		test_val	('#text :input:eq(2)#cancel_button[type=button]', 'Cancel');
   315 		test_val	('#text :input:eq(2)#cancel_button[type=button]', 'Cancel');
   266         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);
   267     });
   325     });
   268 
   326 
   269 	suite ('edit profile page conformity', function () {
   327 	suite ('edit profile page conformity', function () {
   270         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']);
   271 		test_logged_header	(w.USER_ADMIN, no_tagline);
   329 		test_logged_header	(w.USER_ADMIN, no_tagline);
   298         test_logged_header	(w.USER_ADMIN);
   356         test_logged_header	(w.USER_ADMIN);
   299         test_default_tabs	();
   357         test_default_tabs	();
   300         test_count  ('#user ul.sub_list:eq(0) a', 2);
   358         test_count  ('#user ul.sub_list:eq(0) a', 2);
   301         test_text   ('#user ul.sub_list:eq(0) a:eq(0)[href="/user/add/"]', 'Add a new user');
   359         test_text   ('#user ul.sub_list:eq(0) a:eq(0)[href="/user/add/"]', 'Add a new user');
   302         test_text   ('#user ul.sub_list:eq(0) a:eq(1)[href="/user/mass-add/"]', 'Add users in bulk');
   360         test_text   ('#user ul.sub_list:eq(0) a:eq(1)[href="/user/mass-add/"]', 'Add users in bulk');
   303         // TOTEST : filter by tag
   361         // TOTEST : filter by tag -> commentator user should be tagged commentator
   304         test_count  ('form#filter_form[action="."] :input', 1);
   362         test_count  ('form#filter_form[action="."] :input', 1);
   305 		test_text	('#filter_form a[href="?display=1"]', 'Display suspended users');
   363 		test_text	('#filter_form a[href="?display=1"]', 'Display suspended users');
   306         test_text   ('select#tag_selected option:eq(0)[selected][value="0"]', '- All -', non_visible);
   364         test_text   ('select#tag_selected option:eq(0)[selected][value="0"]', '- All -', non_visible);
   307         // TOTEST : pagination
   365         // TOTEST : pagination
   308         // TOTEST : Bulk Actions -> Apply does enable
   366         // TOTEST : Bulk Actions -> Apply does enable
   323         test_text   ('table.large_table:eq(1) th:eq(4) a[href="?order=role__name"]', 'Role');
   381         test_text   ('table.large_table:eq(1) th:eq(4) a[href="?order=role__name"]', 'Role');
   324         test_text   ('table.large_table:eq(1) th:eq(5)', 'Last week activity');
   382         test_text   ('table.large_table:eq(1) th:eq(5)', 'Last week activity');
   325 		test_text	('table.large_table:eq(1) tr:last a[href="/user/-/edit/"]', 'Anonymous users');
   383 		test_text	('table.large_table:eq(1) tr:last a[href="/user/-/edit/"]', 'Anonymous users');
   326 		test_text	('table.large_table:eq(1) a.main_object_title[href="/profile/"]', w.USER_ADMIN);
   384 		test_text	('table.large_table:eq(1) a.main_object_title[href="/profile/"]', w.USER_ADMIN);
   327 		test_text	('table.large_table:eq(1) div.hidden-user-actions a[href="/profile/"]', 'Your profile');
   385 		test_text	('table.large_table:eq(1) div.hidden-user-actions a[href="/profile/"]', 'Your profile');
       
   386 		// TOTEST presence of commentator and editor user
   328         test_unlogged_footer ();
   387         test_unlogged_footer ();
   329     });
   388     });
   330 
   389 
   331 	suite ('check user number', function () {
   390 	suite ('check user number', function () {
   332         test_page_loading	('/user/?display=1', 'People\' list\n - '+t['#id_workspace_name']);
   391         test_page_loading	('/user/?display=1', 'People\' list\n - '+t['#id_workspace_name']);
   367         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);
   368         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);
   369 		test_val	('#user :input:eq(6)[type=submit]', 'Add user');
   428 		test_val	('#user :input:eq(6)[type=submit]', 'Add user');
   370 		test_val	('#user :input:eq(7)#cancel_button[type=button]', 'Cancel');
   429 		test_val	('#user :input:eq(7)#cancel_button[type=button]', 'Cancel');
   371         test_unlogged_footer ();
   430         test_unlogged_footer ();
   372 		// TOTEST add user (pending)
   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);
       
   439 		// X TOTEST add user (pending)
   373     });
   440     });
   374 
   441 
   375 	suite ('add users in bulk page conformity', function () {
   442 	suite ('add users in bulk page conformity', function () {
   376         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']);
   377 		test_logged_header	(w.USER_ADMIN);
   444 		test_logged_header	(w.USER_ADMIN);
   393         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);
   394 		test_val	('#user :input:eq(4)[type=submit]', 'Add users');
   461 		test_val	('#user :input:eq(4)[type=submit]', 'Add users');
   395 		test_val	('#user :input:eq(5)#cancel_button[type=button]', 'Cancel');
   462 		test_val	('#user :input:eq(5)#cancel_button[type=button]', 'Cancel');
   396 		// X TOTEST add users (pending) -> can't be deleted
   463 		// X TOTEST add users (pending) -> can't be deleted
   397         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);
   398     });
   473     });
   399 
   474 
   400 	suite ('settings page conformity', function () {
   475 	suite ('settings page conformity', function () {
   401         test_page_loading	('/settings/', 'Settings - '+t['#id_workspace_name']);
   476         test_page_loading	('/settings/', 'Settings - '+t['#id_workspace_name']);
   402 		test_logged_header	(w.USER_ADMIN);
   477 		test_logged_header	(w.USER_ADMIN);
   416 		test_form_field ('settings', 'id_workspace_category_3', 'text', 7, 'Label for the third category of comments');
   491 		test_form_field ('settings', 'id_workspace_category_3', 'text', 7, 'Label for the third category of comments');
   417 		test_form_field ('settings', 'id_workspace_category_4', 'text', 8, 'Label for the fourth category of comments');
   492 		test_form_field ('settings', 'id_workspace_category_4', 'text', 8, 'Label for the fourth category of comments');
   418 		test_form_field ('settings', 'id_workspace_category_5', 'text', 9, 'Label for the fifth category of comments');
   493 		test_form_field ('settings', 'id_workspace_category_5', 'text', 9, 'Label for the fifth category of comments');
   419 		test_val	('#settings :input:eq(10)[type=submit]', 'Save');
   494 		test_val	('#settings :input:eq(10)[type=submit]', 'Save');
   420 		test_val	('#settings :input:eq(11)#cancel_button[type=button]', 'Cancel');
   495 		test_val	('#settings :input:eq(11)#cancel_button[type=button]', 'Cancel');
   421 		// TOTEST Workspace registration
   496 		// TOTEST Workspace registration feature (with newly accessible page)
   422 		test_unlogged_footer ();
   497 		test_unlogged_footer ();
   423     });
   498     });
   424 
   499 
   425 	suite ('settings design page conformity', function () {
   500 	suite ('settings design page conformity', function () {
   426         test_page_loading	('/settings/design/', 'Settings - '+t['#id_workspace_name']);
   501         test_page_loading	('/settings/design/', 'Settings - '+t['#id_workspace_name']);
   434 		test_form_field ('settings', 'id_custom_font', 'text', 2, 'Custom font');
   509 		test_form_field ('settings', 'id_custom_font', 'text', 2, 'Custom font');
   435 		test_form_field ('settings', 'id_custom_titles_font', 'text', 3, 'Custom font for titles');
   510 		test_form_field ('settings', 'id_custom_titles_font', 'text', 3, 'Custom font for titles');
   436 		test_val	('#settings :input:eq(4)[type=submit]', 'Save');
   511 		test_val	('#settings :input:eq(4)[type=submit]', 'Save');
   437 		test_val	('#settings :input:eq(5)#cancel_button[type=button]', 'Cancel');
   512 		test_val	('#settings :input:eq(5)#cancel_button[type=button]', 'Cancel');
   438 		test_val	('#settings :input:eq(6)#delete_logo_button[type=submit]', 'Delete logo');
   513 		test_val	('#settings :input:eq(6)#delete_logo_button[type=submit]', 'Delete logo');
   439 		// TOTEST custom CSS, font, font for titles like the rest of the settings
       
   440 		test_unlogged_footer ();
   514 		test_unlogged_footer ();
   441     });
   515     });
   442 
   516 
   443 	suite ('followup page conformity', function () {
   517 	suite ('followup page conformity', function () {
   444 		test_page_loading	('/followup/', 'Followup\n - '+t['#id_workspace_name']);
   518 		test_page_loading	('/followup/', 'Followup\n - '+t['#id_workspace_name']);
   450 		test_count	('form#followup_form[action="."] :input', 3);
   524 		test_count	('form#followup_form[action="."] :input', 3);
   451 		test_val	('form#followup_form input[type=submit]', '(Activate private feed|Reset private feed url)');
   525 		test_val	('form#followup_form input[type=submit]', '(Activate private feed|Reset private feed url)');
   452 		test_val	('form#followup_form input#workspace_notify_check[type=checkbox]', 'on');
   526 		test_val	('form#followup_form input#workspace_notify_check[type=checkbox]', 'on');
   453 		test_val	('form#followup_form input#own_notify_check[type=checkbox]', 'on');
   527 		test_val	('form#followup_form input#own_notify_check[type=checkbox]', 'on');
   454 	
   528 	
   455 		// tester qu'une fois cliqué, le bouton à le nvo label, et qu'une adresse est disponible
   529 		// X TOTEST qu'une fois cliqué, le bouton a le nvo label, et qu'une adresse est disponible
   456 		// tester que si on reclique l'adresse est changée
   530 		// X TOTEST que si on reclique l'adresse est changée
   457 
   531 
   458 		test_unlogged_footer ();
   532 		test_unlogged_footer ();
   459 	});
   533 	});
       
   534 
       
   535 	// vérifier les valeurs de settings sauvées
       
   536 	// Tester les champs obligatoires
       
   537 	// Tester les créations de textes
       
   538 	// Tester les liens masqués des textes listés si bien créés
       
   539 	// Tester suppression de text
       
   540 	// Tester bulk actions sur les textes
       
   541 
       
   542 	// tester l'affichage d'un texte
       
   543 	// tester que : #textcontainer.custom h1 font: Test_Sopinspace_custom_titles_font
       
   544 	// tester que si Text preferences -> custom -> #textcontainer.custom font: Test_Sopinspace_custom_font
       
   545 	// #textcontainer #add_comment_btn span -> #textcontainer font-family: Test_Sopinspace
   460 
   546 
   461 	suite ('settings restoration', function () {
   547 	suite ('settings restoration', function () {
   462         test_page_loading	('/settings/', 'Settings');
   548         test_page_loading	('/settings/', 'Settings');
   463 		test_fill_settings (z);
   549 		test_fill_settings (z);
   464 		test ('Restore settings ', dsl (function () {
   550 		test ('Restore settings ', dsl (function () {
   533 	test_text	('#footer a:nth-of-type(7)[href="/i18n/setlang/es/"]',		'Español');
   619 	test_text	('#footer a:nth-of-type(7)[href="/i18n/setlang/es/"]',		'Español');
   534 	test_text	('#footer a:nth-of-type(8)[href="/i18n/setlang/bg/"]',		'Български');
   620 	test_text	('#footer a:nth-of-type(8)[href="/i18n/setlang/bg/"]',		'Български');
   535 	test_text	('#footer a:nth-of-type(9)[href="/i18n/setlang/it/"]',		'Italiano');
   621 	test_text	('#footer a:nth-of-type(9)[href="/i18n/setlang/it/"]',		'Italiano');
   536 }
   622 }
   537 
   623 
       
   624 function test_readz_field (field_id) {
       
   625 	test ('get '+field_id, dsl(function () {
       
   626 		element (field_id).val (function (v) {
       
   627 			z[field_id] = v;
       
   628 		});
       
   629 	}));
       
   630 }
       
   631 
       
   632 function test_fill_field (field_id, stored) {
       
   633 	test ('set '+field_id, dsl(function () {
       
   634 		input (field_id).enter (stored[field_id]);
       
   635 	}));
       
   636 }
       
   637 
       
   638 function test_fill_settings (s) {
       
   639 	test_fill_field ('#id_workspace_name', s);
       
   640 	test_fill_field ('#id_workspace_tagline', s);
       
   641 	test_fill_field ('#id_workspace_registration', s);
       
   642 	test_fill_field ('#id_workspace_registration_moderation', s);
       
   643 	test_fill_field ('#id_workspace_role_model', s);
       
   644 	test_fill_field ('#id_workspace_category_1', s);
       
   645 	test_fill_field ('#id_workspace_category_2', s);
       
   646 	test_fill_field ('#id_workspace_category_3', s);
       
   647 	test_fill_field ('#id_workspace_category_4', s);
       
   648 	test_fill_field ('#id_workspace_category_5', s);
       
   649 }
       
   650 
       
   651 function test_fill_design (s) {
       
   652 	test_fill_field ('#id_custom_css', s);
       
   653 	test_fill_field ('#id_custom_font', s);
       
   654 	test_fill_field ('#id_custom_titles_font', s);
       
   655 }
       
   656 
   538 function test_i18n () {
   657 function test_i18n () {
   539 	test ('can change lang to french', dsl(function () {
   658 	test ('can change lang to french', dsl(function () {
   540 		element ('#footer a[href="/i18n/setlang/fr/"]').click ();
   659 		element ('#footer a[href="/i18n/setlang/fr/"]').click ();
   541 //		browser.waitForPageLoad ();
   660 //		browser.waitForPageLoad ();
   542 //		browser.navigateTo ('/');
   661 //		browser.navigateTo ('/');
   608 /** Test Django form field presence
   727 /** Test Django form field presence
   609  */
   728  */
   610 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) {
   611 	test ('has a '+label+' form field', dsl(function () {
   730 	test ('has a '+label+' form field', dsl(function () {
   612 		var s = '';
   731 		var s = '';
       
   732 
   613 		switch (type) {
   733 		switch (type) {
   614 			case 'textarea':s = 'textarea#'+field_id; break;
   734 			case 'textarea':s = 'textarea#'+field_id; break;
   615 			case 'select':	s = 'select#'+field_id; break;
   735 			case 'select':	s = 'select#'+field_id; break;
   616 			default:		s = 'input#'+field_id+'[type="'+type+'"]';
   736 			default:		s = 'input#'+field_id+'[type="'+type+'"]';
   617 		}
   737 		}
   618 //		var s = type == 'textarea' ? 'textarea#'+field_id : 'input#'+field_id+'[type='+type+']';
   738 
   619 		expect (elt (s).val ()).toBeDefined ();
   739 		expect (elt (s).val ()).toBeDefined ();
   620 		expect (elt ('#'+form_id+' :input:eq('+position+')#'+field_id).val ()).toBeDefined ();
   740 		expect (elt ('#'+form_id+' :input:eq('+position+')#'+field_id).val ()).toBeDefined ();
   621 		expect (elt ('label[for='+field_id+']').text ()).toBe (label);
   741 		expect (elt ('label[for='+field_id+']').text ()).toBe (label);
   622 
   742 
   623 		if (mandatory)
   743 		if (mandatory)
   624 			expect (elt ('label[for='+field_id+'] + span.required_star').val ()).toBeDefined ();
   744 			expect (elt ('label[for='+field_id+'] + span.required_star').val ()).toBeDefined ();
   625 	}));
   745 	}));
   626 }
       
   627 
       
   628 function test_readz_field (field_id) {
       
   629 	test ('get '+field_id, dsl(function () {
       
   630 		element (field_id).val (function (v) {
       
   631 			z[field_id] = v;
       
   632 		});
       
   633 	}));
       
   634 }
       
   635 
       
   636 function test_fill_field (field_id, stored) {
       
   637 	test ('set '+field_id, dsl(function () {
       
   638 		input (field_id).enter (stored[field_id]);
       
   639 	}));
       
   640 }
       
   641 
       
   642 function test_fill_settings (s) {
       
   643 	test_fill_field ('#id_workspace_name', s);
       
   644 	test_fill_field ('#id_workspace_tagline', s);
       
   645 	test_fill_field ('#id_workspace_registration', s);
       
   646 	test_fill_field ('#id_workspace_registration_moderation', s);
       
   647 	test_fill_field ('#id_workspace_role_model', s);
       
   648 	test_fill_field ('#id_workspace_category_1', s);
       
   649 	test_fill_field ('#id_workspace_category_2', s);
       
   650 	test_fill_field ('#id_workspace_category_3', s);
       
   651 	test_fill_field ('#id_workspace_category_4', s);
       
   652 	test_fill_field ('#id_workspace_category_5', s);
       
   653 }
       
   654 
       
   655 function test_fill_design (s) {
       
   656 	test_fill_field ('#id_custom_css', s);
       
   657 	test_fill_field ('#id_custom_font', s);
       
   658 	test_fill_field ('#id_custom_titles_font', s);
       
   659 }
   746 }
   660 
   747 
   661 /** Ensure the given element is visible
   748 /** Ensure the given element is visible
   662  *  s : CSS selector of the DOM element to check
   749  *  s : CSS selector of the DOM element to check
   663  *  v : should the element being visible
   750  *  v : should the element being visible