From 97dbcc68706bb6c55433b277e7442c754a552cd6 Mon Sep 17 00:00:00 2001 From: Abe Jellinek Date: Wed, 23 Jul 2025 16:25:16 -0400 Subject: [PATCH] Restore timeout in dataObjectTest.js, fix test OK, the timeout removed in 05e8da wasn't actually useless, but this test was. 41706a changed erase() so it no longer forwards skipNotifier when deleting child items. That means that we *would* get a notify() call for the deleted child, so the test should have been failing. However! Because of a bug in Bluebird's filtered catch() implementation, Promise.TimeoutError wasn't recognized as an Error subclass, and it was instead used as a predicate function, which would always pass. So all errors were caught as "timeouts" and suppressed, making this test always pass. Now it no longer always passes (but does pass with the current behavior). --- test/tests/dataObjectTest.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/test/tests/dataObjectTest.js b/test/tests/dataObjectTest.js index 8bdd2ce263..9aa9f21b1a 100644 --- a/test/tests/dataObjectTest.js +++ b/test/tests/dataObjectTest.js @@ -379,8 +379,8 @@ describe("Zotero.DataObject", function () { promises.push(deferred.promise); observerIDs.push(Zotero.Notifier.registerObserver( { - notify: function (event) { - if (event == 'delete') { + notify: function (event, type, ids) { + if (event == 'delete' && ids.includes(obj.id)) { deferred.reject("Notifier called for erase on " + type); } } @@ -392,7 +392,11 @@ describe("Zotero.DataObject", function () { skipNotifier: true }); } - await Promise.all(promises); + await Promise.race([ + Promise.all(promises), + // Give notifier time to trigger + Zotero.Promise.delay(100), + ]); for (let id of observerIDs) { Zotero.Notifier.unregisterObserver(id);