www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit 84bb61ab7b74e30376682d1261ab990ddf9be8da
parent 935d48013b55f553d62055e1ec38ac70e4e4e0e8
Author: Dan Stillman <dstillman@zotero.org>
Date:   Tue, 22 Nov 2016 20:02:13 -0500

Fix test timeouts caused by Quick Copy initialization

When an export translator is selected for Quick Copy, Quick Copy
initialization triggers translator initialization a few seconds after
startup, because the translator code needs to be available synchronously
for drag/drop. A Quick Copy test was changing the setting to BibTeX,
which was resulting in random timeouts after subsequent resetDB() calls
due to slow translator loading. This change skips initialization in test
mode. This might actually fix a lot of timeouts on Travis in the second
half of the tests...

This also resets the Quick Copy pref in those tests so that it's left at
the default, though really we should automatically reset all prefs after
all test groups and in resetDB().

Diffstat:
Mchrome/content/zotero/xpcom/quickCopy.js | 4++++
Mchrome/content/zotero/xpcom/translation/translators.js | 5-----
Mtest/tests/quickCopyTest.js | 16+++++++++++++---
3 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/chrome/content/zotero/xpcom/quickCopy.js b/chrome/content/zotero/xpcom/quickCopy.js @@ -38,6 +38,10 @@ Zotero.QuickCopy = new function() { // Load code for selected export translator ahead of time // (in the background, because it requires translator initialization) _initTimeoutID = setTimeout(() => { + // Avoid random translator initialization during tests, which can result in timeouts, + // if an export format is selected + if (Zotero.test) return; + _initTimeoutID = null; _initPromise = _loadOutputFormat().then(() => _initPromise = null); }, 5000); diff --git a/chrome/content/zotero/xpcom/translation/translators.js b/chrome/content/zotero/xpcom/translation/translators.js @@ -43,11 +43,6 @@ Zotero.Translators = new function() { * available (e.g., in updateBundledFiles()), to avoid unnecesary file reads */ this.reinit = Zotero.Promise.coroutine(function* (options = {}) { - // Travis debugging - Zotero.Debug.init(true); - Zotero.debug(new Error().stack); - Zotero.Debug.init(); - // Wait until bundled files have been updated, except when this is called by the schema update // code itself if (!options.fromSchemaUpdate) { diff --git a/test/tests/quickCopyTest.js b/test/tests/quickCopyTest.js @@ -1,6 +1,16 @@ describe("Zotero.QuickCopy", function() { - var quickCopyPref = Zotero.Prefs.get("export.quickCopy.setting"); - quickCopyPref = JSON.stringify(Zotero.QuickCopy.unserializeSetting(quickCopyPref)); + var quickCopyPref; + var prefName = "export.quickCopy.setting"; + + before(function () { + Zotero.Prefs.clear(prefName); + quickCopyPref = Zotero.Prefs.get(prefName); + quickCopyPref = JSON.stringify(Zotero.QuickCopy.unserializeSetting(quickCopyPref)); + }); + + afterEach(function () { + Zotero.Prefs.clear(prefName); + }); // TODO: These should set site-specific prefs and test the actual response against it, // but that will need to wait for 5.0. For now, just make sure they don't fail. @@ -44,7 +54,7 @@ describe("Zotero.QuickCopy", function() { var translatorID = '9cb70025-a888-4a29-a210-93ec52da40d4'; // BibTeX var format = 'export=' + translatorID; - Zotero.Prefs.set('export.quickCopy.setting', format); + Zotero.Prefs.set(prefName, format); // Translator code for selected format is loaded automatically, so wait for it var translator = Zotero.Translators.get(translatorID); while (!translator.code) {