Skip to content

Commit e5f0136

Browse files
committed
Added test for focusWindow
1 parent 3a02763 commit e5f0136

File tree

2 files changed

+64
-36
lines changed

2 files changed

+64
-36
lines changed

test/window-integration-tests/package-lock.json

+36-36
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/window-integration-tests/test.js

+28
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,34 @@ describe("getActiveWindow", () => {
9595
});
9696
});
9797

98+
describe("focusWindow", () => {
99+
it("should properly focus the correct window", async () => {
100+
// GIVEN
101+
const openWindowHandle = libnut.getActiveWindow();
102+
103+
// WHEN
104+
const secondApp = await electron.launch({args: ['second.js']});
105+
const secondPage = await secondApp.firstWindow({timeout: APP_TIMEOUT});
106+
const secondWindowHandle = await app.browserWindow(page);
107+
await secondPage.waitForLoadState("domcontentloaded");
108+
await secondWindowHandle.evaluate((win) => {
109+
win.minimize();
110+
win.restore();
111+
win.focus();
112+
});
113+
114+
libnut.focusWindow(openWindowHandle);
115+
116+
// THEN
117+
const activeWindowHandle = libnut.getActiveWindow();
118+
const activeWindowName = libnut.getWindowTitle(activeWindowHandle);
119+
expect(activeWindowName).toBe(TITLE);
120+
if (secondApp) {
121+
await secondApp.close();
122+
}
123+
});
124+
});
125+
98126
afterEach(async () => {
99127
if (app) {
100128
await app.close();

0 commit comments

Comments
 (0)