2 new commits in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/ee365d4406e6/ Changeset: ee365d4406e6 User: jmchilton Date: 2013-12-13 06:25:25 Summary: casperjs: Fix user login, registration, logout for recent masthead changes... They are generated in javascript instead of HTML now so I don't think they are available when page loads. My fix is to wait for the User menu to appear before attempting these operations. Affected #: 4 files diff -r b3eeedb81a1e0db8d643af0cbba68f55eb49cdb0 -r ee365d4406e604b573c3011e5b642dd7075f561d test/casperjs/api-configuration-tests.js --- a/test/casperjs/api-configuration-tests.js +++ b/test/casperjs/api-configuration-tests.js @@ -102,18 +102,19 @@ //}, function failedLoginRegister(){ // this.info( 'Admin level configuration API tests not run: no admin account available' ); spaceghost.thenOpen( spaceghost.baseUrl ).then( function(){ + spaceghost.waitForMasthead( function() { + if( spaceghost.user.userIsAdmin() ){ + this.test.comment( 'index should get a (full) list of configuration settings ' + + 'when requested by an admin user' ); + configIndex = this.api.configuration.index(); + this.debug( this.jsonStr( configIndex ) ); + this.test.assert( utils.isObject( configIndex ), "index returned an object" ); + this.test.assert( hasKeys( configIndex, adminKeys ), 'Has the proper keys' ); - if( spaceghost.user.userIsAdmin() ){ - this.test.comment( 'index should get a (full) list of configuration settings ' - + 'when requested by an admin user' ); - configIndex = this.api.configuration.index(); - this.debug( this.jsonStr( configIndex ) ); - this.test.assert( utils.isObject( configIndex ), "index returned an object" ); - this.test.assert( hasKeys( configIndex, adminKeys ), 'Has the proper keys' ); - - } else { - this.info( 'Admin level configuration API tests not run: no admin account available' ); - } + } else { + this.info( 'Admin level configuration API tests not run: no admin account available' ); + } + }); }); // =================================================================== diff -r b3eeedb81a1e0db8d643af0cbba68f55eb49cdb0 -r ee365d4406e604b573c3011e5b642dd7075f561d test/casperjs/modules/user.js --- a/test/casperjs/modules/user.js +++ b/test/casperjs/modules/user.js @@ -44,17 +44,18 @@ }; spaceghost.thenOpen( spaceghost.baseUrl, function(){ - this.clickLabel( spaceghost.data.labels.masthead.menus.user ); - this.clickLabel( spaceghost.data.labels.masthead.userMenu.register ); + this.waitForMasthead( function() { + this.clickLabel( spaceghost.data.labels.masthead.menus.user ); + this.clickLabel( spaceghost.data.labels.masthead.userMenu.register ); - this.withMainPanel( function mainBeforeRegister(){ - spaceghost.debug( '(' + spaceghost.getCurrentUrl() + ') registering user:\n' - + spaceghost.jsonStr( userInfo ) ); - this.fill( spaceghost.data.selectors.registrationPage.form, userInfo, false ); - // need manual submit (not a normal html form) - this.click( xpath( spaceghost.data.selectors.registrationPage.submit_xpath ) ); + this.withMainPanel( function mainBeforeRegister(){ + spaceghost.debug( '(' + spaceghost.getCurrentUrl() + ') registering user:\n' + + spaceghost.jsonStr( userInfo ) ); + this.fill( spaceghost.data.selectors.registrationPage.form, userInfo, false ); + // need manual submit (not a normal html form) + this.click( xpath( spaceghost.data.selectors.registrationPage.submit_xpath ) ); + }); }); - //// debugging //spaceghost.withFrame( spaceghost.data.selectors.frames.main, function mainAfterRegister(){ // var messageInfo = spaceghost.getElementInfo( spaceghost.data.selectors.messages.all ); @@ -79,24 +80,26 @@ }; spaceghost.thenOpen( spaceghost.baseUrl, function(){ - spaceghost.clickLabel( spaceghost.data.labels.masthead.menus.user ); - spaceghost.clickLabel( spaceghost.data.labels.masthead.userMenu.login ); + spaceghost.waitForMasthead( function() { + spaceghost.clickLabel( spaceghost.data.labels.masthead.menus.user ); + spaceghost.clickLabel( spaceghost.data.labels.masthead.userMenu.login ); - spaceghost.withMainPanel( function mainBeforeLogin(){ - spaceghost.debug( '(' + spaceghost.getCurrentUrl() + ') logging in user:\n' - + spaceghost.jsonStr( loginInfo ) ); - spaceghost.fill( spaceghost.data.selectors.loginPage.form, loginInfo, false ); - spaceghost.click( xpath( spaceghost.data.selectors.loginPage.submit_xpath ) ); + spaceghost.withMainPanel( function mainBeforeLogin(){ + spaceghost.debug( '(' + spaceghost.getCurrentUrl() + ') logging in user:\n' + + spaceghost.jsonStr( loginInfo ) ); + spaceghost.fill( spaceghost.data.selectors.loginPage.form, loginInfo, false ); + spaceghost.click( xpath( spaceghost.data.selectors.loginPage.submit_xpath ) ); + }); + + //// debugging + //spaceghost.withFrame( spaceghost.data.selectors.frames.main, function mainAfterLogin(){ + // //TODO: prob. could use a more generalized form of this for url breakdown/checking + // if( spaceghost.getCurrentUrl().search( spaceghost.data.selectors.loginPage.url_regex ) != -1 ){ + // var messageInfo = spaceghost.getElementInfo( spaceghost.data.selectors.messages.all ); + // spaceghost.debug( 'post login message:\n' + spaceghost.jsonStr( messageInfo ) ); + // } + //}); }); - - //// debugging - //spaceghost.withFrame( spaceghost.data.selectors.frames.main, function mainAfterLogin(){ - // //TODO: prob. could use a more generalized form of this for url breakdown/checking - // if( spaceghost.getCurrentUrl().search( spaceghost.data.selectors.loginPage.url_regex ) != -1 ){ - // var messageInfo = spaceghost.getElementInfo( spaceghost.data.selectors.messages.all ); - // spaceghost.debug( 'post login message:\n' + spaceghost.jsonStr( messageInfo ) ); - // } - //}); }); }; @@ -133,17 +136,19 @@ var spaceghost = this.spaceghost; this._submitLogin( email, password ); - spaceghost.withMainPanel( function mainAfterLogin(){ - if( spaceghost.getCurrentUrl().search( spaceghost.data.selectors.loginPage.url_regex ) !== -1 ){ - var messageInfo = spaceghost.getElementInfo( spaceghost.data.selectors.messages.all ); - if( messageInfo && messageInfo.attributes[ 'class' ] === 'errormessage' ){ - this.warning( 'Login failed: ' + messageInfo.text ); - throw new spaceghost.GalaxyError( 'LoginError: ' + messageInfo.text ); + spaceghost.waitForMasthead( function() { + spaceghost.withMainPanel( function mainAfterLogin(){ + if( spaceghost.getCurrentUrl().search( spaceghost.data.selectors.loginPage.url_regex ) !== -1 ){ + var messageInfo = spaceghost.getElementInfo( spaceghost.data.selectors.messages.all ); + if( messageInfo && messageInfo.attributes[ 'class' ] === 'errormessage' ){ + this.warning( 'Login failed: ' + messageInfo.text ); + throw new spaceghost.GalaxyError( 'LoginError: ' + messageInfo.text ); + } } - } - if( spaceghost.user.loggedInAs() === email ){ - spaceghost.info( 'logged in as ' + email ); - } + if( spaceghost.user.loggedInAs() === email ){ + spaceghost.info( 'logged in as ' + email ); + } + }); }); return spaceghost; }; @@ -173,8 +178,10 @@ spaceghost.thenOpen( spaceghost.baseUrl, function(){ this.info( 'user logging out' ); //TODO: handle already logged out - spaceghost.clickLabel( spaceghost.data.labels.masthead.menus.user ); - spaceghost.clickLabel( spaceghost.data.labels.masthead.userMenu.logout ); + spaceghost.waitForMasthead( function _logout() { + spaceghost.clickLabel( spaceghost.data.labels.masthead.menus.user ); + spaceghost.clickLabel( spaceghost.data.labels.masthead.userMenu.logout ); + }); }); return spaceghost; }; diff -r b3eeedb81a1e0db8d643af0cbba68f55eb49cdb0 -r ee365d4406e604b573c3011e5b642dd7075f561d test/casperjs/registration-tests.js --- a/test/casperjs/registration-tests.js +++ b/test/casperjs/registration-tests.js @@ -62,18 +62,24 @@ this.user._submitRegistration( email, password, username, confirm ); }); spaceghost.thenOpen( spaceghost.baseUrl, function(){ - this.clickLabel( 'User' ); - this.test.assertSelectorHasText( 'a #user-email', email, '#user-email === ' + email ); + this.waitForMasthead( function() { + this.clickLabel( 'User' ); + this.test.assertSelectorHasText( 'a #user-email', email, '#user-email === ' + email ); + }); }); // ------------------------------------------------------------------- log out that user spaceghost.then( function(){ - this.test.comment( 'logging out user: ' + email ); - this.user.logout(); + this.waitForMasthead( function() { + this.test.comment( 'logging out user: ' + email ); + this.user.logout(); + }); }); spaceghost.then( function(){ - this.debug( 'email:' + this.getElementInfo( 'a #user-email' ).html ); - this.test.assert( !this.getElementInfo( 'a #user-email' ).html, '#user-email is empty' ); + this.waitForMasthead( function() { + this.debug( 'email:' + this.getElementInfo( 'a #user-email' ).html ); + this.test.assert( !this.getElementInfo( 'a #user-email' ).html, '#user-email is empty' ); + }); }); // ------------------------------------------------------------------- bad user registrations diff -r b3eeedb81a1e0db8d643af0cbba68f55eb49cdb0 -r ee365d4406e604b573c3011e5b642dd7075f561d test/casperjs/spaceghost.js --- a/test/casperjs/spaceghost.js +++ b/test/casperjs/spaceghost.js @@ -1103,6 +1103,10 @@ return match[2]; }; +SpaceGhost.prototype.waitForMasthead = function wait( then ) { + return this.waitForText( this.data.labels.masthead.menus.user, then ); +} + // =================================================================== TEST DATA /** General use selectors, labels, and text. Kept here to allow a centralized location. https://bitbucket.org/galaxy/galaxy-central/commits/90a639389de4/ Changeset: 90a639389de4 User: jmchilton Date: 2013-12-17 14:30:24 Summary: Merged in jmchilton/galaxy-central-fork-1 (pull request #274) casperjs: Fix user login, registration, logout for recent masthead changes... Affected #: 4 files diff -r af87cdcf36084831fce7d99e621b1efc943d2aff -r 90a639389de4a4348a32e21d87a13de4b1a72f56 test/casperjs/api-configuration-tests.js --- a/test/casperjs/api-configuration-tests.js +++ b/test/casperjs/api-configuration-tests.js @@ -102,18 +102,19 @@ //}, function failedLoginRegister(){ // this.info( 'Admin level configuration API tests not run: no admin account available' ); spaceghost.thenOpen( spaceghost.baseUrl ).then( function(){ + spaceghost.waitForMasthead( function() { + if( spaceghost.user.userIsAdmin() ){ + this.test.comment( 'index should get a (full) list of configuration settings ' + + 'when requested by an admin user' ); + configIndex = this.api.configuration.index(); + this.debug( this.jsonStr( configIndex ) ); + this.test.assert( utils.isObject( configIndex ), "index returned an object" ); + this.test.assert( hasKeys( configIndex, adminKeys ), 'Has the proper keys' ); - if( spaceghost.user.userIsAdmin() ){ - this.test.comment( 'index should get a (full) list of configuration settings ' - + 'when requested by an admin user' ); - configIndex = this.api.configuration.index(); - this.debug( this.jsonStr( configIndex ) ); - this.test.assert( utils.isObject( configIndex ), "index returned an object" ); - this.test.assert( hasKeys( configIndex, adminKeys ), 'Has the proper keys' ); - - } else { - this.info( 'Admin level configuration API tests not run: no admin account available' ); - } + } else { + this.info( 'Admin level configuration API tests not run: no admin account available' ); + } + }); }); // =================================================================== diff -r af87cdcf36084831fce7d99e621b1efc943d2aff -r 90a639389de4a4348a32e21d87a13de4b1a72f56 test/casperjs/modules/user.js --- a/test/casperjs/modules/user.js +++ b/test/casperjs/modules/user.js @@ -44,17 +44,18 @@ }; spaceghost.thenOpen( spaceghost.baseUrl, function(){ - this.clickLabel( spaceghost.data.labels.masthead.menus.user ); - this.clickLabel( spaceghost.data.labels.masthead.userMenu.register ); + this.waitForMasthead( function() { + this.clickLabel( spaceghost.data.labels.masthead.menus.user ); + this.clickLabel( spaceghost.data.labels.masthead.userMenu.register ); - this.withMainPanel( function mainBeforeRegister(){ - spaceghost.debug( '(' + spaceghost.getCurrentUrl() + ') registering user:\n' - + spaceghost.jsonStr( userInfo ) ); - this.fill( spaceghost.data.selectors.registrationPage.form, userInfo, false ); - // need manual submit (not a normal html form) - this.click( xpath( spaceghost.data.selectors.registrationPage.submit_xpath ) ); + this.withMainPanel( function mainBeforeRegister(){ + spaceghost.debug( '(' + spaceghost.getCurrentUrl() + ') registering user:\n' + + spaceghost.jsonStr( userInfo ) ); + this.fill( spaceghost.data.selectors.registrationPage.form, userInfo, false ); + // need manual submit (not a normal html form) + this.click( xpath( spaceghost.data.selectors.registrationPage.submit_xpath ) ); + }); }); - //// debugging //spaceghost.withFrame( spaceghost.data.selectors.frames.main, function mainAfterRegister(){ // var messageInfo = spaceghost.getElementInfo( spaceghost.data.selectors.messages.all ); @@ -79,24 +80,26 @@ }; spaceghost.thenOpen( spaceghost.baseUrl, function(){ - spaceghost.clickLabel( spaceghost.data.labels.masthead.menus.user ); - spaceghost.clickLabel( spaceghost.data.labels.masthead.userMenu.login ); + spaceghost.waitForMasthead( function() { + spaceghost.clickLabel( spaceghost.data.labels.masthead.menus.user ); + spaceghost.clickLabel( spaceghost.data.labels.masthead.userMenu.login ); - spaceghost.withMainPanel( function mainBeforeLogin(){ - spaceghost.debug( '(' + spaceghost.getCurrentUrl() + ') logging in user:\n' - + spaceghost.jsonStr( loginInfo ) ); - spaceghost.fill( spaceghost.data.selectors.loginPage.form, loginInfo, false ); - spaceghost.click( xpath( spaceghost.data.selectors.loginPage.submit_xpath ) ); + spaceghost.withMainPanel( function mainBeforeLogin(){ + spaceghost.debug( '(' + spaceghost.getCurrentUrl() + ') logging in user:\n' + + spaceghost.jsonStr( loginInfo ) ); + spaceghost.fill( spaceghost.data.selectors.loginPage.form, loginInfo, false ); + spaceghost.click( xpath( spaceghost.data.selectors.loginPage.submit_xpath ) ); + }); + + //// debugging + //spaceghost.withFrame( spaceghost.data.selectors.frames.main, function mainAfterLogin(){ + // //TODO: prob. could use a more generalized form of this for url breakdown/checking + // if( spaceghost.getCurrentUrl().search( spaceghost.data.selectors.loginPage.url_regex ) != -1 ){ + // var messageInfo = spaceghost.getElementInfo( spaceghost.data.selectors.messages.all ); + // spaceghost.debug( 'post login message:\n' + spaceghost.jsonStr( messageInfo ) ); + // } + //}); }); - - //// debugging - //spaceghost.withFrame( spaceghost.data.selectors.frames.main, function mainAfterLogin(){ - // //TODO: prob. could use a more generalized form of this for url breakdown/checking - // if( spaceghost.getCurrentUrl().search( spaceghost.data.selectors.loginPage.url_regex ) != -1 ){ - // var messageInfo = spaceghost.getElementInfo( spaceghost.data.selectors.messages.all ); - // spaceghost.debug( 'post login message:\n' + spaceghost.jsonStr( messageInfo ) ); - // } - //}); }); }; @@ -133,17 +136,19 @@ var spaceghost = this.spaceghost; this._submitLogin( email, password ); - spaceghost.withMainPanel( function mainAfterLogin(){ - if( spaceghost.getCurrentUrl().search( spaceghost.data.selectors.loginPage.url_regex ) !== -1 ){ - var messageInfo = spaceghost.getElementInfo( spaceghost.data.selectors.messages.all ); - if( messageInfo && messageInfo.attributes[ 'class' ] === 'errormessage' ){ - this.warning( 'Login failed: ' + messageInfo.text ); - throw new spaceghost.GalaxyError( 'LoginError: ' + messageInfo.text ); + spaceghost.waitForMasthead( function() { + spaceghost.withMainPanel( function mainAfterLogin(){ + if( spaceghost.getCurrentUrl().search( spaceghost.data.selectors.loginPage.url_regex ) !== -1 ){ + var messageInfo = spaceghost.getElementInfo( spaceghost.data.selectors.messages.all ); + if( messageInfo && messageInfo.attributes[ 'class' ] === 'errormessage' ){ + this.warning( 'Login failed: ' + messageInfo.text ); + throw new spaceghost.GalaxyError( 'LoginError: ' + messageInfo.text ); + } } - } - if( spaceghost.user.loggedInAs() === email ){ - spaceghost.info( 'logged in as ' + email ); - } + if( spaceghost.user.loggedInAs() === email ){ + spaceghost.info( 'logged in as ' + email ); + } + }); }); return spaceghost; }; @@ -173,8 +178,10 @@ spaceghost.thenOpen( spaceghost.baseUrl, function(){ this.info( 'user logging out' ); //TODO: handle already logged out - spaceghost.clickLabel( spaceghost.data.labels.masthead.menus.user ); - spaceghost.clickLabel( spaceghost.data.labels.masthead.userMenu.logout ); + spaceghost.waitForMasthead( function _logout() { + spaceghost.clickLabel( spaceghost.data.labels.masthead.menus.user ); + spaceghost.clickLabel( spaceghost.data.labels.masthead.userMenu.logout ); + }); }); return spaceghost; }; diff -r af87cdcf36084831fce7d99e621b1efc943d2aff -r 90a639389de4a4348a32e21d87a13de4b1a72f56 test/casperjs/registration-tests.js --- a/test/casperjs/registration-tests.js +++ b/test/casperjs/registration-tests.js @@ -62,18 +62,24 @@ this.user._submitRegistration( email, password, username, confirm ); }); spaceghost.thenOpen( spaceghost.baseUrl, function(){ - this.clickLabel( 'User' ); - this.test.assertSelectorHasText( 'a #user-email', email, '#user-email === ' + email ); + this.waitForMasthead( function() { + this.clickLabel( 'User' ); + this.test.assertSelectorHasText( 'a #user-email', email, '#user-email === ' + email ); + }); }); // ------------------------------------------------------------------- log out that user spaceghost.then( function(){ - this.test.comment( 'logging out user: ' + email ); - this.user.logout(); + this.waitForMasthead( function() { + this.test.comment( 'logging out user: ' + email ); + this.user.logout(); + }); }); spaceghost.then( function(){ - this.debug( 'email:' + this.getElementInfo( 'a #user-email' ).html ); - this.test.assert( !this.getElementInfo( 'a #user-email' ).html, '#user-email is empty' ); + this.waitForMasthead( function() { + this.debug( 'email:' + this.getElementInfo( 'a #user-email' ).html ); + this.test.assert( !this.getElementInfo( 'a #user-email' ).html, '#user-email is empty' ); + }); }); // ------------------------------------------------------------------- bad user registrations diff -r af87cdcf36084831fce7d99e621b1efc943d2aff -r 90a639389de4a4348a32e21d87a13de4b1a72f56 test/casperjs/spaceghost.js --- a/test/casperjs/spaceghost.js +++ b/test/casperjs/spaceghost.js @@ -1103,6 +1103,10 @@ return match[2]; }; +SpaceGhost.prototype.waitForMasthead = function wait( then ) { + return this.waitForText( this.data.labels.masthead.menus.user, then ); +} + // =================================================================== TEST DATA /** General use selectors, labels, and text. Kept here to allow a centralized location. Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.