Skip to content

Commit

Permalink
Translator tester: Only test URL-specified translators when ready.
Browse files Browse the repository at this point in the history
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 zotero#20.
  • Loading branch information
zoe-translates committed Mar 26, 2023
1 parent fcb7b8a commit e10c3e0
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions testTranslators/testTranslators.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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));
}
}));

Expand Down Expand Up @@ -531,6 +532,7 @@ async function init() {
translatorBox.appendChild(lastP);

// Run translators specified in the hash params if any
await Promise.all(whenReadyToRun);
runURLSpecifiedTranslators();
}
}
Expand Down Expand Up @@ -650,4 +652,4 @@ function serializeToDownload(e) {
e.preventDefault();
}

window.addEventListener("load", load, false);
window.addEventListener("load", load, false);

0 comments on commit e10c3e0

Please sign in to comment.