From 873beebc0f8d3aa4aa0d9ab87dc0edc48b904ce6 Mon Sep 17 00:00:00 2001 From: abaevbog Date: Sat, 2 Aug 2025 00:40:21 -0500 Subject: [PATCH] close more leftover windows in tests (#5460) - close hyphenationTest window. - properly close zoteroPane window in preferences_syncTest. after() hook inside of the test would not close the window until the very end of the entire test run. Without this, during subsequent tests that open their own zoteroPane window, there are two instances of zoteroPane open at the same time. - close open tabs in readerTest cleanup, since subsequent tests expect library tab to be selected. Followup to https://github.com/zotero/zotero/pull/5444#issuecomment-3141879892 --- test/tests/hyphenationTest.js | 8 +++++++- test/tests/preferences_syncTest.js | 5 ++--- test/tests/readerTest.js | 1 + 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/test/tests/hyphenationTest.js b/test/tests/hyphenationTest.js index 80cdce67da..2f58df8b88 100644 --- a/test/tests/hyphenationTest.js +++ b/test/tests/hyphenationTest.js @@ -1,8 +1,14 @@ describe("Hyphenation", function () { + let win; + + after(function() { + win.close(); + }); + it("should not cause a segfault", async function () { // Files in test/tests/data/ (resources://) can't be parsed as XUL/XHTML, so the data for this test is in // test/content/ (chrome://), which can - window.openDialog('chrome://zotero-unit/content/hyphenationTest.xhtml', 'test', 'chrome'); + win = window.openDialog('chrome://zotero-unit/content/hyphenationTest.xhtml', 'test', 'chrome'); await Zotero.Promise.delay(200); }); }); diff --git a/test/tests/preferences_syncTest.js b/test/tests/preferences_syncTest.js index d185a45c65..b61ae2a712 100644 --- a/test/tests/preferences_syncTest.js +++ b/test/tests/preferences_syncTest.js @@ -122,9 +122,6 @@ describe("Sync Preferences", function () { it("should clear sync errors from the toolbar after logging in", async function () { let win = await loadZoteroPane(); - after(function () { - win.close(); - }); let syncError = win.document.getElementById('zotero-tb-sync-error'); @@ -134,6 +131,8 @@ describe("Sync Preferences", function () { getAPIKeyFromCredentialsStub.resolves(apiResponse); await setCredentials("Username", "correctPassword"); assert.isTrue(syncError.hidden); + + win.close(); }); }) }) diff --git a/test/tests/readerTest.js b/test/tests/readerTest.js index 9edaa6cf65..c456133f12 100644 --- a/test/tests/readerTest.js +++ b/test/tests/readerTest.js @@ -9,6 +9,7 @@ describe("Reader", function () { }); after(function () { + win.Zotero_Tabs.closeAll(); win.close(); });