test-suite/tests/013_comt-admin-user-list.js
changeset 646 24067001082c
child 649 fcf5309284df
equal deleted inserted replaced
641:8f7dafe42d15 646:24067001082c
       
     1 
       
     2 suite ('comt logged admin user list', function () {
       
     3 
       
     4 	this.timeout(20000);
       
     5 
       
     6 	suite ('people list page conformity', function () {
       
     7 		test_page_loading	('/user/', 'People\' list\n - '+C['#id_workspace_name']);
       
     8 		test_comt_logged_header (C.W.USER_ADMIN);
       
     9 		test_comt_default_tabs	(test_comt.text_nb, test_comt.user_nb);
       
    10 		test_count	('#user ul.sub_list:eq(0) a', 2);
       
    11 		test_text	('#user ul.sub_list:eq(0) a:eq(0)[href="/user/add/"]', 'Add a new user');
       
    12 		test_text	('#user ul.sub_list:eq(0) a:eq(1)[href="/user/mass-add/"]', 'Add users in bulk');
       
    13 		test_text	('#filter_form a[href="?display=1"]', 'Display suspended users');
       
    14 		test_count	('form#filter_form[action="."] :input', 1);
       
    15 		test_text	('select#tag_selected option:eq(0)[selected][value="0"]', '- All -', C.HIDDEN);
       
    16 		test_text	('select#bulk_actions option:eq(0)[selected][value="-1"]', '- Bulk Actions -', C.HIDDEN);
       
    17 		test_text	('select#bulk_actions option:eq(1)[value="disable"]', 'Suspend access', C.HIDDEN);
       
    18 		test_text	('select#bulk_actions option:eq(2)[value="enable"]', 'Enable access', C.HIDDEN);
       
    19 		test_text	('select#bulk_actions option:eq(3)[value="role_1"]', 'Change role to Manager', C.HIDDEN);
       
    20 		test_text	('select#bulk_actions option:eq(4)[value="role_2"]', 'Change role to Editor', C.HIDDEN);
       
    21 		test_text	('select#bulk_actions option:eq(5)[value="role_3"]', 'Change role to Moderator', C.HIDDEN);
       
    22 		test_text	('select#bulk_actions option:eq(6)[value="role_4"]', 'Change role to Commentator', C.HIDDEN);
       
    23 		test_text	('select#bulk_actions option:eq(7)[value="role_5"]', 'Change role to Observer', C.HIDDEN);
       
    24 		test_val	('form#user_form input#apply[type=button][disabled]', 'Apply');
       
    25 		test_match	('#paginator', /\s1-4 of 4\s/m);
       
    26 		test_count	('table.large_table:eq(1) th', 6);
       
    27 		test_val	('table.large_table:eq(1) th:eq(0) input#all_check[type="checkbox"]', 'on');
       
    28 		test_text	('table.large_table:eq(1) th:eq(1) a[href="?order=user__username"]', 'User');
       
    29 		test_text	('table.large_table:eq(1) th:eq(2) a[href="?order=user__email"]', 'Email');
       
    30 		test_text	('table.large_table:eq(1) th:eq(3) a[href="?order=-user__date_joined"]', 'Date joined');
       
    31 		test_text	('table.large_table:eq(1) th:eq(4) a[href="?order=role__name"]', 'Role');
       
    32 		test_text	('table.large_table:eq(1) th:eq(5)', 'Last week activity');
       
    33 		test_text	('table.large_table:eq(1) tr:last a[href="/user/-/edit/"]', 'Anonymous users');
       
    34 		test_text	('table.large_table:eq(1) a.main_object_title[href="/profile/"]', C.W.USER_ADMIN);
       
    35 		test_text	('table.large_table:eq(1) div.hidden-user-actions a[href="/profile/"]', 'Your profile');
       
    36 		test_val	('form#user_form input#save[type="submit"][disabled]', 'Save');
       
    37 		test_exist	('#user_form tr:eq(1) td:eq(4) select[disabled]');
       
    38 		test_exist	('#user_form tr:eq(1) td:eq(0) input[type=checkbox][disabled]');
       
    39 
       
    40 		for (var i=1; i < 5; i++) {
       
    41 			test_text	('#user_form tr:eq('+i+') td:eq(1) a.main_object_title', C.USERS[i].name);
       
    42 			test_text	('#user_form tr:eq('+i+') td:eq(2) a[href="mailto:'+C.USERS[i].email+'"]', C.USERS[i].email);
       
    43 			test_text	('#user_form tr:eq('+i+') td:eq(3)', C.USERS[i].date);
       
    44 			test_count	('#user_form tr:eq('+i+') td:eq(4) select option', 6);
       
    45 			test_text	('#user_form tr:eq('+i+') td:eq(4) select option:eq(0)[value=""]', '---------', C.H);
       
    46 			test_text	('#user_form tr:eq('+i+') td:eq(4) select option:eq(1)[value="1"]', 'Manager', C.H);
       
    47 			test_text	('#user_form tr:eq('+i+') td:eq(4) select option:eq(2)[value="2"]', 'Editor', C.H);
       
    48 			test_text	('#user_form tr:eq('+i+') td:eq(4) select option:eq(3)[value="3"]', 'Moderator', C.H);
       
    49 			test_text	('#user_form tr:eq('+i+') td:eq(4) select option:eq(4)[value="4"]', 'Commentator', C.H);
       
    50 			test_text	('#user_form tr:eq('+i+') td:eq(4) select option:eq(5)[value="5"]', 'Observer', C.H);
       
    51 			test_val	('#user_form tr:eq('+i+') td:eq(4) select', C.USERS[i].role);
       
    52 		}
       
    53 
       
    54 		test_text	('#user_form tr:eq(6) td:eq(1) a.main_object_title[href="/user/-/edit/"]', 'Anonymous users');
       
    55 		test_text	('#user_form tr:eq(6) td:eq(2)', '-');
       
    56 		test_text	('#user_form tr:eq(6) td:eq(3)', '-');
       
    57 		test_exist	('#user_form tr:eq(6) td:eq(4) select');
       
    58 		test_count	('#user_form tr:eq(6) td:eq(4) select option', 3);
       
    59 		test_text	('#user_form tr:eq(6) td:eq(4) select option:eq(0)[value=""][selected]', '---------', C.H);
       
    60 		test_text	('#user_form tr:eq(6) td:eq(4) select option:eq(1)[value="4"]', 'Commentator', C.H);
       
    61 		test_text	('#user_form tr:eq(6) td:eq(4) select option:eq(2)[value="5"]', 'Observer', C.H);
       
    62 		test_text	('#user_form div.hidden-user-actions:eq(1) a:eq(0)[href^="/user/"][href$="/edit/"]', 'Edit');
       
    63 		test_text	('#user_form div.hidden-user-actions:eq(1) a:eq(1)[href^="/use"][href$="ontact/"]','Contact');
       
    64 		test_text	('#user_form div.hidden-user-actions:eq(1) a:eq(2)[id^="user-suspend-"]', 'Suspend access');
       
    65 		test_text	('#user_form div.hidden-user-actions:eq(1) a:eq(3)[id^="user-resen"]','(Re-)send invitation');
       
    66 		test_comt_unlogged_footer ();
       
    67 	});
       
    68 
       
    69 	suite_check_user_nb (1);
       
    70 
       
    71 	suite ('Reset fixture user roles', function () {
       
    72 		test		('set user-com Commentator', dsl(function () {
       
    73 			input ('#user_form tr:eq(2) td:eq(4) select').option ('4');
       
    74 			input ('#user_form tr:eq(3) td:eq(4) select').option ('2');
       
    75 			input ('#user_form tr:eq(4) td:eq(4) select').option ('5');
       
    76 			input ('#save').prop ('disabled', false);
       
    77 		}));
       
    78 		test_click	('#save', C.WAIT_PAGE_LOAD);
       
    79 		test_page_loading ('/user/', 'People\' list\n - '+C['#id_workspace_name']);
       
    80 		test_val	('#user_form tr:eq(2) td:eq(4) select option:selected', '4');
       
    81 		test_val	('#user_form tr:eq(3) td:eq(4) select option:selected', '2');
       
    82 		test_val	('#user_form tr:eq(4) td:eq(4) select option:selected', '5');
       
    83 	});
       
    84 
       
    85 	suite ('Add a single user', function () {
       
    86 		test_comt_create_user (C.USERS[5]);
       
    87 	});
       
    88 
       
    89 	suite_check_user_nb (2);
       
    90 
       
    91 	suite ('Add users in bulk', function () {
       
    92 		test_page_loading ('/user/mass-add/', 'Add users in bulk\n - '+C['#id_workspace_name']);
       
    93 	    test ('fill emails', dsl(function (){
       
    94 	        elt ('#id_email').val ('uc2@t.co,uc3@t.co,uc4@t.co,uc5@t.co,uc6@t.co,uc7@t.co');
       
    95 	    }));
       
    96 		test_fill_field	('#id_tags', {'#id_tags': 'tag_ucs, other_tag' });
       
    97 		// TOTEST fill note field
       
    98 		test_click  ('#user input[type="submit"]', C.WAIT_PAGE_LOAD);
       
    99 		test_comt.user_nb += 6;
       
   100 	});
       
   101 
       
   102 	suite_check_user_nb (3);
       
   103 
       
   104     suite ('users list pagination conformity', function () {
       
   105 		test_page_loading	('/user/', 'People\' list\n - '+C['#id_workspace_name']);
       
   106         test_count  ('#user_form :input', 6 + (test_comt.user_nb < 10 ? test_comt.user_nb : 10) * 2);
       
   107         test_match  ('#paginator', new RegExp ('\\s1-10 of '+test_comt.user_nb+'\\s','m'));
       
   108         test_text   ('#paginator a:eq(0)[href="?page=2"]', '»');
       
   109         test_text   ('#paginator a:eq(1)[href="?paginate=0"]', 'all');
       
   110         test_click  ('#paginator a:eq(0)[href="?page=2"]');
       
   111         test_match  ('#paginator', new RegExp ('\\s11-11 of '+test_comt.user_nb+'\\s','m'));
       
   112         test_count  ('#user_form :input', test_comt.user_nb % 10 * 2 + 6);
       
   113         test_click  ('#paginator a:eq(0)[href="?page=1"]');
       
   114         test_match  ('#paginator', new RegExp ('\\s1-10 of '+test_comt.user_nb+'\\s','m'));
       
   115         test_count  ('#user_form :input', (test_comt.user_nb < 10 ? test_comt.user_nb : 10) * 2 + 6);
       
   116         test_click  ('#paginator a:eq(1)[href="?paginate=0&page=1"]');
       
   117         test_match  ('#paginator', /\s\(paginate\)\s/m);
       
   118         test_count  ('#user_form :input', test_comt.user_nb * 2 + 6);
       
   119         test_click  ('#paginator a:eq(0)[href="?paginate=&page=1"]');
       
   120         test_count  ('#user_form :input', (test_comt.user_nb < 10 ? test_comt.user_nb : 10) * 2 + 6);
       
   121         test_match  ('#paginator', new RegExp ('\\s1-10 of '+test_comt.user_nb+'\\s','m'));
       
   122     });
       
   123 
       
   124     suite ('users list filter by tag conformity', function () {
       
   125 		test_page_loading ('/user/?tag_selected=tag_ucs', 'People\' list\n - '+C['#id_workspace_name']);
       
   126 		test_count	('#user_form :input', 6 + 6 * 2);
       
   127 		test_match	('#paginator', new RegExp ('\\s1-6 of 6\\s','m'));
       
   128 		
       
   129     });
       
   130 
       
   131 	// TOTEST : filter by tag -> commentator user should be tagged commentator (to change in fixture)
       
   132 	// TOTEST : Bulk Actions -> Apply does enable
       
   133 	// suspend users
       
   134 	// TOTEST display suspended users
       
   135 	// TOTEST user édition
       
   136 
       
   137 	// TOTEST suspended user can't login anymore
       
   138 	// TOTEST roles of users
       
   139 	// TOTEST si les users anonymes ont droits, ils ont droits…
       
   140 });
       
   141 
       
   142 function suite_check_user_nb (n) {
       
   143 	suite ('check user number #'+n, function () {
       
   144 		test_page_loading	('/user/?display=1', 'People\' list\n - '+C['#id_workspace_name']);
       
   145 		test_count	('#user_form :input', 6 + (test_comt.user_nb < 10 ? test_comt.user_nb : 10) * 2);
       
   146 		test_match	('#paginator', new RegExp ('\\s\\d+-\\d+ of '+test_comt.user_nb+'\\s','m'));
       
   147 	});
       
   148 }