From 87d8f5762a015840ce2084294241bbadd88ba7b1 Mon Sep 17 00:00:00 2001 From: John Chilton Date: Wed, 6 May 2015 14:21:14 -0400 Subject: [PATCH 1/3] Add qunit tests to Travis CI. --- .travis.yml | 2 ++ tox.ini | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 07c577b414c..6e1c444185d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,9 +5,11 @@ env: - TOX_ENV=py26-lint - TOX_ENV=py27-unit - TOX_ENV=py26-unit + - TOX_ENV=qunit install: - pip install tox + - if [ "$TOX_ENV" == "qunit" ]; then bash -c 'cd test/qunit && npm install'; fi script: tox -e $TOX_ENV diff --git a/tox.ini b/tox.ini index d9fa62054fb..54521a66993 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py27-lint, py26-lint, py27-unit, py26-unit +envlist = py27-lint, py26-lint, py27-unit, py26-unit, qunit skipsdist = True [testenv:py27-lint] @@ -21,3 +21,6 @@ commands = bash run_tests.sh -u whitelist_externals = bash deps = unittest2 +[testenv:qunit] +commands = bash run_tests.sh -q +whitelist_externals = bash From 19d00d6ac6d2fed64973373edea94fabc9a4ff1b Mon Sep 17 00:00:00 2001 From: Carl Eberhard Date: Tue, 5 May 2015 17:04:13 -0400 Subject: [PATCH 2/3] Testing, qunit: remove unfortunately silent error of missing global Galaxy when running via require and phantom by checking scope first, update list of pairs tests with recent option changes, remove debugging cruft --- .../scripts/mvc/history/history-content-model.js | 2 +- static/maps/mvc/history/history-content-model.js.map | 2 +- static/scripts/mvc/history/history-content-model.js | 2 +- test/qunit/tests/hda-base.js | 1 - test/qunit/tests/history_contents_model_tests.js | 1 + test/qunit/tests/job-dag.js | 2 -- test/qunit/tests/metrics-logger.js | 3 +-- test/qunit/tests/paired-collection-creator.js | 11 +++++------ 8 files changed, 10 insertions(+), 14 deletions(-) diff --git a/client/galaxy/scripts/mvc/history/history-content-model.js b/client/galaxy/scripts/mvc/history/history-content-model.js index 54a510caa02..af63301349a 100644 --- a/client/galaxy/scripts/mvc/history/history-content-model.js +++ b/client/galaxy/scripts/mvc/history/history-content-model.js @@ -92,7 +92,7 @@ var HistoryContentMixin = { //TODO: global //TODO: these are probably better done on the leaf classes /** history content goes through the 'api/histories' API */ - urlRoot: Galaxy.options.root + 'api/histories/', + urlRoot: ( window.Galaxy? Galaxy.options.root : '/' ) + 'api/histories/', /** full url spec. for this content */ url : function(){ diff --git a/static/maps/mvc/history/history-content-model.js.map b/static/maps/mvc/history/history-content-model.js.map index 57c25eb1813..a95237f5b84 100644 --- a/static/maps/mvc/history/history-content-model.js.map +++ b/static/maps/mvc/history/history-content-model.js.map @@ -1 +1 @@ -{"version":3,"file":"history-content-model.js","sources":["../../../src/mvc/history/history-content-model.js"],"names":["define","STATES","BASE_MVC","typeIdStr","type","id","join","HistoryContentMixin","defaults","history_id","history_content_type","hid","visible","idAttribute","constructor","attrs","type_id","this","debug","Backbone","Model","apply","arguments","_typeIdStr","get","initialize","on","_createTypeId","set","isNew","hidden","isVisible","show_deleted","show_hidden","urlRoot","Galaxy","options","root","url","hide","save","jQuery","when","unhide","toString","nameAndId","HistoryContent","extend","LoggableMixin"],"mappings":"AAAAA,QACI,qBACA,eACA,sBACD,SAAUC,EAAQC,GAGrB,GAAIC,GAAY,SAAqBC,EAAMC,GACvC,OAASD,EAAMC,GAAKC,KAAM,MAM1BC,GAIAC,UAEIC,WAAsB,KAEtBC,qBAAsB,KAEtBC,IAAsB,KAEtBC,SAAsB,GAQ1BC,YAAc,UAGdC,YAAc,SAAUC,GACpBA,EAAMC,QAAUb,EAAWY,EAAML,qBAAsBK,EAAMV,IAC7DY,KAAKC,MAAO,mCAAoCH,EAAMC,SACtDG,SAASC,MAAMC,MAAOJ,KAAMK,YAIhCC,WAAa,WACT,MAAOpB,GAAWc,KAAKO,IAAK,wBAA0BP,KAAKO,IAAK,QAIpEC,WAAa,WACTR,KAAKS,GAAI,YAAaT,KAAKU,gBAI/BA,cAAgB,WACZV,KAAKW,IAAK,UAAWX,KAAKM,eAM9BM,MAAQ,WACJ,OAAQZ,KAAKO,IAAK,OAKtBM,OAAS,WACL,OAAQb,KAAKO,IAAK,YAQtBO,UAAY,SAAUC,EAAcC,GAEhC,GAAIF,IAAY,CAShB,OAROC,KACDf,KAAKO,IAAK,aAAeP,KAAKO,IAAK,YACrCO,GAAY,GAETE,GACAhB,KAAKO,IAAK,aACbO,GAAY,GAETA,GAOXG,QAASC,OAAOC,QAAQC,KAAO,iBAG/BC,IAAM,WACF,GAAIA,GAAMrB,KAAKiB,QAAUjB,KAAKO,IAAK,cAAiB,aAC7CP,KAAKO,IAAI,wBAA0B,KAAOP,KAAKO,IAAK,KAC3D,OAAOc,IAIXC,KAAO,SAAUH,GACb,MAAKnB,MAAKO,IAAK,WACRP,KAAKuB,MAAQ5B,SAAS,GAASwB,GADDK,OAAOC,QAIhDC,OAAS,SAAUP,GACf,MAAInB,MAAKO,IAAK,WAAsBiB,OAAOC,OACpCzB,KAAKuB,MAAQ5B,SAAS,GAAQwB,IAKzCQ,SAAW,WACP,GAAIC,GAAY5B,KAAKO,IAAK,OAAU,EAIpC,OAHIP,MAAKO,IAAK,UACVqB,EAAY5B,KAAKO,IAAK,OAAU,MAAQP,KAAKO,IAAK,QAAW,KAAOqB,GAEjE,kBAAoBA,EAAY,MAS3CC,EAAiB3B,SAASC,MAAM2B,OAAQ7C,EAAS8C,eAAgBD,OAAQxC,EAIzE,QACIJ,UAAsBA,EACtBI,oBAAsBA,EACtBuC,eAAsBA"} \ No newline at end of file +{"version":3,"file":"history-content-model.js","sources":["../../../src/mvc/history/history-content-model.js"],"names":["define","STATES","BASE_MVC","typeIdStr","type","id","join","HistoryContentMixin","defaults","history_id","history_content_type","hid","visible","idAttribute","constructor","attrs","type_id","this","debug","Backbone","Model","apply","arguments","_typeIdStr","get","initialize","on","_createTypeId","set","isNew","hidden","isVisible","show_deleted","show_hidden","urlRoot","window","Galaxy","options","root","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,SAAW,WACP,GAAIC,GAAY7B,KAAKO,IAAK,OAAU,EAIpC,OAHIP,MAAKO,IAAK,UACVsB,EAAY7B,KAAKO,IAAK,OAAU,MAAQP,KAAKO,IAAK,QAAW,KAAOsB,GAEjE,kBAAoBA,EAAY,MAS3CC,EAAiB5B,SAASC,MAAM4B,OAAQ9C,EAAS+C,eAAgBD,OAAQzC,EAIzE,QACIJ,UAAsBA,EACtBI,oBAAsBA,EACtBwC,eAAsBA"} \ No newline at end of file diff --git a/static/scripts/mvc/history/history-content-model.js b/static/scripts/mvc/history/history-content-model.js index 6179e1da692..b53f8588b16 100644 --- a/static/scripts/mvc/history/history-content-model.js +++ b/static/scripts/mvc/history/history-content-model.js @@ -1,2 +1,2 @@ -define(["mvc/dataset/states","mvc/base-mvc","utils/localization"],function(a,b){var c=function(a,b){return[a,b].join("-")},d={defaults:{history_id:null,history_content_type:null,hid:null,visible:!0},idAttribute:"type_id",constructor:function(a){a.type_id=c(a.history_content_type,a.id),this.debug("HistoryContentMixin.constructor:",a.type_id),Backbone.Model.apply(this,arguments)},_typeIdStr:function(){return c(this.get("history_content_type"),this.get("id"))},initialize:function(){this.on("change:id",this._createTypeId)},_createTypeId:function(){this.set("type_id",this._typeIdStr())},isNew:function(){return!this.get("id")},hidden:function(){return!this.get("visible")},isVisible:function(a,b){var c=!0;return a||!this.get("deleted")&&!this.get("purged")||(c=!1),b||this.get("visible")||(c=!1),c},urlRoot:Galaxy.options.root+"api/histories/",url:function(){var a=this.urlRoot+this.get("history_id")+"/contents/"+this.get("history_content_type")+"s/"+this.get("id");return a},hide:function(a){return this.get("visible")?this.save({visible:!1},a):jQuery.when()},unhide:function(a){return this.get("visible")?jQuery.when():this.save({visible:!0},a)},toString:function(){var a=this.get("id")||"";return this.get("name")&&(a=this.get("hid")+' :"'+this.get("name")+'",'+a),"HistoryContent("+a+")"}},e=Backbone.Model.extend(b.LoggableMixin).extend(d);return{typeIdStr:c,HistoryContentMixin:d,HistoryContent:e}}); +define(["mvc/dataset/states","mvc/base-mvc","utils/localization"],function(a,b){var c=function(a,b){return[a,b].join("-")},d={defaults:{history_id:null,history_content_type:null,hid:null,visible:!0},idAttribute:"type_id",constructor:function(a){a.type_id=c(a.history_content_type,a.id),this.debug("HistoryContentMixin.constructor:",a.type_id),Backbone.Model.apply(this,arguments)},_typeIdStr:function(){return c(this.get("history_content_type"),this.get("id"))},initialize:function(){this.on("change:id",this._createTypeId)},_createTypeId:function(){this.set("type_id",this._typeIdStr())},isNew:function(){return!this.get("id")},hidden:function(){return!this.get("visible")},isVisible:function(a,b){var c=!0;return a||!this.get("deleted")&&!this.get("purged")||(c=!1),b||this.get("visible")||(c=!1),c},urlRoot:(window.Galaxy?Galaxy.options.root:"/")+"api/histories/",url:function(){var a=this.urlRoot+this.get("history_id")+"/contents/"+this.get("history_content_type")+"s/"+this.get("id");return a},hide:function(a){return this.get("visible")?this.save({visible:!1},a):jQuery.when()},unhide:function(a){return this.get("visible")?jQuery.when():this.save({visible:!0},a)},toString:function(){var a=this.get("id")||"";return this.get("name")&&(a=this.get("hid")+' :"'+this.get("name")+'",'+a),"HistoryContent("+a+")"}},e=Backbone.Model.extend(b.LoggableMixin).extend(d);return{typeIdStr:c,HistoryContentMixin:d,HistoryContent:e}}); //# sourceMappingURL=../../../maps/mvc/history/history-content-model.js.map \ No newline at end of file diff --git a/test/qunit/tests/hda-base.js b/test/qunit/tests/hda-base.js index add75a29f42..7870880e376 100644 --- a/test/qunit/tests/hda-base.js +++ b/test/qunit/tests/hda-base.js @@ -13,7 +13,6 @@ define([ ){ /*globals equal test module expect deepEqual strictEqual */ "use strict"; - module( "HDA base backbone view tests" ); test( "Base HDA view default construction, initialize", function() { diff --git a/test/qunit/tests/history_contents_model_tests.js b/test/qunit/tests/history_contents_model_tests.js index cbb16f611af..d1c9dc6d189 100644 --- a/test/qunit/tests/history_contents_model_tests.js +++ b/test/qunit/tests/history_contents_model_tests.js @@ -2,6 +2,7 @@ // (or demonstrating) qunit+backbone interactions. define([ "mvc/history/hda-model", + "jquery", "sinon-qunit" ], function( diff --git a/test/qunit/tests/job-dag.js b/test/qunit/tests/job-dag.js index 16d25481602..0bb51ca86b4 100644 --- a/test/qunit/tests/job-dag.js +++ b/test/qunit/tests/job-dag.js @@ -4,8 +4,6 @@ define([ "sinon-qunit", 'test-data/job-dag-1' ], function( JobDAG, $, sinon, testData ){ - console.debug( '' ); - /*globals equal ok, test module expect deepEqual strictEqual */ "use strict"; diff --git a/test/qunit/tests/metrics-logger.js b/test/qunit/tests/metrics-logger.js index c6e62d8bee4..61c713122a9 100644 --- a/test/qunit/tests/metrics-logger.js +++ b/test/qunit/tests/metrics-logger.js @@ -66,7 +66,6 @@ define([ }; module( "Metrics logger tests" ); - console.debug( '\n' ); // ======================================================================== MetricsLogger test( "logger construction/initializiation defaults", function() { var logger = new metrics.MetricsLogger({}); @@ -177,7 +176,7 @@ define([ logger.emit( 'metric', 'test', [ 1, 2, { three: 3 }] ); logger._postCache(); server.respond(); - + ok( callback.calledOnce, 'onServerResponse was called' ); equal( logger.cache.length(), 0, 'should have emptied cache (on success)' ); equal( logger._postSize, 1000, '_postSize still at default' ); diff --git a/test/qunit/tests/paired-collection-creator.js b/test/qunit/tests/paired-collection-creator.js index 5393b65ea65..5d752af15f5 100644 --- a/test/qunit/tests/paired-collection-creator.js +++ b/test/qunit/tests/paired-collection-creator.js @@ -1,5 +1,5 @@ define([ - "mvc/collection/paired-collection-creator", + "mvc/collection/list-of-pairs-collection-creator", "test-data/paired-collection-creator.data", "jquery", "sinon-qunit" @@ -19,11 +19,10 @@ define([ test( "Creator base/empty construction/initializiation defaults", function() { var pcc = new PCC([]); ok( pcc instanceof PCC ); - ok( pcc.hasOwnProperty( 'options' ) && typeof pcc.options === 'object' ); - deepEqual( pcc.options.filters, pcc.DEFAULT_FILTERS ); - ok( pcc.options.automaticallyPair ); - equal( pcc.options.matchPercentage, 0.9 ); - equal( pcc.options.strategy, 'lcs' ); + deepEqual( pcc.filters, pcc.commonFilters[ pcc.DEFAULT_FILTERS ] ); + ok( pcc.automaticallyPair ); + equal( pcc.matchPercentage, 0.9 ); + equal( pcc.strategy, 'autopairLCS' ); }); test( "Creator construction/initializiation with datasets", function() { From a0bd971beb3609f90bf8d184567e2ae9ca050e85 Mon Sep 17 00:00:00 2001 From: Carl Eberhard Date: Tue, 5 May 2015 17:09:39 -0400 Subject: [PATCH 3/3] Testing, qunit: rename paired-collection-creator test to match actual mvc script, update README to include silent error warning --- test/qunit/README.txt | 7 +++++++ ...-creator.html => list-of-pairs-collection-creator.html} | 0 ...tion-creator.js => list-of-pairs-collection-creator.js} | 0 3 files changed, 7 insertions(+) rename test/qunit/tests/{paired-collection-creator.html => list-of-pairs-collection-creator.html} (100%) rename test/qunit/tests/{paired-collection-creator.js => list-of-pairs-collection-creator.js} (100%) diff --git a/test/qunit/README.txt b/test/qunit/README.txt index d5d198956bd..a103a4db238 100644 --- a/test/qunit/README.txt +++ b/test/qunit/README.txt @@ -23,3 +23,10 @@ From Web Browser (no additional dependencies): Just open test HTML file in Web Browser. +Note: + The combination of requirejs and phantomjs used to load some of these +scripts can lead to error suppression. If any of the dependencies of the +scripts you're requiring throw an error, grunt+phantom+require will not +show a visible error (even with --verbose and/or --debug). You will instead +see a timeout error thrown from phantomjs. + This generally(?) applies only to errors when evaluating the dependency. \ No newline at end of file diff --git a/test/qunit/tests/paired-collection-creator.html b/test/qunit/tests/list-of-pairs-collection-creator.html similarity index 100% rename from test/qunit/tests/paired-collection-creator.html rename to test/qunit/tests/list-of-pairs-collection-creator.html diff --git a/test/qunit/tests/paired-collection-creator.js b/test/qunit/tests/list-of-pairs-collection-creator.js similarity index 100% rename from test/qunit/tests/paired-collection-creator.js rename to test/qunit/tests/list-of-pairs-collection-creator.js