|
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 k = __karma__.config, |
|
8 test_ = JSON.parse (k.t, new Function (['k','v'], k.r)); // revive helper functions sent from Karma |
|
9 |
|
10 suite ('comt unlogged prelude', function () { |
|
11 |
|
12 this.timeout(20000); |
|
13 |
|
14 suite ('contact page conformity', function () { |
|
15 test_.page_loading ('/contact/', 'Contact'); |
|
16 test_unlogged_header (); |
|
17 test_.exist ('form#profile[action="."]'); // the form exists |
|
18 test_.count ('form#profile :input', 7); // it has no more than 5 labels (may be no more fields) |
|
19 test_.field ('profile', 'id_name', 'text', 0, 'Your name', true); // the field id_name is… |
|
20 test_.field ('profile', 'id_email', 'text', 1, 'Your email address', true); |
|
21 test_.field ('profile', 'id_title', 'text', 2, 'Subject of the message', true); |
|
22 test_.field ('profile', 'id_body', 'textarea', 3, 'Body of the message', true); |
|
23 test_.field ('profile', 'id_copy', 'checkbox', 4, 'Send me a copy of the email', false); |
|
24 test_.val ('#profile input[type=submit]','Send'); // test that a the .val() of the element is |
|
25 test_.val ('input#cancel_button[type=button]', 'Cancel'); |
|
26 test_unlogged_footer (); |
|
27 test ('to check that toBeDefined test still works', dsl(function () { |
|
28 expect (test_.elt ('#header_controls a[href="/xxx/"]').val ()).not ().toBeDefined (); |
|
29 })); |
|
30 test ('get back to / to avoid bugging next page load', dsl(function () { browser.navigateTo ('/'); })); |
|
31 }); |
|
32 |
|
33 suite ('help page conformity', function () { |
|
34 test_.page_loading ('/help/', 'Help'); |
|
35 test_unlogged_header (); |
|
36 test_unlogged_footer (); |
|
37 }); |
|
38 |
|
39 suite ('can change lang', function () { |
|
40 test ('get back to / to avoid bugging next page load', dsl(function () { browser.navigateTo ('/'); })); |
|
41 test_.i18n ('fr', 'Aide'); |
|
42 test_.i18n ('en', 'Help'); |
|
43 test_.i18n ('es', 'Ayuda'); |
|
44 test_.i18n ('it', 'Aiuto'); |
|
45 test_.i18n ('de', 'Hilfe'); |
|
46 test_.i18n ('pt_BR', 'Ajuda'); |
|
47 test_.i18n ('nb', 'Hjelp'); |
|
48 test_.i18n ('bg', 'Помощ'); |
|
49 test_.i18n ('en', 'Help'); |
|
50 }); |
|
51 |
|
52 suite ('contact page mandatory field test', function () { |
|
53 test_.page_loading ('/contact/', 'Contact'); |
|
54 test_.submit('#profile input[type="submit"]'); |
|
55 test_.count ('div.help_text span.error-text', 4); |
|
56 test_.field ('profile div.error', 'id_name', 'text', 0, 'Your name', true); // the field id_name is… |
|
57 test_.field ('profile div.error', 'id_email', 'text', 1, 'Your email address', true); |
|
58 test_.field ('profile div.error', 'id_title', 'text', 2, 'Subject of the message', true); |
|
59 test_.field ('profile div.error', 'id_body', 'textarea', 3, 'Body of the message', true); |
|
60 test_.field ('profile', 'id_copy', 'checkbox', 4, 'Send me a copy of the email', false); |
|
61 }); |
|
62 |
|
63 suite ('reset password page conformity', function () { |
|
64 test_.page_loading ('/password_reset/', 'Reset my password'); |
|
65 test_unlogged_header (); |
|
66 test_.count ('form#profile :input', 3); |
|
67 test_.field ('profile', 'id_email', 'text', 1, 'E-mail', true); |
|
68 test_.val ('#profile input[type=submit]', 'Reset my password'); |
|
69 test_unlogged_footer (); |
|
70 test_.submit('#profile input[type="submit"]'); |
|
71 test_.count ('div.help_text span.error-text', 1); |
|
72 test_.field ('profile div.error', 'id_email', 'text', 0, 'E-mail', true); |
|
73 }); |
|
74 |
|
75 suite ('login page conformity', function () { |
|
76 test_.page_loading ('/', 'Home'); |
|
77 test_unlogged_header (); |
|
78 test_.count ('form#login[action="/login/"] :input', 3); |
|
79 test_.field ('login', 'id_username', 'text', 0, 'Username', true); |
|
80 test_.field ('login', 'id_password', 'password', 1, 'Password', true); |
|
81 test_.val ('form#login input[type=submit]', 'Login'); |
|
82 test_.text ('form#login a[href="/password_reset/"]', 'Forgot password?'); |
|
83 test_unlogged_footer (); |
|
84 // test_.i18n (); |
|
85 |
|
86 test ('get back to / to avoid bugging next page load', dsl(function () { |
|
87 browser.navigateTo ('/'); |
|
88 })); |
|
89 test_.page_loading ('/login/', 'Login'); |
|
90 test_.submit('#login input[type="submit"]'); |
|
91 test_.field ('login div.error', 'id_username', 'text', 0, 'Username', true); |
|
92 test_.field ('login div.error', 'id_password', 'password', 1, 'Password', true); |
|
93 }); |
|
94 }); |
|
95 |
|
96 function test_unlogged_header () { |
|
97 test_.count ('#header_controls a', 2); |
|
98 test_.text ('#header_controls a[href="/"]', 'Home'); |
|
99 test_.text ('#header_controls a[href="/login/"]', 'Login'); |
|
100 } |
|
101 |
|
102 function test_unlogged_footer (url) { |
|
103 test_.count ('#footer a', 10); |
|
104 test_.text ('#footer a:nth-of-type(1)[href="/contact/"]', 'Contact'); |
|
105 test_.match ('#footer #comentlink[href="http://www.co-ment.com"]', /Powered by/m); |
|
106 test_.text ('#footer a:nth-of-type(3)[href="/help/"]', 'Help'); |
|
107 test_.text ('#footer a:nth-of-type(4)[href="/i18n/setlang/fr/"]', 'Français'); |
|
108 test_.text ('#footer a:nth-of-type(5)[href="/i18n/setlang/es/"]', 'Español'); |
|
109 test_.text ('#footer a:nth-of-type(6)[href="/i18n/setlang/it/"]', 'Italiano'); |
|
110 test_.text ('#footer a:nth-of-type(7)[href="/i18n/setlang/de/"]', 'Deutsch'); |
|
111 test_.text ('#footer a:nth-of-type(8)[href="/i18n/setlang/pt_BR/"]', 'Português Brasileiro'); |
|
112 test_.text ('#footer a:nth-of-type(9)[href="/i18n/setlang/nb/"]', 'Norsk'); |
|
113 test_.text ('#footer a:nth-of-type(10)[href="/i18n/setlang/bg/"]', 'Български'); |
|
114 } |
|
115 |