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