commit/galaxy-central: carlfeberhard: Browser tests: fix to timeout length in waitForNavigation, change display button tooltip text, cleanup
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/ad1ad2e1cce3/ Changeset: ad1ad2e1cce3 User: carlfeberhard Date: 2013-04-15 17:21:14 Summary: Browser tests: fix to timeout length in waitForNavigation, change display button tooltip text, cleanup Affected #: 5 files diff -r 388e86c30bad627de5aecb41675d5b35051d9e1d -r ad1ad2e1cce31b1d4f916633970e8a39d54067eb test/casperjs/anon-history-tests.js --- a/test/casperjs/anon-history-tests.js +++ b/test/casperjs/anon-history-tests.js @@ -68,45 +68,43 @@ }); // ------------------------------------------------------------------- check the empty history for well formedness -spaceghost.thenOpen( spaceghost.baseUrl, function testPanelStructure(){ +spaceghost.historypanel.waitForHdas( function testPanelStructure(){ this.test.comment( 'history panel for anonymous user, new history' ); - this.withHistoryPanel( function(){ - this.test.comment( "frame should have proper url and title: 'History'" ); - this.test.assertMatch( this.getCurrentUrl(), /\/history/, 'Found history frame url' ); - this.test.assertTitle( this.getTitle(), 'History', 'Found history frame title' ); + this.test.comment( "frame should have proper url and title: 'History'" ); + this.test.assertMatch( this.getCurrentUrl(), /\/history/, 'Found history frame url' ); + this.test.assertTitle( this.getTitle(), 'History', 'Found history frame title' ); - this.test.comment( "history name should exist, be visible, and have text " + unnamedName ); - this.test.assertExists( nameSelector, nameSelector + ' exists' ); - this.test.assertVisible( nameSelector, 'History name is visible' ); - this.test.assertSelectorHasText( nameSelector, unnamedName, 'History name is ' + unnamedName ); + this.test.comment( "history name should exist, be visible, and have text " + unnamedName ); + this.test.assertExists( nameSelector, nameSelector + ' exists' ); + this.test.assertVisible( nameSelector, 'History name is visible' ); + this.test.assertSelectorHasText( nameSelector, unnamedName, 'History name is ' + unnamedName ); - this.test.comment( "history subtitle should display size and size should be 0 bytes" ); - this.test.assertExists( subtitleSelector, 'Found ' + subtitleSelector ); - this.test.assertVisible( subtitleSelector, 'History subtitle is visible' ); - this.test.assertSelectorHasText( subtitleSelector, initialSizeStr, - 'History subtitle has "' + initialSizeStr + '"' ); + this.test.comment( "history subtitle should display size and size should be 0 bytes" ); + this.test.assertExists( subtitleSelector, 'Found ' + subtitleSelector ); + this.test.assertVisible( subtitleSelector, 'History subtitle is visible' ); + this.test.assertSelectorHasText( subtitleSelector, initialSizeStr, + 'History subtitle has "' + initialSizeStr + '"' ); - this.test.comment( "NO tags or annotations icons should be available for an anonymous user" ); - this.test.assertDoesntExist( tagIconSelector, 'Tag icon button not found' ); - this.test.assertDoesntExist( annoIconSelector, 'Annotation icon button not found' ); + this.test.comment( "NO tags or annotations icons should be available for an anonymous user" ); + this.test.assertDoesntExist( tagIconSelector, 'Tag icon button not found' ); + this.test.assertDoesntExist( annoIconSelector, 'Annotation icon button not found' ); - this.test.assertExists( emptyMsgSelector, emptyMsgSelector + ' exists' ); - this.test.comment( "A message about the current history being empty should be displayed" ); - this.test.assertVisible( emptyMsgSelector, 'Empty history message is visible' ); - this.test.assertSelectorHasText( emptyMsgSelector, emptyMsgStr, - 'Message contains "' + emptyMsgStr + '"' ); + this.test.assertExists( emptyMsgSelector, emptyMsgSelector + ' exists' ); + this.test.comment( "A message about the current history being empty should be displayed" ); + this.test.assertVisible( emptyMsgSelector, 'Empty history message is visible' ); + this.test.assertSelectorHasText( emptyMsgSelector, emptyMsgStr, + 'Message contains "' + emptyMsgStr + '"' ); - this.test.comment( 'name should have a tooltip with info on anon-user name editing' ); - this.historypanel.hoverOver( nameSelector ); - this.test.assertExists( tooltipSelector, "Found tooltip after name hover" ); - this.test.assertSelectorHasText( tooltipSelector, anonNameTooltip ); + this.test.comment( 'name should have a tooltip with info on anon-user name editing' ); + this.historypanel.hoverOver( nameSelector ); + this.test.assertExists( tooltipSelector, "Found tooltip after name hover" ); + this.test.assertSelectorHasText( tooltipSelector, anonNameTooltip ); - this.test.comment( 'name should NOT be editable when clicked by anon-user' ); - this.assertDoesntHaveClass( nameSelector, editableTextClass, "Name field is not classed as editable text" ); - this.click( nameSelector ); - this.test.assertDoesntExist( editableTextInput, "Clicking on name does not create an input" ); - }); + this.test.comment( 'name should NOT be editable when clicked by anon-user' ); + this.assertDoesntHaveClass( nameSelector, editableTextClass, "Name field is not classed as editable text" ); + this.click( nameSelector ); + this.test.assertDoesntExist( editableTextInput, "Clicking on name does not create an input" ); }); // ------------------------------------------------------------------- anon user can upload file diff -r 388e86c30bad627de5aecb41675d5b35051d9e1d -r ad1ad2e1cce31b1d4f916633970e8a39d54067eb test/casperjs/modules/api.js --- a/test/casperjs/modules/api.js +++ b/test/casperjs/modules/api.js @@ -50,6 +50,13 @@ options = options || {}; options.async = false; + // PUT data needs to be stringified in jq.ajax and the content changed + //TODO: server side handling could change this? + if( ( options.type && options.type === 'PUT' ) && ( options.data ) ){ + options.contentType = 'application/json'; + options.data = JSON.stringify( options.data ); + } + this.ensureJQuery( '../../static/scripts/libs/jquery/jquery.js' ); var resp = this.spaceghost.evaluate( function( url, options ){ return jQuery.ajax( url, options ); @@ -189,10 +196,8 @@ HDAAPI.prototype.urlTpls = { index : 'api/histories/%s/contents', show : 'api/histories/%s/contents/%s', - create : 'api/histories/%s/contents'//, - // not implemented - //delete_ : 'api/histories/%s', - //undelete: 'api/histories/deleted/%s/undelete' + create : 'api/histories/%s/contents', + update : 'api/histories/%s/contents/%s' }; HDAAPI.prototype.index = function index( historyId, ids ){ @@ -213,7 +218,7 @@ id = ( id === 'most_recently_used' )?( id ):( this.api.ensureId( id ) ); deleted = deleted || false; - return this.api._ajax( utils.format( this.urlTpls.show, id ), { + return this.api._ajax( utils.format( this.urlTpls.show, this.api.ensureId( historyId ), id ), { data : { deleted: deleted } }); }; @@ -223,9 +228,24 @@ // py.payload <-> ajax.data payload = this.api.ensureObject( payload ); - return this.api._ajax( utils.format( this.urlTpls.create ), { + return this.api._ajax( utils.format( this.urlTpls.create, this.api.ensureId( historyId ) ), { type : 'POST', data : payload }); }; +HDAAPI.prototype.update = function create( historyId, id, payload ){ + this.api.spaceghost.info( 'history.update: ' + this.api.spaceghost.jsonStr( payload ) ); + + // py.payload <-> ajax.data + historyId = this.api.ensureId( historyId ); + id = this.api.ensureId( id ); + payload = this.api.ensureObject( payload ); + url = utils.format( this.urlTpls.update, historyId, id ); + + return this.api._ajax( url, { + type : 'PUT', + data : payload + }); +}; + diff -r 388e86c30bad627de5aecb41675d5b35051d9e1d -r ad1ad2e1cce31b1d4f916633970e8a39d54067eb test/casperjs/modules/historypanel.js --- a/test/casperjs/modules/historypanel.js +++ b/test/casperjs/modules/historypanel.js @@ -315,7 +315,7 @@ // mixing text and selectors here display : { selector : '.icon-button.display', - tooltip : 'Display data in browser', + tooltip : 'View data', hrefTpl : '/datasets/%s/display', nodeName : 'a' }, diff -r 388e86c30bad627de5aecb41675d5b35051d9e1d -r ad1ad2e1cce31b1d4f916633970e8a39d54067eb test/casperjs/modules/user.js --- a/test/casperjs/modules/user.js +++ b/test/casperjs/modules/user.js @@ -1,11 +1,4 @@ // =================================================================== module object, exports -/** Creates a new user module object. - * @exported - */ -exports.create = function createUser( spaceghost ){ - return new User( spaceghost ); -}; - /** User object constructor. * @param {SpaceGhost} spaceghost a spaceghost instance */ @@ -15,6 +8,13 @@ }; exports.User = User; +/** Creates a new user module object. + * @exported + */ +exports.create = function createUser( spaceghost ){ + return new User( spaceghost ); +}; + User.prototype.toString = function toString(){ return this.spaceghost + '.User'; }; diff -r 388e86c30bad627de5aecb41675d5b35051d9e1d -r ad1ad2e1cce31b1d4f916633970e8a39d54067eb test/casperjs/spaceghost.js --- a/test/casperjs/spaceghost.js +++ b/test/casperjs/spaceghost.js @@ -551,6 +551,7 @@ }; /** Wait for a multiple navigation requests then call a function. + * NOTE: waitFor time is set to <number of urls> * options.waitTimeout * NOTE: uses string indexOf - doesn't play well with urls like [ 'history', 'history/bler' ] * @param {String[]} urlsToWaitFor the relative urls to wait for * @param {Function} then the function to call after the nav request @@ -563,7 +564,7 @@ function catchNavReq( url ){ //this.debug( 'nav.req: ' + url ); - for( var i=( urlsToWaitFor.length - 1 ); i>=0; i-- ){ + for( var i=( urlsToWaitFor.length - 1 ); i>=0; i -= 1 ){ //this.debug( '\t checking: ' + urlsToWaitFor[i] ); if( urlMatches( urlsToWaitFor[i], url ) ){ this.info( 'Navigation (' + urlsToWaitFor[i] + ') found: ' + url ); @@ -584,7 +585,8 @@ }, function callThen(){ if( utils.isFunction( then ) ){ then.call( this ); } - } + }, + this.options.waitTimeout * urlsToWaitFor.length ); return this; }; @@ -779,7 +781,7 @@ //TODO: * @param {Boolean} removeOtherListeners option to remove other listeners while this fires var spaceghost = this; function testTheError( msg, backtrace ){ - spaceghost.test.assert( msg.indexOf( msgContains ) != -1, 'Raised correct error: ' + msg ); + spaceghost.test.assert( msg.indexOf( msgContains ) !== -1, 'Raised correct error: ' + msg ); } this.tryStepsCatch( stepsFn, testTheError ); }; @@ -824,7 +826,7 @@ * @param {String} className the class to test for (classes passed in with a leading '.' will have it trimmed) */ SpaceGhost.prototype.assertHasClass = function assertHasClass( selector, className, msg ){ - className = ( className[0] == '.' )?( className.slice( 1 ) ):( className ); + className = ( className[0] === '.' )?( className.slice( 1 ) ):( className ); msg = msg || 'selector "' + selector + '" has class: "' + className + '"'; var classes = this.getElementAttribute( selector, 'class' ); this.test.assert( classes.indexOf( className ) !== -1, msg ); @@ -835,7 +837,7 @@ * @param {String} className the class to test for (classes passed in with a leading '.' will have it trimmed) */ SpaceGhost.prototype.assertDoesntHaveClass = function assertDoesntHaveClass( selector, className, msg ){ - className = ( className[0] == '.' )?( className.slice( 1 ) ):( className ); + className = ( className[0] === '.' )?( className.slice( 1 ) ):( className ); msg = msg || 'selector "' + selector + '" has class: "' + className + '"'; var classes = this.getElementAttribute( selector, 'class' ); this.test.assert( classes.indexOf( className ) === -1, msg ); @@ -908,6 +910,7 @@ count -= 1; if( count <= 0 ){ clearInterval( interval ); } }, delay ); + return this; }; /** Pop all handlers for eventName from casper and return them in order. 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