test-suite/tests/011_comt-logged-admin.js
changeset 647 c28be856aad5
parent 646 24067001082c
equal deleted inserted replaced
645:4d1aa030e746 647:c28be856aad5
   135 		test_val	('#profile :input:eq(4)[type=submit]', 'Save');
   135 		test_val	('#profile :input:eq(4)[type=submit]', 'Save');
   136 		test_comt_unlogged_footer ();
   136 		test_comt_unlogged_footer ();
   137 	});
   137 	});
   138 
   138 
   139 	suite ('edit password page conformity', function () {
   139 	suite ('edit password page conformity', function () {
   140 		test_page_loading	('/profile-pw/', 'Your profile [(]'+C.W.USER_ADMIN+'[)]\n - '+C['#id_workspace_name']);
   140 		test_page_loading ('/profile-pw/', 'Your profile [(]'+C.W.USER_ADMIN+'[)]\n - '+C['#id_workspace_name']);
   141 		test_comt_logged_header	(C.W.USER_ADMIN, C.NO_TAGLINE);
   141 		test_comt_logged_header	(C.W.USER_ADMIN, C.NO_TAGLINE);
   142 		test_count	('#content ul.sub_list:eq(0) a', 1);
   142 		test_count	('#content ul.sub_list:eq(0) a', 1);
   143 		test_text	('#content ul.sub_list:eq(0) a:eq(0)[href="/profile/"]', 'Profile');
   143 		test_text	('#content ul.sub_list:eq(0) a:eq(0)[href="/profile/"]', 'Profile');
   144 		test_count	('form#profile[action="."]:eq(0) :input', 4);
   144 		test_count	('form#profile[action="."]:eq(0) :input', 4);
   145 		test_field	('profile', 'id_old_password',	'password', 0, 'Old password', true);
   145 		test_field	('profile', 'id_old_password',	'password', 0, 'Old password', true);
   147 		test_field	('profile', 'id_new_password2',	'password', 2, 'New password confirmation', true);
   147 		test_field	('profile', 'id_new_password2',	'password', 2, 'New password confirmation', true);
   148 		test_val	('#profile :input:eq(3)[type=submit]', 'Save');
   148 		test_val	('#profile :input:eq(3)[type=submit]', 'Save');
   149 		test_comt_unlogged_footer ();
   149 		test_comt_unlogged_footer ();
   150 	});
   150 	});
   151 
   151 
   152 	suite ('people list page conformity', function () {
       
   153 		test_page_loading	('/user/', 'People\' list\n - '+C['#id_workspace_name']);
       
   154 		test_comt_logged_header	(C.W.USER_ADMIN);
       
   155 		test_comt_default_tabs	(test_comt.text_nb, test_comt.user_nb);
       
   156 		test_count	('#user ul.sub_list:eq(0) a', 2);
       
   157 		test_text	('#user ul.sub_list:eq(0) a:eq(0)[href="/user/add/"]', 'Add a new user');
       
   158 		test_text	('#user ul.sub_list:eq(0) a:eq(1)[href="/user/mass-add/"]', 'Add users in bulk');
       
   159 		test_text	('#filter_form a[href="?display=1"]', 'Display suspended users');
       
   160 		test_count	('form#filter_form[action="."] :input', 1);
       
   161 		test_text	('select#tag_selected option:eq(0)[selected][value="0"]', '- All -', C.HIDDEN);
       
   162 		test_text	('select#bulk_actions option:eq(0)[selected][value="-1"]', '- Bulk Actions -', C.HIDDEN);
       
   163 		test_text	('select#bulk_actions option:eq(1)[value="disable"]', 'Suspend access', C.HIDDEN);
       
   164 		test_text	('select#bulk_actions option:eq(2)[value="enable"]', 'Enable access', C.HIDDEN);
       
   165 		test_text	('select#bulk_actions option:eq(3)[value="role_1"]', 'Change role to Manager', C.HIDDEN);
       
   166 		test_text	('select#bulk_actions option:eq(4)[value="role_2"]', 'Change role to Editor', C.HIDDEN);
       
   167 		test_text	('select#bulk_actions option:eq(5)[value="role_3"]', 'Change role to Moderator', C.HIDDEN);
       
   168 		test_text	('select#bulk_actions option:eq(6)[value="role_4"]', 'Change role to Commentator', C.HIDDEN);
       
   169 		test_text	('select#bulk_actions option:eq(7)[value="role_5"]', 'Change role to Observer', C.HIDDEN);
       
   170 		test_val	('form#user_form input#apply[type=button][disabled]', 'Apply');
       
   171 		test_match  ('#paginator', /\s1-4 of 4\s/m);
       
   172 		test_count	('table.large_table:eq(1) th', 6);
       
   173 		test_val	('table.large_table:eq(1) th:eq(0) input#all_check[type="checkbox"]', 'on');
       
   174 		test_text	('table.large_table:eq(1) th:eq(1) a[href="?order=user__username"]', 'User');
       
   175 		test_text	('table.large_table:eq(1) th:eq(2) a[href="?order=user__email"]', 'Email');
       
   176 		test_text	('table.large_table:eq(1) th:eq(3) a[href="?order=-user__date_joined"]', 'Date joined');
       
   177 		test_text	('table.large_table:eq(1) th:eq(4) a[href="?order=role__name"]', 'Role');
       
   178 		test_text	('table.large_table:eq(1) th:eq(5)', 'Last week activity');
       
   179 		test_text	('table.large_table:eq(1) tr:last a[href="/user/-/edit/"]', 'Anonymous users');
       
   180 		test_text	('table.large_table:eq(1) a.main_object_title[href="/profile/"]', C.W.USER_ADMIN);
       
   181 		test_text	('table.large_table:eq(1) div.hidden-user-actions a[href="/profile/"]', 'Your profile');
       
   182 		test_val	('form#user_form input#save[type="submit"][disabled]', 'Save');
       
   183 		test_exist	('#user_form tr:eq(1) td:eq(4) select[disabled]');
       
   184 		test_count	('#user_form tr:eq(1) td:eq(4) select[disabled] option', 6);
       
   185 		test_text	('#user_form tr:eq(1) td:eq(4) select option:eq(0)[value=""][selected]', '---------', C.H);
       
   186 		test_text	('#user_form tr:eq(1) td:eq(4) select[disabled] option:eq(1)[value="1"]', 'Manager', C.H);
       
   187 		test_text	('#user_form tr:eq(1) td:eq(4) select[disabled] option:eq(2)[value="2"]', 'Editor', C.H);
       
   188 		test_text	('#user_form tr:eq(1) td:eq(4) select[disabled] option:eq(3)[value="3"]', 'Moderator', C.H);
       
   189 		test_text	('#user_form tr:eq(1) td:eq(4) select[disabled] option:eq(4)[value="4"]', 'Commentator', C.H);
       
   190 		test_text	('#user_form tr:eq(1) td:eq(4) select[disabled] option:eq(5)[value="5"]', 'Observer', C.H);
       
   191 		test_val	('#user_form tr:eq(2) td:eq(4) select', '5'); // this is a bug should be 4
       
   192 		test_val	('#user_form tr:eq(3) td:eq(4) select', '5'); // this is a bug should be 2
       
   193 		test_val	('#user_form tr:eq(4) td:eq(4) select', '5');
       
   194 		test_exist	('#user_form tr:eq(6) td:eq(4) select');
       
   195 		test_count	('#user_form tr:eq(6) td:eq(4) select option', 3);
       
   196 		test_text	('#user_form tr:eq(6) td:eq(4) select option:eq(0)[value=""][selected]', '---------', C.H);
       
   197 		test_text	('#user_form tr:eq(6) td:eq(4) select option:eq(1)[value="4"]', 'Commentator', C.H);
       
   198 		test_text	('#user_form tr:eq(6) td:eq(4) select option:eq(2)[value="5"]', 'Observer', C.H);
       
   199 		test_exist	('#user_form tr:eq(1) td:eq(0) input[type=checkbox][disabled]');
       
   200 		test_text	('#user_form div.hidden-user-actions:eq(1) a:eq(0)[href^="/user/"][href$="/edit/"]', 'Edit');
       
   201 		test_text	('#user_form div.hidden-user-actions:eq(1) a:eq(1)[href^="/use"][href$="ontact/"]', 'Contact');
       
   202 		test_text	('#user_form div.hidden-user-actions:eq(1) a:eq(2)[id^="user-suspend-"]', 'Suspend access');
       
   203 		test_text	('#user_form div.hidden-user-actions:eq(1) a:eq(3)[id^="user-resen"]', '(Re-)send invitation');
       
   204 		test_comt_unlogged_footer ();
       
   205 	});
       
   206 
       
   207 	suite ('check user number', function () {
       
   208 		test_page_loading	('/user/?display=1', 'People\' list\n - '+C['#id_workspace_name']);
       
   209 		test_count	('#user_form :input', 6 + (test_comt.user_nb % 10) * 2);
       
   210 		test_match	('#paginator', new RegExp ('\\s\\d+-\\d+ of '+test_comt.user_nb+'\\s','m'));
       
   211 	});
       
   212 
       
   213 	suite ('Reset fixture user roles', function () {
       
   214 		test        ('set user-com Commentator', dsl(function () {
       
   215 			input ('#user_form tr:eq(2) td:eq(4) select').option ('4');
       
   216 			input ('#user_form tr:eq(3) td:eq(4) select').option ('2');
       
   217 			input ('#user_form tr:eq(4) td:eq(4) select').option ('5');
       
   218 			input ('#save').prop ('disabled', false);
       
   219 		}));
       
   220 		test_click	('#save', C.WAIT_PAGE_LOAD);
       
   221 		test_page_loading ('/user/', 'People\' list\n - '+C['#id_workspace_name']);
       
   222 		test_val	('#user_form tr:eq(2) td:eq(4) select option:selected', '4');
       
   223 		test_val	('#user_form tr:eq(3) td:eq(4) select option:selected', '2');
       
   224 		test_val	('#user_form tr:eq(4) td:eq(4) select option:selected', '5');
       
   225 
       
   226 
       
   227 		// TOTEST roles of users
       
   228 		// TOTEST : filter by tag -> commentator user should be tagged commentator (to change in fixture)
       
   229 		// TOTEST : pagination
       
   230 		// TOTEST : Bulk Actions -> Apply does enable
       
   231 		// TOTEST display suspended users
       
   232 	});
       
   233 
   152 
   234 	suite ('add a user page conformity', function () {
   153 	suite ('add a user page conformity', function () {
   235 		test_page_loading	('/user/add/', 'Add a new user\n - '+C['#id_workspace_name']);
   154 		test_page_loading	('/user/add/', 'Add a new user\n - '+C['#id_workspace_name']);
   236 		test_comt_logged_header	(C.W.USER_ADMIN);
   155 		test_comt_logged_header	(C.W.USER_ADMIN);
   237 		test_comt_default_tabs	(test_comt.text_nb, test_comt.user_nb);
   156 		test_comt_default_tabs	(test_comt.text_nb, test_comt.user_nb);
   280 		test_text	('select#id_role option:eq(3)[value="3"]', 'Moderator', C.HIDDEN);
   199 		test_text	('select#id_role option:eq(3)[value="3"]', 'Moderator', C.HIDDEN);
   281 		test_text	('select#id_role option:eq(4)[value="4"]', 'Commentator', C.HIDDEN);
   200 		test_text	('select#id_role option:eq(4)[value="4"]', 'Commentator', C.HIDDEN);
   282 		test_text	('select#id_role option:eq(5)[value="5"]', 'Observer', C.HIDDEN);
   201 		test_text	('select#id_role option:eq(5)[value="5"]', 'Observer', C.HIDDEN);
   283 		test_val	('#user :input:eq(4)[type=submit]', 'Add users');
   202 		test_val	('#user :input:eq(4)[type=submit]', 'Add users');
   284 		test_val	('#user :input:eq(5)#cancel_button[type=button]', 'Cancel');
   203 		test_val	('#user :input:eq(5)#cancel_button[type=button]', 'Cancel');
   285 		// X TOTEST add users (pending) -> can't be deleted
       
   286 		test_comt_unlogged_footer ();
   204 		test_comt_unlogged_footer ();
   287 		test_click	('#user input[type="submit"]', C.WAIT_PAGE_LOAD);
   205 		test_click	('#user input[type="submit"]', C.WAIT_PAGE_LOAD);
   288 		test_count	('div.help_text span.error-text', 1);
   206 		test_count	('div.help_text span.error-text', 1);
   289 		test_field	('user div.error', 'id_email', 'textarea', 0, 'Emails', true);
   207 		test_field	('user div.error', 'id_email', 'textarea', 0, 'Emails', true);
       
   208 		test_match	('#user div.help_text:eq(0) span.error-text:eq(0)', /This field is required/m);
       
   209 	});
       
   210 
       
   211 	suite ('edit anonymous user page conformity', function () {
       
   212 		test_page_loading	('/user/-/edit/', 'Edit anonymous users\n - '+C['#id_workspace_name']);
       
   213 		test_comt_logged_header	(C.W.USER_ADMIN);
       
   214 		test_comt_default_tabs	(test_comt.text_nb, test_comt.user_nb);
       
   215 		test_count	('#user ul.sub_list:eq(0) a', 2);
       
   216 		test_text	('#user ul.sub_list:eq(0) a:eq(0)[href="/user/"]', 'Users\' list');
       
   217 		test_text	('#user ul.sub_list:eq(0) a:eq(1)[href="/user/add/"]', 'Add a new user');
       
   218 		test_count	('#user form[action="."] :input', 3);
       
   219 		test_field	('user', 'id_role', 'select', 0, 'Role');
       
   220 		test_count	('#user form[action="."] select option', 3);
       
   221 		test_text	('#user form[action="."] select option:eq(0)[value=""][selected]', '---------', C.H);
       
   222 		test_text	('#user form[action="."] select option:eq(1)[value="4"]', 'Commentator', C.H);
       
   223 		test_text	('#user form[action="."] select option:eq(2)[value="5"]', 'Observer', C.H);
       
   224 		test_val	('#user :input:eq(1)[type=submit]', 'Save');
       
   225 		test_val	('#user :input:eq(2)#cancel_button[type=button]', 'Cancel');
       
   226 		test_comt_unlogged_footer ();
       
   227 	});
       
   228 
       
   229 	suite ('edit user-com page conformity', function () {
       
   230 		test_page_loading	('/user/3sh3WZqNzXs/edit/', 'Edit user user-com\n - '+C['#id_workspace_name']);
       
   231 		test_comt_logged_header (C.W.USER_ADMIN);
       
   232 		test_comt_default_tabs	(test_comt.text_nb, test_comt.user_nb);
       
   233 		test_count	('#user ul.sub_list:eq(0) a', 2);
       
   234 		test_text	('#user ul.sub_list:eq(0) a:eq(0)[href="/user/"]', 'Users\' list');
       
   235 		test_text	('#user ul.sub_list:eq(0) a:eq(1)[href="/user/add/"]', 'Add a new user');
       
   236 		test_count	('#user form[action="."] :input', 8);
       
   237 		test_field	('user', 'id_email',		'text',		0, 'E-mail address', true);
       
   238 		test_field	('user', 'id_first_name',	'text',		1, 'First name');
       
   239 		test_field	('user', 'id_last_name', 	'text',		2, 'Last name');
       
   240 		test_field	('user', 'id_is_suspended',	'checkbox',	3, 'Suspended access');
       
   241 		test_field	('user', 'id_tags',			'text',		4, 'Tags');
       
   242 		test_field	('user', 'id_role',			'select',	5, 'Workspace level role');
       
   243 		test_count	('select#id_role option', 6);
       
   244 		test_text	('select#id_role option:eq(0)[value]', '---------', C.HIDDEN);
       
   245 		test_text	('select#id_role option:eq(1)[value="1"]', 'Manager', C.HIDDEN);
       
   246 		test_text	('select#id_role option:eq(2)[value="2"]', 'Editor', C.HIDDEN);
       
   247 		test_text	('select#id_role option:eq(3)[value="3"]', 'Moderator', C.HIDDEN);
       
   248 		test_text	('select#id_role option:eq(4)[value="4"]', 'Commentator', C.HIDDEN);
       
   249 		test_text	('select#id_role option:eq(5)[value="5"][selected]', 'Observer', C.HIDDEN);
       
   250 		test_val	('#user :input:eq(6)[type=submit]', 'Save');
       
   251 		test_val	('#user :input:eq(7)#cancel_button[type=button]', 'Cancel');
       
   252 		test_comt_unlogged_footer ();
       
   253 		test_fill_field	('#id_email', {'#id_email': ''});
       
   254 		test_click	('#user input[type="submit"]', C.WAIT_PAGE_LOAD);
       
   255 		test_count	('div.help_text span.error-text', 1);
       
   256 		test_field	('user div.error', 'id_email', 'text', 0, 'E-mail address', true);
   290 		test_match	('#user div.help_text:eq(0) span.error-text:eq(0)', /This field is required/m);
   257 		test_match	('#user div.help_text:eq(0) span.error-text:eq(0)', /This field is required/m);
   291 	});
   258 	});
   292 
   259 
   293 	suite ('settings page conformity', function () {
   260 	suite ('settings page conformity', function () {
   294 		test_page_loading	('/settings/', 'Settings - '+C['#id_workspace_name']);
   261 		test_page_loading	('/settings/', 'Settings - '+C['#id_workspace_name']);
   300 		test_field	('settings', 'id_workspace_name', 'text', 0, 'Workspace name');
   267 		test_field	('settings', 'id_workspace_name', 'text', 0, 'Workspace name');
   301 		test_field	('settings', 'id_workspace_tagline', 'text', 1, 'Workspace tagline');
   268 		test_field	('settings', 'id_workspace_tagline', 'text', 1, 'Workspace tagline');
   302 		test_field	('settings', 'id_workspace_registration', 'checkbox', 2, 'Workspace registration');
   269 		test_field	('settings', 'id_workspace_registration', 'checkbox', 2, 'Workspace registration');
   303 		test_field	('settings', 'id_workspace_registration_moderation', 'checkbox', 3, 'Workspace registration moderation');
   270 		test_field	('settings', 'id_workspace_registration_moderation', 'checkbox', 3, 'Workspace registration moderation');
   304 		test_field	('settings', 'id_workspace_role_model', 'select', 4, 'Role model');
   271 		test_field	('settings', 'id_workspace_role_model', 'select', 4, 'Role model');
   305 		test_text	('select#id_workspace_role_model option:eq(0)[selected][value="generic"]', 'Generic', C.HIDDEN);
   272 		test_text	('select#id_workspace_role_model option:eq(0)[selected][value="generic"]', 'Generic', C.H);
   306 		test_text	('select#id_workspace_role_model option:eq(1)[value="teacher"]', 'Class (education)', C.HIDDEN);
   273 		test_text	('select#id_workspace_role_model option:eq(1)[value="teacher"]', 'Class (education)', C.H);
   307 		test_field	('settings', 'id_workspace_category_1', 'text', 5, 'Label for the first category of comments');
   274 		test_field	('settings', 'id_workspace_category_1','text',5,'Label for the first category of comments');
   308 		test_field	('settings', 'id_workspace_category_2', 'text', 6, 'Label for the second category of comments');
   275 		test_field	('settings', 'id_workspace_category_2','text',6,'Label for the second category of comments');
   309 		test_field	('settings', 'id_workspace_category_3', 'text', 7, 'Label for the third category of comments');
   276 		test_field	('settings', 'id_workspace_category_3','text',7,'Label for the third category of comments');
   310 		test_field	('settings', 'id_workspace_category_4', 'text', 8, 'Label for the fourth category of comments');
   277 		test_field	('settings', 'id_workspace_category_4','text',8,'Label for the fourth category of comments');
   311 		test_field	('settings', 'id_workspace_category_5', 'text', 9, 'Label for the fifth category of comments');
   278 		test_field	('settings', 'id_workspace_category_5','text',9,'Label for the fifth category of comments');
   312 		test_val	('#settings :input:eq(10)[type=submit]', 'Save');
   279 		test_val	('#settings :input:eq(10)[type=submit]', 'Save');
   313 		test_val	('#settings :input:eq(11)#cancel_button[type=button]', 'Cancel');
   280 		test_val	('#settings :input:eq(11)#cancel_button[type=button]', 'Cancel');
   314 		// TOTEST Workspace registration feature (with newly accessible page)
       
   315 		test_comt_unlogged_footer ();
   281 		test_comt_unlogged_footer ();
   316 	});
   282 	});
   317 
   283 
   318 	suite ('settings design page conformity', function () {
   284 	suite ('settings design page conformity', function () {
   319 		test_page_loading	('/settings/design/', 'Settings - '+C['#id_workspace_name']);
   285 		test_page_loading	('/settings/design/', 'Settings - '+C['#id_workspace_name']);
   338 		test_comt_default_tabs	(test_comt.text_nb, test_comt.user_nb);
   304 		test_comt_default_tabs	(test_comt.text_nb, test_comt.user_nb);
   339 		test_text	('#followup a:eq(0)[href="/help/#public_private_feed"]', '?');
   305 		test_text	('#followup a:eq(0)[href="/help/#public_private_feed"]', '?');
   340 		test_match	('#followup a:eq(1)[href$="/feed/"]', new RegExp (C.W.WORKSPACE_URL+'feed/', 'm'));
   306 		test_match	('#followup a:eq(1)[href$="/feed/"]', new RegExp (C.W.WORKSPACE_URL+'feed/', 'm'));
   341 		test_text	('#followup a:eq(2)[href="/help/#public_private_feed"]', '?');
   307 		test_text	('#followup a:eq(2)[href="/help/#public_private_feed"]', '?');
   342 		test_count	('form#followup_form[action="."] :input', 3);
   308 		test_count	('form#followup_form[action="."] :input', 3);
   343 		test_val	('form#followup_form input[type=submit]', '(Activate private feed|Reset private feed url)');
   309 		test_val	('form#followup_form input#activate[type=submit]', 'Activate private feed');
   344 		test_val	('form#followup_form input#workspace_notify_check[type=checkbox]', 'on');
   310 		test_click	('#activate', C.WAIT_PAGE_LOAD);
   345 		test_val	('form#followup_form input#own_notify_check[type=checkbox]', 'on');
   311 		test_match	('#followup a:eq(3)[href^="/feed/"]', new RegExp (C.W.WORKSPACE_URL+'feed/(\\d|\\w)+/', 'm'));
   346 	
   312 		test_val	('form#followup_form input#reset[type=submit]', 'Reset private feed url');
   347 		// X TOTEST qu'une fois cliqué, le bouton a le nvo label, et qu'une adresse est disponible
   313 		test_exist	('form#followup_form input#workspace_notify_check[type=checkbox]:not(:checked)');
   348 		// X TOTEST que si on reclique l'adresse est changée
   314 		test_exist	('form#followup_form input#own_notify_check:not(:checked)');
   349 
   315 		test_click	('#workspace_notify_check');
       
   316 		test_exist	('form#followup_form input#workspace_notify_check[type=checkbox]:checked');
       
   317 		test_exist	('form#followup_form input#own_notify_check:not(:visible)');
       
   318 		test_click	('#workspace_notify_check');
   350 		test_comt_unlogged_footer ();
   319 		test_comt_unlogged_footer ();
   351 	});
   320 	});
   352 
   321 
   353 });
   322 });
   354 
   323