commit/galaxy-central: carlfeberhard: Functional browser tests: fix registration tests
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/2a23dec18caa/ Changeset: 2a23dec18caa User: carlfeberhard Date: 2014-01-07 23:09:21 Summary: Functional browser tests: fix registration tests Affected #: 3 files diff -r 64c6c98b9976c3dadb77426b6a6805922aa7810c -r 2a23dec18caabf3e326447db7eabd0b2d963fef4 test/casperjs/modules/user.js --- a/test/casperjs/modules/user.js +++ b/test/casperjs/modules/user.js @@ -160,11 +160,13 @@ var spaceghost = this.spaceghost, userEmail = ''; try { - var loggedInInfo = spaceghost.getElementInfo( - xpath( spaceghost.data.selectors.masthead.userMenu.userEmail_xpath ) ); - userEmail = loggedInInfo.text; + var emailSelector = xpath( spaceghost.data.selectors.masthead.userMenu.userEmail_xpath ), + loggedInInfo = spaceghost.elementInfoOrNull( emailSelector ); + if( loggedInInfo ){ + userEmail = loggedInInfo.text.replace( 'Logged in as ', '' ); + } } catch( err ){ - spaceghost.error( err ); + spaceghost.warn( err ); } //console.debug( 'loggedInInfo:', spaceghost.jsonStr( loggedInInfo ) ); return userEmail; @@ -175,6 +177,7 @@ */ User.prototype.logout = function logout(){ var spaceghost = this.spaceghost; + if( !this.loggedInAs() ){ return spaceghost; } spaceghost.thenOpen( spaceghost.baseUrl, function(){ this.info( 'user logging out' ); //TODO: handle already logged out diff -r 64c6c98b9976c3dadb77426b6a6805922aa7810c -r 2a23dec18caabf3e326447db7eabd0b2d963fef4 test/casperjs/registration-tests.js --- a/test/casperjs/registration-tests.js +++ b/test/casperjs/registration-tests.js @@ -64,7 +64,8 @@ spaceghost.thenOpen( spaceghost.baseUrl, function(){ this.waitForMasthead( function() { this.clickLabel( 'User' ); - this.test.assertSelectorHasText( 'a #user-email', email, '#user-email === ' + email ); + this.test.assertSelectorHasText( xpath( spaceghost.data.selectors.masthead.userMenu.userEmail_xpath ), + email, '#user-email === ' + email ); }); }); @@ -77,8 +78,9 @@ }); spaceghost.then( function(){ 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' ); + var emailSelector = xpath( this.data.selectors.masthead.userMenu.userEmail_xpath ); + this.debug( 'email:' + this.elementInfoOrNull( emailSelector ) ); + this.test.assert( !this.elementInfoOrNull( emailSelector ), 'user email not found' ); }); }); @@ -99,7 +101,7 @@ this.user._submitRegistration( badEmail, password, username, confirm ); }); self.then(function(){ - this.assertErrorMessage( 'Enter a real email address' ); + this.assertErrorMessage( 'Please enter your valid email address' ); }); }); @@ -108,10 +110,10 @@ spaceghost.each( badPasswords, function( self, badPassword ){ self.then( function(){ this.test.comment( 'attempting bad password: ' + badPassword ); - this.user._submitRegistration( spaceghost.user.getRandomEmail(), badPassword, username, confirm ); + this.user._submitRegistration( spaceghost.user.getRandomEmail(), badPassword, username, badPassword ); }); self.then(function(){ - this.assertErrorMessage( 'Use a password of at least 6 characters' ); + this.assertErrorMessage( 'Please use a password of at least 6 characters' ); }); }); @@ -123,7 +125,7 @@ this.user._submitRegistration( spaceghost.user.getRandomEmail(), password, username, badConfirm ); }); self.then(function(){ - this.assertErrorMessage( 'Passwords do not match' ); + this.assertErrorMessage( 'Passwords don\'t match' ); }); }); @@ -149,7 +151,7 @@ this.user._submitRegistration( newEmail, password, badUsername, confirm ); }); self.then(function(){ - this.assertErrorMessage( "Public name must contain only lower-case letters, numbers and '-'" ); + this.assertErrorMessage( 'Public name must contain only lowercase letters, numbers and "-"' ); }); }); diff -r 64c6c98b9976c3dadb77426b6a6805922aa7810c -r 2a23dec18caabf3e326447db7eabd0b2d963fef4 test/casperjs/spaceghost.js --- a/test/casperjs/spaceghost.js +++ b/test/casperjs/spaceghost.js @@ -793,7 +793,7 @@ * @param {CasperJS selector} messageSelector what element in which to search for the text * (defaults to '.errormessage') */ -SpaceGhost.prototype.assertErrorMessage = function assertSelectorAndTextInFrame( message, frame, messageSelector ){ +SpaceGhost.prototype.assertErrorMessage = function assertErrorMessage( message, frame, messageSelector ){ messageSelector = messageSelector || this.data.selectors.messages.error; frame = frame || this.data.selectors.frames.main; this.assertSelectorAndTextInFrame( messageSelector, message, frame ); @@ -1135,8 +1135,7 @@ masthead : { adminLink : '#masthead a[href="/admin/index"]', userMenu : { - userEmail : 'a #user-email', - userEmail_xpath : '//a[contains(text(),"Logged in as")]/span["id=#user-email"]' + userEmail_xpath : '//a[contains(text(),"Logged in as")]' } }, loginPage : { 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.
participants (1)
-
commits-noreply@bitbucket.org