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).
This commit is contained in:
Abe Jellinek 2025-07-23 16:25:16 -04:00 • committed by Dan Stillman
parent 6203b9712d
commit 97dbcc6870

View file

@ -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);