From fbd21bae1600ac6b338a80c08de76b9c0530d823 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Thu, 8 Dec 2016 05:52:22 -0500 Subject: [PATCH] Don't update feeds after syncs during tests This reverts commit 60befe52e4fec76ff7cbe6c169510661d443a971 and adds a better fix that leaves the notifier event in place. Feeds just don't need to update after syncs during tests. --- chrome/content/zotero/xpcom/data/feeds.js | 2 ++ test/tests/syncRunnerTest.js | 25 +---------------------- 2 files changed, 3 insertions(+), 24 deletions(-) diff --git a/chrome/content/zotero/xpcom/data/feeds.js b/chrome/content/zotero/xpcom/data/feeds.js index d79996aa60..19780edaef 100644 --- a/chrome/content/zotero/xpcom/data/feeds.js +++ b/chrome/content/zotero/xpcom/data/feeds.js @@ -44,6 +44,8 @@ Zotero.Feeds = new function() { Zotero.Notifier.registerObserver({notify: function(event) { if (event == 'finish') { + // Don't update during tests, since the database will have been closed + if (Zotero.test) return; Zotero.Feeds.updateFeeds(); } }}, ['sync'], 'feedsUpdate'); diff --git a/test/tests/syncRunnerTest.js b/test/tests/syncRunnerTest.js index 36f06a0bf8..1470bb3d6c 100644 --- a/test/tests/syncRunnerTest.js +++ b/test/tests/syncRunnerTest.js @@ -556,18 +556,6 @@ describe("Zotero.Sync.Runner", function () { }) describe("#sync()", function () { - // Notifier is triggered without waiting for async actions to finish, which - // fires off database queries after its been closed. - var observerTriggerDeferred; - beforeEach(function() { - observerTriggerDeferred = Zotero.Promise.defer(); - sinon.stub(Zotero.Notifier, 'trigger', - (e) => {if (e == 'finish') observerTriggerDeferred.resolve(); return Zotero.Promise.resolve()}); - }); - afterEach(function* () { - yield observerTriggerDeferred.promise; - Zotero.Notifier.trigger.restore(); - }); it("should perform a sync across all libraries and update library versions", function* () { setResponse('keyInfo.fullAccess'); setResponse('userGroups.groupVersions'); @@ -958,18 +946,7 @@ describe("Zotero.Sync.Runner", function () { describe("Error Handling", function () { var win; - // Notifier is triggered without waiting for async actions to finish, which - // fires off database queries after its been closed. - var observerTriggerDeferred; - beforeEach(function() { - observerTriggerDeferred = Zotero.Promise.defer(); - sinon.stub(Zotero.Notifier, 'trigger', - (e) => {if (e == 'finish') observerTriggerDeferred.resolve(); return Zotero.Promise.resolve()}); - }); - - afterEach(function* () { - yield observerTriggerDeferred.promise; - Zotero.Notifier.trigger.restore(); + afterEach(function () { if (win) { win.close(); }