src/cm/scripts/test-suite/tests/tests.js
changeset 577 65fab7b5ce5e
parent 575 8ce80860c3fe
child 578 1793daa8df8a
equal deleted inserted replaced
576:43700c10a1fc 577:65fab7b5ce5e
     1 
     1 
     2 // console.log ('args '+args);
     2 // console.log ('args '+args);
       
     3 
       
     4 // try to login
       
     5 
       
     6 // create texts and co-ments
       
     7 // collect newly created URLs
       
     8 
       
     9 // unlog
       
    10 
       
    11 // check that public texts still work while unlogged
       
    12 
       
    13 // check that non public texts are unavailable
     3 
    14 
     4 describe ('comt', function () {
    15 describe ('comt', function () {
     5 
    16 
     6 	this.timeout(150000);
    17 	this.timeout(150000);
     7 
    18 
     8 	describe ('connexion', function () {
    19 	describe ('login page', function () {
     9 		it ('should load login page', dsl(function () {
    20 		it ('should load', dsl(function () {
    10 			// here we are in Karma page
    21 			// here we are in Karma page
    11 			browser.navigateTo ('/');
    22 			browser.navigateTo ('/');
    12 
    23 
    13 			/*element ('title').text (function (page_title) {
    24 			/*element ('title').text (function (page_title) {
    14 				// here we got a value from the test iframe
    25 				// here we got a value from the test iframe
    15 				if (typeof page_title != 'string') throw 'page_title not a string, network problem ?';
    26 				if (typeof page_title != 'string') throw 'page_title not a string, network problem ?';
    16 				if (!/(Accueil|Home) - Workspace/.test (page_title)) throw 'got page '+page_title+' instead';
    27 				if (!/(Accueil|Home) - Workspace/.test (page_title)) throw 'got page '+page_title+' instead';
    17 			});*/
    28 			});*/
    18 
    29 
    19 			expect (element ('title').text ()).toBeDefined ();
    30 			expect (element ('title').text ()).toBeDefined ();
    20 			expect (element ('title').text ()).toMatch (/Home - Workspace/);
    31 			expect (element ('title').text ()).toMatch (/Home/);
    21 
    32 
    22 			// it should have a header
    33 		}));
       
    34 		it ('should have 2 links in #header_controls', dsl(function () {
       
    35 			expect (element ('#header_controls a').count ()).toBe (2);
       
    36 		}));
       
    37 		it ('should have a Home link in #header_controls', dsl(function () {
       
    38 			expect (element ('#header_controls a[href="/"]').val ()).toBeDefined ();
       
    39 			// to display the tested value :
       
    40 			//element ('#header_controls a[href="/"]').text ( function (txt) { console.log (txt); });
       
    41 			// returns defined ? "" : undefined;
       
    42 		}));
       
    43 		it ('should have a Login link in #header_controls', dsl(function () {
       
    44 			expect (element ('#header_controls a[href="/login/"]').val ()).toBeDefined ();
       
    45 		}));
       
    46 		it ('should not have a XXX link in #header_controls', dsl(function () {
       
    47 			expect (element ('#header_controls a[href="/xxx/"]').val ()).not ().toBeDefined ();
       
    48 		}));
    23 				// with visible homepage and login links
    49 				// with visible homepage and login links
    24 			// it should have a title
    50 			// it should have a title
    25 				// with workspace name in it… ?
    51 				// with workspace name in it… ?
    26 			// it may have public texts
    52 			// it may have public texts
    27 				// how many max ?
    53 				// 0-5
    28 				// do we announce the right number of texts ?
    54 				// do we announce the right number of texts ?
    29 			// it should have a login form
    55 			// it should have a login form
    30 				// with labels
    56 				// with labels
    31 				// with red stars
    57 				// with red stars
    32 				// green button
    58 				// green button
    35 				// with contact link, powered by co-ment logo, help link, languages links
    61 				// with contact link, powered by co-ment logo, help link, languages links
    36 
    62 
    37 			// we should try the links
    63 			// we should try the links
    38 			// we should try urls as not logged to check the access avoidance
    64 			// we should try urls as not logged to check the access avoidance
    39 
    65 
    40 		}));
       
    41 		it ('should log in', dsl(function () {
    66 		it ('should log in', dsl(function () {
    42 			browser.navigateTo ('/');
    67 			browser.navigateTo ('/');
    43 			input ('#id_username').enter ('siltaar');
    68 			input ('#id_username').enter ('siltaar');
    44 			input ('#id_password').enter ('oaueoaue');
    69 			input ('#id_password').enter ('oaueoaue');
    45 			element ('#login input[type=submit]').click ();
    70 			element ('#login input[type=submit]').click ();
    46 			browser.waitForPageLoad ()
    71 			browser.waitForPageLoad ()
    47 			browser.navigateTo ('/');
    72 			browser.navigateTo ('/');
    48 			expect (element ('title').text ()).toMatch (/Dashboard\n - Workspace/m);
    73 			expect (element ('title').text ()).toMatch (/Dashboard/m);
    49 
    74 
    50 		}));
    75 		}));
    51 	});
    76 	});
    52 });
    77 });