test-suite/tests/tests.js
changeset 623 09640f41fed1
parent 622 c35e69910785
equal deleted inserted replaced
622:c35e69910785 623:09640f41fed1
     1 
     1 
     2 // " Vim settings
     2 // " Vim settings
     3 // set tabstop=4          " number of spaces in a tab
     3 // set tabstop=4		  " number of spaces in a tab
     4 // set softtabstop=4      " as above
     4 // set softtabstop=4	  " as above
     5 // set shiftwidth=4       " as above
     5 // set shiftwidth=4		  " as above
     6 
     6 
     7 
     7 
     8 // check that public texts still work while unlogged
     8 // check that public texts still work while unlogged
     9 // check that non public texts are unavailable
     9 // check that non public texts are unavailable
    10 // Are the public texts displayed in the login page ?
    10 // Are the public texts displayed in the login page ?
    11 
    11 
    12 var w = __karma__.config.w,
    12 var w = __karma__.config.w;
    13 	z = {};
       
    14 const non_visible = false, no_tagline = false;
    13 const non_visible = false, no_tagline = false;
    15 const t = {
    14 const t = {
    16 	'#id_workspace_name':	'Test workspace name',
    15 	'#id_workspace_name':	'Test workspace name',
    17 	'#id_workspace_tagline':	'Test workspace tagline',
    16 	'#id_workspace_tagline':	'Test workspace tagline',
    18 	'#id_workspace_registration':		'on',		// registration
    17 	'#id_workspace_registration':		'on',		// registration
    24 	'#id_workspace_category_4':	'ws_cat_4',
    23 	'#id_workspace_category_4':	'ws_cat_4',
    25 	'#id_workspace_category_5':	'ws_cat_5',
    24 	'#id_workspace_category_5':	'ws_cat_5',
    26 	'#id_custom_css': "h2 {  font-family: Test_Sopinspace !important; }",
    25 	'#id_custom_css': "h2 {  font-family: Test_Sopinspace !important; }",
    27 	'#id_custom_font': 'Test_Sopinspace_custom_font',
    26 	'#id_custom_font': 'Test_Sopinspace_custom_font',
    28 	'#id_custom_titles_font': 'Test_Sopinspace_custom_titles_font',
    27 	'#id_custom_titles_font': 'Test_Sopinspace_custom_titles_font',
       
    28 	'text_nb': 0,
       
    29 	'user_nb': 4
    29 };
    30 };
    30 
    31 
    31 
    32 
    32 suite ('comt', function () {
    33 suite ('comt', function () {
    33 
    34 
   124 			browser.navigateTo ('/');
   125 			browser.navigateTo ('/');
   125 			expect (element ('title').text ()).toMatch (/Dashboard/m);
   126 			expect (element ('title').text ()).toMatch (/Dashboard/m);
   126 		}));
   127 		}));
   127 	});
   128 	});
   128 
   129 
   129 	suite ('reading settings', function () {
       
   130         test_page_loading	('/settings/', 'Settings');
       
   131 		test_readz_field	('#id_workspace_name');
       
   132 		test_readz_field	('#id_workspace_tagline');
       
   133 		test_readz_field	('#id_workspace_registration');
       
   134 		test_readz_field	('#id_workspace_registration_moderation');
       
   135 		test_readz_field	('#id_workspace_role_model');
       
   136 		test_readz_field	('#id_workspace_category_1');
       
   137 		test_readz_field	('#id_workspace_category_2');
       
   138 		test_readz_field	('#id_workspace_category_3');
       
   139 		test_readz_field	('#id_workspace_category_4');
       
   140 		test_readz_field	('#id_workspace_category_5');
       
   141 		test_page_loading	('/settings/design/', 'Settings');
       
   142 		test_readz_field	('#id_custom_css');
       
   143 		test_readz_field	('#id_custom_font');
       
   144 		test_readz_field	('#id_custom_titles_font');
       
   145 		/*test ('display z', dsl(function () {
       
   146 			elt ('#main-tabs').text (function (t) {
       
   147 				console.log ('z '+JSON.stringify(z));
       
   148 			});
       
   149 		}));*/
       
   150     });
       
   151 
       
   152 	suite ('setting settings to test-values', function () {
   130 	suite ('setting settings to test-values', function () {
   153 		test_page_loading ('/settings/', 'Settings');
   131 		test_page_loading ('/settings/', 'Settings');
   154 		test_fill_settings (t);
   132 		test_fill_settings (t);
   155 		test_val ('#id_workspace_name', t['#id_workspace_name']);
   133 		test_val ('#id_workspace_name', t['#id_workspace_name']);
   156 		test ('Save test settings ', dsl (function () {
   134 		test ('Save test settings ', dsl (function () {
   157 			elt ('#settings input[type="submit"]').click ();
   135 			elt ('#settings input[type="submit"]').click ();
   158 			browser.waitForPageLoad ();
   136 			browser.waitForPageLoad ();
   159 		}));
   137 		}));
   160         test_page_loading	('/settings/', 'Settings');
   138 		test_page_loading	('/settings/', 'Settings');
   161 		test_text ('#content h1.main_title a[href="/"]', t['#id_workspace_name']);
   139 		test_text ('#content h1.main_title a[href="/"]', t['#id_workspace_name']);
   162 		test_page_loading	('/settings/design/', 'Settings');
   140 		test_page_loading	('/settings/design/', 'Settings');
   163 		test_fill_design (t);
   141 		test_fill_design (t);
   164 		test ('Save test design settings ', dsl (function () {
   142 		test ('Save test design settings ', dsl (function () {
   165 			elt ('#settings input[type="submit"]').click ();
   143 			elt ('#settings input[type="submit"]').click ();
   166 			browser.waitForPageLoad ();
   144 			browser.waitForPageLoad ();
   167 		}));
   145 		}));
   168     });
   146 	});
   169 
   147 
   170 	suite ('admin dashboard page conformity', function () {
   148 	suite ('admin dashboard page conformity', function () {
   171 		test_page_loading ('/', 'Dashboard\n - '+t['#id_workspace_name']);
   149 		test_page_loading ('/', 'Dashboard\n - '+t['#id_workspace_name']);
   172 		test_logged_header (w.USER_ADMIN);
   150 		test_logged_header (w.USER_ADMIN);
   173 		test ('get text and user nb', dsl(function () {
   151 		test_default_tabs (t.text_nb, t.user_nb);
   174 			element ('span.metadata:eq(0)').text (function (metadata) {
       
   175 				var r = metadata.match (/(\d+) texts, (\d+) users/);
       
   176 				if (r.length != 3) throw 'expected 3 matches got '+r.length;
       
   177 				z.text_nb = r[1];
       
   178 				z.user_nb = r[2];
       
   179 			});
       
   180 		}));
       
   181 		test_default_tabs ();
       
   182 		test_count	('table.dash_table', 5);
   152 		test_count	('table.dash_table', 5);
   183 		test_text	('table.dash_table th:eq(0)', 'Actions');
   153 		test_text	('table.dash_table th:eq(0)', 'Actions');
   184 		test_match	('table.dash_table:eq(0) a:eq(0)[href="/create/content/"]', /\sCreate a text/);
   154 		test_match	('table.dash_table:eq(0) a:eq(0)[href="/create/content/"]', /\sCreate a text/);
   185 		test_text	('table.dash_table:eq(0) a:eq(1).tip[href="#"]', '\xa0');
   155 		test_text	('table.dash_table:eq(0) a:eq(1).tip[href="#"]', '\xa0');
   186 		test_match	('table.dash_table:eq(0) a:eq(2)[href="/create/upload/"]', /\sUpload a text/);
   156 		test_match	('table.dash_table:eq(0) a:eq(2)[href="/create/upload/"]', /\sUpload a text/);
   199 		test_text	('table.dash_table:eq(3) a:eq(1)[href="?span=day"]', '24 hours');
   169 		test_text	('table.dash_table:eq(3) a:eq(1)[href="?span=day"]', '24 hours');
   200 		test_text	('table.dash_table th:eq(4) span.em', 'Activities');
   170 		test_text	('table.dash_table th:eq(4) span.em', 'Activities');
   201 		test_unlogged_footer ();
   171 		test_unlogged_footer ();
   202 	});
   172 	});
   203 
   173 
   204 	suite ('texts list page conformity', function () {
   174 	suite ('empty texts list page conformity', function () {
   205 		test_page_loading	('/text/', 'Texts\n - '+t['#id_workspace_name']);
   175 		test_page_loading	('/text/', 'Texts\n - '+t['#id_workspace_name']);
   206 		test_logged_header	(w.USER_ADMIN);
   176 		test_logged_header	(w.USER_ADMIN);
   207 		test_default_tabs	();
   177 		test_default_tabs	(t.text_nb, t.user_nb);
       
   178 		test_count	('#text ul.sub_list:eq(0) a', 3);
       
   179 		test_text	('#text ul.sub_list:eq(0) a:eq(0)[href="/create/content/"]', 'Create a text');
       
   180 		test_text	('#text ul.sub_list:eq(0) a:eq(1)[href="/create/upload/"]', 'Upload a text');
       
   181 		test_text	('#text ul.sub_list:eq(0) a:eq(2)[href="/create/import/"]', 'Import a co-mented text');
       
   182 		test_match	('#text', /No texts yet/m);
       
   183 		test_count	('#texts_form :input', 0);
       
   184 	});
       
   185 
       
   186 	suite ('create a text page conformity', function () {
       
   187 		test_page_loading	('/create/content/', 'Create a text - '+t['#id_workspace_name']);
       
   188 		test_logged_header	(w.USER_ADMIN);
       
   189 		test_default_tabs	(t.text_nb, t.user_nb);
       
   190 		test_count	('#text ul.sub_list:eq(0) a', 3);
       
   191 		test_text	('#text ul.sub_list:eq(0) a:eq(0)[href="/text/"]', 'Text list');
       
   192 		test_text	('#text ul.sub_list:eq(0) a:eq(1)[href="/create/upload/"]', 'Upload a text');
       
   193 		test_text	('#text ul.sub_list:eq(0) a:eq(2)[href="/create/import/"]', 'Import a co-mented text');
       
   194 		test_count	('#text form[action="."]:eq(0) :input', 6);
       
   195 		test_form_field ('text', 'id_title',	'text', 0, 'Title', true);
       
   196 		test_form_field ('text', 'id_format',	'select', 1, 'Format', true);
       
   197 		test_form_field ('text', 'id_content',	'textarea', 2, 'Content', true);
       
   198 		test_form_field ('text', 'id_tags',		'text', 3, 'Tags');
       
   199 		test_val	('#text :input:eq(4)[type=submit]', 'Save');
       
   200 		test_val	('#text :input:eq(5)#cancel_button[type=button]', 'Cancel');
       
   201 		test_count	('select#id_format option', 3);
       
   202 		test_text	('select#id_format option:eq(0)[value="markdown"][selected]', 'markdown', non_visible);
       
   203 		test_text	('select#id_format option:eq(1)[value="rst"]', 'rst', non_visible);
       
   204 		test_text	('select#id_format option:eq(2)[value="html"]', 'html', non_visible);
       
   205 		test_count	('#markItUpId_content li', 20); // How many buttons are in the WYSIWYG editor toolbar ?
       
   206 		test_unlogged_footer ();
       
   207 
       
   208 		test ('submit empty fields', dsl(function () {
       
   209 			elt ('#text input[type="submit"]').click ();
       
   210 			browser.waitForPageLoad ();
       
   211 		}));
       
   212 		test_count ('div.help_text span.error-text', 2);
       
   213 		test_form_field ('text div.error', 'id_title',		'text', 0, 'Title', true);
       
   214 		test_form_field ('text div.error', 'id_content',	'textarea', 1, 'Content', true);
       
   215 	});
       
   216 
       
   217 	suite ('upload text page conformity', function () {
       
   218 		test_page_loading	('/create/upload/', 'Upload a text - '+t['#id_workspace_name']);
       
   219 		test_logged_header	(w.USER_ADMIN);
       
   220 		test_default_tabs	(t.text_nb, t.user_nb);
       
   221 		test_count	('#text ul.sub_list:eq(0) a', 3);
       
   222 		test_text	('#text ul.sub_list:eq(0) a:eq(0)[href="/text/"]', 'Text list');
       
   223 		test_text	('#text ul.sub_list:eq(0) a:eq(1)[href="/create/content/"]', 'Create a text');
       
   224 		test_text	('#text ul.sub_list:eq(0) a:eq(2)[href="/create/import/"]', 'Import a co-mented text');
       
   225 		test_count	('#text form[action="."]:eq(0) :input', 6);
       
   226 		test_form_field ('text', 'id_title',	'text', 0, 'Title');
       
   227 		test_form_field ('text', 'id_format',	'select', 1, 'Format', true);
       
   228 		test_form_field ('text', 'id_tags',		'text', 2, 'Tags');
       
   229 		test_form_field ('text', 'id_file',		'file', 3, 'Upload file');
       
   230 		test_val	('#text :input:eq(4)[type=submit]', 'Save');
       
   231 		test_val	('#text :input:eq(5)#cancel_button[type=button]', 'Cancel');
       
   232 		test_count	('select#id_format option', 3);
       
   233 		test_text	('select#id_format option:eq(0)[value="markdown"][selected]', 'markdown', non_visible);
       
   234 		test_text	('select#id_format option:eq(1)[value="rst"]', 'rst', non_visible);
       
   235 		test_text	('select#id_format option:eq(2)[value="html"]', 'html', non_visible);
       
   236 		test_unlogged_footer ();
       
   237 
       
   238 		test ('submit empty fields', dsl(function () {
       
   239 			elt ('#text input[type="submit"]').click ();
       
   240 			browser.waitForPageLoad ();
       
   241 		}));
       
   242 		test_count ('div.help_text span.error-text', 1);
       
   243 		test_form_field ('text div.error', 'id_file',		'file', 0, 'Upload file');
       
   244 		test_match	('#text div.help_text:eq(3) span.error-text:eq(0)', /You should specify a file to upload/m);
       
   245 	});
       
   246 
       
   247 	suite ('import a co-mented text page conformity', function () {
       
   248 		test_page_loading	('/create/import/', 'Import a co-mented text - '+t['#id_workspace_name']);
       
   249 		test_logged_header	(w.USER_ADMIN);
       
   250 		test_default_tabs	(t.text_nb, t.user_nb);
       
   251 		test_count	('#text ul.sub_list:eq(0) a', 3);
       
   252 		test_text	('#text ul.sub_list:eq(0) a:eq(0)[href="/text/"]', 'Text list');
       
   253 		test_text	('#text ul.sub_list:eq(0) a:eq(1)[href="/create/content/"]', 'Create a text');
       
   254 		test_text	('#text ul.sub_list:eq(0) a:eq(2)[href="/create/upload/"]', 'Upload a text');
       
   255 		test_count	('#text form[action="."]:eq(0) :input', 3);
       
   256 		test_form_field ('text', 'id_file',	'file', 0, 'Upload XML file', true);
       
   257 		test_val	('#text :input:eq(1)[type=submit]', 'Save');
       
   258 		test_val	('#text :input:eq(2)#cancel_button[type=button]', 'Cancel');
       
   259 		test_unlogged_footer ();
       
   260 
       
   261 		test ('submit empty fields', dsl(function () {
       
   262 			elt ('#text input[type="submit"]').click ();
       
   263 			browser.waitForPageLoad ();
       
   264 		}));
       
   265 		test_count	('div.help_text span.error-text', 1);
       
   266 		test_form_field ('text div.error', 'id_file',		'file', 0, 'Upload XML file', true);
       
   267 		test_match	('#text div.help_text:eq(0) span.error-text:eq(0)', /You should specify a file to upload/m);
       
   268 	});
       
   269 
       
   270 	suite.skip ('texts list page conformity', function () {
       
   271 		test_page_loading	('/text/', 'Texts\n - '+t['#id_workspace_name']);
       
   272 		test_logged_header	(w.USER_ADMIN);
       
   273 		test_default_tabs	(t.text_nb, t.user_nb);
   208 		test_count	('#text ul.sub_list:eq(0) a', 3);
   274 		test_count	('#text ul.sub_list:eq(0) a', 3);
   209 		test_text	('#text ul.sub_list:eq(0) a:eq(0)[href="/create/content/"]', 'Create a text');
   275 		test_text	('#text ul.sub_list:eq(0) a:eq(0)[href="/create/content/"]', 'Create a text');
   210 		test_text	('#text ul.sub_list:eq(0) a:eq(1)[href="/create/upload/"]', 'Upload a text');
   276 		test_text	('#text ul.sub_list:eq(0) a:eq(1)[href="/create/upload/"]', 'Upload a text');
   211 		test_text	('#text ul.sub_list:eq(0) a:eq(2)[href="/create/import/"]', 'Import a co-mented text');
   277 		test_text	('#text ul.sub_list:eq(0) a:eq(2)[href="/create/import/"]', 'Import a co-mented text');
   212 		// TOTEST : filter by tag
   278 		// TOTEST : filter by tag
   213 		test_count	('form#filter_form[action="."] :input', 1);
   279 		test_count	('form#filter_form[action="."] :input', 1);
   214 		test_text	('select#tag_selected option:eq(0)[selected][value="0"]', '- All -', non_visible);
   280 		test_text	('select#tag_selected option:eq(0)[selected][value="0"]', '- All -', non_visible);
   215 		test		('#texts_form input count', dsl (function () {
   281 		test_count	('#texts_form :input', 3 + t.text_nb % 10);
   216 			elt ('form#texts_form[action="."] :input').count (function (c) {
   282 		test_match	('#paginator', new RegExp ('\\s\\d+-\\d+ of '+t.text_nb+'\\s','m'));
   217 				var n = 3 + z.text_nb % 10;
       
   218 				if (c != n) throw 'expected computed '+n+' to equal got '+c;
       
   219 			});
       
   220 		}));
       
   221 		test		('#paginator "of #" value', dsl (function () {
       
   222 			elt ('span#paginator').text (function (t) {
       
   223 				var r = t.match (/\s\d+-\d+ of (\d+)\s/m);
       
   224 				if (r.length != 2) throw 'expected 2 matches got '+r.length;
       
   225 				if (r[1] != z.text_nb) throw 'expected paginator total ('+r[1]+') to be '+z.text_nb;
       
   226 			});
       
   227 		}));
       
   228 		// TOTEST : pagination
   283 		// TOTEST : pagination
   229 		// TOTEST : Bulk Actions -> Apply does enable
   284 		// TOTEST : Bulk Actions -> Apply does enable
   230 		test_text	('select#bulk_actions option:eq(0)[selected][value="-1"]', 'Bulk Actions', non_visible);
   285 		test_text	('select#bulk_actions option:eq(0)[selected][value="-1"]', 'Bulk Actions', non_visible);
   231 		test_text	('select#bulk_actions option:eq(1)[value="delete"]', 'Delete', non_visible);
   286 		test_text	('select#bulk_actions option:eq(1)[value="delete"]', 'Delete', non_visible);
   232 		test_val	('form#texts_form input#apply[type=button][disabled]', 'Apply');
   287 		test_val	('form#texts_form input#apply[type=button][disabled]', 'Apply');
   238 		test_text	('table.large_table:eq(1) th:eq(4)', '# comments');
   293 		test_text	('table.large_table:eq(1) th:eq(4)', '# comments');
   239 		test_text	('table.large_table:eq(1) th:eq(5)', 'Last week activity');
   294 		test_text	('table.large_table:eq(1) th:eq(5)', 'Last week activity');
   240 		test_unlogged_footer ();
   295 		test_unlogged_footer ();
   241 	});
   296 	});
   242 
   297 
   243 	suite ('create a text page conformity', function () {
       
   244         test_page_loading	('/create/content/', 'Create a text - '+t['#id_workspace_name']);
       
   245 		test_logged_header	(w.USER_ADMIN);
       
   246 		test_default_tabs	();
       
   247         test_count  ('#text ul.sub_list:eq(0) a', 3);
       
   248         test_text   ('#text ul.sub_list:eq(0) a:eq(0)[href="/text/"]', 'Text list');
       
   249         test_text   ('#text ul.sub_list:eq(0) a:eq(1)[href="/create/upload/"]', 'Upload a text');
       
   250         test_text   ('#text ul.sub_list:eq(0) a:eq(2)[href="/create/import/"]', 'Import a co-mented text');
       
   251         test_count  ('#text form[action="."]:eq(0) :input', 6);
       
   252 		test_form_field ('text', 'id_title',	'text', 0, 'Title', true);
       
   253 		test_form_field ('text', 'id_format',	'select', 1, 'Format', true);
       
   254 		test_form_field ('text', 'id_content',	'textarea', 2, 'Content', true);
       
   255 		test_form_field ('text', 'id_tags',		'text', 3, 'Tags');
       
   256 		test_val	('#text :input:eq(4)[type=submit]', 'Save');
       
   257 		test_val	('#text :input:eq(5)#cancel_button[type=button]', 'Cancel');
       
   258 		test_count	('select#id_format option', 3);
       
   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);
       
   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 ?
       
   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);
       
   272     });
       
   273 
       
   274 	suite ('upload text page conformity', function () {
       
   275         test_page_loading	('/create/upload/', 'Upload a text - '+t['#id_workspace_name']);
       
   276 		test_logged_header	(w.USER_ADMIN);
       
   277 		test_default_tabs	();
       
   278         test_count  ('#text ul.sub_list:eq(0) a', 3);
       
   279         test_text   ('#text ul.sub_list:eq(0) a:eq(0)[href="/text/"]', 'Text list');
       
   280         test_text   ('#text ul.sub_list:eq(0) a:eq(1)[href="/create/content/"]', 'Create a 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);
       
   283 		test_form_field ('text', 'id_title',	'text', 0, 'Title');
       
   284 		test_form_field ('text', 'id_format',	'select', 1, 'Format', true);
       
   285 		test_form_field ('text', 'id_tags',		'text', 2, 'Tags');
       
   286 		test_form_field ('text', 'id_file',		'file', 3, 'Upload file');
       
   287 		test_val	('#text :input:eq(4)[type=submit]', 'Save');
       
   288 		test_val	('#text :input:eq(5)#cancel_button[type=button]', 'Cancel');
       
   289 		test_count	('select#id_format option', 3);
       
   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);
       
   292         test_text   ('select#id_format option:eq(2)[value="html"]', 'html', non_visible);
       
   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);
       
   302     });
       
   303 
       
   304 	suite ('import a co-mented text page conformity', function () {
       
   305         test_page_loading	('/create/import/', 'Import a co-mented text - '+t['#id_workspace_name']);
       
   306 		test_logged_header	(w.USER_ADMIN);
       
   307 		test_default_tabs	();
       
   308         test_count  ('#text ul.sub_list:eq(0) a', 3);
       
   309         test_text   ('#text ul.sub_list:eq(0) a:eq(0)[href="/text/"]', 'Text list');
       
   310         test_text   ('#text ul.sub_list:eq(0) a:eq(1)[href="/create/content/"]', 'Create a text');
       
   311         test_text   ('#text ul.sub_list:eq(0) a:eq(2)[href="/create/upload/"]', 'Upload a text');
       
   312         test_count  ('#text form[action="."]:eq(0) :input', 3);
       
   313 		test_form_field ('text', 'id_file',	'file', 0, 'Upload XML file', true);
       
   314 		test_val	('#text :input:eq(1)[type=submit]', 'Save');
       
   315 		test_val	('#text :input:eq(2)#cancel_button[type=button]', 'Cancel');
       
   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);
       
   325     });
       
   326 
       
   327 	suite ('edit profile page conformity', function () {
   298 	suite ('edit profile page conformity', function () {
   328         test_page_loading	('/profile/', 'Your profile [(]'+w.USER_ADMIN+'[)]\n - '+t['#id_workspace_name']);
   299 		test_page_loading	('/profile/', 'Your profile [(]'+w.USER_ADMIN+'[)]\n - '+t['#id_workspace_name']);
   329 		test_logged_header	(w.USER_ADMIN, no_tagline);
   300 		test_logged_header	(w.USER_ADMIN, no_tagline);
   330         test_count  ('#content ul.sub_list:eq(0) a', 1);
   301 		test_count	('#content ul.sub_list:eq(0) a', 1);
   331         test_text   ('#content ul.sub_list:eq(0) a:eq(0)[href="/profile-pw/"]', 'Password');
   302 		test_text	('#content ul.sub_list:eq(0) a:eq(0)[href="/profile-pw/"]', 'Password');
   332         test_count  ('form#profile[action="."]:eq(0) :input', 5);
   303 		test_count	('form#profile[action="."]:eq(0) :input', 5);
   333 		test_form_field ('profile', 'id_email',		'text', 0, 'E-mail address', true);
   304 		test_form_field ('profile', 'id_email',		'text', 0, 'E-mail address', true);
   334 		test_form_field ('profile', 'id_first_name','text', 1, 'First name');
   305 		test_form_field ('profile', 'id_first_name','text', 1, 'First name');
   335 		test_form_field ('profile', 'id_last_name',	'text', 2, 'Last name');
   306 		test_form_field ('profile', 'id_last_name',	'text', 2, 'Last name');
   336 		test_form_field ('profile', 'id_tags',		'text', 3, 'Tags');
   307 		test_form_field ('profile', 'id_tags',		'text', 3, 'Tags');
   337 		test_val	('#profile :input:eq(4)[type=submit]', 'Save');
   308 		test_val	('#profile :input:eq(4)[type=submit]', 'Save');
   338         test_unlogged_footer ();
   309 		test_unlogged_footer ();
   339     });
   310 	});
   340 
   311 
   341 	suite ('edit password page conformity', function () {
   312 	suite ('edit password page conformity', function () {
   342         test_page_loading	('/profile-pw/', 'Your profile [(]'+w.USER_ADMIN+'[)]\n - '+t['#id_workspace_name']);
   313 		test_page_loading	('/profile-pw/', 'Your profile [(]'+w.USER_ADMIN+'[)]\n - '+t['#id_workspace_name']);
   343 		test_logged_header	(w.USER_ADMIN, no_tagline);
   314 		test_logged_header	(w.USER_ADMIN, no_tagline);
   344         test_count  ('#content ul.sub_list:eq(0) a', 1);
   315 		test_count	('#content ul.sub_list:eq(0) a', 1);
   345         test_text   ('#content ul.sub_list:eq(0) a:eq(0)[href="/profile/"]', 'Profile');
   316 		test_text	('#content ul.sub_list:eq(0) a:eq(0)[href="/profile/"]', 'Profile');
   346         test_count  ('form#profile[action="."]:eq(0) :input', 4);
   317 		test_count	('form#profile[action="."]:eq(0) :input', 4);
   347 		test_form_field ('profile', 'id_old_password',	'password', 0, 'Old password', true);
   318 		test_form_field ('profile', 'id_old_password',	'password', 0, 'Old password', true);
   348 		test_form_field ('profile', 'id_new_password1', 'password', 1, 'New password', true);
   319 		test_form_field ('profile', 'id_new_password1', 'password', 1, 'New password', true);
   349 		test_form_field ('profile', 'id_new_password2',	'password', 2, 'New password confirmation', true);
   320 		test_form_field ('profile', 'id_new_password2',	'password', 2, 'New password confirmation', true);
   350 		test_val	('#profile :input:eq(3)[type=submit]', 'Save');
   321 		test_val	('#profile :input:eq(3)[type=submit]', 'Save');
   351         test_unlogged_footer ();
   322 		test_unlogged_footer ();
   352     });
   323 	});
   353 
   324 
   354     suite ('people list page conformity', function () {
   325 	suite ('people list page conformity', function () {
   355         test_page_loading	('/user/', 'People\' list\n - '+t['#id_workspace_name']);
   326 		test_page_loading	('/user/', 'People\' list\n - '+t['#id_workspace_name']);
   356         test_logged_header	(w.USER_ADMIN);
   327 		test_logged_header	(w.USER_ADMIN);
   357         test_default_tabs	();
   328 		test_default_tabs	(t.text_nb, t.user_nb);
   358         test_count  ('#user ul.sub_list:eq(0) a', 2);
   329 		test_count	('#user ul.sub_list:eq(0) a', 2);
   359         test_text   ('#user ul.sub_list:eq(0) a:eq(0)[href="/user/add/"]', 'Add a new user');
   330 		test_text	('#user ul.sub_list:eq(0) a:eq(0)[href="/user/add/"]', 'Add a new user');
   360         test_text   ('#user ul.sub_list:eq(0) a:eq(1)[href="/user/mass-add/"]', 'Add users in bulk');
   331 		test_text	('#user ul.sub_list:eq(0) a:eq(1)[href="/user/mass-add/"]', 'Add users in bulk');
   361         // TOTEST : filter by tag -> commentator user should be tagged commentator
   332 		// TOTEST : filter by tag -> commentator user should be tagged commentator
   362         test_count  ('form#filter_form[action="."] :input', 1);
   333 		test_count	('form#filter_form[action="."] :input', 1);
   363 		test_text	('#filter_form a[href="?display=1"]', 'Display suspended users');
   334 		test_text	('#filter_form a[href="?display=1"]', 'Display suspended users');
   364         test_text   ('select#tag_selected option:eq(0)[selected][value="0"]', '- All -', non_visible);
   335 		test_text	('select#tag_selected option:eq(0)[selected][value="0"]', '- All -', non_visible);
   365         // TOTEST : pagination
   336 		// TOTEST : pagination
   366         // TOTEST : Bulk Actions -> Apply does enable
   337 		// TOTEST : Bulk Actions -> Apply does enable
   367         test_text   ('select#bulk_actions option:eq(0)[selected][value="-1"]', '- Bulk Actions -', non_visible);
   338 		test_text	('select#bulk_actions option:eq(0)[selected][value="-1"]', '- Bulk Actions -', non_visible);
   368         test_text   ('select#bulk_actions option:eq(1)[value="disable"]', 'Suspend access', non_visible);
   339 		test_text	('select#bulk_actions option:eq(1)[value="disable"]', 'Suspend access', non_visible);
   369         test_text   ('select#bulk_actions option:eq(2)[value="enable"]', 'Enable access', non_visible);
   340 		test_text	('select#bulk_actions option:eq(2)[value="enable"]', 'Enable access', non_visible);
   370         test_text   ('select#bulk_actions option:eq(3)[value="role_1"]', 'Change role to Manager', non_visible);
   341 		test_text	('select#bulk_actions option:eq(3)[value="role_1"]', 'Change role to Manager', non_visible);
   371         test_text   ('select#bulk_actions option:eq(4)[value="role_2"]', 'Change role to Editor', non_visible);
   342 		test_text	('select#bulk_actions option:eq(4)[value="role_2"]', 'Change role to Editor', non_visible);
   372         test_text   ('select#bulk_actions option:eq(5)[value="role_3"]', 'Change role to Moderator', non_visible);
   343 		test_text	('select#bulk_actions option:eq(5)[value="role_3"]', 'Change role to Moderator', non_visible);
   373         test_text   ('select#bulk_actions option:eq(6)[value="role_4"]', 'Change role to Commentator', non_visible);
   344 		test_text	('select#bulk_actions option:eq(6)[value="role_4"]', 'Change role to Commentator', non_visible);
   374         test_text   ('select#bulk_actions option:eq(7)[value="role_5"]', 'Change role to Observer', non_visible);
   345 		test_text	('select#bulk_actions option:eq(7)[value="role_5"]', 'Change role to Observer', non_visible);
   375         test_val    ('form#user_form input#apply[type=button][disabled]', 'Apply');
   346 		test_val	('form#user_form input#apply[type=button][disabled]', 'Apply');
   376         test_count  ('table.large_table:eq(1) th', 6);
   347 		test_count	('table.large_table:eq(1) th', 6);
   377         test_val    ('table.large_table:eq(1) th:eq(0) input#all_check[type="checkbox"]', 'on');
   348 		test_val	('table.large_table:eq(1) th:eq(0) input#all_check[type="checkbox"]', 'on');
   378         test_text   ('table.large_table:eq(1) th:eq(1) a[href="?order=user__username"]', 'User');
   349 		test_text	('table.large_table:eq(1) th:eq(1) a[href="?order=user__username"]', 'User');
   379         test_text   ('table.large_table:eq(1) th:eq(2) a[href="?order=user__email"]', 'Email');
   350 		test_text	('table.large_table:eq(1) th:eq(2) a[href="?order=user__email"]', 'Email');
   380         test_text   ('table.large_table:eq(1) th:eq(3) a[href="?order=-user__date_joined"]', 'Date joined');
   351 		test_text	('table.large_table:eq(1) th:eq(3) a[href="?order=-user__date_joined"]', 'Date joined');
   381         test_text   ('table.large_table:eq(1) th:eq(4) a[href="?order=role__name"]', 'Role');
   352 		test_text	('table.large_table:eq(1) th:eq(4) a[href="?order=role__name"]', 'Role');
   382         test_text   ('table.large_table:eq(1) th:eq(5)', 'Last week activity');
   353 		test_text	('table.large_table:eq(1) th:eq(5)', 'Last week activity');
   383 		test_text	('table.large_table:eq(1) tr:last a[href="/user/-/edit/"]', 'Anonymous users');
   354 		test_text	('table.large_table:eq(1) tr:last a[href="/user/-/edit/"]', 'Anonymous users');
   384 		test_text	('table.large_table:eq(1) a.main_object_title[href="/profile/"]', w.USER_ADMIN);
   355 		test_text	('table.large_table:eq(1) a.main_object_title[href="/profile/"]', w.USER_ADMIN);
   385 		test_text	('table.large_table:eq(1) div.hidden-user-actions a[href="/profile/"]', 'Your profile');
   356 		test_text	('table.large_table:eq(1) div.hidden-user-actions a[href="/profile/"]', 'Your profile');
   386 		// TOTEST presence of commentator and editor user
   357 		// TOTEST presence of commentator and editor user
   387         test_unlogged_footer ();
   358 		test_unlogged_footer ();
   388     });
   359 	});
   389 
   360 
   390 	suite ('check user number', function () {
   361 	suite ('check user number', function () {
   391         test_page_loading	('/user/?display=1', 'People\' list\n - '+t['#id_workspace_name']);
   362 		test_page_loading	('/user/?display=1', 'People\' list\n - '+t['#id_workspace_name']);
   392         test        ('#user_form input count', dsl (function () {
   363 		test_count	('#user_form :input', 6 + (t.user_nb % 10) * 2);
   393             elt ('form#user_form[action="."] :input').count (function (c) {
   364 		test_match	('#paginator', new RegExp ('\\s\\d+-\\d+ of '+t.user_nb+'\\s','m'));
   394                 var n = 6 + (z.user_nb % 10) * 2;
   365 	});
   395                 if (c != n) throw 'expected computed '+n+' to equal got '+c;
       
   396             });
       
   397         }));
       
   398         test        ('#paginator "of #" value', dsl (function () {
       
   399             elt ('span#paginator').text (function (t) {
       
   400                 var r = t.match (/\s\d+-\d+ of (\d+)\s/m);
       
   401                 if (r.length != 2) throw 'expected 2 matches got '+r.length;
       
   402                 if (r[1] != z.user_nb) throw 'expected paginator total ('+r[1]+') to be '+z.user_nb;
       
   403             });
       
   404         }));
       
   405     });
       
   406 
   366 
   407 	suite ('add a user page conformity', function () {
   367 	suite ('add a user page conformity', function () {
   408         test_page_loading	('/user/add/', 'Add a new user\n - '+t['#id_workspace_name']);
   368 		test_page_loading	('/user/add/', 'Add a new user\n - '+t['#id_workspace_name']);
   409 		test_logged_header	(w.USER_ADMIN);
   369 		test_logged_header	(w.USER_ADMIN);
   410 		test_default_tabs	();
   370 		test_default_tabs	(t.text_nb, t.user_nb);
   411         test_count  ('#user ul.sub_list:eq(0) a', 2);
   371 		test_count	('#user ul.sub_list:eq(0) a', 2);
   412         test_text   ('#user ul.sub_list:eq(0) a:eq(0)[href="/user/"]', 'Users\' list');
   372 		test_text	('#user ul.sub_list:eq(0) a:eq(0)[href="/user/"]', 'Users\' list');
   413         test_text   ('#user ul.sub_list:eq(0) a:eq(1)[href="/user/mass-add/"]', 'Add users in bulk');
   373 		test_text	('#user ul.sub_list:eq(0) a:eq(1)[href="/user/mass-add/"]', 'Add users in bulk');
   414         test_count  ('#user form[action="."]:eq(0) :input', 8);
   374 		test_count	('#user form[action="."]:eq(0) :input', 8);
   415 		test_form_field ('user', 'id_email',		'text', 0, 'E-mail address', true);
   375 		test_form_field ('user', 'id_email',		'text', 0, 'E-mail address', true);
   416 		test_form_field ('user', 'id_first_name',	'text', 1, 'First name');
   376 		test_form_field ('user', 'id_first_name',	'text', 1, 'First name');
   417 		test_form_field ('user', 'id_last_name',	'text', 2, 'Last name');
   377 		test_form_field ('user', 'id_last_name',	'text', 2, 'Last name');
   418 		test_form_field ('user', 'id_tags',			'text', 3, 'Tags');
   378 		test_form_field ('user', 'id_tags',			'text', 3, 'Tags');
   419 		test_form_field ('user', 'id_role',			'select', 4, 'Workspace level role');
   379 		test_form_field ('user', 'id_role',			'select', 4, 'Workspace level role');
   420 		test_form_field ('user', 'id_note',			'textarea', 5, 'Note');
   380 		test_form_field ('user', 'id_note',			'textarea', 5, 'Note');
   421 		test_count	('select#id_role option', 6);
   381 		test_count	('select#id_role option', 6);
   422         test_text   ('select#id_role option:eq(0)[value][selected]', '---------', non_visible);
   382 		test_text	('select#id_role option:eq(0)[value][selected]', '---------', non_visible);
   423         test_text   ('select#id_role option:eq(1)[value="1"]', 'Manager', non_visible);
   383 		test_text	('select#id_role option:eq(1)[value="1"]', 'Manager', non_visible);
   424         test_text   ('select#id_role option:eq(2)[value="2"]', 'Editor', non_visible);
   384 		test_text	('select#id_role option:eq(2)[value="2"]', 'Editor', non_visible);
   425         test_text   ('select#id_role option:eq(3)[value="3"]', 'Moderator', non_visible);
   385 		test_text	('select#id_role option:eq(3)[value="3"]', 'Moderator', non_visible);
   426         test_text   ('select#id_role option:eq(4)[value="4"]', 'Commentator', non_visible);
   386 		test_text	('select#id_role option:eq(4)[value="4"]', 'Commentator', non_visible);
   427         test_text   ('select#id_role option:eq(5)[value="5"]', 'Observer', non_visible);
   387 		test_text	('select#id_role option:eq(5)[value="5"]', 'Observer', non_visible);
   428 		test_val	('#user :input:eq(6)[type=submit]', 'Add user');
   388 		test_val	('#user :input:eq(6)[type=submit]', 'Add user');
   429 		test_val	('#user :input:eq(7)#cancel_button[type=button]', 'Cancel');
   389 		test_val	('#user :input:eq(7)#cancel_button[type=button]', 'Cancel');
   430         test_unlogged_footer ();
   390 		test_unlogged_footer ();
   431 
   391 
   432 		test ('submit empty fields', dsl(function () {
   392 		test ('submit empty fields', dsl(function () {
   433 			elt ('#user input[type="submit"]').click ();
   393 			elt ('#user input[type="submit"]').click ();
   434 			browser.waitForPageLoad ();
   394 			browser.waitForPageLoad ();
   435 		}));
   395 		}));
   436 		test_count	('div.help_text span.error-text', 1);
   396 		test_count	('div.help_text span.error-text', 1);
   437 		test_form_field ('user div.error', 'id_email', 'text', 0, 'E-mail address', true);
   397 		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);
   398 		test_match	('#user div.help_text:eq(0) span.error-text:eq(0)', /This field is required/m);
   439 		// X TOTEST add user (pending)
   399 		// X TOTEST add user (pending)
   440     });
   400 	});
   441 
   401 
   442 	suite ('add users in bulk page conformity', function () {
   402 	suite ('add users in bulk page conformity', function () {
   443         test_page_loading	('/user/mass-add/', 'Add users in bulk\n - '+t['#id_workspace_name']);
   403 		test_page_loading	('/user/mass-add/', 'Add users in bulk\n - '+t['#id_workspace_name']);
   444 		test_logged_header	(w.USER_ADMIN);
   404 		test_logged_header	(w.USER_ADMIN);
   445 		test_default_tabs	();
   405 		test_default_tabs	(t.text_nb, t.user_nb);
   446         test_count  ('#user ul.sub_list:eq(0) a', 2);
   406 		test_count	('#user ul.sub_list:eq(0) a', 2);
   447         test_text   ('#user ul.sub_list:eq(0) a:eq(0)[href="/user/"]', 'Users\' list');
   407 		test_text	('#user ul.sub_list:eq(0) a:eq(0)[href="/user/"]', 'Users\' list');
   448         test_text   ('#user ul.sub_list:eq(0) a:eq(1)[href="/user/add/"]', 'Add a new user');
   408 		test_text	('#user ul.sub_list:eq(0) a:eq(1)[href="/user/add/"]', 'Add a new user');
   449         test_count  ('#user form[action="."]:eq(0) :input', 6);
   409 		test_count	('#user form[action="."]:eq(0) :input', 6);
   450 		test_form_field ('user', 'id_email',		'textarea', 0, 'Emails', true);
   410 		test_form_field ('user', 'id_email',		'textarea', 0, 'Emails', true);
   451 		test_form_field ('user', 'id_tags',			'text',		1, 'Tags');
   411 		test_form_field ('user', 'id_tags',			'text',		1, 'Tags');
   452 		test_form_field ('user', 'id_role',			'select',	2, 'Workspace level role');
   412 		test_form_field ('user', 'id_role',			'select',	2, 'Workspace level role');
   453 		test_form_field ('user', 'id_note',			'textarea', 3, 'Note');
   413 		test_form_field ('user', 'id_note',			'textarea', 3, 'Note');
   454 		test_count	('select#id_role option', 6);
   414 		test_count	('select#id_role option', 6);
   455         test_text   ('select#id_role option:eq(0)[value][selected]', '---------', non_visible);
   415 		test_text	('select#id_role option:eq(0)[value][selected]', '---------', non_visible);
   456         test_text   ('select#id_role option:eq(1)[value="1"]', 'Manager', non_visible);
   416 		test_text	('select#id_role option:eq(1)[value="1"]', 'Manager', non_visible);
   457         test_text   ('select#id_role option:eq(2)[value="2"]', 'Editor', non_visible);
   417 		test_text	('select#id_role option:eq(2)[value="2"]', 'Editor', non_visible);
   458         test_text   ('select#id_role option:eq(3)[value="3"]', 'Moderator', non_visible);
   418 		test_text	('select#id_role option:eq(3)[value="3"]', 'Moderator', non_visible);
   459         test_text   ('select#id_role option:eq(4)[value="4"]', 'Commentator', non_visible);
   419 		test_text	('select#id_role option:eq(4)[value="4"]', 'Commentator', non_visible);
   460         test_text   ('select#id_role option:eq(5)[value="5"]', 'Observer', non_visible);
   420 		test_text	('select#id_role option:eq(5)[value="5"]', 'Observer', non_visible);
   461 		test_val	('#user :input:eq(4)[type=submit]', 'Add users');
   421 		test_val	('#user :input:eq(4)[type=submit]', 'Add users');
   462 		test_val	('#user :input:eq(5)#cancel_button[type=button]', 'Cancel');
   422 		test_val	('#user :input:eq(5)#cancel_button[type=button]', 'Cancel');
   463 		// X TOTEST add users (pending) -> can't be deleted
   423 		// X TOTEST add users (pending) -> can't be deleted
   464         test_unlogged_footer ();
   424 		test_unlogged_footer ();
   465 
   425 
   466 		test ('submit empty fields', dsl(function () {
   426 		test ('submit empty fields', dsl(function () {
   467 			elt ('#user input[type="submit"]').click ();
   427 			elt ('#user input[type="submit"]').click ();
   468 			browser.waitForPageLoad ();
   428 			browser.waitForPageLoad ();
   469 		}));
   429 		}));
   470 		test_count	('div.help_text span.error-text', 1);
   430 		test_count	('div.help_text span.error-text', 1);
   471 		test_form_field ('user div.error', 'id_email', 'textarea', 0, 'Emails', true);
   431 		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);
   432 		test_match	('#user div.help_text:eq(0) span.error-text:eq(0)', /This field is required/m);
   473     });
   433 	});
   474 
   434 
   475 	suite ('settings page conformity', function () {
   435 	suite ('settings page conformity', function () {
   476         test_page_loading	('/settings/', 'Settings - '+t['#id_workspace_name']);
   436 		test_page_loading	('/settings/', 'Settings - '+t['#id_workspace_name']);
   477 		test_logged_header	(w.USER_ADMIN);
   437 		test_logged_header	(w.USER_ADMIN);
   478 		test_default_tabs	();
   438 		test_default_tabs	(t.text_nb, t.user_nb);
   479         test_count  ('#settings ul.sub_list:eq(0) a', 1);
   439 		test_count	('#settings ul.sub_list:eq(0) a', 1);
   480         test_text   ('#settings ul.sub_list:eq(0) a:eq(0)[href="/settings/design/"]', 'Appearance');
   440 		test_text	('#settings ul.sub_list:eq(0) a:eq(0)[href="/settings/design/"]', 'Appearance');
   481         test_count  ('#settings form[action="."]:eq(0) :input', 12);
   441 		test_count	('#settings form[action="."]:eq(0) :input', 12);
   482 		test_form_field ('settings', 'id_workspace_name', 'text', 0, 'Workspace name');
   442 		test_form_field ('settings', 'id_workspace_name', 'text', 0, 'Workspace name');
   483 		test_form_field ('settings', 'id_workspace_tagline', 'text', 1, 'Workspace tagline');
   443 		test_form_field ('settings', 'id_workspace_tagline', 'text', 1, 'Workspace tagline');
   484 		test_form_field ('settings', 'id_workspace_registration', 'checkbox', 2, 'Workspace registration');
   444 		test_form_field ('settings', 'id_workspace_registration', 'checkbox', 2, 'Workspace registration');
   485 		test_form_field ('settings', 'id_workspace_registration_moderation', 'checkbox', 3, 'Workspace registration moderation');
   445 		test_form_field ('settings', 'id_workspace_registration_moderation', 'checkbox', 3, 'Workspace registration moderation');
   486 		test_form_field ('settings', 'id_workspace_role_model', 'select', 4, 'Role model');
   446 		test_form_field ('settings', 'id_workspace_role_model', 'select', 4, 'Role model');
   487         test_text   ('select#id_workspace_role_model option:eq(0)[selected][value="generic"]', 'Generic', non_visible);
   447 		test_text	('select#id_workspace_role_model option:eq(0)[selected][value="generic"]', 'Generic', non_visible);
   488         test_text   ('select#id_workspace_role_model option:eq(1)[value="teacher"]', 'Class (education)', non_visible);
   448 		test_text	('select#id_workspace_role_model option:eq(1)[value="teacher"]', 'Class (education)', non_visible);
   489 		test_form_field ('settings', 'id_workspace_category_1', 'text', 5, 'Label for the first category of comments');
   449 		test_form_field ('settings', 'id_workspace_category_1', 'text', 5, 'Label for the first category of comments');
   490 		test_form_field ('settings', 'id_workspace_category_2', 'text', 6, 'Label for the second category of comments');
   450 		test_form_field ('settings', 'id_workspace_category_2', 'text', 6, 'Label for the second category of comments');
   491 		test_form_field ('settings', 'id_workspace_category_3', 'text', 7, 'Label for the third category of comments');
   451 		test_form_field ('settings', 'id_workspace_category_3', 'text', 7, 'Label for the third category of comments');
   492 		test_form_field ('settings', 'id_workspace_category_4', 'text', 8, 'Label for the fourth category of comments');
   452 		test_form_field ('settings', 'id_workspace_category_4', 'text', 8, 'Label for the fourth category of comments');
   493 		test_form_field ('settings', 'id_workspace_category_5', 'text', 9, 'Label for the fifth category of comments');
   453 		test_form_field ('settings', 'id_workspace_category_5', 'text', 9, 'Label for the fifth category of comments');
   494 		test_val	('#settings :input:eq(10)[type=submit]', 'Save');
   454 		test_val	('#settings :input:eq(10)[type=submit]', 'Save');
   495 		test_val	('#settings :input:eq(11)#cancel_button[type=button]', 'Cancel');
   455 		test_val	('#settings :input:eq(11)#cancel_button[type=button]', 'Cancel');
   496 		// TOTEST Workspace registration feature (with newly accessible page)
   456 		// TOTEST Workspace registration feature (with newly accessible page)
   497 		test_unlogged_footer ();
   457 		test_unlogged_footer ();
   498     });
   458 	});
   499 
   459 
   500 	suite ('settings design page conformity', function () {
   460 	suite ('settings design page conformity', function () {
   501         test_page_loading	('/settings/design/', 'Settings - '+t['#id_workspace_name']);
   461 		test_page_loading	('/settings/design/', 'Settings - '+t['#id_workspace_name']);
   502 		test_logged_header	(w.USER_ADMIN);
   462 		test_logged_header	(w.USER_ADMIN);
   503 		test_default_tabs	();
   463 		test_default_tabs	(t.text_nb, t.user_nb);
   504         test_count  ('#settings ul.sub_list:eq(0) a', 1);
   464 		test_count	('#settings ul.sub_list:eq(0) a', 1);
   505         test_text   ('#settings ul.sub_list:eq(0) a:eq(0)[href="/settings/"]', 'General');
   465 		test_text	('#settings ul.sub_list:eq(0) a:eq(0)[href="/settings/"]', 'General');
   506         test_count  ('#settings form[action="."]:eq(0) :input', 7);
   466 		test_count	('#settings form[action="."]:eq(0) :input', 7);
   507 		test_form_field ('settings', 'id_workspace_logo_file', 'file', 0, 'Workspace logo');
   467 		test_form_field ('settings', 'id_workspace_logo_file', 'file', 0, 'Workspace logo');
   508 		test_form_field ('settings', 'id_custom_css', 'textarea', 1, 'Custom CSS rules');
   468 		test_form_field ('settings', 'id_custom_css', 'textarea', 1, 'Custom CSS rules');
   509 		test_form_field ('settings', 'id_custom_font', 'text', 2, 'Custom font');
   469 		test_form_field ('settings', 'id_custom_font', 'text', 2, 'Custom font');
   510 		test_form_field ('settings', 'id_custom_titles_font', 'text', 3, 'Custom font for titles');
   470 		test_form_field ('settings', 'id_custom_titles_font', 'text', 3, 'Custom font for titles');
   511 		test_val	('#settings :input:eq(4)[type=submit]', 'Save');
   471 		test_val	('#settings :input:eq(4)[type=submit]', 'Save');
   512 		test_val	('#settings :input:eq(5)#cancel_button[type=button]', 'Cancel');
   472 		test_val	('#settings :input:eq(5)#cancel_button[type=button]', 'Cancel');
   513 		test_val	('#settings :input:eq(6)#delete_logo_button[type=submit]', 'Delete logo');
   473 		test_val	('#settings :input:eq(6)#delete_logo_button[type=submit]', 'Delete logo');
   514 		test_unlogged_footer ();
   474 		test_unlogged_footer ();
   515     });
   475 	});
   516 
   476 
   517 	suite ('followup page conformity', function () {
   477 	suite ('followup page conformity', function () {
   518 		test_page_loading	('/followup/', 'Followup\n - '+t['#id_workspace_name']);
   478 		test_page_loading	('/followup/', 'Followup\n - '+t['#id_workspace_name']);
   519 		test_logged_header	(w.USER_ADMIN);
   479 		test_logged_header	(w.USER_ADMIN);
   520 		test_default_tabs	();
   480 		test_default_tabs	(t.text_nb, t.user_nb);
   521 		test_text	('#followup a:eq(0)[href="/help/#public_private_feed"]', '?');
   481 		test_text	('#followup a:eq(0)[href="/help/#public_private_feed"]', '?');
   522 		test_match	('#followup a:eq(1)[href$="/feed/"]', new RegExp (w.WORKSPACE_URL+'feed/', 'm'));
   482 		test_match	('#followup a:eq(1)[href$="/feed/"]', new RegExp (w.WORKSPACE_URL+'feed/', 'm'));
   523 		test_text	('#followup a:eq(2)[href="/help/#public_private_feed"]', '?');
   483 		test_text	('#followup a:eq(2)[href="/help/#public_private_feed"]', '?');
   524 		test_count	('form#followup_form[action="."] :input', 3);
   484 		test_count	('form#followup_form[action="."] :input', 3);
   525 		test_val	('form#followup_form input[type=submit]', '(Activate private feed|Reset private feed url)');
   485 		test_val	('form#followup_form input[type=submit]', '(Activate private feed|Reset private feed url)');
   542 	// tester l'affichage d'un texte
   502 	// tester l'affichage d'un texte
   543 	// tester que : #textcontainer.custom h1 font: Test_Sopinspace_custom_titles_font
   503 	// 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
   504 	// tester que si Text preferences -> custom -> #textcontainer.custom font: Test_Sopinspace_custom_font
   545 	// #textcontainer #add_comment_btn span -> #textcontainer font-family: Test_Sopinspace
   505 	// #textcontainer #add_comment_btn span -> #textcontainer font-family: Test_Sopinspace
   546 
   506 
   547 	suite ('settings restoration', function () {
       
   548         test_page_loading	('/settings/', 'Settings');
       
   549 		test_fill_settings (z);
       
   550 		test ('Restore settings ', dsl (function () {
       
   551 			elt ('#settings input[type="submit"]').click ();
       
   552 			browser.waitForPageLoad ();
       
   553 		}));
       
   554 		test_page_loading ('/settings/design/', 'Settings');
       
   555 		test_fill_design (z);
       
   556 		test ('Restore design settings ', dsl (function () {
       
   557 			elt ('#settings input[type="submit"]').click ();
       
   558 			browser.waitForPageLoad ();
       
   559 		}));
       
   560 		// next instruction must be a page loading
       
   561         // test_page_loading	('/settings/', 'Settings');
       
   562     });
       
   563 
       
   564 });
   507 });
   565 
   508 
   566 function test_default_tabs () {
   509 function test_default_tabs (text_nb, user_nb) {
   567 	test_count	('#main-tabs a', 5);
   510 	test_count	('#main-tabs a', 5);
   568 	test_text	('#main-tabs li:nth-of-type(1) a[href="/"]',			'Dashboard');
   511 	test_text	('#main-tabs li:nth-of-type(1) a[href="/"]',			'Dashboard');
   569 	test_match	('#main-tabs li:nth-of-type(2) a[href="/text/"]',		/^Texts \(\d+\) $/);
   512 	test_match	('#main-tabs li:nth-of-type(2) a[href="/text/"]',		/^Texts \(\d+\) $/);
   570 	test_match	('#main-tabs li:nth-of-type(3) a[href="/user/"]',		/^People  \(\d+\)$/);
   513 	test_match	('#main-tabs li:nth-of-type(3) a[href="/user/"]',		/^People  \(\d+\)$/);
   571 	test_text	('#main-tabs li:nth-of-type(4) a[href="/settings/"]',	'Settings');
   514 	test_text	('#main-tabs li:nth-of-type(4) a[href="/settings/"]',	'Settings');
   572 	test_text	('#main-tabs li:nth-of-type(5) a[href="/followup/"]',	'Followup');
   515 	test_text	('#main-tabs li:nth-of-type(5) a[href="/followup/"]',	'Followup');
   573 	test ('right tab nb', dsl(function () {
   516 	test_match	('#main-tabs a[href="/text/"]', new RegExp ('^Texts\\s*\\('+text_nb+'\\)\\s*$'));
   574 		elt ('#main-tabs a[href="/text/"]').text (function (t) {
   517 	test_match	('#main-tabs a[href="/user/"]', new RegExp ('^People\\s*\\('+user_nb+'\\)\\s*$'));
   575 			var r = t.match (/^Texts \((\d+)\) $/);
       
   576 			if (r.length != 2) throw 'for Texts expected 2 matches got '+r.length;
       
   577 			if (z.text_nb != r[1]) throw 'expected tab text nb ('+r[1]+') to be '+z.text_nb;
       
   578 		});
       
   579 		elt ('#main-tabs a[href="/user/"]').text (function (t) {
       
   580 			var r = t.match (/^People  \((\d+)\)$/);
       
   581 			if (r.length != 2) throw 'for People expected 2 matches got '+r.length;
       
   582 			if (z.user_nb != r[1]) throw 'expected tab people nb ('+r[1]+') to be '+z.user_nb;
       
   583 		});
       
   584 	}));
       
   585 }
   518 }
   586 
   519 
   587 function test_logged_header (username, is_tagline) {
   520 function test_logged_header (username, is_tagline) {
   588 	is_tagline = typeof is_tagline == 'undefined' ? true : is_tagline;
   521 	is_tagline = typeof is_tagline == 'undefined' ? true : is_tagline;
   589 
   522 
   620 	test_text	('#footer a:nth-of-type(8)[href="/i18n/setlang/pt_BR/"]',	'Português Brasileiro');
   553 	test_text	('#footer a:nth-of-type(8)[href="/i18n/setlang/pt_BR/"]',	'Português Brasileiro');
   621 	test_text	('#footer a:nth-of-type(9)[href="/i18n/setlang/nb/"]',		'Norsk');
   554 	test_text	('#footer a:nth-of-type(9)[href="/i18n/setlang/nb/"]',		'Norsk');
   622 	test_text	('#footer a:nth-of-type(10)[href="/i18n/setlang/bg/"]',		'Български');
   555 	test_text	('#footer a:nth-of-type(10)[href="/i18n/setlang/bg/"]',		'Български');
   623 }
   556 }
   624 
   557 
   625 function test_readz_field (field_id) {
   558 function test_fill_field (field_id, stored) { 
   626 	test ('get '+field_id, dsl(function () {
       
   627 		element (field_id).val (function (v) {
       
   628 			z[field_id] = v;
       
   629 		});
       
   630 	}));
       
   631 }
       
   632 
       
   633 function test_fill_field (field_id, stored) {
       
   634 	test ('set '+field_id, dsl(function () {
   559 	test ('set '+field_id, dsl(function () {
   635 		input (field_id).enter (stored[field_id]);
   560 		input (field_id).enter (stored[field_id]);
   636 	}));
   561 	}));
   637 }
   562 }
   638 
   563 
   653 	test_fill_field ('#id_custom_css', s);
   578 	test_fill_field ('#id_custom_css', s);
   654 	test_fill_field ('#id_custom_font', s);
   579 	test_fill_field ('#id_custom_font', s);
   655 	test_fill_field ('#id_custom_titles_font', s);
   580 	test_fill_field ('#id_custom_titles_font', s);
   656 }
   581 }
   657 
   582 
       
   583 
   658 function test_i18n () {
   584 function test_i18n () {
   659 	test ('can change lang to french', dsl(function () {
   585 	test ('can change lang to french', dsl(function () {
   660 		element ('#footer a[href="/i18n/setlang/fr/"]').click ();
   586 		element ('#footer a[href="/i18n/setlang/fr/"]').click ();
   661 //		browser.waitForPageLoad ();
   587 //		browser.waitForPageLoad ();
   662 //		browser.navigateTo ('/');
   588 //		browser.navigateTo ('/');
   681 		});
   607 		});
   682 	}));
   608 	}));
   683 }
   609 }
   684 
   610 
   685 /** Test if the selected DOM element is defined or has a given value : .val()
   611 /** Test if the selected DOM element is defined or has a given value : .val()
   686  *  s : CSS selector
   612  *	s : CSS selector
   687  *  e : expected value, if omited, test existence
   613  *	e : expected value, if omited, test existence
   688  */
   614  */
   689 function test_val (s, e) {
   615 function test_val (s, e) {
   690 	e = typeof e == 'undefined' ? '' : e; // .val() returns defined ? '' : undefined; // if no value
   616 	e = typeof e == 'undefined' ? '' : e; // .val() returns defined ? '' : undefined; // if no value
   691 	test (s+' is '+e, dsl(function () {
   617 	test (s+' is '+e, dsl(function () {
   692 		expect (elt (s).val ()).toMatch (new RegExp (e, 'm'));
   618 		expect (elt (s).val ()).toMatch (new RegExp (e, 'm'));
   693 	}));
   619 	}));
   694 }
   620 }
   695 
   621 
   696 /** Test if the selected DOM element has the given text : .text()
   622 /** Test if the selected DOM element has the given text : .text()
   697  *  s : CSS selector
   623  *	s : CSS selector
   698  *  e : expected value
   624  *	e : expected value
   699  *  v : should we test a visible value ?
   625  *	v : should we test a visible value ?
   700  */
   626  */
   701 function test_text (s, e, v) {
   627 function test_text (s, e, v) {
   702 	v = typeof v == 'undefined' ? true : v;
   628 	v = typeof v == 'undefined' ? true : v;
   703 	test (s+' has text '+e, dsl(function () {
   629 	test (s+' has text '+e, dsl(function () {
   704 		expect (elt (s, v).text ()).toBe (e);
   630 		expect (elt (s, v).text ()).toBe (e);
   705 	}));
   631 	}));
   706 }
   632 }
   707 
   633 
   708 /** Test if the selected DOM element .text() value match the given regexp
   634 /** Test if the selected DOM element .text() value match the given regexp
   709  *  s : CSS selector
   635  *	s : CSS selector
   710  *  r : regexp to match
   636  *	r : regexp to match
   711  */
   637  */
   712 function test_match (s, r) {
   638 function test_match (s, r) {
   713 	test (s+' text match '+r, dsl(function () {
   639 	test (s+' text match '+r, dsl(function () {
   714 		expect (elt (s).text ()).toMatch (r);
   640 		expect (elt (s).text ()).toMatch (r);
   715 	}));
   641 	}));
   716 }
   642 }
   717 
   643 
   718 /** Count selector occurences
   644 /** Count selector occurences
   719  *  s : CSS selector
   645  *	s : CSS selector
   720  *  e : expected count
   646  *	e : expected count
   721  */
   647  */
   722 function test_count (s, e) {
   648 function test_count (s, e) {
   723 	test (s+' count is '+e, dsl(function () {
   649 	test (s+' count is '+e, dsl(function () {
   724 		expect (elt (s).count ()).toBe (e);
   650 		expect (elt (s).count ()).toBe (e);
   725 	}));
   651 	}));
   745 			expect (elt ('label[for='+field_id+'] + span.required_star').val ()).toBeDefined ();
   671 			expect (elt ('label[for='+field_id+'] + span.required_star').val ()).toBeDefined ();
   746 	}));
   672 	}));
   747 }
   673 }
   748 
   674 
   749 /** Ensure the given element is visible
   675 /** Ensure the given element is visible
   750  *  s : CSS selector of the DOM element to check
   676  *	s : CSS selector of the DOM element to check
   751  *  v : should the element being visible
   677  *	v : should the element being visible
   752  */
   678  */
   753 function elt (s, v) {
   679 function elt (s, v) {
   754 	return element (s + (v ? ':visible' : ''));
   680 	return element (s + (v ? ':visible' : ''));
   755 }
   681 }