test-suite/tests/001_comt-unlogged-prelude.js
changeset 636 a8ab808d33c3
parent 635 57d3834c5c01
equal deleted inserted replaced
635:57d3834c5c01 636:a8ab808d33c3
     1 
     1 
     2 // " Vim settings
     2 // " Vim settings
     3 // set tabstop=4		  " number of spaces in a tab
     3 // set tabstop=4		  " number of spaces in a tab
     4 // set softtabstop=4	  " as above
     4 // set softtabstop=4	  " as above
     5 // set shiftwidth=4		  " as above
     5 // set shiftwidth=4		  " as above
       
     6 
       
     7 const wait_page_load = true;
     6 
     8 
     7 suite ('comt unlogged prelude', function () {
     9 suite ('comt unlogged prelude', function () {
     8 
    10 
     9 	this.timeout(20000);
    11 	this.timeout(20000);
    10 
    12 
    11 	suite ('contact page conformity', function () {
    13 	suite ('contact page conformity', function () {
    12 		test_page_loading ('/contact/', 'Contact');
    14 		test_page_loading ('/contact/', 'Contact');
    13 		test_unlogged_header ();
    15 		test_unlogged_header ();
    14 		test_exist	('form#profile[action="."]'); // the form exists
    16 		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)
    17 		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…
    18 		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);
    19 		test_field	('profile', 'id_email', 'text', 1, 'Your email address', true);
    18 		test_field ('profile', 'id_title', 'text', 2, 'Subject of the message', true);
    20 		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);
    21 		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);
    22 		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
    23 		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');
    24 		test_val	('input#cancel_button[type=button]', 'Cancel');
    23 		test_unlogged_footer ();
    25 		test_unlogged_footer ();
    24 		test		('to check that toBeDefined test still works', dsl(function () {
    26 		test		('to check that toBeDefined test still works', dsl(function () {
    25 			expect (elt ('#header_controls a[href="/xxx/"]').val ()).not ().toBeDefined ();
    27 			expect (elt ('#header_controls a[href="/xxx/"]').val ()).not ().toBeDefined ();
    46 		test_i18n ('en', 'Help');
    48 		test_i18n ('en', 'Help');
    47 	});
    49 	});
    48 
    50 
    49 	suite ('contact page mandatory field test', function () {
    51 	suite ('contact page mandatory field test', function () {
    50 		test_page_loading ('/contact/', 'Contact');
    52 		test_page_loading ('/contact/', 'Contact');
    51 		test_submit('#profile input[type="submit"]');
    53 		test_click	('#profile input[type="submit"]', wait_page_load);
    52 		test_count ('div.help_text span.error-text', 4);
    54 		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…
    55 		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);
    56 		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);
    57 		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);
    58 		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);
    59 		test_field	('profile', 'id_copy', 'checkbox', 4, 'Send me a copy of the email', false);
    58 	});
    60 	});
    59 
    61 
    60 	suite ('reset password page conformity', function () {
    62 	suite ('reset password page conformity', function () {
    61 		test_page_loading ('/password_reset/', 'Reset my password');
    63 		test_page_loading ('/password_reset/', 'Reset my password');
    62 		test_unlogged_header ();
    64 		test_unlogged_header ();
    63 		test_count	('form#profile :input', 3);
    65 		test_count	('form#profile :input', 3);
    64 		test_field ('profile', 'id_email', 'text', 1, 'E-mail', true);
    66 		test_field	('profile', 'id_email', 'text', 1, 'E-mail', true);
    65 		test_val	('#profile input[type=submit]', 'Reset my password');
    67 		test_val	('#profile input[type=submit]', 'Reset my password');
    66 		test_unlogged_footer ();
    68 		test_unlogged_footer ();
    67 		test_submit('#profile input[type="submit"]');
    69 		test_click	('#profile input[type="submit"]', wait_page_load);
    68 		test_count ('div.help_text span.error-text', 1);
    70 		test_count	('div.help_text span.error-text', 1);
    69 		test_field ('profile div.error', 'id_email', 'text', 0, 'E-mail', true);
    71 		test_field	('profile div.error', 'id_email', 'text', 0, 'E-mail', true);
    70 	});
    72 	});
    71 
    73 
    72 	suite ('login page conformity', function () {
    74 	suite ('login page conformity', function () {
    73 		test_page_loading ('/', 'Home');
    75 		test_page_loading ('/', 'Home');
    74 		test_unlogged_header ();
    76 		test_unlogged_header ();
    75 		test_count	('form#login[action="/login/"] :input', 3);
    77 		test_count	('form#login[action="/login/"] :input', 3);
    76 		test_field ('login', 'id_username', 'text', 0, 'Username', true);
    78 		test_field	('login', 'id_username', 'text', 0, 'Username', true);
    77 		test_field ('login', 'id_password', 'password', 1, 'Password', true);
    79 		test_field	('login', 'id_password', 'password', 1, 'Password', true);
    78 		test_val	('form#login input[type=submit]', 'Login');
    80 		test_val	('form#login input[type=submit]', 'Login');
    79 		test_text	('form#login a[href="/password_reset/"]', 'Forgot password?');
    81 		test_text	('form#login a[href="/password_reset/"]', 'Forgot password?');
    80 		test_unlogged_footer ();
    82 		test_unlogged_footer ();
    81 		// test_i18n ();
    83 		// test_i18n ();
    82 
    84 
    83 		test ('get back to / to avoid bugging next page load', dsl(function () {
    85 		test ('get back to / to avoid bugging next page load', dsl(function () {
    84 			browser.navigateTo ('/');
    86 			browser.navigateTo ('/');
    85 		}));
    87 		}));
    86 		test_page_loading ('/login/', 'Login');
    88 		test_page_loading ('/login/', 'Login');
    87 		test_submit('#login input[type="submit"]');
    89 		test_click	('#login input[type="submit"]', wait_page_load);
    88 		test_field ('login div.error', 'id_username', 'text', 0, 'Username', true);
    90 		test_field	('login div.error', 'id_username', 'text', 0, 'Username', true);
    89 		test_field ('login div.error', 'id_password', 'password', 1, 'Password', true);
    91 		test_field	('login div.error', 'id_password', 'password', 1, 'Password', true);
    90 	});
    92 	});
    91 });
    93 });
    92 
    94 
    93 function test_unlogged_header () {
    95 function test_unlogged_header () {
    94 	test_count	('#header_controls a', 2);
    96 	test_count	('#header_controls a', 2);