1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/17e9e3ffb571/ Changeset: 17e9e3ffb571 User: carlfeberhard Date: 2014-01-09 20:34:25 Summary: Remove extra includes in index.mako; Functional browser tests: create 'is loaded' fn for home page to simplify, improve loading in user module, misc. fixes Affected #: 13 files diff -r 4e6b003daaa44a06ac13c74c5ce8c75fa7bbb7ee -r 17e9e3ffb571e8f200ee8bf195a3708b2be4792b templates/webapps/galaxy/root/index.mako --- a/templates/webapps/galaxy/root/index.mako +++ b/templates/webapps/galaxy/root/index.mako @@ -1,9 +1,7 @@ <%inherit file="/webapps/galaxy/base_panels.mako"/><%namespace file="/root/tool_menu.mako" import="*" /> -<%namespace file="/history/history_panel.mako" import="history_panel_javascripts" /><%namespace file="/history/history_panel.mako" import="current_history_panel" /> -<%namespace file="/history/history_panel.mako" import="history_panel" /><%def name="stylesheets()"> ${parent.stylesheets()} diff -r 4e6b003daaa44a06ac13c74c5ce8c75fa7bbb7ee -r 17e9e3ffb571e8f200ee8bf195a3708b2be4792b test/casperjs/anon-history-tests.js --- a/test/casperjs/anon-history-tests.js +++ b/test/casperjs/anon-history-tests.js @@ -60,16 +60,8 @@ // =================================================================== TESTS -// ------------------------------------------------------------------- anonymous new, history -// open galaxy - ensure not logged in -spaceghost.thenOpen( spaceghost.baseUrl, function(){ - var loggedInAs = spaceghost.user.loggedInAs(); - this.debug( 'loggedInAs: ' + loggedInAs ); - if( loggedInAs ){ this.logout(); } -}); - -// ------------------------------------------------------------------- check the empty history for well formedness -spaceghost.historypanel.waitForHdas( function testPanelStructure(){ +// ------------------------------------------------------------------- check the anonymous new, history for form +spaceghost.openHomePage().historypanel.waitForHdas( function testPanelStructure(){ this.test.comment( 'history panel for anonymous user, new history' ); this.test.comment( "history name should exist, be visible, and have text " + unnamedName ); @@ -121,8 +113,7 @@ // ------------------------------------------------------------------- anon user can run tool on file // ------------------------------------------------------------------- anon user registers/logs in -> same history -spaceghost.user.loginOrRegisterUser( email, password ); -spaceghost.thenOpen( spaceghost.baseUrl, function(){ +spaceghost.user.loginOrRegisterUser( email, password ).openHomePage( function(){ this.test.comment( 'anon-user should login and be associated with previous history' ); var loggedInAs = spaceghost.user.loggedInAs(); @@ -139,8 +130,7 @@ }); // ------------------------------------------------------------------- logs out -> new history -spaceghost.user.logout(); -spaceghost.thenOpen( spaceghost.baseUrl, function(){ +spaceghost.user.logout().openHomePage( function(){ this.test.comment( 'logging out should create a new, anonymous history' ); this.historypanel.waitForHdas( function(){ diff -r 4e6b003daaa44a06ac13c74c5ce8c75fa7bbb7ee -r 17e9e3ffb571e8f200ee8bf195a3708b2be4792b test/casperjs/api-history-tests.js --- a/test/casperjs/api-history-tests.js +++ b/test/casperjs/api-history-tests.js @@ -304,13 +304,15 @@ //this.debug( 'returned:\n' + this.jsonStr( returned ) ); historyShow = this.api.histories.show( newFirstHistory.id ); this.test.assert( historyShow.genome_build === unicodeBuild, - "Update accepted unicode genome_build: " + historyShow.name ); + "Update accepted unicode genome_build: " + historyShow.genome_build ); } catch( err ){ //this.debug( this.jsonStr( err ) ); if( ( err instanceof this.api.APIError ) && ( err.status === 500 ) && ( err.message.indexOf( '(ProgrammingError) You must not use 8-bit bytestrings' ) !== -1 ) ){ this.skipTest( 'Unicode update failed. Are you using sqlite3 as the db?' ); + } else { + throw err; } } diff -r 4e6b003daaa44a06ac13c74c5ce8c75fa7bbb7ee -r 17e9e3ffb571e8f200ee8bf195a3708b2be4792b test/casperjs/hda-state-tests.js --- a/test/casperjs/hda-state-tests.js +++ b/test/casperjs/hda-state-tests.js @@ -62,17 +62,14 @@ peekShouldBeArray = []; // ------------------------------------------------------------------- set up -// start a new user +// start a new user and upload a file spaceghost.user.loginOrRegisterUser( email, password ); - -// upload a file spaceghost.then( function upload(){ spaceghost.tools.uploadFile( filepathToUpload, function uploadCallback( _uploadInfo ){ testUploadInfo = _uploadInfo; }); }); - // =================================================================== TEST HELPERS //NOTE: to be called with fn.call( spaceghost, ... ) diff -r 4e6b003daaa44a06ac13c74c5ce8c75fa7bbb7ee -r 17e9e3ffb571e8f200ee8bf195a3708b2be4792b test/casperjs/history-options-tests.js --- a/test/casperjs/history-options-tests.js +++ b/test/casperjs/history-options-tests.js @@ -47,9 +47,8 @@ // =================================================================== TESTS // ------------------------------------------------------------------- set up -// start a new user +// start a new user and upload a file spaceghost.user.loginOrRegisterUser( email, password ); - spaceghost.tools.uploadFile( filepathToUpload, function uploadCallback( _uploadInfo ){ testUploadInfo = _uploadInfo; }); diff -r 4e6b003daaa44a06ac13c74c5ce8c75fa7bbb7ee -r 17e9e3ffb571e8f200ee8bf195a3708b2be4792b test/casperjs/history-panel-tests.js --- a/test/casperjs/history-panel-tests.js +++ b/test/casperjs/history-panel-tests.js @@ -73,7 +73,7 @@ spaceghost.user.loginOrRegisterUser( email, password ); // ------------------------------------------------------------------- check structure of empty history -spaceghost.thenOpen( spaceghost.baseUrl ).historypanel.waitForHdas( function(){ +spaceghost.openHomePage().historypanel.waitForHdas( function(){ this.test.comment( 'history panel with a new, empty history should be well formed' ); this.test.comment( "history name should exist, be visible, and have text " + unnamedName ); @@ -173,9 +173,9 @@ this.test.assertVisible( nameSelector, 'History name is visible' ); this.test.assertSelectorHasText( nameSelector, newHistoryName, 'History name is ' + newHistoryName ); - this.test.comment( "history subtitle should display size and size should be " + onetxtFilesize + " bytes" ); var onetxtFilesize = require( 'fs' ).size( this.options.scriptDir + filepathToUpload ), expectedSubtitle = onetxtFilesize + ' bytes'; + this.test.comment( "history subtitle should display size and size should be " + onetxtFilesize + " bytes" ); this.test.assertExists( subtitleSelector, 'Found ' + subtitleSelector ); this.test.assertVisible( subtitleSelector, 'History subtitle is visible' ); this.test.assertSelectorHasText( subtitleSelector, expectedSubtitle, diff -r 4e6b003daaa44a06ac13c74c5ce8c75fa7bbb7ee -r 17e9e3ffb571e8f200ee8bf195a3708b2be4792b test/casperjs/login-tests.js --- a/test/casperjs/login-tests.js +++ b/test/casperjs/login-tests.js @@ -1,5 +1,3 @@ -// have to handle errors here - or phantom/casper won't bail but _HANG_ -//TODO: global error handler? try { var utils = require( 'utils' ), xpath = require( 'casper' ).selectXPath, @@ -25,12 +23,6 @@ phantom.exit( 1 ); } -// =================================================================== -/* TODO: - move selectors and assertText strings into global object for easier editing - - -*/ // =================================================================== globals and helpers var email = spaceghost.user.getRandomEmail(), password = '123456'; @@ -43,21 +35,14 @@ // =================================================================== TESTS // register a user (again...) -spaceghost.thenOpen( spaceghost.baseUrl, function(){ - this.test.comment( 'registering: ' + email ); - spaceghost.user.registerUser( email, password ); -}); +spaceghost.openHomePage() + .user.registerUser( email, password ) + .user.logout(); -// log them out - check for empty logged in text -spaceghost.then( function(){ - this.test.comment( 'logging out: ' + email ); - spaceghost.user.logout(); -}); -spaceghost.thenOpen( spaceghost.baseUrl, function(){ - spaceghost.waitForMasthead( function() { - this.test.assertDoesntExist( xpath( userEmailSelector ) ); - this.test.assert( spaceghost.user.loggedInAs() === '', 'loggedInAs() is empty string' ); - }); +spaceghost.openHomePage( function(){ + this.test.comment( 'log out should be reflected in user menu' ); + this.test.assertDoesntExist( xpath( userEmailSelector ) ); + this.test.assert( spaceghost.user.loggedInAs() === '', 'loggedInAs() is empty string' ); }); // log them back in - check for email in logged in text @@ -65,16 +50,13 @@ this.test.comment( 'logging back in: ' + email ); spaceghost.user._submitLogin( email, password ); //No such user }); -spaceghost.thenOpen( spaceghost.baseUrl, function(){ +spaceghost.openHomePage( function(){ this.test.assertSelectorHasText( xpath( userEmailSelector ), email ); this.test.assert( spaceghost.user.loggedInAs() === email, 'loggedInAs() matches email' ); }); // finally log back out for next tests -spaceghost.then( function(){ - this.test.comment( 'logging out: ' + email ); - spaceghost.user.logout(); -}); +spaceghost.user.logout(); // ------------------------------------------------------------------- shouldn't work // can't log in: users that don't exist, bad emails, sql injection (hurhur) @@ -120,10 +102,6 @@ }); }); }); - -spaceghost.then( function(){ - this.user.logout(); -}); /* */ // =================================================================== diff -r 4e6b003daaa44a06ac13c74c5ce8c75fa7bbb7ee -r 17e9e3ffb571e8f200ee8bf195a3708b2be4792b test/casperjs/modules/api.js --- a/test/casperjs/modules/api.js +++ b/test/casperjs/modules/api.js @@ -1,12 +1,4 @@ // =================================================================== module object, exports -/** Creates a new api module object. - * @param {SpaceGhost} spaceghost a spaceghost instance - * @exported - */ -exports.create = function createAPI( spaceghost, apikey ){ - return new API( spaceghost ); -}; - /** User object constructor. * @param {SpaceGhost} spaceghost a spaceghost instance * @param {String} apikey apikey for use when not using session authentication @@ -28,14 +20,21 @@ }; exports.API = API; +/** Creates a new api module object. + * @param {SpaceGhost} spaceghost a spaceghost instance + * @exported + */ +exports.create = function createAPI( spaceghost, apikey ){ + return new API( spaceghost ); +}; + + API.prototype.toString = function toString(){ return ( this.spaceghost + '.API:' + (( this.apikey )?( this.apikey ):( '(session)' )) ); }; // ------------------------------------------------------------------- APIError -APIError.prototype = new Error(); -APIError.prototype.constructor = Error; /** @class Thrown when Galaxy the API returns an error from a request */ function APIError( msg, status ){ Error.apply( this, arguments ); @@ -43,6 +42,8 @@ this.message = msg; this.status = status; } +APIError.prototype = new Error(); +APIError.prototype.constructor = Error; API.prototype.APIError = APIError; exports.APIError = APIError; diff -r 4e6b003daaa44a06ac13c74c5ce8c75fa7bbb7ee -r 17e9e3ffb571e8f200ee8bf195a3708b2be4792b test/casperjs/modules/tools.js --- a/test/casperjs/modules/tools.js +++ b/test/casperjs/modules/tools.js @@ -86,14 +86,12 @@ uploadInfo = {}; uploadInfo[ spaceghost.data.selectors.tools.upload.fileInput ] = filepath; - // click the upload tool - spaceghost.thenOpen( spaceghost.baseUrl, function(){ - // we can apprently click a tool label without expanding the tool container for it - this.waitForSelector( '.toolMenu', function(){ - this.click( xpath( '//a[contains(text(),"Upload File")]' ) ); - this.jumpToMain( function(){ - this.waitForSelector( 'body' ); - }); + spaceghost.openHomePage( function(){ + // load the upload tool form + // (we can apprently click a tool label without expanding the tool container for it) + this.click( xpath( '//a[contains(text(),"Upload File")]' ) ); + this.jumpToMain( function(){ + this.waitForSelector( 'body' ); }); }); diff -r 4e6b003daaa44a06ac13c74c5ce8c75fa7bbb7ee -r 17e9e3ffb571e8f200ee8bf195a3708b2be4792b test/casperjs/modules/user.js --- a/test/casperjs/modules/user.js +++ b/test/casperjs/modules/user.js @@ -43,11 +43,11 @@ confirm : ( confirm !== undefined )?( confirm ):( password ) }; - spaceghost.thenOpen( spaceghost.baseUrl, function(){ - this.waitForMasthead( function() { - this.clickLabel( spaceghost.data.labels.masthead.menus.user ); - this.clickLabel( spaceghost.data.labels.masthead.userMenu.register ); + spaceghost.openHomePage( function(){ + this.clickLabel( spaceghost.data.labels.masthead.menus.user ); + this.clickLabel( spaceghost.data.labels.masthead.userMenu.register ); + this.waitForNavigation( 'user/create', function beforeRegister(){ this.withMainPanel( function mainBeforeRegister(){ spaceghost.debug( '(' + spaceghost.getCurrentUrl() + ') registering user:\n' + spaceghost.jsonStr( userInfo ) ); @@ -56,11 +56,13 @@ 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 ); - // spaceghost.debug( 'post registration message:\n' + spaceghost.jsonStr( messageInfo ) ); - //}); + + this.waitForNavigation( 'user/create', function afterRegister(){ + // this.withMainPanel( function mainAfterRegister(){ + // var messageInfo = spaceghost.getElementInfo( spaceghost.data.selectors.messages.all ); + // spaceghost.debug( 'post registration message:\n' + spaceghost.jsonStr( messageInfo ) ); + // }); + }); }); }; @@ -79,24 +81,23 @@ password: password }; - spaceghost.thenOpen( spaceghost.baseUrl, function(){ - spaceghost.waitForMasthead( function() { - spaceghost.clickLabel( spaceghost.data.labels.masthead.userMenu.login ); + spaceghost.openHomePage( function(){ + this.clickLabel( spaceghost.data.labels.masthead.menus.user ); + this.clickLabel( spaceghost.data.labels.masthead.userMenu.login ); - spaceghost.withMainPanel( function mainBeforeLogin(){ + this.waitForNavigation( 'user/login', function beforeLogin(){ + this.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 ) ); - // } + this.waitForNavigation( 'user/login', function afterLogin(){ + //this.withMainPanel( function mainAfterLogin(){ + // var messageInfo = spaceghost.getElementInfo( spaceghost.data.selectors.messages.all ); + // spaceghost.debug( 'post login message:\n' + spaceghost.jsonStr( messageInfo ) ); //}); }); }); @@ -122,6 +123,9 @@ this.warning( 'Registration failed: ' + messageInfo.text ); throw new spaceghost.GalaxyError( 'RegistrationError: ' + messageInfo.text ); } + + this.clickLabel( 'Return to the home page.' ); + this.waitForNavigation( '' ); }); return spaceghost; }; @@ -135,19 +139,21 @@ var spaceghost = this.spaceghost; this._submitLogin( email, password ); - 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 ); - } - }); + //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 ); + // } + // } + //}); + this.spaceghost.then( function checkLogin(){ + if( spaceghost.user.loggedInAs() !== email ){ + throw new spaceghost.GalaxyError( 'LoginError' ); + } else { + spaceghost.info( 'logged in as ' + email ); + } }); return spaceghost; }; @@ -156,19 +162,19 @@ * @returns {String} email of currently logged in user or '' if no one logged in */ User.prototype.loggedInAs = function loggedInAs(){ - var spaceghost = this.spaceghost, - userEmail = ''; - try { - var emailSelector = xpath( spaceghost.data.selectors.masthead.userMenu.userEmail_xpath ), - loggedInInfo = spaceghost.elementInfoOrNull( emailSelector ); - if( loggedInInfo !== null ){ - userEmail = loggedInInfo.text.replace( 'Logged in as ', '' ); + return this.spaceghost.jumpToTop( function(){ + var userEmail = ''; + try { + var emailSelector = xpath( this.data.selectors.masthead.userMenu.userEmail_xpath ), + loggedInInfo = this.elementInfoOrNull( emailSelector ); + if( loggedInInfo !== null ){ + userEmail = loggedInInfo.text.replace( 'Logged in as ', '' ); + } + } catch( err ){ + this.warn( err ); } - } catch( err ){ - spaceghost.warn( err ); - } - //console.debug( 'loggedInInfo:', spaceghost.jsonStr( loggedInInfo ) ); - return userEmail; + return userEmail; + }); }; /** Log out the current user @@ -176,14 +182,15 @@ */ User.prototype.logout = function logout(){ var spaceghost = this.spaceghost; - spaceghost.thenOpen( spaceghost.baseUrl, function(){ - this.info( 'user logging out' ); - spaceghost.waitForMasthead( function _logout() { - if( spaceghost.user.loggedInAs() ){ - spaceghost.clickLabel( spaceghost.data.labels.masthead.menus.user ); - spaceghost.clickLabel( spaceghost.data.labels.masthead.userMenu.logout ); - } - }); + this.spaceghost.openHomePage( function(){ + if( spaceghost.user.loggedInAs() ){ + spaceghost.clickLabel( spaceghost.data.labels.masthead.menus.user ); + spaceghost.clickLabel( spaceghost.data.labels.masthead.userMenu.logout ); + spaceghost.waitForNavigation( 'user/logout', function _toLogoutPage() { + spaceghost.clickLabel( 'go to the home page' ); + spaceghost.waitForNavigation( '' ); + }); + } }); return spaceghost; }; @@ -198,10 +205,10 @@ var spaceghost = this.spaceghost; // attempt a login, if that fails - register spaceghost.tryStepsCatch( function tryToLogin(){ - spaceghost.open( spaceghost.baseUrl ).user.login( email, password ); + spaceghost.openHomePage().user.login( email, password ); }, function failedLoginRegister(){ - spaceghost.open( spaceghost.baseUrl ).user.registerUser( email, password, username ); + spaceghost.openHomePage().user.registerUser( email, password, username ); }); return spaceghost; }; @@ -216,7 +223,8 @@ // check for the setting in sg and the universe_wsgi.ini file var adminData = this.spaceghost.options.adminUser, iniAdminEmails = this.spaceghost.getUniverseSetting( 'admin_users' ); - iniAdminEmails = ( iniAdminEmails )?( iniAdminEmails.split( ',' ).map( function( email ) { return email.trim(); } ) ):( null ); + iniAdminEmails = ( iniAdminEmails )? + ( iniAdminEmails.split( ',' ).map( function( email ) { return email.trim(); } ) ):( null ); //TODO: seems like we only need the wsgi setting - that's the only thing we can't change if( adminData ){ diff -r 4e6b003daaa44a06ac13c74c5ce8c75fa7bbb7ee -r 17e9e3ffb571e8f200ee8bf195a3708b2be4792b test/casperjs/registration-tests.js --- a/test/casperjs/registration-tests.js +++ b/test/casperjs/registration-tests.js @@ -1,4 +1,3 @@ -// have to handle errors here - or phantom/casper won't bail but _HANG_ try { var utils = require( 'utils' ), xpath = require( 'casper' ).selectXPath, @@ -24,13 +23,6 @@ phantom.exit( 1 ); } -// =================================================================== -/* TODO: - move selectors and assertText strings into global object for easier editing - pass email, etc. for first (successful) registration (for use with other tests) - - -*/ // =================================================================== globals and helpers var email = spaceghost.user.getRandomEmail(), password = '123456', @@ -38,50 +30,27 @@ username = 'test' + Date.now(); // =================================================================== TESTS -spaceghost.thenOpen( spaceghost.baseUrl, function(){ +spaceghost.openHomePage( function(){ this.test.comment( 'loading galaxy homepage' ); - // can we load galaxy? this.test.assertTitle( 'Galaxy' ); - // xpath selector use: this.test.assertExists( xpath( "//div[@id='masthead']" ), 'found masthead' ); }); -// failing tests for...testing...the tests -//spaceghost.thenOpen( spaceghost.baseUrl, function(){ -// this.test.comment( 'loading galaxy homepage' ); -// // can we load galaxy? -// this.test.assertTitle( 'Blorgo' ); -// // xpath selector use: -// this.test.assertExists( xpath( "//div[@id='facebook']" ), 'found facebook' ); -//}); - - // ------------------------------------------------------------------- register a new user spaceghost.then( function(){ this.test.comment( 'registering user: ' + email ); this.user._submitRegistration( email, password, username, confirm ); }); -spaceghost.thenOpen( spaceghost.baseUrl, function(){ - this.waitForMasthead( function() { - this.clickLabel( 'User' ); - this.test.assertSelectorHasText( xpath( spaceghost.data.selectors.masthead.userMenu.userEmail_xpath ), - email, '#user-email === ' + email ); - }); +spaceghost.openHomePage( function(){ + this.clickLabel( 'User' ); + var loggedInAs = this.fetchText( xpath( spaceghost.data.selectors.masthead.userMenu.userEmail_xpath ) ); + this.test.assert( loggedInAs.indexOf( email ) !== -1, 'found proper email in user menu: ' + loggedInAs ); }); // ------------------------------------------------------------------- log out that user -spaceghost.then( function(){ - this.waitForMasthead( function() { - this.test.comment( 'logging out user: ' + email ); - this.user.logout(); - }); -}); -spaceghost.then( function(){ - this.waitForMasthead( function() { - 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' ); - }); +spaceghost.user.logout().openHomePage( function(){ + var emailSelector = xpath( this.data.selectors.masthead.userMenu.userEmail_xpath ); + this.test.assert( !this.elementInfoOrNull( emailSelector ), 'user email not found' ); }); // ------------------------------------------------------------------- bad user registrations @@ -165,7 +134,6 @@ this.assertErrorMessage( 'Public name is taken; please choose another' ); }); - // ------------------------------------------------------------------- test the convenience fns // these versions are for conv. use in other tests, they should throw errors if used improperly spaceghost.then( function(){ @@ -177,11 +145,6 @@ }); }); -spaceghost.then( function(){ - //??: necessary? - this.user.logout(); -}); - // =================================================================== spaceghost.run( function(){ this.test.done(); diff -r 4e6b003daaa44a06ac13c74c5ce8c75fa7bbb7ee -r 17e9e3ffb571e8f200ee8bf195a3708b2be4792b test/casperjs/spaceghost.js --- a/test/casperjs/spaceghost.js +++ b/test/casperjs/spaceghost.js @@ -507,6 +507,38 @@ Casper.prototype.run.call( this, new_onComplete, time ); }; +// ------------------------------------------------------------------- home page +/** Wait for the homepage/index/Analyze Data to load fully. + */ +SpaceGhost.prototype.openHomePage = function openHomePage( then, delay ){ +//TODO: delay doesn't seem to work + this.thenOpen( this.baseUrl, function _openHomePage(){ + this.waitFor( + function waitForCheck(){ + return this.homePageIsLoaded(); + }, + then, + function openHomePageTimeout(){ + throw new GalaxyError( 'Homepage timed out' ); + }, + delay + ); + }); + return this; +}; + +/** Check for visibility of main home page elements: masthead, tool menu, history panel. + */ +SpaceGhost.prototype.homePageIsLoaded = function homePageIsLoaded(){ + //this.debug( 'homePageIsLoaded: ' + [ + // this.visible( '#masthead' ), + // this.visible( this.data.selectors.toolMenu.container ), + // this.visible( '#current-history-panel' )].join( ', ' ) ); + return ( this.visible( '#masthead' ) + && this.visible( this.data.selectors.toolMenu.container ) + && this.visible( '#current-history-panel' ) ); +}; + // ------------------------------------------------------------------- try step /** Install a function as an error handler temporarily, run a function with steps, then remove the handler. * A rough stand-in for try catch with steps. @@ -549,6 +581,7 @@ }); }; + // ------------------------------------------------------------------- misc /** Hover over an element. * NOTE: not for use with iframes (main, tool, history) - they need to re-calc @@ -662,15 +695,6 @@ return returned; }; -///** Jumps into history frame, exectutes fn, and jumps back to original frame. -// * @param {Selector} frame the selector for the frame to jump to -// * @param {Function} fn function called when in the frame -// * @returns {Any} the return value of fn -// */ -//SpaceGhost.prototype.jumpToHistory = function jumpToHistory( fn ){ -// return this.jumpToFrame( this.data.selectors.frames.history, fn ); -//}; - /** Jumps into main frame, exectutes fn, and jumps back to original frame. * @param {Selector} frame the selector for the frame to jump to * @param {Function} fn function called when in the frame @@ -862,6 +886,7 @@ this.test.assert( classes.indexOf( className ) === -1, msg ); }; + // =================================================================== CONVENIENCE /** Wraps casper.getElementInfo in try, returning null if element not found instead of erroring. * @param {String} selector css or xpath selector for the element to find @@ -1096,7 +1121,7 @@ SpaceGhost.prototype.waitForMasthead = function wait( then ) { return this.waitForText( this.data.labels.masthead.menus.user, then ); -} +}; // =================================================================== TEST DATA @@ -1118,16 +1143,23 @@ }, frames : { - main : 'galaxy_main', - history : 'galaxy_history' + main : 'galaxy_main' }, masthead : { - adminLink : '#masthead a[href="/admin/index"]', - userMenu : { + id : '#masthead', + adminLink : '#masthead a[href="/admin/index"]', + userMenu : { userEmail_xpath : '//a[contains(text(),"Logged in as")]' } }, + toolMenu : { + container : '.toolMenuContainer' + }, + historyPanel : { + current : '#current-history-panel' + }, + loginPage : { form : 'form#login', submit_xpath : "//input[@value='Login']", @@ -1135,7 +1167,8 @@ }, registrationPage : { form : 'form#registration', - submit_xpath : "//input[@value='Submit']" + submit_xpath : "//input[@value='Submit']", + returnLink : '//a[contains(text(),"Return to the home page")]' }, tools : { general : { diff -r 4e6b003daaa44a06ac13c74c5ce8c75fa7bbb7ee -r 17e9e3ffb571e8f200ee8bf195a3708b2be4792b test/casperjs/upload-tests.js --- a/test/casperjs/upload-tests.js +++ b/test/casperjs/upload-tests.js @@ -43,16 +43,12 @@ // =================================================================== TESTS // ------------------------------------------------------------------- start a new user -spaceghost.user.loginOrRegisterUser( email, password ); -//??: why is a reload needed here? If we don't, loggedInAs === '' ... -spaceghost.thenOpen( spaceghost.baseUrl, function(){ +spaceghost.user.loginOrRegisterUser( email, password ).openHomePage( function(){ var loggedInAs = spaceghost.user.loggedInAs(); this.test.assert( loggedInAs === email, 'loggedInAs() matches email: "' + loggedInAs + '"' ); }); - // ------------------------------------------------------------------- long form - // upload a file... spaceghost.then( function(){ this.test.comment( 'Test uploading a file' ); 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.