Skip to content

Commit

Permalink
Added test for focusWindow
Browse files Browse the repository at this point in the history
  • Loading branch information
s1hofmann committed Mar 11, 2024
1 parent 3a02763 commit e5f0136
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 36 deletions.
72 changes: 36 additions & 36 deletions test/window-integration-tests/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions test/window-integration-tests/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,34 @@ describe("getActiveWindow", () => {
});
});

describe("focusWindow", () => {
it("should properly focus the correct window", async () => {
// GIVEN
const openWindowHandle = libnut.getActiveWindow();

// WHEN
const secondApp = await electron.launch({args: ['second.js']});
const secondPage = await secondApp.firstWindow({timeout: APP_TIMEOUT});
const secondWindowHandle = await app.browserWindow(page);
await secondPage.waitForLoadState("domcontentloaded");
await secondWindowHandle.evaluate((win) => {
win.minimize();
win.restore();
win.focus();
});

libnut.focusWindow(openWindowHandle);

// THEN
const activeWindowHandle = libnut.getActiveWindow();
const activeWindowName = libnut.getWindowTitle(activeWindowHandle);
expect(activeWindowName).toBe(TITLE);
if (secondApp) {
await secondApp.close();
}
});
});

afterEach(async () => {
if (app) {
await app.close();
Expand Down

0 comments on commit e5f0136

Please sign in to comment.