23 suite ('contact page', function () { |
23 suite ('contact page', function () { |
24 test_page_loading ('/contact/', 'Contact'); |
24 test_page_loading ('/contact/', 'Contact'); |
25 test_unlogged_header (); |
25 test_unlogged_header (); |
26 test_val ('form#profile[action="."]'); // the form exists |
26 test_val ('form#profile[action="."]'); // the form exists |
27 test_count ('form#profile .label', 5); // it has no more than 5 labels (may be no more fields) |
27 test_count ('form#profile .label', 5); // it has no more than 5 labels (may be no more fields) |
28 test_form_field ('id_name', 'text', 'Your name', true); // the field id_name is… |
28 test_form_field ('profile', 'id_name', 'text', 0, 'Your name', true); // the field id_name is… |
29 test_form_field ('id_email', 'text', 'Your email address', true); |
29 test_form_field ('profile', 'id_email', 'text', 1, 'Your email address', true); |
30 test_form_field ('id_title', 'text', 'Subject of the message', true); |
30 test_form_field ('profile', 'id_title', 'text', 2, 'Subject of the message', true); |
31 test_form_field ('id_body', 'textarea', 'Body of the message', true); |
31 test_form_field ('profile', 'id_body', 'textarea', 3, 'Body of the message', true); |
32 test_form_field ('id_copy', 'checkbox', 'Send me a copy of the email', false); |
32 test_form_field ('profile', 'id_copy', 'checkbox', 4, 'Send me a copy of the email', false); |
33 test_val ('#profile input[type=submit]','Send'); // test that a the .val() of the element is |
33 test_val ('#profile input[type=submit]','Send'); // test that a the .val() of the element is |
34 test_val ('input#cancel_button[type=button]', 'Cancel'); |
34 test_val ('input#cancel_button[type=button]', 'Cancel'); |
35 test_unlogged_footer (); |
35 test_unlogged_footer (); |
36 test ('to check that toBeDefined test still works', dsl(function () { |
36 test ('to check that toBeDefined test still works', dsl(function () { |
37 expect (elt ('#header_controls a[href="/xxx/"]').val ()).not ().toBeDefined (); |
37 expect (elt ('#header_controls a[href="/xxx/"]').val ()).not ().toBeDefined (); |
50 suite ('reset password page', function () { |
50 suite ('reset password page', function () { |
51 test_page_loading ('/password_reset/', 'Reset my password'); |
51 test_page_loading ('/password_reset/', 'Reset my password'); |
52 test_unlogged_header (); |
52 test_unlogged_header (); |
53 test_val ('form#profile[action="."]'); |
53 test_val ('form#profile[action="."]'); |
54 test_count ('form#profile .label', 1); |
54 test_count ('form#profile .label', 1); |
55 test_form_field ('id_email', 'text', 'E-mail', true); |
55 test_form_field ('profile', 'id_email', 'text', 1, 'E-mail', true); |
56 test_val ('#profile input[type=submit]', 'Reset my password'); |
56 test_val ('#profile input[type=submit]', 'Reset my password'); |
57 test_unlogged_footer (); |
57 test_unlogged_footer (); |
58 }); |
58 }); |
59 |
59 |
60 suite ('login page', function () { |
60 suite ('login page', function () { |
61 test_page_loading ('/', 'Home'); |
61 test_page_loading ('/', 'Home'); |
62 test_unlogged_header (); |
62 test_unlogged_header (); |
63 test_val ('form#login[action="/login/"]'); |
63 test_val ('form#login[action="/login/"]'); |
64 test_count ('form#login[action="/login/"] .label', 2); |
64 test_count ('form#login[action="/login/"] .label', 2); |
65 test_form_field ('id_username', 'text', 'Username', true); |
65 test_form_field ('login', 'id_username', 'text', 0, 'Username', true); |
66 test_form_field ('id_password', 'password', 'Password', true); |
66 test_form_field ('login', 'id_password', 'password', 1, 'Password', true); |
67 test_val ('form#login input[type=submit]', 'Login'); |
67 test_val ('form#login input[type=submit]', 'Login'); |
68 test_text ('form#login a[href="/password_reset/"]', 'Forgot password?'); |
68 test_text ('form#login a[href="/password_reset/"]', 'Forgot password?'); |
69 test_unlogged_footer (); |
69 test_unlogged_footer (); |
70 // test_i18n (); |
70 // test_i18n (); |
71 test ('logs an admin in', dsl(function () { |
71 test ('logs an admin in', dsl(function () { |
83 // Should starts with : |
83 // Should starts with : |
84 // test_page_loading ('/', 'Dashboard'); |
84 // test_page_loading ('/', 'Dashboard'); |
85 // But its the last thing we did in the previous test |
85 // But its the last thing we did in the previous test |
86 test_logged_header (w.USER_ADMIN); |
86 test_logged_header (w.USER_ADMIN); |
87 test_default_tabs (); |
87 test_default_tabs (); |
88 test_count ('table.dash_table', 5); |
88 test_count ('table.dash_table', 5); |
89 test_text ('table.dash_table th:eq(0)', 'Actions', 0); |
89 test_text ('table.dash_table th:eq(0)', 'Actions'); |
90 test_text ('table.dash_table th:eq(1)', 'Recent texts (all)', 2); |
90 test_match ('table.dash_table:eq(0) a:eq(0)[href="/create/content/"]', /\sCreate a text/); |
91 test_text ('table.dash_table th:eq(2)', 'Recent comments', 1); |
91 test_text ('table.dash_table:eq(0) a:eq(1).tip[href="#"]', ' '); |
92 test_match ('table.dash_table th:eq(3)', /^Workspace activity\n\s+\(month\/week\/24 hours\)$/m); |
92 test_match ('table.dash_table:eq(0) a:eq(2)[href="/create/upload/"]', /\sUpload a text/); |
93 test_text ('table.dash_table th:eq(4) span.em', 'Activities', 4); |
93 test_text ('table.dash_table:eq(0) a:eq(3).tip[href="#"]', ' '); |
94 test_unlogged_footer (); |
94 test_match ('table.dash_table:eq(0) a:eq(4)[href="/create/import/"]', /\sImport a co-mented text/); |
|
95 test_text ('table.dash_table:eq(0) a:eq(5).tip[href="#"]', ' '); |
|
96 test_match ('table.dash_table:eq(0) a:eq(6)[href="/user/add/"]', /\sInvite user/); |
|
97 test_match ('table.dash_table:eq(0) a:eq(7)[href="/profile/"]', /\sEdit your profile/); |
|
98 test_match ('table.dash_table:eq(0) a:eq(8)[href="/text/"]', /\sView text list/); |
|
99 test_match ('table.dash_table:eq(0) a:eq(9)[href="/settings/"]', /\sConfigure workspace/); |
|
100 test_text ('table.dash_table th:eq(1)', 'Recent texts (all)'); |
|
101 test_text ('table.dash_table:eq(1) a:eq(0)[href="/text/"]', 'all'); |
|
102 test_text ('table.dash_table th:eq(2)', 'Recent comments'); |
|
103 test_match ('table.dash_table th:eq(3)', /^Workspace activity\n\s+\(month\/week\/24 hours\)$/m); |
|
104 test_text ('table.dash_table:eq(3) a:eq(0)[href="?span=month"]', 'month'); |
|
105 test_text ('table.dash_table:eq(3) a:eq(1)[href="?span=day"]', '24 hours'); |
|
106 test_text ('table.dash_table th:eq(4) span.em', 'Activities'); |
|
107 test_unlogged_footer (); |
|
108 }); |
|
109 |
|
110 suite ('followup', function () { |
|
111 test_page_loading ('/followup/', 'Followup'); |
|
112 test_text ('#followup a:eq(0)[href="/help/#public_private_feed"]', '?'); |
|
113 test_match ('#followup a:eq(1)[href$="/feed/"]', new RegExp (w.WORKSPACE_URL+'feed/', 'm')); |
|
114 test_text ('#followup a:eq(2)[href="/help/#public_private_feed"]', '?'); |
|
115 test_count ('form#followup_form[action="."] input', 3); |
|
116 test_val ('form#followup_form input[type=submit]', '(Activate private feed|Reset private feed url)'); |
|
117 test_val ('form#followup_form input#workspace_notify_check[type=checkbox]', 'on'); |
|
118 test_val ('form#followup_form input#own_notify_check[type=checkbox]', 'on'); |
|
119 |
|
120 // tester qu'une fois cliqué, le bouton à le nvo label, et qu'une adresse est disponible |
|
121 // tester que si on reclique l'adresse est changée |
|
122 |
95 }); |
123 }); |
96 }); |
124 }); |
97 |
125 |
98 function test_default_tabs () { |
126 function test_default_tabs () { |
99 test_count ('#main-tabs a', 5); |
127 test_count ('#main-tabs a', 5); |
100 test_text ('#main-tabs li:nth-of-type(1) a[href="/"]', 'Dashboard'); |
128 test_text ('#main-tabs li:nth-of-type(1) a[href="/"]', 'Dashboard'); |
101 test_match ('#main-tabs li:nth-of-type(2) a[href="/text/"]', /^Texts \(\d+\) $/); |
129 test_match ('#main-tabs li:nth-of-type(2) a[href="/text/"]', /^Texts \(\d+\) $/); |
102 test_match ('#main-tabs li:nth-of-type(3) a[href="/user/"]', /^People \(\d+\)$/); |
130 test_match ('#main-tabs li:nth-of-type(3) a[href="/user/"]', /^People \(\d+\)$/); |
103 test_text ('#main-tabs li:nth-of-type(4) a[href="/settings/"]', 'Settings'); |
131 test_text ('#main-tabs li:nth-of-type(4) a[href="/settings/"]', 'Settings'); |
104 test_text ('#main-tabs li:nth-of-type(5) a[href="/followup/"]', 'Followup'); |
132 test_text ('#main-tabs li:nth-of-type(5) a[href="/followup/"]', 'Followup'); |
105 } |
133 } |
106 |
134 |
107 function test_logged_header (username) { |
135 function test_logged_header (username) { |
108 test_text ('#header_controls b', username) |
136 test_text ('#header_controls b', username) |
109 test_count ('#header_controls a', 6); |
137 test_count ('#header_controls a', 6); |
202 })); |
230 })); |
203 } |
231 } |
204 |
232 |
205 /** Test Django form field presence |
233 /** Test Django form field presence |
206 */ |
234 */ |
207 function test_form_field (id, type, label, mandatory) { |
235 function test_form_field (form_id, field_id, type, position, label, mandatory) { |
208 test ('has a '+label+' field', dsl(function () { |
236 test ('has a '+label+' form field', dsl(function () { |
209 var s = type == 'textarea' ? 'textarea#'+id : 'input#'+id+'[type='+type+']'; |
237 var s = type == 'textarea' ? 'textarea#'+field_id : 'input#'+field_id+'[type='+type+']'; |
210 expect (elt (s).val ()).toBeDefined (); |
238 expect (elt (s).val ()).toBeDefined (); |
211 expect (elt ('label[for='+id+']').text ()).toBe (label); |
239 expect (elt ('#'+form_id+' :input:eq('+position+')#'+field_id).val ()).toBeDefined (); |
|
240 expect (elt ('label[for='+field_id+']').text ()).toBe (label); |
212 |
241 |
213 if (mandatory) |
242 if (mandatory) |
214 expect (elt ('label[for='+id+'] + span.required_star').val ()).toBeDefined (); |
243 expect (elt ('label[for='+field_id+'] + span.required_star').val ()).toBeDefined (); |
215 })); |
244 })); |
216 } |
245 } |
217 |
246 |
218 /** Ensure the given element is visible |
247 /** Ensure the given element is visible |
219 * s : CSS selector of the DOM element to check |
248 * s : CSS selector of the DOM element to check |