1 |
|
2 // " Vim settings |
|
3 // set tabstop=4 " number of spaces in a tab |
|
4 // set softtabstop=4 " as above |
|
5 // set shiftwidth=4 " as above |
|
6 |
|
7 var w = __karma__.config.w, |
|
8 t = {'text_nb': 12, 'user_nb': 4}, |
|
9 long_text = ''; |
|
10 |
|
11 for (var i = 20; i--;) |
|
12 long_text += 'Contenu du troisième texte.<br/>Sur <b>plusieurs</b> lignes<br/>'; |
|
13 |
|
14 const non_visible = false, |
|
15 no_tagline = false, |
|
16 c = { |
|
17 '#id_workspace_name': 'Test workspace name', |
|
18 '#id_workspace_tagline': 'Test workspace tagline', |
|
19 '#id_workspace_registration': 'on', // registration |
|
20 '#id_workspace_registration_moderation':'on', // registration moderation |
|
21 '#id_workspace_role_model': 'generic', |
|
22 '#id_workspace_category_1': 'ws_cat_1', |
|
23 '#id_workspace_category_2': 'ws_cat_2', |
|
24 '#id_workspace_category_3': 'ws_cat_3', |
|
25 '#id_workspace_category_4': 'ws_cat_4', |
|
26 '#id_workspace_category_5': 'ws_cat_5', |
|
27 '#id_custom_css': "h2 { font-family: Test_Sopinspace !important; }", |
|
28 '#id_custom_font': 'Test_Sopinspace_custom_font', |
|
29 '#id_custom_titles_font': 'Test_Sopinspace_custom_titles_font', |
|
30 'texts': [ |
|
31 { |
|
32 '#id_title': 'Text One Sopinspace-Test éléguant', |
|
33 '#id_format': 'markdown', |
|
34 '#id_content': 'Contenu du premier texte.\nSur plusieurs lignes\nPour tester un cas réaliste', |
|
35 '#id_tags': 'test_text, Text Premier' |
|
36 }, |
|
37 { |
|
38 '#id_title': 'Text Two Sopinspace-Test éléguant', |
|
39 '#id_format': 'rst', |
|
40 '#id_content': 'Contenu du deuxième texte.\nSur plusieurs lignes aussi\nPour tester un cas réaliste', |
|
41 '#id_tags': 'test_text, Text Second' |
|
42 }, |
|
43 { |
|
44 '#id_title': 'Text Three Sopinspace-Test éléguant', |
|
45 '#id_format': 'html', |
|
46 '#id_content': long_text, |
|
47 '#id_tags': 'test_text, Text Troisième' |
|
48 } |
|
49 ] |
|
50 }; |
|
51 |
|
52 suite ('comt logged admin', function () { |
|
53 |
|
54 this.timeout(20000); |
|
55 |
|
56 suite ('logs as an admin', function () { |
|
57 test ('logs an admin in', dsl(function () { |
|
58 browser.navigateTo ('/'); |
|
59 input ('#id_username').enter (w.USER_ADMIN); |
|
60 input ('#id_password').enter (w.PASS_ADMIN); |
|
61 elt ('#login input[type=submit]').click (); |
|
62 browser.waitForPageLoad (); // Must be done here in this test() block |
|
63 browser.navigateTo ('/'); |
|
64 expect (element ('title').text ()).toMatch (/Dashboard/m); |
|
65 })); |
|
66 }); |
|
67 |
|
68 suite ('setting settings to test-values', function () { |
|
69 test_page_loading ('/settings/', 'Settings'); |
|
70 test_fill_settings (c); |
|
71 test_val ('#id_workspace_name', c['#id_workspace_name']); |
|
72 test_submit ('#settings input[type="submit"]'); |
|
73 test_page_loading ('/settings/', 'Settings'); |
|
74 test_text ('#content h1.main_title a[href="/"]', c['#id_workspace_name']); |
|
75 test_page_loading ('/settings/design/', 'Settings'); |
|
76 test_fill_design (c); |
|
77 test_submit ('#settings input[type="submit"]'); |
|
78 }); |
|
79 |
|
80 suite ('admin dashboard page conformity', function () { |
|
81 test_page_loading ('/', 'Dashboard\n - '+c['#id_workspace_name']); |
|
82 test_logged_header (w.USER_ADMIN); |
|
83 test_default_tabs (t.text_nb, t.user_nb); |
|
84 test_count ('table.dash_table', 5); |
|
85 test_text ('table.dash_table th:eq(0)', 'Actions'); |
|
86 test_match ('table.dash_table:eq(0) a:eq(0)[href="/create/content/"]', /\sCreate a text/); |
|
87 test_text ('table.dash_table:eq(0) a:eq(1).tip[href="#"]', '\xa0'); |
|
88 test_match ('table.dash_table:eq(0) a:eq(2)[href="/create/upload/"]', /\sUpload a text/); |
|
89 test_text ('table.dash_table:eq(0) a:eq(3).tip[href="#"]', '\xa0'); |
|
90 test_match ('table.dash_table:eq(0) a:eq(4)[href="/create/import/"]', /\sImport a co-mented text/); |
|
91 test_text ('table.dash_table:eq(0) a:eq(5).tip[href="#"]', '\xa0'); |
|
92 test_match ('table.dash_table:eq(0) a:eq(6)[href="/user/add/"]', /\sInvite user/); |
|
93 test_match ('table.dash_table:eq(0) a:eq(7)[href="/profile/"]', /\sEdit your profile/); |
|
94 test_match ('table.dash_table:eq(0) a:eq(8)[href="/text/"]', /\sView text list/); |
|
95 test_match ('table.dash_table:eq(0) a:eq(9)[href="/settings/"]', /\sConfigure workspace/); |
|
96 test_text ('table.dash_table th:eq(1)', 'Recent texts (all)'); |
|
97 test_text ('table.dash_table:eq(1) a:eq(0)[href="/text/"]', 'all'); |
|
98 test_text ('table.dash_table th:eq(2)', 'Recent comments'); |
|
99 test_match ('table.dash_table th:eq(3)', /^Workspace activity\n\s+\(month\/week\/24 hours\)$/m); |
|
100 test_text ('table.dash_table:eq(3) a:eq(0)[href="?span=month"]', 'month'); |
|
101 test_text ('table.dash_table:eq(3) a:eq(1)[href="?span=day"]', '24 hours'); |
|
102 test_text ('table.dash_table th:eq(4) span.em', 'Activities'); |
|
103 test_unlogged_footer (); |
|
104 }); |
|
105 |
|
106 suite.skip ('empty texts list page conformity', function () { |
|
107 test_page_loading ('/text/', 'Texts\n - '+c['#id_workspace_name']); |
|
108 test_logged_header (w.USER_ADMIN); |
|
109 test_default_tabs (t.text_nb, t.user_nb); |
|
110 test_count ('#text ul.sub_list:eq(0) a', 3); |
|
111 test_text ('#text ul.sub_list:eq(0) a:eq(0)[href="/create/content/"]', 'Create a text'); |
|
112 test_text ('#text ul.sub_list:eq(0) a:eq(1)[href="/create/upload/"]', 'Upload a text'); |
|
113 test_text ('#text ul.sub_list:eq(0) a:eq(2)[href="/create/import/"]', 'Import a co-mented text'); |
|
114 test_match ('#text', /No texts yet/m); |
|
115 test_count ('#texts_form :input', 0); |
|
116 }); |
|
117 |
|
118 suite ('create a text page conformity', function () { |
|
119 test_page_loading ('/create/content/', 'Create a text - '+c['#id_workspace_name']); |
|
120 test_logged_header (w.USER_ADMIN); |
|
121 test_default_tabs (t.text_nb, t.user_nb); |
|
122 test_count ('#text ul.sub_list:eq(0) a', 3); |
|
123 test_text ('#text ul.sub_list:eq(0) a:eq(0)[href="/text/"]', 'Text list'); |
|
124 test_text ('#text ul.sub_list:eq(0) a:eq(1)[href="/create/upload/"]', 'Upload a text'); |
|
125 test_text ('#text ul.sub_list:eq(0) a:eq(2)[href="/create/import/"]', 'Import a co-mented text'); |
|
126 test_count ('#text form[action="."]:eq(0) :input', 6); |
|
127 test_field ('text', 'id_title', 'text', 0, 'Title', true); |
|
128 test_field ('text', 'id_format', 'select', 1, 'Format', true); |
|
129 test_field ('text', 'id_content', 'textarea', 2, 'Content', true); |
|
130 test_field ('text', 'id_tags', 'text', 3, 'Tags'); |
|
131 test_val ('#text :input:eq(4)[type=submit]', 'Save'); |
|
132 test_val ('#text :input:eq(5)#cancel_button[type=button]', 'Cancel'); |
|
133 test_count ('select#id_format option', 3); |
|
134 test_text ('select#id_format option:eq(0)[value="markdown"][selected]', 'markdown', non_visible); |
|
135 test_text ('select#id_format option:eq(1)[value="rst"]', 'rst', non_visible); |
|
136 test_text ('select#id_format option:eq(2)[value="html"]', 'html', non_visible); |
|
137 test_count ('.markdown #markItUpId_content li', 20); // How many buttons in the WYSIWYG editor toolbar ? |
|
138 test_unlogged_footer (); |
|
139 test_submit('#text input[type="submit"]'); |
|
140 test_count ('div.help_text span.error-text', 2); |
|
141 test_field ('text div.error', 'id_title', 'text', 0, 'Title', true); |
|
142 test_field ('text div.error', 'id_content', 'textarea', 1, 'Content', true); |
|
143 }); |
|
144 |
|
145 suite ('upload text page conformity', function () { |
|
146 test_page_loading ('/create/upload/', 'Upload a text - '+c['#id_workspace_name']); |
|
147 test_logged_header (w.USER_ADMIN); |
|
148 test_default_tabs (t.text_nb, t.user_nb); |
|
149 test_count ('#text ul.sub_list:eq(0) a', 3); |
|
150 test_text ('#text ul.sub_list:eq(0) a:eq(0)[href="/text/"]', 'Text list'); |
|
151 test_text ('#text ul.sub_list:eq(0) a:eq(1)[href="/create/content/"]', 'Create a text'); |
|
152 test_text ('#text ul.sub_list:eq(0) a:eq(2)[href="/create/import/"]', 'Import a co-mented text'); |
|
153 test_count ('#text form[action="."]:eq(0) :input', 6); |
|
154 test_field ('text', 'id_title', 'text', 0, 'Title'); |
|
155 test_field ('text', 'id_format', 'select', 1, 'Format', true); |
|
156 test_field ('text', 'id_tags', 'text', 2, 'Tags'); |
|
157 test_field ('text', 'id_file', 'file', 3, 'Upload file'); |
|
158 test_val ('#text :input:eq(4)[type=submit]', 'Save'); |
|
159 test_val ('#text :input:eq(5)#cancel_button[type=button]', 'Cancel'); |
|
160 test_count ('select#id_format option', 3); |
|
161 test_text ('select#id_format option:eq(0)[value="markdown"][selected]', 'markdown', non_visible); |
|
162 test_text ('select#id_format option:eq(1)[value="rst"]', 'rst', non_visible); |
|
163 test_text ('select#id_format option:eq(2)[value="html"]', 'html', non_visible); |
|
164 test_unlogged_footer (); |
|
165 test_submit('#text input[type="submit"]'); |
|
166 test_count ('div.help_text span.error-text', 1); |
|
167 test_field ('text div.error', 'id_file', 'file', 0, 'Upload file'); |
|
168 test_match ('#text div.help_text:eq(3) span.error-text:eq(0)', /You should specify a file to upload/m); |
|
169 }); |
|
170 |
|
171 suite ('import a co-mented text page conformity', function () { |
|
172 test_page_loading ('/create/import/', 'Import a co-mented text - '+c['#id_workspace_name']); |
|
173 test_logged_header (w.USER_ADMIN); |
|
174 test_default_tabs (t.text_nb, t.user_nb); |
|
175 test_count ('#text ul.sub_list:eq(0) a', 3); |
|
176 test_text ('#text ul.sub_list:eq(0) a:eq(0)[href="/text/"]', 'Text list'); |
|
177 test_text ('#text ul.sub_list:eq(0) a:eq(1)[href="/create/content/"]', 'Create a text'); |
|
178 test_text ('#text ul.sub_list:eq(0) a:eq(2)[href="/create/upload/"]', 'Upload a text'); |
|
179 test_count ('#text form[action="."]:eq(0) :input', 3); |
|
180 test_field ('text', 'id_file', 'file', 0, 'Upload XML file', true); |
|
181 test_val ('#text :input:eq(1)[type=submit]', 'Save'); |
|
182 test_val ('#text :input:eq(2)#cancel_button[type=button]', 'Cancel'); |
|
183 test_unlogged_footer (); |
|
184 test_submit('#text input[type="submit"]'); |
|
185 test_count ('div.help_text span.error-text', 1); |
|
186 test_field ('text div.error', 'id_file', 'file', 0, 'Upload XML file', true); |
|
187 test_match ('#text div.help_text:eq(0) span.error-text:eq(0)', /You should specify a file to upload/m); |
|
188 }); |
|
189 |
|
190 suite.skip ('create texts', function () { |
|
191 /* for (var j=4; j--;) |
|
192 for (var i=3; i--;) |
|
193 create_text (i);*/ |
|
194 }); |
|
195 |
|
196 // check that public texts still worwhile unlogged |
|
197 // check that non public texts are unavailable |
|
198 // Are the public texts displayed in the login page ? |
|
199 |
|
200 // vérifier les valeurs de settings sauvées |
|
201 // Tester les liens masqués des textes listés si bien créés |
|
202 // Tester suppression de text |
|
203 // Tester bulk actions sur les textes |
|
204 |
|
205 // tester l'affichage d'un texte |
|
206 // tester que : #textcontainer.custom h1 font: Test_Sopinspace_custom_titles_font |
|
207 // tester que si Text preferences -> custom -> #textcontainer.custom font: Test_Sopinspace_custom_font |
|
208 // #textcontainer #add_comment_btn span -> #textcontainer font-family: Test_Sopinspace |
|
209 |
|
210 suite ('texts list page conformity', function () { |
|
211 test_page_loading ('/text/', 'Texts\n - '+c['#id_workspace_name']); |
|
212 test_logged_header (w.USER_ADMIN); |
|
213 test_default_tabs (t.text_nb, t.user_nb); |
|
214 test_count ('#text ul.sub_list:eq(0) a', 3); |
|
215 test_text ('#text ul.sub_list:eq(0) a:eq(0)[href="/create/content/"]', 'Create a text'); |
|
216 test_text ('#text ul.sub_list:eq(0) a:eq(1)[href="/create/upload/"]', 'Upload a text'); |
|
217 test_text ('#text ul.sub_list:eq(0) a:eq(2)[href="/create/import/"]', 'Import a co-mented text'); |
|
218 test_count ('form#filter_form[action="."] :input', 1); |
|
219 test_text ('select#tag_selected option:eq(0)[selected][value="0"]', '- All -', non_visible); |
|
220 test_page_loading ('/text/?tag_selected=Text+Troisième', 'Texts\n - '+c['#id_workspace_name']); |
|
221 test_count ('#texts_form :input', 4 + 3); |
|
222 test_match ('#paginator', /\s1-4 of 4\s/m); |
|
223 |
|
224 for (var i=4; i--;) { |
|
225 test_text ('a.main_object_title:eq('+i+')', c.texts[2]['#id_title']); |
|
226 test_match ('.tag_list:eq('+i+')', /tags: test_text Text Troisième /); |
|
227 test_text ('.tag_list:eq('+i+') a:eq(0)[href="?tag_selected=test_text"]', 'test_text'); |
|
228 test_text ('.tag_list:eq('+i+') a:eq(1)[href="?tag_selected=Text+Troisi%C3%A8me"]','Text Troisième'); |
|
229 test_text ('#text .hidden-text-actions:eq('+i+') a:eq(0)[href^="/text/"][href$="/view/"]', 'View'); |
|
230 test_text ('#text .hidden-text-actions:eq('+i+') a:eq(1)[href^="/text/"][href$="/edit/"]', 'Edit'); |
|
231 test_text ('#text .hidden-text-actions:eq('+i+') a:eq(2)[href$="#"][id*=delete]', 'Delete'); |
|
232 test_text ('#text .hidden-text-actions:eq('+i+') a:eq(3)[href^="/text/"][href$="/share/"]', 'Users'); |
|
233 test_text ('#text .hidden-text-actions:eq('+i+') a:eq(4)[href^="/text/"][href$="/settings/"]', 'Settings'); |
|
234 test_text ('#text a[title="Edit user"][href^="/user/"][href$="/edit/"]:eq('+i+')', 'admin'); |
|
235 test_text ('#text table[summary="text list"] tr:eq('+(i+1)+') td:eq(4)', '0'); |
|
236 } |
|
237 |
|
238 test_page_loading ('/text/', 'Texts\n - '+c['#id_workspace_name']); |
|
239 test_count ('#texts_form :input', (t.text_nb < 10 ? t.text_nb : 10) + 3); |
|
240 test_match ('#paginator', new RegExp ('\\s1-10 of '+t.text_nb+'\\s','m')); |
|
241 test_text ('#paginator a:eq(0)[href="?page=2"]', '»'); |
|
242 test_text ('#paginator a:eq(1)[href="?paginate=0"]', 'all'); |
|
243 test_click ('#paginator a:eq(0)[href="?page=2"]'); |
|
244 test_match ('#paginator', new RegExp ('\\s11-12 of '+t.text_nb+'\\s','m')); |
|
245 test_count ('#texts_form :input', t.text_nb % 10 + 3); |
|
246 test_click ('#paginator a:eq(0)[href="?page=1"]'); |
|
247 test_match ('#paginator', new RegExp ('\\s1-10 of '+t.text_nb+'\\s','m')); |
|
248 test_count ('#texts_form :input', (t.text_nb < 10 ? t.text_nb : 10) + 3); |
|
249 test_click ('#paginator a:eq(1)[href="?paginate=0&page=1"]'); |
|
250 test_match ('#paginator', /\s\(paginate\)\s/m); |
|
251 test_count ('#texts_form :input', t.text_nb + 3); |
|
252 test_click ('#paginator a:eq(0)[href="?paginate=&page=1"]'); |
|
253 test_count ('#texts_form :input', (t.text_nb < 10 ? t.text_nb : 10) + 3); |
|
254 test_match ('#paginator', new RegExp ('\\s1-10 of '+t.text_nb+'\\s','m')); |
|
255 |
|
256 // TOTEST : Bulk Actions -> Apply does enable |
|
257 // TOTEST : unitary delete |
|
258 test_page_loading ('/text/', 'Texts\n - '+c['#id_workspace_name']); |
|
259 test_text ('select#bulk_actions option:eq(0)[selected][value="-1"]', 'Bulk Actions', non_visible); |
|
260 test_text ('select#bulk_actions option:eq(1)[value="delete"]', 'Delete', non_visible); |
|
261 test_val ('form#texts_form input#apply[type=button][disabled]', 'Apply'); |
|
262 test_count ('table.large_table:eq(1) th', 6); |
|
263 test_val ('table.large_table:eq(1) th:eq(0) input#all_check[type="checkbox"]', 'on'); |
|
264 test_text ('table.large_table:eq(1) th:eq(1) a[href="?order=title"]', 'Text'); |
|
265 test_text ('table.large_table:eq(1) th:eq(2)', 'Author'); |
|
266 test_text ('table.large_table:eq(1) th:eq(3) a[href="?order=-modified"]', 'Modified'); |
|
267 test_text ('table.large_table:eq(1) th:eq(4)', '# comments'); |
|
268 test_text ('table.large_table:eq(1) th:eq(5)', 'Last week activity'); |
|
269 test_unlogged_footer (); |
|
270 }); |
|
271 |
|
272 suite ('edit profile page conformity', function () { |
|
273 test_page_loading ('/profile/', 'Your profile [(]'+w.USER_ADMIN+'[)]\n - '+c['#id_workspace_name']); |
|
274 test_logged_header (w.USER_ADMIN, no_tagline); |
|
275 test_count ('#content ul.sub_list:eq(0) a', 1); |
|
276 test_text ('#content ul.sub_list:eq(0) a:eq(0)[href="/profile-pw/"]', 'Password'); |
|
277 test_count ('form#profile[action="."]:eq(0) :input', 5); |
|
278 test_field ('profile', 'id_email', 'text', 0, 'E-mail address', true); |
|
279 test_field ('profile', 'id_first_name','text', 1, 'First name'); |
|
280 test_field ('profile', 'id_last_name', 'text', 2, 'Last name'); |
|
281 test_field ('profile', 'id_tags', 'text', 3, 'Tags'); |
|
282 test_val ('#profile :input:eq(4)[type=submit]', 'Save'); |
|
283 test_unlogged_footer (); |
|
284 }); |
|
285 |
|
286 suite ('edit password page conformity', function () { |
|
287 test_page_loading ('/profile-pw/', 'Your profile [(]'+w.USER_ADMIN+'[)]\n - '+c['#id_workspace_name']); |
|
288 test_logged_header (w.USER_ADMIN, no_tagline); |
|
289 test_count ('#content ul.sub_list:eq(0) a', 1); |
|
290 test_text ('#content ul.sub_list:eq(0) a:eq(0)[href="/profile/"]', 'Profile'); |
|
291 test_count ('form#profile[action="."]:eq(0) :input', 4); |
|
292 test_field ('profile', 'id_old_password', 'password', 0, 'Old password', true); |
|
293 test_field ('profile', 'id_new_password1', 'password', 1, 'New password', true); |
|
294 test_field ('profile', 'id_new_password2', 'password', 2, 'New password confirmation', true); |
|
295 test_val ('#profile :input:eq(3)[type=submit]', 'Save'); |
|
296 test_unlogged_footer (); |
|
297 }); |
|
298 |
|
299 suite ('people list page conformity', function () { |
|
300 test_page_loading ('/user/', 'People\' list\n - '+c['#id_workspace_name']); |
|
301 test_logged_header (w.USER_ADMIN); |
|
302 test_default_tabs (t.text_nb, t.user_nb); |
|
303 test_count ('#user ul.sub_list:eq(0) a', 2); |
|
304 test_text ('#user ul.sub_list:eq(0) a:eq(0)[href="/user/add/"]', 'Add a new user'); |
|
305 test_text ('#user ul.sub_list:eq(0) a:eq(1)[href="/user/mass-add/"]', 'Add users in bulk'); |
|
306 // TOTEST : filter by tag -> commentator user should be tagged commentator (to change in fixture) |
|
307 test_count ('form#filter_form[action="."] :input', 1); |
|
308 test_text ('#filter_form a[href="?display=1"]', 'Display suspended users'); |
|
309 test_text ('select#tag_selected option:eq(0)[selected][value="0"]', '- All -', non_visible); |
|
310 // TOTEST : pagination |
|
311 // TOTEST : Bulk Actions -> Apply does enable |
|
312 // TOTEST display suspended users |
|
313 test_text ('select#bulk_actions option:eq(0)[selected][value="-1"]', '- Bulk Actions -', non_visible); |
|
314 test_text ('select#bulk_actions option:eq(1)[value="disable"]', 'Suspend access', non_visible); |
|
315 test_text ('select#bulk_actions option:eq(2)[value="enable"]', 'Enable access', non_visible); |
|
316 test_text ('select#bulk_actions option:eq(3)[value="role_1"]', 'Change role to Manager', non_visible); |
|
317 test_text ('select#bulk_actions option:eq(4)[value="role_2"]', 'Change role to Editor', non_visible); |
|
318 test_text ('select#bulk_actions option:eq(5)[value="role_3"]', 'Change role to Moderator', non_visible); |
|
319 test_text ('select#bulk_actions option:eq(6)[value="role_4"]', 'Change role to Commentator', non_visible); |
|
320 test_text ('select#bulk_actions option:eq(7)[value="role_5"]', 'Change role to Observer', non_visible); |
|
321 test_val ('form#user_form input#apply[type=button][disabled]', 'Apply'); |
|
322 test_count ('table.large_table:eq(1) th', 6); |
|
323 test_val ('table.large_table:eq(1) th:eq(0) input#all_check[type="checkbox"]', 'on'); |
|
324 test_text ('table.large_table:eq(1) th:eq(1) a[href="?order=user__username"]', 'User'); |
|
325 test_text ('table.large_table:eq(1) th:eq(2) a[href="?order=user__email"]', 'Email'); |
|
326 test_text ('table.large_table:eq(1) th:eq(3) a[href="?order=-user__date_joined"]', 'Date joined'); |
|
327 test_text ('table.large_table:eq(1) th:eq(4) a[href="?order=role__name"]', 'Role'); |
|
328 test_text ('table.large_table:eq(1) th:eq(5)', 'Last week activity'); |
|
329 test_text ('table.large_table:eq(1) tr:last a[href="/user/-/edit/"]', 'Anonymous users'); |
|
330 test_text ('table.large_table:eq(1) a.main_object_title[href="/profile/"]', w.USER_ADMIN); |
|
331 test_text ('table.large_table:eq(1) div.hidden-user-actions a[href="/profile/"]', 'Your profile'); |
|
332 // TOTEST roles of users |
|
333 test_unlogged_footer (); |
|
334 }); |
|
335 |
|
336 suite ('check user number', function () { |
|
337 test_page_loading ('/user/?display=1', 'People\' list\n - '+c['#id_workspace_name']); |
|
338 test_count ('#user_form :input', 6 + (t.user_nb % 10) * 2); |
|
339 test_match ('#paginator', new RegExp ('\\s\\d+-\\d+ of '+t.user_nb+'\\s','m')); |
|
340 }); |
|
341 |
|
342 suite ('add a user page conformity', function () { |
|
343 test_page_loading ('/user/add/', 'Add a new user\n - '+c['#id_workspace_name']); |
|
344 test_logged_header (w.USER_ADMIN); |
|
345 test_default_tabs (t.text_nb, t.user_nb); |
|
346 test_count ('#user ul.sub_list:eq(0) a', 2); |
|
347 test_text ('#user ul.sub_list:eq(0) a:eq(0)[href="/user/"]', 'Users\' list'); |
|
348 test_text ('#user ul.sub_list:eq(0) a:eq(1)[href="/user/mass-add/"]', 'Add users in bulk'); |
|
349 test_count ('#user form[action="."]:eq(0) :input', 8); |
|
350 test_field ('user', 'id_email', 'text', 0, 'E-mail address', true); |
|
351 test_field ('user', 'id_first_name', 'text', 1, 'First name'); |
|
352 test_field ('user', 'id_last_name', 'text', 2, 'Last name'); |
|
353 test_field ('user', 'id_tags', 'text', 3, 'Tags'); |
|
354 test_field ('user', 'id_role', 'select', 4, 'Workspace level role'); |
|
355 test_field ('user', 'id_note', 'textarea', 5, 'Note'); |
|
356 test_count ('select#id_role option', 6); |
|
357 test_text ('select#id_role option:eq(0)[value][selected]', '---------', non_visible); |
|
358 test_text ('select#id_role option:eq(1)[value="1"]', 'Manager', non_visible); |
|
359 test_text ('select#id_role option:eq(2)[value="2"]', 'Editor', non_visible); |
|
360 test_text ('select#id_role option:eq(3)[value="3"]', 'Moderator', non_visible); |
|
361 test_text ('select#id_role option:eq(4)[value="4"]', 'Commentator', non_visible); |
|
362 test_text ('select#id_role option:eq(5)[value="5"]', 'Observer', non_visible); |
|
363 test_val ('#user :input:eq(6)[type=submit]', 'Add user'); |
|
364 test_val ('#user :input:eq(7)#cancel_button[type=button]', 'Cancel'); |
|
365 test_unlogged_footer (); |
|
366 test_submit('#user input[type="submit"]'); |
|
367 test_count ('div.help_text span.error-text', 1); |
|
368 test_field ('user div.error', 'id_email', 'text', 0, 'E-mail address', true); |
|
369 test_match ('#user div.help_text:eq(0) span.error-text:eq(0)', /This field is required/m); |
|
370 // X TOTEST add user (pending) |
|
371 }); |
|
372 |
|
373 suite ('add-users-in-bulk page conformity', function () { |
|
374 test_page_loading ('/user/mass-add/', 'Add users in bulk\n - '+c['#id_workspace_name']); |
|
375 test_logged_header (w.USER_ADMIN); |
|
376 test_default_tabs (t.text_nb, t.user_nb); |
|
377 test_count ('#user ul.sub_list:eq(0) a', 2); |
|
378 test_text ('#user ul.sub_list:eq(0) a:eq(0)[href="/user/"]', 'Users\' list'); |
|
379 test_text ('#user ul.sub_list:eq(0) a:eq(1)[href="/user/add/"]', 'Add a new user'); |
|
380 test_count ('#user form[action="."]:eq(0) :input', 6); |
|
381 test_field ('user', 'id_email', 'textarea', 0, 'Emails', true); |
|
382 test_field ('user', 'id_tags', 'text', 1, 'Tags'); |
|
383 test_field ('user', 'id_role', 'select', 2, 'Workspace level role'); |
|
384 test_field ('user', 'id_note', 'textarea', 3, 'Note'); |
|
385 test_count ('select#id_role option', 6); |
|
386 test_text ('select#id_role option:eq(0)[value][selected]', '---------', non_visible); |
|
387 test_text ('select#id_role option:eq(1)[value="1"]', 'Manager', non_visible); |
|
388 test_text ('select#id_role option:eq(2)[value="2"]', 'Editor', non_visible); |
|
389 test_text ('select#id_role option:eq(3)[value="3"]', 'Moderator', non_visible); |
|
390 test_text ('select#id_role option:eq(4)[value="4"]', 'Commentator', non_visible); |
|
391 test_text ('select#id_role option:eq(5)[value="5"]', 'Observer', non_visible); |
|
392 test_val ('#user :input:eq(4)[type=submit]', 'Add users'); |
|
393 test_val ('#user :input:eq(5)#cancel_button[type=button]', 'Cancel'); |
|
394 // X TOTEST add users (pending) -> can't be deleted |
|
395 test_unlogged_footer (); |
|
396 test_submit('#user input[type="submit"]'); |
|
397 test_count ('div.help_text span.error-text', 1); |
|
398 test_field ('user div.error', 'id_email', 'textarea', 0, 'Emails', true); |
|
399 test_match ('#user div.help_text:eq(0) span.error-text:eq(0)', /This field is required/m); |
|
400 }); |
|
401 |
|
402 suite ('settings page conformity', function () { |
|
403 test_page_loading ('/settings/', 'Settings - '+c['#id_workspace_name']); |
|
404 test_logged_header (w.USER_ADMIN); |
|
405 test_default_tabs (t.text_nb, t.user_nb); |
|
406 test_count ('#settings ul.sub_list:eq(0) a', 1); |
|
407 test_text ('#settings ul.sub_list:eq(0) a:eq(0)[href="/settings/design/"]', 'Appearance'); |
|
408 test_count ('#settings form[action="."]:eq(0) :input', 12); |
|
409 test_field ('settings', 'id_workspace_name', 'text', 0, 'Workspace name'); |
|
410 test_field ('settings', 'id_workspace_tagline', 'text', 1, 'Workspace tagline'); |
|
411 test_field ('settings', 'id_workspace_registration', 'checkbox', 2, 'Workspace registration'); |
|
412 test_field ('settings', 'id_workspace_registration_moderation', 'checkbox', 3, 'Workspace registration moderation'); |
|
413 test_field ('settings', 'id_workspace_role_model', 'select', 4, 'Role model'); |
|
414 test_text ('select#id_workspace_role_model option:eq(0)[selected][value="generic"]', 'Generic', non_visible); |
|
415 test_text ('select#id_workspace_role_model option:eq(1)[value="teacher"]', 'Class (education)', non_visible); |
|
416 test_field ('settings', 'id_workspace_category_1', 'text', 5, 'Label for the first category of comments'); |
|
417 test_field ('settings', 'id_workspace_category_2', 'text', 6, 'Label for the second category of comments'); |
|
418 test_field ('settings', 'id_workspace_category_3', 'text', 7, 'Label for the third category of comments'); |
|
419 test_field ('settings', 'id_workspace_category_4', 'text', 8, 'Label for the fourth category of comments'); |
|
420 test_field ('settings', 'id_workspace_category_5', 'text', 9, 'Label for the fifth category of comments'); |
|
421 test_val ('#settings :input:eq(10)[type=submit]', 'Save'); |
|
422 test_val ('#settings :input:eq(11)#cancel_button[type=button]', 'Cancel'); |
|
423 // TOTEST Workspace registration feature (with newly accessible page) |
|
424 test_unlogged_footer (); |
|
425 }); |
|
426 |
|
427 suite ('settings design page conformity', function () { |
|
428 test_page_loading ('/settings/design/', 'Settings - '+c['#id_workspace_name']); |
|
429 test_logged_header (w.USER_ADMIN); |
|
430 test_default_tabs (t.text_nb, t.user_nb); |
|
431 test_count ('#settings ul.sub_list:eq(0) a', 1); |
|
432 test_text ('#settings ul.sub_list:eq(0) a:eq(0)[href="/settings/"]', 'General'); |
|
433 test_count ('#settings form[action="."]:eq(0) :input', 7); |
|
434 test_field ('settings', 'id_workspace_logo_file', 'file', 0, 'Workspace logo'); |
|
435 test_field ('settings', 'id_custom_css', 'textarea', 1, 'Custom CSS rules'); |
|
436 test_field ('settings', 'id_custom_font', 'text', 2, 'Custom font'); |
|
437 test_field ('settings', 'id_custom_titles_font', 'text', 3, 'Custom font for titles'); |
|
438 test_val ('#settings :input:eq(4)[type=submit]', 'Save'); |
|
439 test_val ('#settings :input:eq(5)#cancel_button[type=button]', 'Cancel'); |
|
440 test_val ('#settings :input:eq(6)#delete_logo_button[type=submit]', 'Delete logo'); |
|
441 test_unlogged_footer (); |
|
442 }); |
|
443 |
|
444 suite ('followup page conformity', function () { |
|
445 test_page_loading ('/followup/', 'Followup\n - '+c['#id_workspace_name']); |
|
446 test_logged_header (w.USER_ADMIN); |
|
447 test_default_tabs (t.text_nb, t.user_nb); |
|
448 test_text ('#followup a:eq(0)[href="/help/#public_private_feed"]', '?'); |
|
449 test_match ('#followup a:eq(1)[href$="/feed/"]', new RegExp (w.WORKSPACE_URL+'feed/', 'm')); |
|
450 test_text ('#followup a:eq(2)[href="/help/#public_private_feed"]', '?'); |
|
451 test_count ('form#followup_form[action="."] :input', 3); |
|
452 test_val ('form#followup_form input[type=submit]', '(Activate private feed|Reset private feed url)'); |
|
453 test_val ('form#followup_form input#workspace_notify_check[type=checkbox]', 'on'); |
|
454 test_val ('form#followup_form input#own_notify_check[type=checkbox]', 'on'); |
|
455 |
|
456 // X TOTEST qu'une fois cliqué, le bouton a le nvo label, et qu'une adresse est disponible |
|
457 // X TOTEST que si on reclique l'adresse est changée |
|
458 |
|
459 test_unlogged_footer (); |
|
460 }); |
|
461 |
|
462 }); |
|
463 |
|
464 function test_default_tabs (text_nb, user_nb) { |
|
465 test_count ('#main-tabs a', 5); |
|
466 test_text ('#main-tabs li:nth-of-type(1) a[href="/"]', 'Dashboard'); |
|
467 test_match ('#main-tabs li:nth-of-type(2) a[href="/text/"]', /^Texts \(\d+\) $/); |
|
468 test_match ('#main-tabs li:nth-of-type(3) a[href="/user/"]', /^People \(\d+\)$/); |
|
469 test_text ('#main-tabs li:nth-of-type(4) a[href="/settings/"]', 'Settings'); |
|
470 test_text ('#main-tabs li:nth-of-type(5) a[href="/followup/"]', 'Followup'); |
|
471 test_match ('#main-tabs a[href="/text/"]', new RegExp ('^Texts\\s*\\('+text_nb+'\\)\\s*$')); |
|
472 test_match ('#main-tabs a[href="/user/"]', new RegExp ('^People\\s*\\('+user_nb+'\\)\\s*$')); |
|
473 } |
|
474 |
|
475 function test_logged_header (username, is_tagline) { |
|
476 is_tagline = typeof is_tagline == 'undefined' ? true : is_tagline; |
|
477 |
|
478 test_text ('#header_controls b', username) |
|
479 test_count ('#header_controls a', 6); |
|
480 test_text ('#header_controls a:nth-of-type(1)[href="/"]', 'Home'); |
|
481 test_text ('#header_controls a:nth-of-type(2)[href="/create/content/"]', 'Create a text'); |
|
482 test_text ('#header_controls a:nth-of-type(3)[href="/create/upload/"]', 'Upload a text'); |
|
483 test_text ('#header_controls a:nth-of-type(4)[href="/create/import/"]', 'Import a co-mented text'); |
|
484 test_text ('#header_controls a:nth-of-type(5)[href="/profile/"]', 'Profile'); |
|
485 test_text ('#header_controls a:nth-of-type(6)[href="/logout/"]', 'Logout'); |
|
486 test_text ('#content h1.main_title a[href="/"]', c['#id_workspace_name']); |
|
487 |
|
488 if (is_tagline) { |
|
489 test_match ('#content h1.main_title + div', new RegExp (c['#id_workspace_tagline'], 'm')); |
|
490 } |
|
491 } |
|
492 |
|
493 function test_fill_settings (s) { |
|
494 test_fill_field ('#id_workspace_name', s); |
|
495 test_fill_field ('#id_workspace_tagline', s); |
|
496 test_fill_field ('#id_workspace_registration', s); |
|
497 test_fill_field ('#id_workspace_registration_moderation', s); |
|
498 test_fill_field ('#id_workspace_role_model', s); |
|
499 test_fill_field ('#id_workspace_category_1', s); |
|
500 test_fill_field ('#id_workspace_category_2', s); |
|
501 test_fill_field ('#id_workspace_category_3', s); |
|
502 test_fill_field ('#id_workspace_category_4', s); |
|
503 test_fill_field ('#id_workspace_category_5', s); |
|
504 } |
|
505 |
|
506 function test_fill_design (s) { |
|
507 test_fill_field ('#id_custom_css', s); |
|
508 test_fill_field ('#id_custom_font', s); |
|
509 test_fill_field ('#id_custom_titles_font', s); |
|
510 } |
|
511 |
|
512 function create_text (i) { |
|
513 test_page_loading ('/create/content/', 'Create a text - '+c['#id_workspace_name']); |
|
514 test ('test creation', dsl(function () { |
|
515 dropdownlist ('#id_format').option (c['texts'][i]['#id_format']); |
|
516 })); |
|
517 |
|
518 test_fill_field ('#id_title', c['texts'][i]); |
|
519 test ('fill content', dsl(function (){ |
|
520 elt ('#id_content').val (c['texts'][i]['#id_content']); |
|
521 })); |
|
522 |
|
523 test_fill_field ('#id_tags', c['texts'][i]); |
|
524 test_submit ('#save_button'); |
|
525 t.text_nb++; |
|
526 } |
|