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 |
|
8 // check that public texts still work while unlogged |
|
9 // check that non public texts are unavailable |
|
10 // Are the public texts displayed in the login page ? |
|
11 |
|
12 var w = __karma__.config.w, |
|
13 z = {}; |
|
14 const non_visible = false, no_tagline = false; |
|
15 const t = { |
|
16 '#id_workspace_name': 'Test workspace name', |
|
17 '#id_workspace_tagline': 'Test workspace tagline', |
|
18 '#id_workspace_registration': 'on', // registration |
|
19 '#id_workspace_registration_moderation': 'on', // registration moderation |
|
20 '#id_workspace_role_model': 'generic', |
|
21 '#id_workspace_category_1': 'ws_cat_1', |
|
22 '#id_workspace_category_2': 'ws_cat_2', |
|
23 '#id_workspace_category_3': 'ws_cat_3', |
|
24 '#id_workspace_category_4': 'ws_cat_4', |
|
25 '#id_workspace_category_5': 'ws_cat_5', |
|
26 '#id_custom_css': "h2 { font-family: Test_Sopinspace !important; }", |
|
27 '#id_custom_font': 'Test_Sopinspace_custom_font', |
|
28 '#id_custom_titles_font': 'Test_Sopinspace_custom_titles_font', |
|
29 }; |
|
30 |
|
31 |
|
32 suite ('comt', function () { |
|
33 |
|
34 this.timeout(150000); |
|
35 |
|
36 suite ('contact page conformity', function () { |
|
37 test_page_loading ('/contact/', 'Contact'); |
|
38 test_unlogged_header (); |
|
39 test_val ('form#profile[action="."]'); // the form exists |
|
40 test_count ('form#profile :input', 7); // it has no more than 5 labels (may be no more fields) |
|
41 test_form_field ('profile', 'id_name', 'text', 0, 'Your name', true); // the field id_name is… |
|
42 test_form_field ('profile', 'id_email', 'text', 1, 'Your email address', true); |
|
43 test_form_field ('profile', 'id_title', 'text', 2, 'Subject of the message', true); |
|
44 test_form_field ('profile', 'id_body', 'textarea', 3, 'Body of the message', true); |
|
45 test_form_field ('profile', 'id_copy', 'checkbox', 4, 'Send me a copy of the email', false); |
|
46 test_val ('#profile input[type=submit]','Send'); // test that a the .val() of the element is |
|
47 test_val ('input#cancel_button[type=button]', 'Cancel'); |
|
48 test_unlogged_footer (); |
|
49 test ('to check that toBeDefined test still works', dsl(function () { |
|
50 expect (elt ('#header_controls a[href="/xxx/"]').val ()).not ().toBeDefined (); |
|
51 })); |
|
52 test ('get back to / to avoid bugging next page load', dsl(function () { |
|
53 browser.navigateTo ('/'); |
|
54 })); |
|
55 }); |
|
56 |
|
57 suite ('help page conformity', function () { |
|
58 test_page_loading ('/help/', 'Help'); |
|
59 test_unlogged_header (); |
|
60 test_unlogged_footer (); |
|
61 }); |
|
62 |
|
63 suite ('contact page mandatory field test', function () { |
|
64 test_page_loading ('/contact/', 'Contact'); |
|
65 |
|
66 test ('submit empty fields', dsl(function () { |
|
67 elt ('#profile input[type="submit"]').click (); |
|
68 browser.waitForPageLoad (); |
|
69 })); |
|
70 test_count ('div.help_text span.error-text', 4); |
|
71 test_form_field ('profile div.error', 'id_name', 'text', 0, 'Your name', true); // the field id_name is… |
|
72 test_form_field ('profile div.error', 'id_email', 'text', 1, 'Your email address', true); |
|
73 test_form_field ('profile div.error', 'id_title', 'text', 2, 'Subject of the message', true); |
|
74 test_form_field ('profile div.error', 'id_body', 'textarea', 3, 'Body of the message', true); |
|
75 test_form_field ('profile', 'id_copy', 'checkbox', 4, 'Send me a copy of the email', false); |
|
76 }); |
|
77 |
|
78 suite ('reset password page conformity', function () { |
|
79 test_page_loading ('/password_reset/', 'Reset my password'); |
|
80 test_unlogged_header (); |
|
81 test_val ('form#profile[action="."]'); |
|
82 test_count ('form#profile :input', 3); |
|
83 test_form_field ('profile', 'id_email', 'text', 1, 'E-mail', true); |
|
84 test_val ('#profile input[type=submit]', 'Reset my password'); |
|
85 test_unlogged_footer (); |
|
86 |
|
87 test ('submit empty fields', dsl(function () { |
|
88 elt ('#profile input[type="submit"]').click (); |
|
89 browser.waitForPageLoad (); |
|
90 })); |
|
91 |
|
92 test_count ('div.help_text span.error-text', 1); |
|
93 test_form_field ('profile div.error', 'id_email', 'text', 0, 'E-mail', true); |
|
94 }); |
|
95 |
|
96 suite ('login page conformity', function () { |
|
97 test_page_loading ('/', 'Home'); |
|
98 test_unlogged_header (); |
|
99 test_val ('form#login[action="/login/"]'); |
|
100 test_count ('form#login[action="/login/"] :input', 3); |
|
101 test_form_field ('login', 'id_username', 'text', 0, 'Username', true); |
|
102 test_form_field ('login', 'id_password', 'password', 1, 'Password', true); |
|
103 test_val ('form#login input[type=submit]', 'Login'); |
|
104 test_text ('form#login a[href="/password_reset/"]', 'Forgot password?'); |
|
105 test_unlogged_footer (); |
|
106 // test_i18n (); |
|
107 |
|
108 test ('get back to / to avoid bugging next page load', dsl(function () { |
|
109 browser.navigateTo ('/'); |
|
110 })); |
|
111 test_page_loading ('/login/', 'Login'); |
|
112 test ('submit empty fields', dsl(function () { |
|
113 elt ('#login input[type="submit"]').click (); |
|
114 browser.waitForPageLoad (); |
|
115 })); |
|
116 test_form_field ('login div.error', 'id_username', 'text', 0, 'Username', true); |
|
117 test_form_field ('login div.error', 'id_password', 'password', 1, 'Password', true); |
|
118 test ('logs an admin in', dsl(function () { |
|
119 input ('#id_username').enter (w.USER_ADMIN); |
|
120 input ('#id_password').enter (w.PASS_ADMIN); |
|
121 elt ('#login input[type=submit]').click (); |
|
122 // Must be done here in this test() block |
|
123 browser.waitForPageLoad (); |
|
124 browser.navigateTo ('/'); |
|
125 expect (element ('title').text ()).toMatch (/Dashboard/m); |
|
126 })); |
|
127 }); |
|
128 |
|
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 () { |
|
153 test_page_loading ('/settings/', 'Settings'); |
|
154 test_fill_settings (t); |
|
155 test_val ('#id_workspace_name', t['#id_workspace_name']); |
|
156 test ('Save test settings ', dsl (function () { |
|
157 elt ('#settings input[type="submit"]').click (); |
|
158 browser.waitForPageLoad (); |
|
159 })); |
|
160 test_page_loading ('/settings/', 'Settings'); |
|
161 test_text ('#content h1.main_title a[href="/"]', t['#id_workspace_name']); |
|
162 test_page_loading ('/settings/design/', 'Settings'); |
|
163 test_fill_design (t); |
|
164 test ('Save test design settings ', dsl (function () { |
|
165 elt ('#settings input[type="submit"]').click (); |
|
166 browser.waitForPageLoad (); |
|
167 })); |
|
168 }); |
|
169 |
|
170 suite ('admin dashboard page conformity', function () { |
|
171 test_page_loading ('/', 'Dashboard\n - '+t['#id_workspace_name']); |
|
172 test_logged_header (w.USER_ADMIN); |
|
173 test ('get text and user nb', dsl(function () { |
|
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); |
|
183 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/); |
|
185 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/); |
|
187 test_text ('table.dash_table:eq(0) a:eq(3).tip[href="#"]', '\xa0'); |
|
188 test_match ('table.dash_table:eq(0) a:eq(4)[href="/create/import/"]', /\sImport a co-mented text/); |
|
189 test_text ('table.dash_table:eq(0) a:eq(5).tip[href="#"]', '\xa0'); |
|
190 test_match ('table.dash_table:eq(0) a:eq(6)[href="/user/add/"]', /\sInvite user/); |
|
191 test_match ('table.dash_table:eq(0) a:eq(7)[href="/profile/"]', /\sEdit your profile/); |
|
192 test_match ('table.dash_table:eq(0) a:eq(8)[href="/text/"]', /\sView text list/); |
|
193 test_match ('table.dash_table:eq(0) a:eq(9)[href="/settings/"]', /\sConfigure workspace/); |
|
194 test_text ('table.dash_table th:eq(1)', 'Recent texts (all)'); |
|
195 test_text ('table.dash_table:eq(1) a:eq(0)[href="/text/"]', 'all'); |
|
196 test_text ('table.dash_table th:eq(2)', 'Recent comments'); |
|
197 test_match ('table.dash_table th:eq(3)', /^Workspace activity\n\s+\(month\/week\/24 hours\)$/m); |
|
198 test_text ('table.dash_table:eq(3) a:eq(0)[href="?span=month"]', 'month'); |
|
199 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'); |
|
201 test_unlogged_footer (); |
|
202 }); |
|
203 |
|
204 suite ('texts list page conformity', function () { |
|
205 test_page_loading ('/text/', 'Texts\n - '+t['#id_workspace_name']); |
|
206 test_logged_header (w.USER_ADMIN); |
|
207 test_default_tabs (); |
|
208 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'); |
|
210 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'); |
|
212 // TOTEST : filter by tag |
|
213 test_count ('form#filter_form[action="."] :input', 1); |
|
214 test_text ('select#tag_selected option:eq(0)[selected][value="0"]', '- All -', non_visible); |
|
215 test ('#texts_form input count', dsl (function () { |
|
216 elt ('form#texts_form[action="."] :input').count (function (c) { |
|
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 |
|
229 // TOTEST : Bulk Actions -> Apply does enable |
|
230 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); |
|
232 test_val ('form#texts_form input#apply[type=button][disabled]', 'Apply'); |
|
233 test_count ('table.large_table:eq(1) th', 6); |
|
234 test_val ('table.large_table:eq(1) th:eq(0) input#all_check[type="checkbox"]', 'on'); |
|
235 test_text ('table.large_table:eq(1) th:eq(1) a[href="?order=title"]', 'Text'); |
|
236 test_text ('table.large_table:eq(1) th:eq(2)', 'Author'); |
|
237 test_text ('table.large_table:eq(1) th:eq(3) a[href="?order=-modified"]', 'Modified'); |
|
238 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'); |
|
240 test_unlogged_footer (); |
|
241 }); |
|
242 |
|
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 () { |
|
328 test_page_loading ('/profile/', 'Your profile [(]'+w.USER_ADMIN+'[)]\n - '+t['#id_workspace_name']); |
|
329 test_logged_header (w.USER_ADMIN, no_tagline); |
|
330 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'); |
|
332 test_count ('form#profile[action="."]:eq(0) :input', 5); |
|
333 test_form_field ('profile', 'id_email', 'text', 0, 'E-mail address', true); |
|
334 test_form_field ('profile', 'id_first_name','text', 1, 'First name'); |
|
335 test_form_field ('profile', 'id_last_name', 'text', 2, 'Last name'); |
|
336 test_form_field ('profile', 'id_tags', 'text', 3, 'Tags'); |
|
337 test_val ('#profile :input:eq(4)[type=submit]', 'Save'); |
|
338 test_unlogged_footer (); |
|
339 }); |
|
340 |
|
341 suite ('edit password page conformity', function () { |
|
342 test_page_loading ('/profile-pw/', 'Your profile [(]'+w.USER_ADMIN+'[)]\n - '+t['#id_workspace_name']); |
|
343 test_logged_header (w.USER_ADMIN, no_tagline); |
|
344 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'); |
|
346 test_count ('form#profile[action="."]:eq(0) :input', 4); |
|
347 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); |
|
349 test_form_field ('profile', 'id_new_password2', 'password', 2, 'New password confirmation', true); |
|
350 test_val ('#profile :input:eq(3)[type=submit]', 'Save'); |
|
351 test_unlogged_footer (); |
|
352 }); |
|
353 |
|
354 suite ('people list page conformity', function () { |
|
355 test_page_loading ('/user/', 'People\' list\n - '+t['#id_workspace_name']); |
|
356 test_logged_header (w.USER_ADMIN); |
|
357 test_default_tabs (); |
|
358 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'); |
|
360 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 |
|
362 test_count ('form#filter_form[action="."] :input', 1); |
|
363 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); |
|
365 // TOTEST : pagination |
|
366 // TOTEST : Bulk Actions -> Apply does enable |
|
367 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); |
|
369 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); |
|
371 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); |
|
373 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); |
|
375 test_val ('form#user_form input#apply[type=button][disabled]', 'Apply'); |
|
376 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'); |
|
378 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'); |
|
380 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'); |
|
382 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'); |
|
384 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'); |
|
386 // TOTEST presence of commentator and editor user |
|
387 test_unlogged_footer (); |
|
388 }); |
|
389 |
|
390 suite ('check user number', function () { |
|
391 test_page_loading ('/user/?display=1', 'People\' list\n - '+t['#id_workspace_name']); |
|
392 test ('#user_form input count', dsl (function () { |
|
393 elt ('form#user_form[action="."] :input').count (function (c) { |
|
394 var n = 6 + (z.user_nb % 10) * 2; |
|
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 |
|
407 suite ('add a user page conformity', function () { |
|
408 test_page_loading ('/user/add/', 'Add a new user\n - '+t['#id_workspace_name']); |
|
409 test_logged_header (w.USER_ADMIN); |
|
410 test_default_tabs (); |
|
411 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'); |
|
413 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); |
|
415 test_form_field ('user', 'id_email', 'text', 0, 'E-mail address', true); |
|
416 test_form_field ('user', 'id_first_name', 'text', 1, 'First name'); |
|
417 test_form_field ('user', 'id_last_name', 'text', 2, 'Last name'); |
|
418 test_form_field ('user', 'id_tags', 'text', 3, 'Tags'); |
|
419 test_form_field ('user', 'id_role', 'select', 4, 'Workspace level role'); |
|
420 test_form_field ('user', 'id_note', 'textarea', 5, 'Note'); |
|
421 test_count ('select#id_role option', 6); |
|
422 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); |
|
424 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); |
|
426 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); |
|
428 test_val ('#user :input:eq(6)[type=submit]', 'Add user'); |
|
429 test_val ('#user :input:eq(7)#cancel_button[type=button]', 'Cancel'); |
|
430 test_unlogged_footer (); |
|
431 |
|
432 test ('submit empty fields', dsl(function () { |
|
433 elt ('#user input[type="submit"]').click (); |
|
434 browser.waitForPageLoad (); |
|
435 })); |
|
436 test_count ('div.help_text span.error-text', 1); |
|
437 test_form_field ('user div.error', 'id_email', 'text', 0, 'E-mail address', true); |
|
438 test_match ('#user div.help_text:eq(0) span.error-text:eq(0)', /This field is required/m); |
|
439 // X TOTEST add user (pending) |
|
440 }); |
|
441 |
|
442 suite ('add users in bulk page conformity', function () { |
|
443 test_page_loading ('/user/mass-add/', 'Add users in bulk\n - '+t['#id_workspace_name']); |
|
444 test_logged_header (w.USER_ADMIN); |
|
445 test_default_tabs (); |
|
446 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'); |
|
448 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); |
|
450 test_form_field ('user', 'id_email', 'textarea', 0, 'Emails', true); |
|
451 test_form_field ('user', 'id_tags', 'text', 1, 'Tags'); |
|
452 test_form_field ('user', 'id_role', 'select', 2, 'Workspace level role'); |
|
453 test_form_field ('user', 'id_note', 'textarea', 3, 'Note'); |
|
454 test_count ('select#id_role option', 6); |
|
455 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); |
|
457 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); |
|
459 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); |
|
461 test_val ('#user :input:eq(4)[type=submit]', 'Add users'); |
|
462 test_val ('#user :input:eq(5)#cancel_button[type=button]', 'Cancel'); |
|
463 // X TOTEST add users (pending) -> can't be deleted |
|
464 test_unlogged_footer (); |
|
465 |
|
466 test ('submit empty fields', dsl(function () { |
|
467 elt ('#user input[type="submit"]').click (); |
|
468 browser.waitForPageLoad (); |
|
469 })); |
|
470 test_count ('div.help_text span.error-text', 1); |
|
471 test_form_field ('user div.error', 'id_email', 'textarea', 0, 'Emails', true); |
|
472 test_match ('#user div.help_text:eq(0) span.error-text:eq(0)', /This field is required/m); |
|
473 }); |
|
474 |
|
475 suite ('settings page conformity', function () { |
|
476 test_page_loading ('/settings/', 'Settings - '+t['#id_workspace_name']); |
|
477 test_logged_header (w.USER_ADMIN); |
|
478 test_default_tabs (); |
|
479 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'); |
|
481 test_count ('#settings form[action="."]:eq(0) :input', 12); |
|
482 test_form_field ('settings', 'id_workspace_name', 'text', 0, 'Workspace name'); |
|
483 test_form_field ('settings', 'id_workspace_tagline', 'text', 1, 'Workspace tagline'); |
|
484 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'); |
|
486 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); |
|
488 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'); |
|
490 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'); |
|
492 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'); |
|
494 test_val ('#settings :input:eq(10)[type=submit]', 'Save'); |
|
495 test_val ('#settings :input:eq(11)#cancel_button[type=button]', 'Cancel'); |
|
496 // TOTEST Workspace registration feature (with newly accessible page) |
|
497 test_unlogged_footer (); |
|
498 }); |
|
499 |
|
500 suite ('settings design page conformity', function () { |
|
501 test_page_loading ('/settings/design/', 'Settings - '+t['#id_workspace_name']); |
|
502 test_logged_header (w.USER_ADMIN); |
|
503 test_default_tabs (); |
|
504 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'); |
|
506 test_count ('#settings form[action="."]:eq(0) :input', 7); |
|
507 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'); |
|
509 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'); |
|
511 test_val ('#settings :input:eq(4)[type=submit]', 'Save'); |
|
512 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'); |
|
514 test_unlogged_footer (); |
|
515 }); |
|
516 |
|
517 suite ('followup page conformity', function () { |
|
518 test_page_loading ('/followup/', 'Followup\n - '+t['#id_workspace_name']); |
|
519 test_logged_header (w.USER_ADMIN); |
|
520 test_default_tabs (); |
|
521 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')); |
|
523 test_text ('#followup a:eq(2)[href="/help/#public_private_feed"]', '?'); |
|
524 test_count ('form#followup_form[action="."] :input', 3); |
|
525 test_val ('form#followup_form input[type=submit]', '(Activate private feed|Reset private feed url)'); |
|
526 test_val ('form#followup_form input#workspace_notify_check[type=checkbox]', 'on'); |
|
527 test_val ('form#followup_form input#own_notify_check[type=checkbox]', 'on'); |
|
528 |
|
529 // X TOTEST qu'une fois cliqué, le bouton a le nvo label, et qu'une adresse est disponible |
|
530 // X TOTEST que si on reclique l'adresse est changée |
|
531 |
|
532 test_unlogged_footer (); |
|
533 }); |
|
534 |
|
535 // vérifier les valeurs de settings sauvées |
|
536 // Tester les champs obligatoires |
|
537 // Tester les créations de textes |
|
538 // Tester les liens masqués des textes listés si bien créés |
|
539 // Tester suppression de text |
|
540 // Tester bulk actions sur les textes |
|
541 |
|
542 // tester l'affichage d'un texte |
|
543 // tester que : #textcontainer.custom h1 font: Test_Sopinspace_custom_titles_font |
|
544 // tester que si Text preferences -> custom -> #textcontainer.custom font: Test_Sopinspace_custom_font |
|
545 // #textcontainer #add_comment_btn span -> #textcontainer font-family: Test_Sopinspace |
|
546 |
|
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 }); |
|
565 |
|
566 function test_default_tabs () { |
|
567 test_count ('#main-tabs a', 5); |
|
568 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+\) $/); |
|
570 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'); |
|
572 test_text ('#main-tabs li:nth-of-type(5) a[href="/followup/"]', 'Followup'); |
|
573 test ('right tab nb', dsl(function () { |
|
574 elt ('#main-tabs a[href="/text/"]').text (function (t) { |
|
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 } |
|
586 |
|
587 function test_logged_header (username, is_tagline) { |
|
588 is_tagline = typeof is_tagline == 'undefined' ? true : is_tagline; |
|
589 |
|
590 test_text ('#header_controls b', username) |
|
591 test_count ('#header_controls a', 6); |
|
592 test_text ('#header_controls a:nth-of-type(1)[href="/"]', 'Home'); |
|
593 test_text ('#header_controls a:nth-of-type(2)[href="/create/content/"]', 'Create a text'); |
|
594 test_text ('#header_controls a:nth-of-type(3)[href="/create/upload/"]', 'Upload a text'); |
|
595 test_text ('#header_controls a:nth-of-type(4)[href="/create/import/"]', 'Import a co-mented text'); |
|
596 test_text ('#header_controls a:nth-of-type(5)[href="/profile/"]', 'Profile'); |
|
597 test_text ('#header_controls a:nth-of-type(6)[href="/logout/"]', 'Logout'); |
|
598 test_text ('#content h1.main_title a[href="/"]', t['#id_workspace_name']); |
|
599 |
|
600 if (is_tagline) { |
|
601 test_match ('#content h1.main_title + div', new RegExp (t['#id_workspace_tagline'], 'm')); |
|
602 } |
|
603 } |
|
604 |
|
605 function test_unlogged_header () { |
|
606 test_count ('#header_controls a', 2); |
|
607 test_text ('#header_controls a[href="/"]', 'Home'); |
|
608 test_text ('#header_controls a[href="/login/"]', 'Login'); |
|
609 } |
|
610 |
|
611 function test_unlogged_footer (url) { |
|
612 test_count ('#footer a', 10); |
|
613 test_text ('#footer a:nth-of-type(1)[href="/contact/"]', 'Contact'); |
|
614 test_match ('#footer #comentlink[href="http://www.co-ment.com"]', /Powered by/m); |
|
615 test_text ('#footer a:nth-of-type(3)[href="/help/"]', 'Help'); |
|
616 test_text ('#footer a:nth-of-type(4)[href="/i18n/setlang/fr/"]', 'Français'); |
|
617 test_text ('#footer a:nth-of-type(5)[href="/i18n/setlang/es/"]', 'Español'); |
|
618 test_text ('#footer a:nth-of-type(6)[href="/i18n/setlang/it/"]', 'Italiano'); |
|
619 test_text ('#footer a:nth-of-type(7)[href="/i18n/setlang/de/"]', 'Deutsch'); |
|
620 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'); |
|
622 test_text ('#footer a:nth-of-type(10)[href="/i18n/setlang/bg/"]', 'Български'); |
|
623 } |
|
624 |
|
625 function test_readz_field (field_id) { |
|
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 () { |
|
635 input (field_id).enter (stored[field_id]); |
|
636 })); |
|
637 } |
|
638 |
|
639 function test_fill_settings (s) { |
|
640 test_fill_field ('#id_workspace_name', s); |
|
641 test_fill_field ('#id_workspace_tagline', s); |
|
642 test_fill_field ('#id_workspace_registration', s); |
|
643 test_fill_field ('#id_workspace_registration_moderation', s); |
|
644 test_fill_field ('#id_workspace_role_model', s); |
|
645 test_fill_field ('#id_workspace_category_1', s); |
|
646 test_fill_field ('#id_workspace_category_2', s); |
|
647 test_fill_field ('#id_workspace_category_3', s); |
|
648 test_fill_field ('#id_workspace_category_4', s); |
|
649 test_fill_field ('#id_workspace_category_5', s); |
|
650 } |
|
651 |
|
652 function test_fill_design (s) { |
|
653 test_fill_field ('#id_custom_css', s); |
|
654 test_fill_field ('#id_custom_font', s); |
|
655 test_fill_field ('#id_custom_titles_font', s); |
|
656 } |
|
657 |
|
658 function test_i18n () { |
|
659 test ('can change lang to french', dsl(function () { |
|
660 element ('#footer a[href="/i18n/setlang/fr/"]').click (); |
|
661 // browser.waitForPageLoad (); |
|
662 // browser.navigateTo ('/'); |
|
663 // browser.reload (); |
|
664 expect (elt ('#footer a[href="/help/"]').text ()).toBe ('Aide'); |
|
665 element ('#footer a[href="/i18n/setlang/en/"]').click (); |
|
666 // browser.waitForPageLoad (); |
|
667 // browser.navigateTo ('/'); |
|
668 })); |
|
669 } |
|
670 |
|
671 function test_page_loading (url, title) { |
|
672 test (url+' loads', dsl(function () { |
|
673 // here we are in Karma page |
|
674 browser.navigateTo (url); |
|
675 expect (element ('title').text ()).toMatch (new RegExp (title,'m')); |
|
676 // The same test agin vaniller javascript |
|
677 element ('title').text (function (page_title) { |
|
678 // here we got a value from the test iframe |
|
679 // to display the tested value : console.log (page_title); |
|
680 if (!(new RegExp (title, 'm').test (page_title))) throw 'got page '+page_title+' instead'; |
|
681 }); |
|
682 })); |
|
683 } |
|
684 |
|
685 /** Test if the selected DOM element is defined or has a given value : .val() |
|
686 * s : CSS selector |
|
687 * e : expected value, if omited, test existence |
|
688 */ |
|
689 function test_val (s, e) { |
|
690 e = typeof e == 'undefined' ? '' : e; // .val() returns defined ? '' : undefined; // if no value |
|
691 test (s+' is '+e, dsl(function () { |
|
692 expect (elt (s).val ()).toMatch (new RegExp (e, 'm')); |
|
693 })); |
|
694 } |
|
695 |
|
696 /** Test if the selected DOM element has the given text : .text() |
|
697 * s : CSS selector |
|
698 * e : expected value |
|
699 * v : should we test a visible value ? |
|
700 */ |
|
701 function test_text (s, e, v) { |
|
702 v = typeof v == 'undefined' ? true : v; |
|
703 test (s+' has text '+e, dsl(function () { |
|
704 expect (elt (s, v).text ()).toBe (e); |
|
705 })); |
|
706 } |
|
707 |
|
708 /** Test if the selected DOM element .text() value match the given regexp |
|
709 * s : CSS selector |
|
710 * r : regexp to match |
|
711 */ |
|
712 function test_match (s, r) { |
|
713 test (s+' text match '+r, dsl(function () { |
|
714 expect (elt (s).text ()).toMatch (r); |
|
715 })); |
|
716 } |
|
717 |
|
718 /** Count selector occurences |
|
719 * s : CSS selector |
|
720 * e : expected count |
|
721 */ |
|
722 function test_count (s, e) { |
|
723 test (s+' count is '+e, dsl(function () { |
|
724 expect (elt (s).count ()).toBe (e); |
|
725 })); |
|
726 } |
|
727 |
|
728 /** Test Django form field presence |
|
729 */ |
|
730 function test_form_field (form_id, field_id, type, position, label, mandatory) { |
|
731 test ('has a '+label+' form field', dsl(function () { |
|
732 var s = ''; |
|
733 |
|
734 switch (type) { |
|
735 case 'textarea':s = 'textarea#'+field_id; break; |
|
736 case 'select': s = 'select#'+field_id; break; |
|
737 default: s = 'input#'+field_id+'[type="'+type+'"]'; |
|
738 } |
|
739 |
|
740 expect (elt (s).val ()).toBeDefined (); |
|
741 expect (elt ('#'+form_id+' :input:eq('+position+')#'+field_id).val ()).toBeDefined (); |
|
742 expect (elt ('label[for='+field_id+']').text ()).toBe (label); |
|
743 |
|
744 if (mandatory) |
|
745 expect (elt ('label[for='+field_id+'] + span.required_star').val ()).toBeDefined (); |
|
746 })); |
|
747 } |
|
748 |
|
749 /** Ensure the given element is visible |
|
750 * s : CSS selector of the DOM element to check |
|
751 * v : should the element being visible |
|
752 */ |
|
753 function elt (s, v) { |
|
754 return element (s + (v ? ':visible' : '')); |
|
755 } |
|