| changeset 601 | d334a616c023 |
| parent 598 | fd0507590413 |
| child 612 | 2bed79bde721 |
| 600:fda73ac53450 | 601:d334a616c023 |
|---|---|
1 |
1 |
2 // try to login |
2 // " Vim settings |
3 |
3 // set tabstop=4 " number of spaces in a tab |
4 // create texts and co-ments |
4 // set softtabstop=4 " as above |
5 // collect newly created URLs |
5 // set shiftwidth=4 " as above |
6 |
6 |
7 // Get workspace name, public texts… |
|
8 |
|
9 // unlog |
|
10 |
7 |
11 // check that public texts still work while unlogged |
8 // check that public texts still work while unlogged |
12 // check that non public texts are unavailable |
9 // check that non public texts are unavailable |
13 |
|
14 // Is the workspace name correctly displayed ? |
|
15 // Are the public texts displayed in the login page ? |
10 // Are the public texts displayed in the login page ? |
16 |
11 |
17 var w = __karma__.config.w; |
12 var w = __karma__.config.w, |
18 const non_visible = false; |
13 z = {}; |
19 var text_nb = 0; |
14 const non_visible = false, no_tagline = false; |
20 var user_nb = 0; |
15 const t = { |
21 var pub_text_nb = 0; |
16 '#id_workspace_name': 'Test workspace name', |
22 var workspace_name = ''; |
17 '#id_workspace_tagline': 'Test workspace tagline', |
23 var 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': ".voted {\n color: #008000;\n}\n\n.rejected, .fallen, .withdrawn {\n color: #ff0000;\n}\n\ndiv.frame {\n border: 1px solid #000;\n padding: 5px;\n}\n\ndiv.frame .title {\n font-weight: bold;\n text-align: center; font-color:purple; \n}", |
|
27 '#id_custom_font': 'Ubuntu', |
|
28 '#id_custom_titles_font': 'Ubuntu Monospaced', |
|
29 }; |
|
30 |
|
24 |
31 |
25 suite ('comt', function () { |
32 suite ('comt', function () { |
26 |
33 |
27 this.timeout(150000); |
34 this.timeout(150000); |
28 |
35 |
29 suite ('contact page', function () { |
36 suite ('contact page conformity', function () { |
30 test_page_loading ('/contact/', 'Contact'); |
37 test_page_loading ('/contact/', 'Contact'); |
31 test_unlogged_header (); |
38 test_unlogged_header (); |
32 test_val ('form#profile[action="."]'); // the form exists |
39 test_val ('form#profile[action="."]'); // the form exists |
33 test_count ('form#profile :input', 7); // it has no more than 5 labels (may be no more fields) |
40 test_count ('form#profile :input', 7); // it has no more than 5 labels (may be no more fields) |
34 test_form_field ('profile', 'id_name', 'text', 0, 'Your name', true); // the field id_name is… |
41 test_form_field ('profile', 'id_name', 'text', 0, 'Your name', true); // the field id_name is… |
45 test ('get back to / to avoid bugging next page load', dsl(function () { |
52 test ('get back to / to avoid bugging next page load', dsl(function () { |
46 browser.navigateTo ('/'); |
53 browser.navigateTo ('/'); |
47 })); |
54 })); |
48 }); |
55 }); |
49 |
56 |
50 suite ('help page', function () { |
57 suite ('help page conformity', function () { |
51 test_page_loading ('/help/', 'Help'); |
58 test_page_loading ('/help/', 'Help'); |
52 test_unlogged_header (); |
59 test_unlogged_header (); |
53 test_unlogged_footer (); |
60 test_unlogged_footer (); |
54 }); |
61 }); |
55 |
62 |
56 suite ('reset password page', function () { |
63 suite ('reset password page conformity', function () { |
57 test_page_loading ('/password_reset/', 'Reset my password'); |
64 test_page_loading ('/password_reset/', 'Reset my password'); |
58 test_unlogged_header (); |
65 test_unlogged_header (); |
59 test_val ('form#profile[action="."]'); |
66 test_val ('form#profile[action="."]'); |
60 test_count ('form#profile :input', 3); |
67 test_count ('form#profile :input', 3); |
61 test_form_field ('profile', 'id_email', 'text', 1, 'E-mail', true); |
68 test_form_field ('profile', 'id_email', 'text', 1, 'E-mail', true); |
62 test_val ('#profile input[type=submit]', 'Reset my password'); |
69 test_val ('#profile input[type=submit]', 'Reset my password'); |
63 test_unlogged_footer (); |
70 test_unlogged_footer (); |
64 }); |
71 }); |
65 |
72 |
66 suite ('login page', function () { |
73 suite ('login page conformity', function () { |
67 test_page_loading ('/', 'Home'); |
74 test_page_loading ('/', 'Home'); |
68 test_unlogged_header (); |
75 test_unlogged_header (); |
69 test_val ('form#login[action="/login/"]'); |
76 test_val ('form#login[action="/login/"]'); |
70 test_count ('form#login[action="/login/"] :input', 3); |
77 test_count ('form#login[action="/login/"] :input', 3); |
71 test_form_field ('login', 'id_username', 'text', 0, 'Username', true); |
78 test_form_field ('login', 'id_username', 'text', 0, 'Username', true); |
83 browser.navigateTo ('/'); |
90 browser.navigateTo ('/'); |
84 expect (element ('title').text ()).toMatch (/Dashboard/m); |
91 expect (element ('title').text ()).toMatch (/Dashboard/m); |
85 })); |
92 })); |
86 }); |
93 }); |
87 |
94 |
88 suite ('admin dashboard', function () { |
95 suite ('reading settings', function () { |
89 // Should starts with : |
96 test_page_loading ('/settings/', 'Settings'); |
90 // test_page_loading ('/', 'Dashboard'); |
97 test_readz_field ('#id_workspace_name'); |
91 // But its the last thing we did in the previous test |
98 test_readz_field ('#id_workspace_tagline'); |
99 test_readz_field ('#id_workspace_registration'); |
|
100 test_readz_field ('#id_workspace_registration_moderation'); |
|
101 test_readz_field ('#id_workspace_role_model'); |
|
102 test_readz_field ('#id_workspace_category_1'); |
|
103 test_readz_field ('#id_workspace_category_2'); |
|
104 test_readz_field ('#id_workspace_category_3'); |
|
105 test_readz_field ('#id_workspace_category_4'); |
|
106 test_readz_field ('#id_workspace_category_5'); |
|
107 test_page_loading ('/settings/design/', 'Settings'); |
|
108 test_readz_field ('#id_custom_css'); |
|
109 test_readz_field ('#id_custom_font'); |
|
110 test_readz_field ('#id_custom_titles_font'); |
|
111 /*test ('display z', dsl(function () { |
|
112 elt ('#main-tabs').text (function (t) { |
|
113 console.log ('z '+JSON.stringify(z)); |
|
114 }); |
|
115 }));*/ |
|
116 }); |
|
117 |
|
118 suite ('setting settings to test values', function () { |
|
119 test_page_loading ('/settings/', 'Settings'); |
|
120 test_fill_settings (t); |
|
121 test_val ('#id_workspace_name', t['#id_workspace_name']); |
|
122 test ('Save test settings ', dsl (function () { |
|
123 elt ('#settings input[type="submit"]').click (); |
|
124 browser.waitForPageLoad (); |
|
125 })); |
|
126 test_page_loading ('/settings/', 'Settings'); |
|
127 test_text ('#content h1.main_title a[href="/"]', t['#id_workspace_name']); |
|
128 test_page_loading ('/settings/design/', 'Settings'); |
|
129 test_fill_design (t); |
|
130 test ('Save test design settings ', dsl (function () { |
|
131 elt ('#settings input[type="submit"]').click (); |
|
132 browser.waitForPageLoad (); |
|
133 })); |
|
134 }); |
|
135 |
|
136 suite ('admin dashboard page conformity', function () { |
|
137 test_page_loading ('/', 'Dashboard\n - '+t['#id_workspace_name']); |
|
92 test_logged_header (w.USER_ADMIN); |
138 test_logged_header (w.USER_ADMIN); |
93 test ('get text and user nb', dsl(function () { |
139 test ('get text and user nb', dsl(function () { |
94 element ('span.metadata:eq(0)').text (function (metadata) { |
140 element ('span.metadata:eq(0)').text (function (metadata) { |
95 var r = metadata.match (/(\d+) texts, (\d+) users/); |
141 var r = metadata.match (/(\d+) texts, (\d+) users/); |
96 if (r.length != 3) throw 'expected 3 matches got '+r.length; |
142 if (r.length != 3) throw 'expected 3 matches got '+r.length; |
97 text_nb = r[1]; |
143 z.text_nb = r[1]; |
98 user_nb = r[2]; |
144 z.user_nb = r[2]; |
99 }); |
145 }); |
100 })); |
146 })); |
101 test_default_tabs (); |
147 test_default_tabs (); |
102 test_count ('table.dash_table', 5); |
148 test_count ('table.dash_table', 5); |
103 test_text ('table.dash_table th:eq(0)', 'Actions'); |
149 test_text ('table.dash_table th:eq(0)', 'Actions'); |
119 test_text ('table.dash_table:eq(3) a:eq(1)[href="?span=day"]', '24 hours'); |
165 test_text ('table.dash_table:eq(3) a:eq(1)[href="?span=day"]', '24 hours'); |
120 test_text ('table.dash_table th:eq(4) span.em', 'Activities'); |
166 test_text ('table.dash_table th:eq(4) span.em', 'Activities'); |
121 test_unlogged_footer (); |
167 test_unlogged_footer (); |
122 }); |
168 }); |
123 |
169 |
124 suite ('texts list', function () { |
170 suite ('texts list page conformity', function () { |
125 test_page_loading ('/text/', 'Texts'); |
171 test_page_loading ('/text/', 'Texts\n - '+t['#id_workspace_name']); |
126 test_logged_header (w.USER_ADMIN); |
172 test_logged_header (w.USER_ADMIN); |
127 test_default_tabs (); |
173 test_default_tabs (); |
128 test_count ('#text ul.sub_list:eq(0) a', 3); |
174 test_count ('#text ul.sub_list:eq(0) a', 3); |
129 test_text ('#text ul.sub_list:eq(0) a:eq(0)[href="/create/content/"]', 'Create a text'); |
175 test_text ('#text ul.sub_list:eq(0) a:eq(0)[href="/create/content/"]', 'Create a text'); |
130 test_text ('#text ul.sub_list:eq(0) a:eq(1)[href="/create/upload/"]', 'Upload a text'); |
176 test_text ('#text ul.sub_list:eq(0) a:eq(1)[href="/create/upload/"]', 'Upload a text'); |
131 test_text ('#text ul.sub_list:eq(0) a:eq(2)[href="/create/import/"]', 'Import a co-mented text'); |
177 test_text ('#text ul.sub_list:eq(0) a:eq(2)[href="/create/import/"]', 'Import a co-mented text'); |
132 // TOTEST : filter by tag |
178 // TOTEST : filter by tag |
133 test_count ('form#filter_form[action="."] :input', 1); |
179 test_count ('form#filter_form[action="."] :input', 1); |
134 test_text ('select#tag_selected option:eq(0)[selected][value="0"]', '- All -', non_visible); |
180 test_text ('select#tag_selected option:eq(0)[selected][value="0"]', '- All -', non_visible); |
135 test ('#texts_form input count', dsl (function () { |
181 test ('#texts_form input count', dsl (function () { |
136 elt ('form#texts_form[action="."] :input').count (function (c) { |
182 elt ('form#texts_form[action="."] :input').count (function (c) { |
137 var n = 3 + text_nb % 10; |
183 var n = 3 + z.text_nb % 10; |
138 if (c != n) throw 'expected computed '+n+' to equal got '+c; |
184 if (c != n) throw 'expected computed '+n+' to equal got '+c; |
139 }); |
185 }); |
140 })); |
186 })); |
141 test ('#paginator "of #" value', dsl (function () { |
187 test ('#paginator "of #" value', dsl (function () { |
142 elt ('span#paginator').text (function (t) { |
188 elt ('span#paginator').text (function (t) { |
143 var r = t.match (/\s\d+-\d+ of (\d+)\s/m); |
189 var r = t.match (/\s\d+-\d+ of (\d+)\s/m); |
144 if (r.length != 2) throw 'expected 2 matches got '+r.length; |
190 if (r.length != 2) throw 'expected 2 matches got '+r.length; |
145 if (r[1] != text_nb) throw 'expected paginator total ('+r[1]+') to be '+text_nb; |
191 if (r[1] != z.text_nb) throw 'expected paginator total ('+r[1]+') to be '+z.text_nb; |
146 }); |
192 }); |
147 })); |
193 })); |
148 // TOTEST : pagination |
194 // TOTEST : pagination |
149 // TOTEST : Bulk Actions -> Apply does enable |
195 // TOTEST : Bulk Actions -> Apply does enable |
150 test_text ('select#bulk_actions option:eq(0)[selected][value="-1"]', 'Bulk Actions', non_visible); |
196 test_text ('select#bulk_actions option:eq(0)[selected][value="-1"]', 'Bulk Actions', non_visible); |
158 test_text ('table.large_table:eq(1) th:eq(4)', '# comments'); |
204 test_text ('table.large_table:eq(1) th:eq(4)', '# comments'); |
159 test_text ('table.large_table:eq(1) th:eq(5)', 'Last week activity'); |
205 test_text ('table.large_table:eq(1) th:eq(5)', 'Last week activity'); |
160 test_unlogged_footer (); |
206 test_unlogged_footer (); |
161 }); |
207 }); |
162 |
208 |
163 suite ('followup', function () { |
209 suite ('create a text page conformity', function () { |
164 test_logged_header (w.USER_ADMIN); |
210 test_page_loading ('/create/content/', 'Create a text - '+t['#id_workspace_name']); |
165 test_default_tabs (); |
211 test_logged_header (w.USER_ADMIN); |
166 test_page_loading ('/followup/', 'Followup'); |
212 test_default_tabs (); |
213 test_count ('#text ul.sub_list:eq(0) a', 3); |
|
214 test_text ('#text ul.sub_list:eq(0) a:eq(0)[href="/text/"]', 'Text list'); |
|
215 test_text ('#text ul.sub_list:eq(0) a:eq(1)[href="/create/upload/"]', 'Upload a text'); |
|
216 test_text ('#text ul.sub_list:eq(0) a:eq(2)[href="/create/import/"]', 'Import a co-mented text'); |
|
217 test_count ('#text form[action="."]:eq(0) :input', 6); |
|
218 test_form_field ('text', 'id_title', 'text', 0, 'Title', true); |
|
219 test_form_field ('text', 'id_format', 'select', 1, 'Format', true); |
|
220 test_form_field ('text', 'id_content', 'textarea', 2, 'Content', true); |
|
221 test_form_field ('text', 'id_tags', 'text', 3, 'Tags'); |
|
222 test_val ('#text :input:eq(4)[type=submit]', 'Save'); |
|
223 test_val ('#text :input:eq(5)#cancel_button[type=button]', 'Cancel'); |
|
224 test_count ('select#id_format option', 3); |
|
225 test_text ('select#id_format option:eq(0)[value="markdown"][selected]', 'markdown', non_visible); |
|
226 test_text ('select#id_format option:eq(1)[value="rst"]', 'rst', non_visible); |
|
227 test_text ('select#id_format option:eq(2)[value="html"]', 'html', non_visible); |
|
228 test_count ('#markItUpId_content li', 20); |
|
229 test_unlogged_footer (); |
|
230 }); |
|
231 |
|
232 suite ('upload text page conformity', function () { |
|
233 test_page_loading ('/create/upload/', 'Upload a text - '+t['#id_workspace_name']); |
|
234 test_logged_header (w.USER_ADMIN); |
|
235 test_default_tabs (); |
|
236 test_count ('#text ul.sub_list:eq(0) a', 3); |
|
237 test_text ('#text ul.sub_list:eq(0) a:eq(0)[href="/text/"]', 'Text list'); |
|
238 test_text ('#text ul.sub_list:eq(0) a:eq(1)[href="/create/content/"]', 'Create a text'); |
|
239 test_text ('#text ul.sub_list:eq(0) a:eq(2)[href="/create/import/"]', 'Import a co-mented text'); |
|
240 test_count ('#text form[action="."]:eq(0) :input', 6); |
|
241 test_form_field ('text', 'id_title', 'text', 0, 'Title'); |
|
242 test_form_field ('text', 'id_format', 'select', 1, 'Format', true); |
|
243 test_form_field ('text', 'id_tags', 'text', 2, 'Tags'); |
|
244 test_form_field ('text', 'id_file', 'file', 3, 'Upload file (optional)'); |
|
245 test_val ('#text :input:eq(4)[type=submit]', 'Save'); |
|
246 test_val ('#text :input:eq(5)#cancel_button[type=button]', 'Cancel'); |
|
247 test_count ('select#id_format option', 3); |
|
248 test_text ('select#id_format option:eq(0)[value="markdown"][selected]', 'markdown', non_visible); |
|
249 test_text ('select#id_format option:eq(1)[value="rst"]', 'rst', non_visible); |
|
250 test_text ('select#id_format option:eq(2)[value="html"]', 'html', non_visible); |
|
251 test_unlogged_footer (); |
|
252 }); |
|
253 |
|
254 suite ('import a co-mented text page conformity', function () { |
|
255 test_page_loading ('/create/import/', 'Import a co-mented text - '+t['#id_workspace_name']); |
|
256 test_logged_header (w.USER_ADMIN); |
|
257 test_default_tabs (); |
|
258 test_count ('#text ul.sub_list:eq(0) a', 3); |
|
259 test_text ('#text ul.sub_list:eq(0) a:eq(0)[href="/text/"]', 'Text list'); |
|
260 test_text ('#text ul.sub_list:eq(0) a:eq(1)[href="/create/content/"]', 'Create a text'); |
|
261 test_text ('#text ul.sub_list:eq(0) a:eq(2)[href="/create/upload/"]', 'Upload a text'); |
|
262 test_count ('#text form[action="."]:eq(0) :input', 3); |
|
263 test_form_field ('text', 'id_file', 'file', 0, 'Upload XML file', true); |
|
264 test_val ('#text :input:eq(1)[type=submit]', 'Save'); |
|
265 test_val ('#text :input:eq(2)#cancel_button[type=button]', 'Cancel'); |
|
266 test_unlogged_footer (); |
|
267 }); |
|
268 |
|
269 suite ('edit profile page conformity', function () { |
|
270 test_page_loading ('/profile/', 'Your profile [(]'+w.USER_ADMIN+'[)]\n - '+t['#id_workspace_name']); |
|
271 test_logged_header (w.USER_ADMIN, no_tagline); |
|
272 test_count ('#content ul.sub_list:eq(0) a', 1); |
|
273 test_text ('#content ul.sub_list:eq(0) a:eq(0)[href="/profile-pw/"]', 'Password'); |
|
274 test_count ('form#profile[action="."]:eq(0) :input', 5); |
|
275 test_form_field ('profile', 'id_email', 'text', 0, 'E-mail address', true); |
|
276 test_form_field ('profile', 'id_first_name','text', 1, 'First name'); |
|
277 test_form_field ('profile', 'id_last_name', 'text', 2, 'Last name'); |
|
278 test_form_field ('profile', 'id_tags', 'text', 3, 'Tags'); |
|
279 test_val ('#profile :input:eq(4)[type=submit]', 'Save'); |
|
280 test_unlogged_footer (); |
|
281 }); |
|
282 |
|
283 suite ('edit password page conformity', function () { |
|
284 test_page_loading ('/profile-pw/', 'Your profile [(]'+w.USER_ADMIN+'[)]\n - '+t['#id_workspace_name']); |
|
285 test_logged_header (w.USER_ADMIN, no_tagline); |
|
286 test_count ('#content ul.sub_list:eq(0) a', 1); |
|
287 test_text ('#content ul.sub_list:eq(0) a:eq(0)[href="/profile/"]', 'Profile'); |
|
288 test_count ('form#profile[action="."]:eq(0) :input', 4); |
|
289 test_form_field ('profile', 'id_old_password', 'password', 0, 'Old password', true); |
|
290 test_form_field ('profile', 'id_new_password1', 'password', 1, 'New password', true); |
|
291 test_form_field ('profile', 'id_new_password2', 'password', 2, 'New password confirmation', true); |
|
292 test_val ('#profile :input:eq(3)[type=submit]', 'Save'); |
|
293 test_unlogged_footer (); |
|
294 }); |
|
295 |
|
296 suite ('people list page conformity', function () { |
|
297 test_page_loading ('/user/', 'People\' list\n - '+t['#id_workspace_name']); |
|
298 test_logged_header (w.USER_ADMIN); |
|
299 test_default_tabs (); |
|
300 test_count ('#user ul.sub_list:eq(0) a', 2); |
|
301 test_text ('#user ul.sub_list:eq(0) a:eq(0)[href="/user/add/"]', 'Add a new user'); |
|
302 test_text ('#user ul.sub_list:eq(0) a:eq(1)[href="/user/mass-add/"]', 'Add users in bulk'); |
|
303 // TOTEST : filter by tag |
|
304 test_count ('form#filter_form[action="."] :input', 1); |
|
305 test_text ('#filter_form a[href="?display=1"]', 'Display suspended users'); |
|
306 test_text ('select#tag_selected option:eq(0)[selected][value="0"]', '- All -', non_visible); |
|
307 // TOTEST : pagination |
|
308 // TOTEST : Bulk Actions -> Apply does enable |
|
309 test_text ('select#bulk_actions option:eq(0)[selected][value="-1"]', '- Bulk Actions -', non_visible); |
|
310 test_text ('select#bulk_actions option:eq(1)[value="disable"]', 'Suspend access', non_visible); |
|
311 test_text ('select#bulk_actions option:eq(2)[value="enable"]', 'Enable access', non_visible); |
|
312 test_text ('select#bulk_actions option:eq(3)[value="role_1"]', 'Change role to Manager', non_visible); |
|
313 test_text ('select#bulk_actions option:eq(4)[value="role_2"]', 'Change role to Editor', non_visible); |
|
314 test_text ('select#bulk_actions option:eq(5)[value="role_3"]', 'Change role to Moderator', non_visible); |
|
315 test_text ('select#bulk_actions option:eq(6)[value="role_4"]', 'Change role to Commentator', non_visible); |
|
316 test_text ('select#bulk_actions option:eq(7)[value="role_5"]', 'Change role to Observer', non_visible); |
|
317 test_val ('form#user_form input#apply[type=button][disabled]', 'Apply'); |
|
318 test_count ('table.large_table:eq(1) th', 6); |
|
319 test_val ('table.large_table:eq(1) th:eq(0) input#all_check[type="checkbox"]', 'on'); |
|
320 test_text ('table.large_table:eq(1) th:eq(1) a[href="?order=user__username"]', 'User'); |
|
321 test_text ('table.large_table:eq(1) th:eq(2) a[href="?order=user__email"]', 'Email'); |
|
322 test_text ('table.large_table:eq(1) th:eq(3) a[href="?order=-user__date_joined"]', 'Date joined'); |
|
323 test_text ('table.large_table:eq(1) th:eq(4) a[href="?order=role__name"]', 'Role'); |
|
324 test_text ('table.large_table:eq(1) th:eq(5)', 'Last week activity'); |
|
325 test_text ('table.large_table:eq(1) tr:last a[href="/user/-/edit/"]', 'Anonymous users'); |
|
326 test_text ('table.large_table:eq(1) a.main_object_title[href="/profile/"]', w.USER_ADMIN); |
|
327 test_text ('table.large_table:eq(1) div.hidden-user-actions a[href="/profile/"]', 'Your profile'); |
|
328 test_unlogged_footer (); |
|
329 }); |
|
330 |
|
331 suite ('check user number', function () { |
|
332 test_page_loading ('/user/?display=1', 'People\' list\n - '+t['#id_workspace_name']); |
|
333 test ('#user_form input count', dsl (function () { |
|
334 elt ('form#user_form[action="."] :input').count (function (c) { |
|
335 var n = 6 + (z.user_nb % 10) * 2; |
|
336 if (c != n) throw 'expected computed '+n+' to equal got '+c; |
|
337 }); |
|
338 })); |
|
339 test ('#paginator "of #" value', dsl (function () { |
|
340 elt ('span#paginator').text (function (t) { |
|
341 var r = t.match (/\s\d+-\d+ of (\d+)\s/m); |
|
342 if (r.length != 2) throw 'expected 2 matches got '+r.length; |
|
343 if (r[1] != z.user_nb) throw 'expected paginator total ('+r[1]+') to be '+z.user_nb; |
|
344 }); |
|
345 })); |
|
346 }); |
|
347 |
|
348 suite ('add a user page conformity', function () { |
|
349 test_page_loading ('/user/add/', 'Add a new user\n - '+t['#id_workspace_name']); |
|
350 test_logged_header (w.USER_ADMIN); |
|
351 test_default_tabs (); |
|
352 test_count ('#user ul.sub_list:eq(0) a', 2); |
|
353 test_text ('#user ul.sub_list:eq(0) a:eq(0)[href="/user/"]', 'Users\' list'); |
|
354 test_text ('#user ul.sub_list:eq(0) a:eq(1)[href="/user/mass-add/"]', 'Add users in bulk'); |
|
355 test_count ('#user form[action="."]:eq(0) :input', 8); |
|
356 test_form_field ('user', 'id_email', 'text', 0, 'E-mail address', true); |
|
357 test_form_field ('user', 'id_first_name', 'text', 1, 'First name'); |
|
358 test_form_field ('user', 'id_last_name', 'text', 2, 'Last name'); |
|
359 test_form_field ('user', 'id_tags', 'text', 3, 'Tags'); |
|
360 test_form_field ('user', 'id_role', 'select', 4, 'Workspace level role'); |
|
361 test_form_field ('user', 'id_note', 'textarea', 5, 'Note'); |
|
362 test_count ('select#id_role option', 6); |
|
363 test_text ('select#id_role option:eq(0)[value][selected]', '---------', non_visible); |
|
364 test_text ('select#id_role option:eq(1)[value="1"]', 'Manager', non_visible); |
|
365 test_text ('select#id_role option:eq(2)[value="2"]', 'Editor', non_visible); |
|
366 test_text ('select#id_role option:eq(3)[value="3"]', 'Moderator', non_visible); |
|
367 test_text ('select#id_role option:eq(4)[value="4"]', 'Commentator', non_visible); |
|
368 test_text ('select#id_role option:eq(5)[value="5"]', 'Observer', non_visible); |
|
369 test_val ('#user :input:eq(6)[type=submit]', 'Add user'); |
|
370 test_val ('#user :input:eq(7)#cancel_button[type=button]', 'Cancel'); |
|
371 test_unlogged_footer (); |
|
372 // TOTEST add user (pending) |
|
373 }); |
|
374 |
|
375 suite ('add users in bulk page conformity', function () { |
|
376 test_page_loading ('/user/mass-add/', 'Add users in bulk\n - '+t['#id_workspace_name']); |
|
377 test_logged_header (w.USER_ADMIN); |
|
378 test_default_tabs (); |
|
379 test_count ('#user ul.sub_list:eq(0) a', 2); |
|
380 test_text ('#user ul.sub_list:eq(0) a:eq(0)[href="/user/"]', 'Users\' list'); |
|
381 test_text ('#user ul.sub_list:eq(0) a:eq(1)[href="/user/add/"]', 'Add a new user'); |
|
382 test_count ('#user form[action="."]:eq(0) :input', 6); |
|
383 test_form_field ('user', 'id_email', 'textarea', 0, 'Emails', true); |
|
384 test_form_field ('user', 'id_tags', 'text', 1, 'Tags'); |
|
385 test_form_field ('user', 'id_role', 'select', 2, 'Workspace level role'); |
|
386 test_form_field ('user', 'id_note', 'textarea', 3, 'Note'); |
|
387 test_count ('select#id_role option', 6); |
|
388 test_text ('select#id_role option:eq(0)[value][selected]', '---------', non_visible); |
|
389 test_text ('select#id_role option:eq(1)[value="1"]', 'Manager', non_visible); |
|
390 test_text ('select#id_role option:eq(2)[value="2"]', 'Editor', non_visible); |
|
391 test_text ('select#id_role option:eq(3)[value="3"]', 'Moderator', non_visible); |
|
392 test_text ('select#id_role option:eq(4)[value="4"]', 'Commentator', non_visible); |
|
393 test_text ('select#id_role option:eq(5)[value="5"]', 'Observer', non_visible); |
|
394 test_val ('#user :input:eq(4)[type=submit]', 'Add users'); |
|
395 test_val ('#user :input:eq(5)#cancel_button[type=button]', 'Cancel'); |
|
396 // X TOTEST add users (pending) -> can't be deleted |
|
397 test_unlogged_footer (); |
|
398 }); |
|
399 |
|
400 suite ('settings page conformity', function () { |
|
401 test_page_loading ('/settings/', 'Settings - '+t['#id_workspace_name']); |
|
402 test_logged_header (w.USER_ADMIN); |
|
403 test_default_tabs (); |
|
404 test_count ('#settings ul.sub_list:eq(0) a', 1); |
|
405 test_text ('#settings ul.sub_list:eq(0) a:eq(0)[href="/settings/design/"]', 'Appearance'); |
|
406 test_count ('#settings form[action="."]:eq(0) :input', 12); |
|
407 test_form_field ('settings', 'id_workspace_name', 'text', 0, 'Workspace name'); |
|
408 test_form_field ('settings', 'id_workspace_tagline', 'text', 1, 'Workspace tagline'); |
|
409 test_form_field ('settings', 'id_workspace_registration', 'checkbox', 2, 'Workspace registration'); |
|
410 test_form_field ('settings', 'id_workspace_registration_moderation', 'checkbox', 3, 'Workspace registration moderation'); |
|
411 test_form_field ('settings', 'id_workspace_role_model', 'select', 4, 'Role model'); |
|
412 test_text ('select#id_workspace_role_model option:eq(0)[selected][value="generic"]', 'Generic', non_visible); |
|
413 test_text ('select#id_workspace_role_model option:eq(1)[value="teacher"]', 'Class (education)', non_visible); |
|
414 test_form_field ('settings', 'id_workspace_category_1', 'text', 5, 'Label for the first category of comments'); |
|
415 test_form_field ('settings', 'id_workspace_category_2', 'text', 6, 'Label for the second category of comments'); |
|
416 test_form_field ('settings', 'id_workspace_category_3', 'text', 7, 'Label for the third category of comments'); |
|
417 test_form_field ('settings', 'id_workspace_category_4', 'text', 8, 'Label for the fourth category of comments'); |
|
418 test_form_field ('settings', 'id_workspace_category_5', 'text', 9, 'Label for the fifth category of comments'); |
|
419 test_val ('#settings :input:eq(10)[type=submit]', 'Save'); |
|
420 test_val ('#settings :input:eq(11)#cancel_button[type=button]', 'Cancel'); |
|
421 // TOTEST Workspace registration |
|
422 test_unlogged_footer (); |
|
423 }); |
|
424 |
|
425 suite ('settings design page conformity', function () { |
|
426 test_page_loading ('/settings/design/', 'Settings - '+t['#id_workspace_name']); |
|
427 test_logged_header (w.USER_ADMIN); |
|
428 test_default_tabs (); |
|
429 test_count ('#settings ul.sub_list:eq(0) a', 1); |
|
430 test_text ('#settings ul.sub_list:eq(0) a:eq(0)[href="/settings/"]', 'General'); |
|
431 test_count ('#settings form[action="."]:eq(0) :input', 7); |
|
432 test_form_field ('settings', 'id_workspace_logo_file', 'file', 0, 'Workspace logo'); |
|
433 test_form_field ('settings', 'id_custom_css', 'textarea', 1, 'Custom CSS rules'); |
|
434 test_form_field ('settings', 'id_custom_font', 'text', 2, 'Custom font'); |
|
435 test_form_field ('settings', 'id_custom_titles_font', 'text', 3, 'Custom font for titles'); |
|
436 test_val ('#settings :input:eq(4)[type=submit]', 'Save'); |
|
437 test_val ('#settings :input:eq(5)#cancel_button[type=button]', 'Cancel'); |
|
438 test_val ('#settings :input:eq(6)#delete_logo_button[type=submit]', 'Delete logo'); |
|
439 // TOTEST custom CSS, font, font for titles like the rest of the settings |
|
440 test_unlogged_footer (); |
|
441 }); |
|
442 |
|
443 suite ('followup page conformity', function () { |
|
444 test_page_loading ('/followup/', 'Followup\n - '+t['#id_workspace_name']); |
|
445 test_logged_header (w.USER_ADMIN); |
|
446 test_default_tabs (); |
|
167 test_text ('#followup a:eq(0)[href="/help/#public_private_feed"]', '?'); |
447 test_text ('#followup a:eq(0)[href="/help/#public_private_feed"]', '?'); |
168 test_match ('#followup a:eq(1)[href$="/feed/"]', new RegExp (w.WORKSPACE_URL+'feed/', 'm')); |
448 test_match ('#followup a:eq(1)[href$="/feed/"]', new RegExp (w.WORKSPACE_URL+'feed/', 'm')); |
169 test_text ('#followup a:eq(2)[href="/help/#public_private_feed"]', '?'); |
449 test_text ('#followup a:eq(2)[href="/help/#public_private_feed"]', '?'); |
170 test_count ('form#followup_form[action="."] :input', 3); |
450 test_count ('form#followup_form[action="."] :input', 3); |
171 test_val ('form#followup_form input[type=submit]', '(Activate private feed|Reset private feed url)'); |
451 test_val ('form#followup_form input[type=submit]', '(Activate private feed|Reset private feed url)'); |
175 // tester qu'une fois cliqué, le bouton à le nvo label, et qu'une adresse est disponible |
455 // tester qu'une fois cliqué, le bouton à le nvo label, et qu'une adresse est disponible |
176 // tester que si on reclique l'adresse est changée |
456 // tester que si on reclique l'adresse est changée |
177 |
457 |
178 test_unlogged_footer (); |
458 test_unlogged_footer (); |
179 }); |
459 }); |
460 |
|
461 suite ('settings restoration', function () { |
|
462 test_page_loading ('/settings/', 'Settings'); |
|
463 test_fill_settings (z); |
|
464 test ('Restore settings ', dsl (function () { |
|
465 elt ('#settings input[type="submit"]').click (); |
|
466 browser.waitForPageLoad (); |
|
467 })); |
|
468 test_page_loading ('/settings/design/', 'Settings'); |
|
469 test_fill_design (z); |
|
470 test ('Restore design settings ', dsl (function () { |
|
471 elt ('#settings input[type="submit"]').click (); |
|
472 browser.waitForPageLoad (); |
|
473 })); |
|
474 // next instruction must be a page loading |
|
475 // test_page_loading ('/settings/', 'Settings'); |
|
476 }); |
|
477 |
|
180 }); |
478 }); |
181 |
479 |
182 function test_default_tabs () { |
480 function test_default_tabs () { |
183 test_count ('#main-tabs a', 5); |
481 test_count ('#main-tabs a', 5); |
184 test_text ('#main-tabs li:nth-of-type(1) a[href="/"]', 'Dashboard'); |
482 test_text ('#main-tabs li:nth-of-type(1) a[href="/"]', 'Dashboard'); |
188 test_text ('#main-tabs li:nth-of-type(5) a[href="/followup/"]', 'Followup'); |
486 test_text ('#main-tabs li:nth-of-type(5) a[href="/followup/"]', 'Followup'); |
189 test ('right tab nb', dsl(function () { |
487 test ('right tab nb', dsl(function () { |
190 elt ('#main-tabs a[href="/text/"]').text (function (t) { |
488 elt ('#main-tabs a[href="/text/"]').text (function (t) { |
191 var r = t.match (/^Texts \((\d+)\) $/); |
489 var r = t.match (/^Texts \((\d+)\) $/); |
192 if (r.length != 2) throw 'for Texts expected 2 matches got '+r.length; |
490 if (r.length != 2) throw 'for Texts expected 2 matches got '+r.length; |
193 if (text_nb != r[1]) throw 'expected tab text nb ('+r[1]+') to be '+text_nb; |
491 if (z.text_nb != r[1]) throw 'expected tab text nb ('+r[1]+') to be '+z.text_nb; |
194 }); |
492 }); |
195 elt ('#main-tabs a[href="/user/"]').text (function (t) { |
493 elt ('#main-tabs a[href="/user/"]').text (function (t) { |
196 var r = t.match (/^People \((\d+)\)$/); |
494 var r = t.match (/^People \((\d+)\)$/); |
197 if (r.length != 2) throw 'for People expected 2 matches got '+r.length; |
495 if (r.length != 2) throw 'for People expected 2 matches got '+r.length; |
198 if (user_nb != r[1]) throw 'expected tab people nb ('+r[1]+') to be '+user_nb; |
496 if (z.user_nb != r[1]) throw 'expected tab people nb ('+r[1]+') to be '+z.user_nb; |
199 }); |
497 }); |
200 })); |
498 })); |
201 } |
499 } |
202 |
500 |
203 function test_logged_header (username) { |
501 function test_logged_header (username, is_tagline) { |
502 is_tagline = typeof is_tagline == 'undefined' ? true : is_tagline; |
|
503 |
|
204 test_text ('#header_controls b', username) |
504 test_text ('#header_controls b', username) |
205 test_count ('#header_controls a', 6); |
505 test_count ('#header_controls a', 6); |
206 test_text ('#header_controls a:nth-of-type(1)[href="/"]', 'Home'); |
506 test_text ('#header_controls a:nth-of-type(1)[href="/"]', 'Home'); |
207 test_text ('#header_controls a:nth-of-type(2)[href="/create/content/"]', 'Create a text'); |
507 test_text ('#header_controls a:nth-of-type(2)[href="/create/content/"]', 'Create a text'); |
208 test_text ('#header_controls a:nth-of-type(3)[href="/create/upload/"]', 'Upload a text'); |
508 test_text ('#header_controls a:nth-of-type(3)[href="/create/upload/"]', 'Upload a text'); |
209 test_text ('#header_controls a:nth-of-type(4)[href="/create/import/"]', 'Import a co-mented text'); |
509 test_text ('#header_controls a:nth-of-type(4)[href="/create/import/"]', 'Import a co-mented text'); |
210 test_text ('#header_controls a:nth-of-type(5)[href="/profile/"]', 'Profile'); |
510 test_text ('#header_controls a:nth-of-type(5)[href="/profile/"]', 'Profile'); |
211 test_text ('#header_controls a:nth-of-type(6)[href="/logout/"]', 'Logout'); |
511 test_text ('#header_controls a:nth-of-type(6)[href="/logout/"]', 'Logout'); |
512 test_text ('#content h1.main_title a[href="/"]', t['#id_workspace_name']); |
|
513 |
|
514 if (is_tagline) { |
|
515 test_match ('#content h1.main_title + div', new RegExp (t['#id_workspace_tagline'], 'm')); |
|
516 } |
|
212 } |
517 } |
213 |
518 |
214 function test_unlogged_header () { |
519 function test_unlogged_header () { |
215 test_count ('#header_controls a', 2); |
520 test_count ('#header_controls a', 2); |
216 test_text ('#header_controls a[href="/"]', 'Home'); |
521 test_text ('#header_controls a[href="/"]', 'Home'); |
302 |
607 |
303 /** Test Django form field presence |
608 /** Test Django form field presence |
304 */ |
609 */ |
305 function test_form_field (form_id, field_id, type, position, label, mandatory) { |
610 function test_form_field (form_id, field_id, type, position, label, mandatory) { |
306 test ('has a '+label+' form field', dsl(function () { |
611 test ('has a '+label+' form field', dsl(function () { |
307 var s = type == 'textarea' ? 'textarea#'+field_id : 'input#'+field_id+'[type='+type+']'; |
612 var s = ''; |
613 switch (type) { |
|
614 case 'textarea':s = 'textarea#'+field_id; break; |
|
615 case 'select': s = 'select#'+field_id; break; |
|
616 default: s = 'input#'+field_id+'[type="'+type+'"]'; |
|
617 } |
|
618 // var s = type == 'textarea' ? 'textarea#'+field_id : 'input#'+field_id+'[type='+type+']'; |
|
308 expect (elt (s).val ()).toBeDefined (); |
619 expect (elt (s).val ()).toBeDefined (); |
309 expect (elt ('#'+form_id+' :input:eq('+position+')#'+field_id).val ()).toBeDefined (); |
620 expect (elt ('#'+form_id+' :input:eq('+position+')#'+field_id).val ()).toBeDefined (); |
310 expect (elt ('label[for='+field_id+']').text ()).toBe (label); |
621 expect (elt ('label[for='+field_id+']').text ()).toBe (label); |
311 |
622 |
312 if (mandatory) |
623 if (mandatory) |
313 expect (elt ('label[for='+field_id+'] + span.required_star').val ()).toBeDefined (); |
624 expect (elt ('label[for='+field_id+'] + span.required_star').val ()).toBeDefined (); |
314 })); |
625 })); |
626 } |
|
627 |
|
628 function test_readz_field (field_id) { |
|
629 test ('get '+field_id, dsl(function () { |
|
630 element (field_id).val (function (v) { |
|
631 z[field_id] = v; |
|
632 }); |
|
633 })); |
|
634 } |
|
635 |
|
636 function test_fill_field (field_id, stored) { |
|
637 test ('set '+field_id, dsl(function () { |
|
638 input (field_id).enter (stored[field_id]); |
|
639 })); |
|
640 } |
|
641 |
|
642 function test_fill_settings (s) { |
|
643 test_fill_field ('#id_workspace_name', s); |
|
644 test_fill_field ('#id_workspace_tagline', s); |
|
645 test_fill_field ('#id_workspace_registration', s); |
|
646 test_fill_field ('#id_workspace_registration_moderation', s); |
|
647 test_fill_field ('#id_workspace_role_model', s); |
|
648 test_fill_field ('#id_workspace_category_1', s); |
|
649 test_fill_field ('#id_workspace_category_2', s); |
|
650 test_fill_field ('#id_workspace_category_3', s); |
|
651 test_fill_field ('#id_workspace_category_4', s); |
|
652 test_fill_field ('#id_workspace_category_5', s); |
|
653 } |
|
654 |
|
655 function test_fill_design (s) { |
|
656 test_fill_field ('#id_custom_css', s); |
|
657 test_fill_field ('#id_custom_font', s); |
|
658 test_fill_field ('#id_custom_titles_font', s); |
|
315 } |
659 } |
316 |
660 |
317 /** Ensure the given element is visible |
661 /** Ensure the given element is visible |
318 * s : CSS selector of the DOM element to check |
662 * s : CSS selector of the DOM element to check |
319 * v : should the element being visible |
663 * v : should the element being visible |