mirror of
https://github.com/zotero/zotero.git
synced 2026-09-08 22:21:04 +00:00
Extract activateZoteroPane(), try different activeness check
This should hopefully fix intermittent CI failures.
This commit is contained in:
parent
d4a5fbbefe
commit
5e1541c5ee
3 changed files with 24 additions and 22 deletions
|
|
@ -125,6 +125,28 @@ var loadZoteroPane = async function (win) {
|
|||
return win;
|
||||
};
|
||||
|
||||
/**
|
||||
* Bring the main window to the front, for tests that rely on focus (e.g., editable-text).
|
||||
*/
|
||||
async function activateZoteroPane() {
|
||||
let win = Zotero.getMainWindow();
|
||||
if (!win) {
|
||||
throw new Error('Main window is not open');
|
||||
}
|
||||
// If the window is already active, we're done.
|
||||
// The main window is active from the start on Linux, but opens in the
|
||||
// background on other platforms.
|
||||
if (Services.focus.activeWindow === win) {
|
||||
return;
|
||||
}
|
||||
let activatePromise = new Promise(
|
||||
resolve => win.addEventListener('activate', resolve, { once: true })
|
||||
);
|
||||
Zotero.Utilities.Internal.activate();
|
||||
Zotero.Utilities.Internal.activate(win);
|
||||
await activatePromise;
|
||||
}
|
||||
|
||||
var loadPrefPane = async function (paneName) {
|
||||
var id = 'zotero-prefpane-' + paneName;
|
||||
var win = await loadWindow("chrome://zotero/content/preferences/preferences.xhtml", {
|
||||
|
|
|
|||
|
|
@ -237,17 +237,7 @@ describe("Item pane", function () {
|
|||
|
||||
describe("Info pane", function () {
|
||||
before(async () => {
|
||||
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;
|
||||
}
|
||||
await activateZoteroPane();
|
||||
});
|
||||
it("should place Title after Item Type and before creators", async function () {
|
||||
var item = await createDataObject('item');
|
||||
|
|
|
|||
|
|
@ -19,17 +19,7 @@ describe("Item Tags Box", function () {
|
|||
|
||||
describe("Tag Editing", function () {
|
||||
before(async () => {
|
||||
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;
|
||||
}
|
||||
await activateZoteroPane();
|
||||
});
|
||||
it("should update tag when pressing Enter in textbox", async function () {
|
||||
var tag = Zotero.Utilities.randomString();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue