diff --git a/grunt/mocha-runner.js b/grunt/mocha-runner.js index d254d254c..fef9a5c1d 100644 --- a/grunt/mocha-runner.js +++ b/grunt/mocha-runner.js @@ -136,7 +136,8 @@ module.exports = function (grunt) { options: { args: { ignoreResourceErrors: true, - timeout: 10000 + timeout: 10000, + fullTrace: true } }, all: { diff --git a/src/js/components/query_mediator.js b/src/js/components/query_mediator.js index d1c09cd16..53aaff418 100644 --- a/src/js/components/query_mediator.js +++ b/src/js/components/query_mediator.js @@ -5,7 +5,6 @@ /** * Mediator to coordinate UI-query exchange */ - define(['underscore', 'jquery', 'cache', @@ -283,24 +282,10 @@ function ( q.lock(); ps.publish(ps.INVITING_REQUEST, q); - // give widgets some time to submit their requests - var self = this; - - if (this.shortDelayInMs) { - setTimeout(function () { - self.__searchCycle.collectingRequests = false; - if (self.startExecutingQueries()) { - self.monitorExecution(); - } - }, this.shortDelayInMs); - } else { - this.__searchCycle.collectingRequests = false; - if (self.startExecutingQueries()) { - setTimeout(function () { - self.monitorExecution(); - }, this.shortDelayInMs); - } - } + // move this off the current stack, to add small delay + setTimeout(_.bind(function () { + this.startExecutingQueries() && this.monitorExecution(); + }, this), 0); }, @@ -372,14 +357,13 @@ function ( })); self.displayTugboatMessages(); - // after we are done with the first query, start executing other queries - var f = function () { + var completeWaiting = function () { + // after we are done with the first query, start executing other queries _.each(_.keys(cycle.waiting), function (k) { data = cycle.waiting[k]; delete cycle.waiting[k]; cycle.inprogress[k] = data; var psk = k; - self._executeRequest.call(self, data.request, data.key) .done(function () { cycle.done[psk] = cycle.inprogress[psk]; @@ -403,14 +387,19 @@ function ( }); }; - // for the display experience, it is better to introduce delays - if (self.longDelayInMs && self.longDelayInMs > 0) { + // wait an initial 500ms to let the widgets get their requests in, + // wait in 100ms increments until we no longer see a change in request cache + (function watchForChanges (l) { setTimeout(function () { - f(); - }, self.longDelayInMs); - } else { - f(); - } + // check the current length, if equal then we can assume nothing has changed + // since last check, let the cycle finish + if (l === self.__searchCycle.waiting.length) { + self.__searchCycle.collectingRequests = false; + return completeWaiting(); + } + setTimeout(watchForChanges, 100, self.__searchCycle.waiting.length); + }, 500); + })(self.__searchCycle.waiting.length); }) .fail(function (jqXHR, textStatus, errorThrown) { self.__searchCycle.error = true; @@ -523,8 +512,17 @@ function ( apiRequest.set('target', ApiTargets.MYADS_STORAGE + '/execute_query/' + qid); } - var ps = this.getPubSub(); - var api = this.getBeeHive().getService('Api'); + try { + var ps = this.getPubSub(); + var api = this.getBeeHive().getService('Api'); + } catch (e) { + return $.Deferred().reject().promise(); + } + + // reject the request if we don't have an api to call + if (!ps || !api) { + return $.Deferred().reject().promise(); + } var requestKey = this._getCacheKey(apiRequest); var maxTry = this.failedRequestsCache.getSync(requestKey) || 0; @@ -534,8 +532,7 @@ function ( request: apiRequest, key: senderKey, requestKey: requestKey, qm: this }, [{ status: ApiFeedback.CODES.TOO_MANY_FAILURES }, 'Error', 'This request has reached maximum number of failures (wait before retrying)']); - var d = $.Deferred(); - return d.reject(); + return $.Deferred().reject().promise(); } diff --git a/test/mocha/js/components/discovery_mediator.spec.js b/test/mocha/js/components/discovery_mediator.spec.js index eb00649bb..e3bacaaa0 100644 --- a/test/mocha/js/components/discovery_mediator.spec.js +++ b/test/mocha/js/components/discovery_mediator.spec.js @@ -114,40 +114,43 @@ define([ minsub.publish(minsub.DELIVERING_REQUEST, x.reqUnAuthorized); }); minsub.publish(minsub.START_SEARCH, x.qError); - - minsub.subscribeOnce(minsub.START_SEARCH, function() { - done()}); // if this fires, query was resurrected - - x.app.getPluginOrWidgetName = sinon.stub().returns(null); - x.app = _.extend(x.app, { - getApiAccess: function() { - var defer = $.Deferred(); - defer.resolve({}); - return defer; - }, - getController: function(name) { - if (name == 'QueryMediator') - return { - resetFailures: function() {} - } - }, - getService: function(name) { - if (name == 'Api') { - return { - request: function (apiReq, options) { - var d = $.Deferred(); - d.done(options.done); - d.fail(options.fail); - d.resolve(); - return d; + done(); + }); // if this fires, query was resurrected + var server = this.server; + + // wait enough time for sub-queries to fire + setTimeout(function () { + + x.app.getPluginOrWidgetName = sinon.stub().returns(null); + x.app = _.extend(x.app, { + getApiAccess: function() { + var defer = $.Deferred(); + defer.resolve({}); + return defer; + }, + getController: function(name) { + if (name == 'QueryMediator') + return { + resetFailures: function() {} + } + }, + getService: function(name) { + if (name == 'Api') { + return { + request: function (apiReq, options) { + var d = $.Deferred(); + d.done(options.done); + d.fail(options.fail); + d.resolve(); + return d; + } } } } - } - }); - this.server.respond(); - + }); + server.respond(); + }, 550); }); it("resets ORCID settings when the ORCID API returns 401, which is passed to the feedback service", function () { @@ -218,4 +221,4 @@ define([ }); }) -}); \ No newline at end of file +}); diff --git a/test/mocha/js/components/query_mediator.spec.js b/test/mocha/js/components/query_mediator.spec.js index 039af6e3b..de804860a 100644 --- a/test/mocha/js/components/query_mediator.spec.js +++ b/test/mocha/js/components/query_mediator.spec.js @@ -111,13 +111,13 @@ define([ afterEach(function(done) { if (this.beehive) { - setTimeout(function(self, xdone) { + setTimeout(function(self) { self.server.restore(); self.server.requests = [] self.beehive.destroy(); self.beehive = null; - xdone(); - }, 5, this, done) + done(); + }, 5, this) } }); @@ -431,7 +431,6 @@ define([ qm.startSearchCycle(new ApiQuery({'q': 'foo'}), key); - expect(qm._cache.size).to.be.eql(0); expect(qm.reset.callCount).to.eql(1); expect(qm.__searchCycle.initiator).to.be.eql(key.getId()); expect(qm.__searchCycle.waiting[key.getId()]).to.be.defined; @@ -500,6 +499,31 @@ define([ }); + it("sends CYCLE signals when job starts and is done", function(done) { + var pubSpy = this.pubSpy; + var x = createTestQM(this.beehive); + var qm = x.qm, key1 = x.key1, key2 = x.key2, req1 = x.req1, req2 = x.req2; + var respond = _.bind(this.server.respond, this.server); + qm.__searchCycle.waiting[key1.getId()] = {key: key1, request: req1}; + qm.__searchCycle.waiting[key2.getId()] = {key: key2, request: req2}; + qm.startExecutingQueries(); + expect(qm.__searchCycle.running).to.be.true; + expect(qm.__searchCycle.inprogress[key1.getId()]).to.be.defined; + respond(); + expect(qm.__searchCycle.done[key1.getId()]).to.be.defined; + expect(pubSpy.lastCall.args[1]).to.be.instanceOf(ApiFeedback); + expect(pubSpy.lastCall.args[1].code).to.be.eql(ApiFeedback.CODES.SEARCH_CYCLE_STARTED); + expect(_.keys(qm.__searchCycle.waiting).length).to.be.eql(1); + respond(); + setTimeout(function() { + respond(); + expect(pubSpy.lastCall.args[1]).to.be.instanceOf(ApiFeedback); + expect(pubSpy.lastCall.args[1].code).to.be.eql(ApiFeedback.CODES.SEARCH_CYCLE_FINISHED); + qm.destroy(); + done(); + }, 600); + }); + it("responds to GET_QTREE signal", function(done) { var pubSpy = this.pubSpy; var x = createTestQM(this.beehive); @@ -550,9 +574,10 @@ define([ expect(qm._executeRequest.callCount).to.be.eql(1); expect(qm.onApiResponse.callCount).to.be.eql(0); - this.server.respond(); - this.server.respond(); + var server = this.server; + server.respond(); setTimeout(function(qm, pubSpy, done) { + server.respond(); expect(pubSpy.firstCall.args[0]).to.be.eql(PubSubEvents.DELIVERING_RESPONSE + key1.getId()); expect(pubSpy.secondCall.args[0]).to.be.eql(PubSubEvents.FEEDBACK); expect(pubSpy.secondCall.args[1].code).to.be.eql(ApiFeedback.CODES.SEARCH_CYCLE_STARTED); @@ -561,7 +586,7 @@ define([ expect(qm.onApiResponse.callCount).to.be.eql(2); qm.destroy(); done(); - }, 50, qm, pubSpy, done); + }, 800, qm, pubSpy, done); }); @@ -673,39 +698,6 @@ define([ done(); }); - - it("sends CYCLE signals when job starts and is done", function(done) { - var pubSpy = this.pubSpy; - var x = createTestQM(this.beehive); - var qm = x.qm, key1 = x.key1, key2 = x.key2, req1 = x.req1, req2 = x.req2; - - this.beehive.addObject('DynamicConfig', {pskToExecuteFirst: key2.getId()}); - qm.__searchCycle.waiting[key1.getId()] = {key: key1, request: req1}; - qm.__searchCycle.waiting[key2.getId()] = {key: key2, request: req2}; - qm.startExecutingQueries(); - expect(qm.__searchCycle.running).to.be.true; - expect(qm.__searchCycle.inprogress[key2.getId()]).to.be.defined; - - this.server.respond(); - expect(qm.__searchCycle.done[key2.getId()]).to.be.defined; - expect(qm.__searchCycle.inprogress[key1.getId()]).to.be.defined; - expect(_.keys(qm.__searchCycle.waiting).length).to.be.eql(0); - - expect(pubSpy.lastCall.args[1]).to.be.instanceOf(ApiFeedback); - expect(pubSpy.lastCall.args[1].code).to.be.eql(ApiFeedback.CODES.SEARCH_CYCLE_STARTED); - - this.server.respond(); - var mydone = done; - - setTimeout(function(self, done, pubSpy) { - self.server.respond(); - expect(pubSpy.lastCall.args[1]).to.be.instanceOf(ApiFeedback); - expect(pubSpy.lastCall.args[1].code).to.be.eql(ApiFeedback.CODES.SEARCH_CYCLE_FINISHED); - qm.destroy(); - done(); - }, 1, this, done, pubSpy); - }); - it("knows to recover from certain errors", function(done) { var pubSpy = this.pubSpy; var x = createTestQM(this.beehive); diff --git a/test/mocha/js/widgets/author_affiliation_tool.spec.js b/test/mocha/js/widgets/author_affiliation_tool.spec.js index fbd5ea07e..72f07fd6c 100644 --- a/test/mocha/js/widgets/author_affiliation_tool.spec.js +++ b/test/mocha/js/widgets/author_affiliation_tool.spec.js @@ -43,7 +43,7 @@ define([ var offGroupedData = [{"id":"22","selected":false,"author":"Aygün, Sezgin","affiliations":[{"id":"23","selected":false,"name":"Department of Physics, Canakkale Onsekiz Mart University, Arts and Sciences Faculty, Terzioglu Campus, 17020, Turkey","years":["2018"]}],"lastActiveDates":[{"id":"24","selected":false,"date":"2018/04"}]},{"id":"25","selected":false,"author":"Baushev, A. N.","affiliations":[{"id":"26","selected":false,"name":"Bogoliubov Laboratory of Theoretical Physics, Joint Institute for Nuclear Research, 141980 Dubna, Moscow Region, Russia","years":["2018"]}],"lastActiveDates":[{"id":"27","selected":false,"date":"2018/04"}]},{"id":"28","selected":false,"author":"Bishi, Binaya K.","affiliations":[{"id":"29","selected":false,"name":"Department of Mathematics, Lovely Professional University, Phagwara, Jalandhar, Punjab 144401, India","years":["2018"]}],"lastActiveDates":[{"id":"30","selected":false,"date":"2018/04"}]},{"id":"31","selected":false,"author":"Chen, Yong","affiliations":[{"id":"32","selected":false,"name":"Shanghai Key Laboratory of Trustworthy Computing, East China Normal University, Shanghai 200062, China; MOE International Joint Lab of Trustworthy Software, East China Normal University, Shanghai 200062, China","years":["2018"]}],"lastActiveDates":[{"id":"33","selected":false,"date":"2018/04"}]},{"id":"34","selected":false,"author":"Ghiasi, Talieh S.","affiliations":[{"id":"35","selected":false,"name":"Faculty of Science and Engineering, Physics of Nanodevices, Zernike Institute for Advanced Materials, University of Groningen, Groningen, Netherlands","years":["2018"]}],"lastActiveDates":[{"id":"36","selected":false,"date":"2018/03"}]},{"id":"37","selected":false,"author":"Goel, Mayank","affiliations":[{"id":"38","selected":false,"name":"Department of MathematicsBirla Institute of Technology and Science (BITS) Pilani, K K Birla Goa Campus, Goa-403726, INDIA","years":["2018"]}],"lastActiveDates":[{"id":"39","selected":false,"date":"2018/04"}]},{"id":"40","selected":false,"author":"Myrzakulov, R.","affiliations":[{"id":"41","selected":false,"name":"Eurasian International Center for Theoretical Physics and Department of General Theoretical Physics, Eurasian National University, Astana 010008, Kazakhstan","years":["2018"]}],"lastActiveDates":[{"id":"42","selected":false,"date":"2018/04"}]},{"id":"43","selected":false,"author":"Quereda, Jorge","affiliations":[{"id":"44","selected":false,"name":"Faculty of Science and Engineering, Physics of Nanodevices, Zernike Institute for Advanced Materials, University of Groningen, Groningen, Netherlands","years":["2018"]}],"lastActiveDates":[{"id":"45","selected":false,"date":"2018/03"}]},{"id":"46","selected":false,"author":"Sahoo, P. K.","affiliations":[{"id":"47","selected":false,"name":"Department of Mathematics, Birla Institute of Technology and Science-Pilani Hyderabad Campus, Hyderabad, 500078, India","years":["2018"]}],"lastActiveDates":[{"id":"48","selected":false,"date":"2018/04"}]},{"id":"49","selected":false,"author":"Sahoo, Parbati","affiliations":[{"id":"50","selected":false,"name":"Department of Mathematics, Birla Institute of Technology and Science-Pilani Hyderabad Campus, Hyderabad, 500078, India","years":["2018"]}],"lastActiveDates":[{"id":"51","selected":false,"date":"2018/04"}]},{"id":"52","selected":false,"author":"Samanta, G. C.","affiliations":[{"id":"53","selected":false,"name":"Department of MathematicsBirla Institute of Technology and Science (BITS) Pilani, K K Birla Goa Campus, Goa-403726, INDIA","years":["2018"]}],"lastActiveDates":[{"id":"54","selected":false,"date":"2018/04"}]},{"id":"55","selected":false,"author":"Xu, Tao","affiliations":[{"id":"56","selected":false,"name":"Shanghai Key Laboratory of Trustworthy Computing, East China Normal University, Shanghai 200062, China; MOE International Joint Lab of Trustworthy Software, East China Normal University, Shanghai 200062, China","years":["2018"]}],"lastActiveDates":[{"id":"57","selected":false,"date":"2018/04"}]},{"id":"58","selected":false,"author":"van Wees, Bart J.","affiliations":[{"id":"59","selected":false,"name":"Faculty of Science and Engineering, Physics of Nanodevices, Zernike Institute for Advanced Materials, University of Groningen, Groningen, Netherlands","years":["2018"]}],"lastActiveDates":[{"id":"60","selected":false,"date":"2018/03"}]},{"id":"61","selected":false,"author":"van Zwol, Feitze A.","affiliations":[{"id":"62","selected":false,"name":"Faculty of Science and Engineering, Physics of Nanodevices, Zernike Institute for Advanced Materials, University of Groningen, Groningen, Netherlands","years":["2018"]}],"lastActiveDates":[{"id":"63","selected":false,"date":"2018/03"}]},{"id":"64","selected":false,"author":"van der Wal, Caspar H.","affiliations":[{"id":"65","selected":false,"name":"Faculty of Science and Engineering, Physics of Nanodevices, Zernike Institute for Advanced Materials, University of Groningen, Groningen, Netherlands","years":["2018"]}],"lastActiveDates":[{"id":"66","selected":false,"date":"2018/03"}]}]; var mockResponse = {"data":[{"affiliations":{"lastActiveDate":"2018/04","name":"Department of Physics, Canakkale Onsekiz Mart University, Arts and Sciences Faculty, Terzioglu Campus, 17020, Turkey","years":["2018"]},"authorName":"Aygün, Sezgin"},{"affiliations":{"lastActiveDate":"2018/04","name":"Bogoliubov Laboratory of Theoretical Physics, Joint Institute for Nuclear Research, 141980 Dubna, Moscow Region, Russia","years":["2018"]},"authorName":"Baushev, A. N."},{"affiliations":{"lastActiveDate":"2018/04","name":"Department of Mathematics, Lovely Professional University, Phagwara, Jalandhar, Punjab 144401, India","years":["2018"]},"authorName":"Bishi, Binaya K."},{"affiliations":{"lastActiveDate":"2018/04","name":"Shanghai Key Laboratory of Trustworthy Computing, East China Normal University, Shanghai 200062, China; MOE International Joint Lab of Trustworthy Software, East China Normal University, Shanghai 200062, China","years":["2018"]},"authorName":"Chen, Yong"},{"affiliations":{"lastActiveDate":"2018/03","name":"Faculty of Science and Engineering, Physics of Nanodevices, Zernike Institute for Advanced Materials, University of Groningen, Groningen, Netherlands","years":["2018"]},"authorName":"Ghiasi, Talieh S."},{"affiliations":{"lastActiveDate":"2018/04","name":"Department of MathematicsBirla Institute of Technology and Science (BITS) Pilani, K K Birla Goa Campus, Goa-403726, INDIA","years":["2018"]},"authorName":"Goel, Mayank"},{"affiliations":{"lastActiveDate":"2018/04","name":"Eurasian International Center for Theoretical Physics and Department of General Theoretical Physics, Eurasian National University, Astana 010008, Kazakhstan","years":["2018"]},"authorName":"Myrzakulov, R."},{"affiliations":{"lastActiveDate":"2018/03","name":"Faculty of Science and Engineering, Physics of Nanodevices, Zernike Institute for Advanced Materials, University of Groningen, Groningen, Netherlands","years":["2018"]},"authorName":"Quereda, Jorge"},{"affiliations":{"lastActiveDate":"2018/04","name":"Department of Mathematics, Birla Institute of Technology and Science-Pilani Hyderabad Campus, Hyderabad, 500078, India","years":["2018"]},"authorName":"Sahoo, P. K."},{"affiliations":{"lastActiveDate":"2018/04","name":"Department of Mathematics, Birla Institute of Technology and Science-Pilani Hyderabad Campus, Hyderabad, 500078, India","years":["2018"]},"authorName":"Sahoo, Parbati"},{"affiliations":{"lastActiveDate":"2018/04","name":"Department of MathematicsBirla Institute of Technology and Science (BITS) Pilani, K K Birla Goa Campus, Goa-403726, INDIA","years":["2018"]},"authorName":"Samanta, G. C."},{"affiliations":{"lastActiveDate":"2018/04","name":"Shanghai Key Laboratory of Trustworthy Computing, East China Normal University, Shanghai 200062, China; MOE International Joint Lab of Trustworthy Software, East China Normal University, Shanghai 200062, China","years":["2018"]},"authorName":"Xu, Tao"},{"affiliations":{"lastActiveDate":"2018/03","name":"Faculty of Science and Engineering, Physics of Nanodevices, Zernike Institute for Advanced Materials, University of Groningen, Groningen, Netherlands","years":["2018"]},"authorName":"van Wees, Bart J."},{"affiliations":{"lastActiveDate":"2018/03","name":"Faculty of Science and Engineering, Physics of Nanodevices, Zernike Institute for Advanced Materials, University of Groningen, Groningen, Netherlands","years":["2018"]},"authorName":"van Zwol, Feitze A."},{"affiliations":{"lastActiveDate":"2018/03","name":"Faculty of Science and Engineering, Physics of Nanodevices, Zernike Institute for Advanced Materials, University of Groningen, Groningen, Netherlands","years":["2018"]},"authorName":"van der Wal, Caspar H."}]}; var mockGroupedData = [{"id":"22","selected":true,"author":"Aygün, Sezgin","affiliations":[{"id":"23","selected":true,"name":"Department of Physics, Canakkale Onsekiz Mart University, Arts and Sciences Faculty, Terzioglu Campus, 17020, Turkey","years":["2018"]}],"lastActiveDates":[{"id":"24","selected":true,"date":"2018/04"}]},{"id":"25","selected":true,"author":"Baushev, A. N.","affiliations":[{"id":"26","selected":true,"name":"Bogoliubov Laboratory of Theoretical Physics, Joint Institute for Nuclear Research, 141980 Dubna, Moscow Region, Russia","years":["2018"]}],"lastActiveDates":[{"id":"27","selected":true,"date":"2018/04"}]},{"id":"28","selected":true,"author":"Bishi, Binaya K.","affiliations":[{"id":"29","selected":true,"name":"Department of Mathematics, Lovely Professional University, Phagwara, Jalandhar, Punjab 144401, India","years":["2018"]}],"lastActiveDates":[{"id":"30","selected":true,"date":"2018/04"}]},{"id":"31","selected":true,"author":"Chen, Yong","affiliations":[{"id":"32","selected":true,"name":"Shanghai Key Laboratory of Trustworthy Computing, East China Normal University, Shanghai 200062, China; MOE International Joint Lab of Trustworthy Software, East China Normal University, Shanghai 200062, China","years":["2018"]}],"lastActiveDates":[{"id":"33","selected":true,"date":"2018/04"}]},{"id":"34","selected":true,"author":"Ghiasi, Talieh S.","affiliations":[{"id":"35","selected":true,"name":"Faculty of Science and Engineering, Physics of Nanodevices, Zernike Institute for Advanced Materials, University of Groningen, Groningen, Netherlands","years":["2018"]}],"lastActiveDates":[{"id":"36","selected":true,"date":"2018/03"}]},{"id":"37","selected":true,"author":"Goel, Mayank","affiliations":[{"id":"38","selected":true,"name":"Department of MathematicsBirla Institute of Technology and Science (BITS) Pilani, K K Birla Goa Campus, Goa-403726, INDIA","years":["2018"]}],"lastActiveDates":[{"id":"39","selected":true,"date":"2018/04"}]},{"id":"40","selected":true,"author":"Myrzakulov, R.","affiliations":[{"id":"41","selected":true,"name":"Eurasian International Center for Theoretical Physics and Department of General Theoretical Physics, Eurasian National University, Astana 010008, Kazakhstan","years":["2018"]}],"lastActiveDates":[{"id":"42","selected":true,"date":"2018/04"}]},{"id":"43","selected":true,"author":"Quereda, Jorge","affiliations":[{"id":"44","selected":true,"name":"Faculty of Science and Engineering, Physics of Nanodevices, Zernike Institute for Advanced Materials, University of Groningen, Groningen, Netherlands","years":["2018"]}],"lastActiveDates":[{"id":"45","selected":true,"date":"2018/03"}]},{"id":"46","selected":true,"author":"Sahoo, P. K.","affiliations":[{"id":"47","selected":true,"name":"Department of Mathematics, Birla Institute of Technology and Science-Pilani Hyderabad Campus, Hyderabad, 500078, India","years":["2018"]}],"lastActiveDates":[{"id":"48","selected":true,"date":"2018/04"}]},{"id":"49","selected":true,"author":"Sahoo, Parbati","affiliations":[{"id":"50","selected":true,"name":"Department of Mathematics, Birla Institute of Technology and Science-Pilani Hyderabad Campus, Hyderabad, 500078, India","years":["2018"]}],"lastActiveDates":[{"id":"51","selected":true,"date":"2018/04"}]},{"id":"52","selected":true,"author":"Samanta, G. C.","affiliations":[{"id":"53","selected":true,"name":"Department of MathematicsBirla Institute of Technology and Science (BITS) Pilani, K K Birla Goa Campus, Goa-403726, INDIA","years":["2018"]}],"lastActiveDates":[{"id":"54","selected":true,"date":"2018/04"}]},{"id":"55","selected":true,"author":"Xu, Tao","affiliations":[{"id":"56","selected":true,"name":"Shanghai Key Laboratory of Trustworthy Computing, East China Normal University, Shanghai 200062, China; MOE International Joint Lab of Trustworthy Software, East China Normal University, Shanghai 200062, China","years":["2018"]}],"lastActiveDates":[{"id":"57","selected":true,"date":"2018/04"}]},{"id":"58","selected":true,"author":"van Wees, Bart J.","affiliations":[{"id":"59","selected":true,"name":"Faculty of Science and Engineering, Physics of Nanodevices, Zernike Institute for Advanced Materials, University of Groningen, Groningen, Netherlands","years":["2018"]}],"lastActiveDates":[{"id":"60","selected":true,"date":"2018/03"}]},{"id":"61","selected":true,"author":"van Zwol, Feitze A.","affiliations":[{"id":"62","selected":true,"name":"Faculty of Science and Engineering, Physics of Nanodevices, Zernike Institute for Advanced Materials, University of Groningen, Groningen, Netherlands","years":["2018"]}],"lastActiveDates":[{"id":"63","selected":true,"date":"2018/03"}]},{"id":"64","selected":true,"author":"van der Wal, Caspar H.","affiliations":[{"id":"65","selected":true,"name":"Faculty of Science and Engineering, Physics of Nanodevices, Zernike Institute for Advanced Materials, University of Groningen, Groningen, Netherlands","years":["2018"]}],"lastActiveDates":[{"id":"66","selected":true,"date":"2018/03"}]}]; - var mockTable = 'Viewing Affiliation Data For 15 AuthorsFrom 2014 to 2018 | 3 authors from each workAuthors:1234510AllYears:1234510All| Lastname, Firstname | Affiliation | Last Active Date | [csv]| Lastname | Firstname | Affiliation | Last Active Date | [csv]| Lastname, Firstname | Affiliation | Last Active Date | [excel]| Lastname | Firstname | Affiliation | Last Active Date | [excel]Lastname, Firstname(Affiliation)Last Active Date[text]Lastname, Firstname(Affiliation)Last Active Date[browser]ExportToggle AllResetAuthorAffiliationsYearsLast Active Date Aygün, Sezgin Department of Physics, Canakkale Onsekiz Mart University, Arts and Sciences Faculty, Terzioglu Campus, 17020, Turkey2018 2018/04 Baushev, A. N. Bogoliubov Laboratory of Theoretical Physics, Joint Institute for Nuclear Research, 141980 Dubna, Moscow Region, Russia2018 2018/04 Bishi, Binaya K. Department of Mathematics, Lovely Professional University, Phagwara, Jalandhar, Punjab 144401, India2018 2018/04 Chen, Yong Shanghai Key Laboratory of Trustworthy Computing, East China Normal University, Shanghai 200062, China; MOE International Joint Lab of Trustworthy Software, East China Normal University, Shanghai 200062, China2018 2018/04 Ghiasi, Talieh S. Faculty of Science and Engineering, Physics of Nanodevices, Zernike Institute for Advanced Materials, University of Groningen, Groningen, Netherlands2018 2018/03 Goel, Mayank Department of MathematicsBirla Institute of Technology and Science (BITS) Pilani, K K Birla Goa Campus, Goa-403726, INDIA2018 2018/04 Myrzakulov, R. Eurasian International Center for Theoretical Physics and Department of General Theoretical Physics, Eurasian National University, Astana 010008, Kazakhstan2018 2018/04 Quereda, Jorge Faculty of Science and Engineering, Physics of Nanodevices, Zernike Institute for Advanced Materials, University of Groningen, Groningen, Netherlands2018 2018/03 Sahoo, P. K. Department of Mathematics, Birla Institute of Technology and Science-Pilani Hyderabad Campus, Hyderabad, 500078, India2018 2018/04 Sahoo, Parbati Department of Mathematics, Birla Institute of Technology and Science-Pilani Hyderabad Campus, Hyderabad, 500078, India2018 2018/04 Samanta, G. C. Department of MathematicsBirla Institute of Technology and Science (BITS) Pilani, K K Birla Goa Campus, Goa-403726, INDIA2018 2018/04 Xu, Tao Shanghai Key Laboratory of Trustworthy Computing, East China Normal University, Shanghai 200062, China; MOE International Joint Lab of Trustworthy Software, East China Normal University, Shanghai 200062, China2018 2018/04 van Wees, Bart J. Faculty of Science and Engineering, Physics of Nanodevices, Zernike Institute for Advanced Materials, University of Groningen, Groningen, Netherlands2018 2018/03 van Zwol, Feitze A. Faculty of Science and Engineering, Physics of Nanodevices, Zernike Institute for Advanced Materials, University of Groningen, Groningen, Netherlands2018 2018/03 van der Wal, Caspar H. Faculty of Science and Engineering, Physics of Nanodevices, Zernike Institute for Advanced Materials, University of Groningen, Groningen, Netherlands2018 2018/03'; + var mockTable = 'Viewing Affiliation Data For 15 Authors | 3 authors from each workAuthors:1234510AllYears:1234510All| Lastname, Firstname | Affiliation | Last Active Date | [csv]| Lastname | Firstname | Affiliation | Last Active Date | [csv]| Lastname, Firstname | Affiliation | Last Active Date | [excel]| Lastname | Firstname | Affiliation | Last Active Date | [excel]Lastname, Firstname(Affiliation)Last Active Date[text]Lastname, Firstname(Affiliation)Last Active Date[browser]ExportToggle AllResetAuthorAffiliationsYearsLast Active Date Aygün, Sezgin Department of Physics, Canakkale Onsekiz Mart University, Arts and Sciences Faculty, Terzioglu Campus, 17020, Turkey2018 2018/04 Baushev, A. N. Bogoliubov Laboratory of Theoretical Physics, Joint Institute for Nuclear Research, 141980 Dubna, Moscow Region, Russia2018 2018/04 Bishi, Binaya K. Department of Mathematics, Lovely Professional University, Phagwara, Jalandhar, Punjab 144401, India2018 2018/04 Chen, Yong Shanghai Key Laboratory of Trustworthy Computing, East China Normal University, Shanghai 200062, China; MOE International Joint Lab of Trustworthy Software, East China Normal University, Shanghai 200062, China2018 2018/04 Ghiasi, Talieh S. Faculty of Science and Engineering, Physics of Nanodevices, Zernike Institute for Advanced Materials, University of Groningen, Groningen, Netherlands2018 2018/03 Goel, Mayank Department of MathematicsBirla Institute of Technology and Science (BITS) Pilani, K K Birla Goa Campus, Goa-403726, INDIA2018 2018/04 Myrzakulov, R. Eurasian International Center for Theoretical Physics and Department of General Theoretical Physics, Eurasian National University, Astana 010008, Kazakhstan2018 2018/04 Quereda, Jorge Faculty of Science and Engineering, Physics of Nanodevices, Zernike Institute for Advanced Materials, University of Groningen, Groningen, Netherlands2018 2018/03 Sahoo, P. K. Department of Mathematics, Birla Institute of Technology and Science-Pilani Hyderabad Campus, Hyderabad, 500078, India2018 2018/04 Sahoo, Parbati Department of Mathematics, Birla Institute of Technology and Science-Pilani Hyderabad Campus, Hyderabad, 500078, India2018 2018/04 Samanta, G. C. Department of MathematicsBirla Institute of Technology and Science (BITS) Pilani, K K Birla Goa Campus, Goa-403726, INDIA2018 2018/04 Xu, Tao Shanghai Key Laboratory of Trustworthy Computing, East China Normal University, Shanghai 200062, China; MOE International Joint Lab of Trustworthy Software, East China Normal University, Shanghai 200062, China2018 2018/04 van Wees, Bart J. Faculty of Science and Engineering, Physics of Nanodevices, Zernike Institute for Advanced Materials, University of Groningen, Groningen, Netherlands2018 2018/03 van Zwol, Feitze A. Faculty of Science and Engineering, Physics of Nanodevices, Zernike Institute for Advanced Materials, University of Groningen, Groningen, Netherlands2018 2018/03 van der Wal, Caspar H. Faculty of Science and Engineering, Physics of Nanodevices, Zernike Institute for Advanced Materials, University of Groningen, Groningen, Netherlands2018 2018/03'; var exportSelection = {"selected":["Aygün, Sezgin|Department of Physics, Canakkale Onsekiz Mart University, Arts and Sciences Faculty, Terzioglu Campus, 17020, Turkey|2018/04","Baushev, A. N.|Bogoliubov Laboratory of Theoretical Physics, Joint Institute for Nuclear Research, 141980 Dubna, Moscow Region, Russia|2018/04","Bishi, Binaya K.|Department of Mathematics, Lovely Professional University, Phagwara, Jalandhar, Punjab 144401, India|2018/04","Chen, Yong|Shanghai Key Laboratory of Trustworthy Computing, East China Normal University, Shanghai 200062, China; MOE International Joint Lab of Trustworthy Software, East China Normal University, Shanghai 200062, China|2018/04","Ghiasi, Talieh S.|Faculty of Science and Engineering, Physics of Nanodevices, Zernike Institute for Advanced Materials, University of Groningen, Groningen, Netherlands|2018/03","Goel, Mayank|Department of MathematicsBirla Institute of Technology and Science (BITS) Pilani, K K Birla Goa Campus, Goa-403726, INDIA|2018/04","Myrzakulov, R.|Eurasian International Center for Theoretical Physics and Department of General Theoretical Physics, Eurasian National University, Astana 010008, Kazakhstan|2018/04","Quereda, Jorge|Faculty of Science and Engineering, Physics of Nanodevices, Zernike Institute for Advanced Materials, University of Groningen, Groningen, Netherlands|2018/03","Sahoo, P. K.|Department of Mathematics, Birla Institute of Technology and Science-Pilani Hyderabad Campus, Hyderabad, 500078, India|2018/04","Sahoo, Parbati|Department of Mathematics, Birla Institute of Technology and Science-Pilani Hyderabad Campus, Hyderabad, 500078, India|2018/04","Samanta, G. C.|Department of MathematicsBirla Institute of Technology and Science (BITS) Pilani, K K Birla Goa Campus, Goa-403726, INDIA|2018/04","Xu, Tao|Shanghai Key Laboratory of Trustworthy Computing, East China Normal University, Shanghai 200062, China; MOE International Joint Lab of Trustworthy Software, East China Normal University, Shanghai 200062, China|2018/04","van Wees, Bart J.|Faculty of Science and Engineering, Physics of Nanodevices, Zernike Institute for Advanced Materials, University of Groningen, Groningen, Netherlands|2018/03","van Zwol, Feitze A.|Faculty of Science and Engineering, Physics of Nanodevices, Zernike Institute for Advanced Materials, University of Groningen, Groningen, Netherlands|2018/03","van der Wal, Caspar H.|Faculty of Science and Engineering, Physics of Nanodevices, Zernike Institute for Advanced Materials, University of Groningen, Groningen, Netherlands|2018/03"],"format":"| Lastname, Firstname | Affiliation | Last Active Date | [csv]"}; var mockIds = [ "2018NewA...60...80S", @@ -165,7 +165,8 @@ define([ expect(el.text()).to.eql('Loading...'); _.delay(function () { var el = Enzyme.render(com); - expect(el.text()).to.eql(mockTable); + var text = el.text().replace(/From\s\d{4}\sto\s\d{4}/, ''); + expect(text).to.eql(mockTable); done(); }, 15); }, 15); @@ -198,7 +199,8 @@ define([ expect(el.text()).to.eql('Loading...'); _.delay(function () { var el = Enzyme.render(com); - expect(el.text()).to.eql(mockTable); + var text = el.text().replace(/From\s\d{4}\sto\s\d{4}/, ''); + expect(text).to.eql(mockTable); done(); }, 25); }); diff --git a/test/mocha/js/widgets/base_widget.spec.js b/test/mocha/js/widgets/base_widget.spec.js index e23bc4546..dc965015a 100644 --- a/test/mocha/js/widgets/base_widget.spec.js +++ b/test/mocha/js/widgets/base_widget.spec.js @@ -61,15 +61,14 @@ define([ widget.activate(minsub.beehive.getHardenedInstance()); - minsub.publish(minsub.START_SEARCH, new ApiQuery({q: 'pluto'})); - - expect(widget.dispatchRequest.firstCall.args[0].url()).to.eql('q=pluto&sort=date%20desc%2C%20bibcode%20desc'); - expect(widget.customizeQuery.calledOnce).to.be.true; - expect(widget.customizeQuery.calledBefore(widget.composeRequest)).to.be.true; - expect(widget.processResponse.called).to.be.true; - done(); - + setTimeout(function () { + expect(widget.dispatchRequest.firstCall.args[0].url()).to.eql('q=pluto&sort=date%20desc%2C%20bibcode%20desc'); + expect(widget.customizeQuery.calledOnce).to.be.true; + expect(widget.customizeQuery.calledBefore(widget.composeRequest)).to.be.true; + expect(widget.processResponse.called).to.be.true; + done(); + }, 550); }); it("has the activate and close methods necessary for most/all ui widgets", function(){ diff --git a/test/mocha/js/widgets/hello_world_widget.spec.js b/test/mocha/js/widgets/hello_world_widget.spec.js index 70d4b376f..f5493b038 100644 --- a/test/mocha/js/widgets/hello_world_widget.spec.js +++ b/test/mocha/js/widgets/hello_world_widget.spec.js @@ -58,7 +58,7 @@ define([ expect(widget.model.get('name')).to.eql('wonderful BumBleBee'); }); - it("knows to listen to the pubsub", function() { + it("knows to listen to the pubsub", function(done) { var widget = new HelloWorldWidget(); widget.activate(this.minsub.beehive.getHardenedInstance()); // this is normally done by application @@ -68,7 +68,11 @@ define([ var minsub = this.minsub; minsub.publish(minsub.START_SEARCH, minsub.createQuery({'q': 'hello'})); - expect($w.find('.message').text()).to.be.eql('The query found: 841359 results.'); + // wait enough time for sub-queries to fire + setTimeout(function () { + expect($w.find('.message').text()).to.be.eql('The query found: 841359 results.'); + done(); + }, 550); }); diff --git a/test/mocha/js/widgets/results_render_widget.spec.js b/test/mocha/js/widgets/results_render_widget.spec.js index a871f24a6..5f46a72b3 100644 --- a/test/mocha/js/widgets/results_render_widget.spec.js +++ b/test/mocha/js/widgets/results_render_widget.spec.js @@ -164,7 +164,7 @@ define([ }, 50); }); - it("provides the openurl linkserver info to each model's data for the link_generator_mixin", function(){ + it("provides the openurl linkserver info to each model's data for the link_generator_mixin", function(done){ //each model will interact with the link generator mixin, which expectes the link_server param @@ -172,8 +172,11 @@ define([ minsub.publish(minsub.START_SEARCH, new ApiQuery({q: "star"})); - expect(widget.collection.pluck("link_server")).to.eql(["foo", "foo", "foo", "foo", "foo", "foo", "foo", "foo", "foo", "foo"]); - + // wait enough time for sub-queries to fire + setTimeout(function () { + expect(widget.collection.pluck("link_server")).to.eql(["foo", "foo", "foo", "foo", "foo", "foo", "foo", "foo", "foo", "foo"]); + done(); + }, 550); }); //TODO: re-enable this test, skipping for now @@ -276,7 +279,7 @@ define([ }); - it("should mark papers as selected", function() { + it("should mark papers as selected", function(done) { var s = new AppStorage(); s.activate(minsub.beehive); minsub.beehive.addObject('AppStorage', s); @@ -286,17 +289,17 @@ define([ s.addSelectedPapers('2013arXiv1305.3460H'); minsub.publish(minsub.START_SEARCH, new ApiQuery({'q': 'foo:bar'})); + // wait enough time for sub-queries to fire + setTimeout(function () { + var $w = widget.render().$el; + $("#test").append($w); - var $w = widget.render().$el; - $("#test").append($w); - - // select a paper and observe it gets into the storage - expect(s.isPaperSelected('1993sfgi.conf..324C')).to.eql(false); - $w.find('input[value="1993sfgi.conf..324C"]').click(); - expect(s.isPaperSelected('1993sfgi.conf..324C')).to.eql(true); - - - + // select a paper and observe it gets into the storage + expect(s.isPaperSelected('1993sfgi.conf..324C')).to.eql(false); + $w.find('input[value="1993sfgi.conf..324C"]').click(); + expect(s.isPaperSelected('1993sfgi.conf..324C')).to.eql(true); + done(); + }, 550); }); }) }); diff --git a/test/mocha/tests.html b/test/mocha/tests.html index 27da4f7ac..9e1519cda 100644 --- a/test/mocha/tests.html +++ b/test/mocha/tests.html @@ -42,14 +42,6 @@ // init mochaPhantomJS global.initMochaPhantomJS(); - - // Stop console.log from cluttering up testing output - global.console = { - info: function () {}, - warn: function () {}, - log: function () {}, - error: function () {} - }; } // parse out url params, needed only to grab suite name