From 4b3f61d8caae3faa718b03aac7b68b2b54e3db09 Mon Sep 17 00:00:00 2001 From: abaevbog Date: Tue, 6 Feb 2024 02:30:29 -0500 Subject: [PATCH] Fix to tagsbox test timeout in CI (#3665) Activate the window only when the document does not have focus. Some platforms (macOS) require the window to be brought to the front, while others (Linux) place it at the front from the start, and activation should be skipped. --- test/tests/tagsboxTest.js | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/test/tests/tagsboxTest.js b/test/tests/tagsboxTest.js index 43ad00357e..4891a1ceba 100644 --- a/test/tests/tagsboxTest.js +++ b/test/tests/tagsboxTest.js @@ -16,15 +16,18 @@ describe("Item Tags Box", function () { describe("Tag Editing", function () { - it.skip("should update tag when pressing Enter in textbox", async function () { - // editable-text behavior relies on focus, so we first need to bring the window to the front. - let win = Zotero.getMainWindow(); - let activatePromise = new Promise( - resolve => win.addEventListener('activate', resolve, { once: true }) - ); - Zotero.Utilities.Internal.activate(); - Zotero.Utilities.Internal.activate(win); - await activatePromise; + it("should update tag when pressing Enter in textbox", async function () { + if (!doc.hasFocus()) { + // editable-text behavior relies on focus, so we first need to bring the window to the front. + // Not required on all platforms. In some cases (e.g. Linux), the window is at the front from the start. + let win = Zotero.getMainWindow(); + let activatePromise = new Promise( + resolve => win.addEventListener('activate', resolve, { once: true }) + ); + Zotero.Utilities.Internal.activate(); + Zotero.Utilities.Internal.activate(win); + await activatePromise; + } var tag = Zotero.Utilities.randomString(); var newTag = Zotero.Utilities.randomString();