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.
This commit is contained in:
abaevbog 2024-02-06 02:30:29 -05:00 committed by GitHub
parent 3a2cd70684
commit 4b3f61d8ca
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -16,8 +16,10 @@ describe("Item Tags Box", function () {
describe("Tag Editing", function () {
it.skip("should update tag when pressing Enter in textbox", async function () {
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 })
@ -25,6 +27,7 @@ describe("Item Tags Box", function () {
Zotero.Utilities.Internal.activate();
Zotero.Utilities.Internal.activate(win);
await activatePromise;
}
var tag = Zotero.Utilities.randomString();
var newTag = Zotero.Utilities.randomString();