From 734faa368c0b9d67838516fb5660283595fe1fc2 Mon Sep 17 00:00:00 2001 From: zoe-translates <116055375+zoe-translates@users.noreply.github.com> Date: Mon, 27 Mar 2023 14:03:37 +0800 Subject: [PATCH 1/3] Testing: Fix failure to run non-web translators' tests in debug build. - In the testTranslators tool included in the debug build, there is an incorrect script path preventing the type schema data from loading. - In cachedTypes.js, the callback passed to `getSchema()` is not called. (The call site is in `translatorTester_viewer.js`). The overall effect is that non-web translators' test code did not run at all. This is fixed by including the correct script path, and call the callback in `getSchema()`. --- src/common/cachedTypes.js | 6 +++--- src/common/tools/testTranslators/testTranslators.html | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/common/cachedTypes.js b/src/common/cachedTypes.js index 213bc0add..f0487a716 100644 --- a/src/common/cachedTypes.js +++ b/src/common/cachedTypes.js @@ -178,7 +178,7 @@ Zotero.Connector_Types = new function() { /** * Passes schema to a callback */ - this.getSchema = async function() { - return TypeSchema; + this.getSchema = async function(callback) { + return callback(TypeSchema); }; -} \ No newline at end of file +} diff --git a/src/common/tools/testTranslators/testTranslators.html b/src/common/tools/testTranslators/testTranslators.html index 9b11e4ade..57b0baacc 100644 --- a/src/common/tools/testTranslators/testTranslators.html +++ b/src/common/tools/testTranslators/testTranslators.html @@ -31,7 +31,7 @@ - + @@ -65,4 +65,4 @@ - \ No newline at end of file + From 6c2d12c1e376eb78031ee60be506fb3d98bf5b98 Mon Sep 17 00:00:00 2001 From: zoe-translates <116055375+zoe-translates@users.noreply.github.com> Date: Mon, 27 Mar 2023 15:31:25 +0800 Subject: [PATCH 2/3] Testing: reinstate `getSchema()`, update the test-runner call site insted. This partially reverts 734faa368c0b9d67838516fb5660283595fe1fc2 and restores the call signature of `getSchema()` (with the stale comment about it removed). Instead, fix the caller by moving the callback to a `then()` handler after it. --- src/common/cachedTypes.js | 7 ++----- .../tools/testTranslators/translatorTester_viewer.js | 4 ++-- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/common/cachedTypes.js b/src/common/cachedTypes.js index f0487a716..adfca8ee8 100644 --- a/src/common/cachedTypes.js +++ b/src/common/cachedTypes.js @@ -175,10 +175,7 @@ Zotero.Connector_Types = new function() { } }; - /** - * Passes schema to a callback - */ - this.getSchema = async function(callback) { - return callback(TypeSchema); + this.getSchema = async function() { + return TypeSchema; }; } diff --git a/src/common/tools/testTranslators/translatorTester_viewer.js b/src/common/tools/testTranslators/translatorTester_viewer.js index eaf3e9e42..b37f7321b 100644 --- a/src/common/tools/testTranslators/translatorTester_viewer.js +++ b/src/common/tools/testTranslators/translatorTester_viewer.js @@ -40,7 +40,7 @@ Zotero_TranslatorTester.prototype.runTests = function(callback) { } else { // other translators get passed right through, after we get schema and preferences var me = this; - Zotero.Connector_Types.getSchema(function(schema) { + Zotero.Connector_Types.getSchema().then(function(schema) { Zotero.Connector_Types.schema = schema; Zotero.Connector_Types.init(); me._runTests(callback); @@ -57,4 +57,4 @@ Zotero.Messaging.addMessageListener("translatorTester_testDone", function(data) // call Zotero_TranslatorTester#_debug Zotero.Messaging.addMessageListener("translatorTester_debug", function(data) { _instanceData[data[0]].debug.apply(null, data[1]); -}); \ No newline at end of file +}); From 177553244d77f3cc48edba52422692b398b409d2 Mon Sep 17 00:00:00 2001 From: zoe-translates <116055375+zoe-translates@users.noreply.github.com> Date: Mon, 27 Mar 2023 16:46:39 +0800 Subject: [PATCH 3/3] [Minor] Remove -