From e10c3e01b74703b16a4a3e69560f864955911f92 Mon Sep 17 00:00:00 2001 From: zoe-translates <116055375+zoe-translates@users.noreply.github.com> Date: Sun, 26 Mar 2023 17:10:06 +0800 Subject: [PATCH] Translator tester: Only test URL-specified translators when ready. Wait for `translatorTestViewsToRun` to be populated, and then call the handler for the URL-specified translators' tests. If the `translatorTestViewsToRun` object is not ready, the handler (`runURLSpecifiedTranslators`) will silently skip the tests it is supposed to run. Fixes #20. --- testTranslators/testTranslators.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/testTranslators/testTranslators.js b/testTranslators/testTranslators.js index e28f655..5ed19f0 100644 --- a/testTranslators/testTranslators.js +++ b/testTranslators/testTranslators.js @@ -425,6 +425,7 @@ async function init() { allOutputView = new OutputView(); allOutputView.setDisplayed(true); + const whenReadyToRun = []; await Promise.all(TRANSLATOR_TYPES.map(async displayType => { let translatorType = displayType.toLowerCase(); @@ -474,7 +475,7 @@ async function init() { // get translators, with code for unsupported translators if(!viewerMode) { let translators = await Zotero.Translators.getAllForType(translatorType, true); - haveTranslators(translators, translatorType); + whenReadyToRun.push(haveTranslators(translators, translatorType)); } })); @@ -531,6 +532,7 @@ async function init() { translatorBox.appendChild(lastP); // Run translators specified in the hash params if any + await Promise.all(whenReadyToRun); runURLSpecifiedTranslators(); } } @@ -650,4 +652,4 @@ function serializeToDownload(e) { e.preventDefault(); } -window.addEventListener("load", load, false); \ No newline at end of file +window.addEventListener("load", load, false);