-
Notifications
You must be signed in to change notification settings - Fork 281
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add E2E tests for quitOnClose setting
Signed-off-by: Adam Pickering <adam.pickering@suse.com>
- Loading branch information
1 parent
63d27ae
commit daba531
Showing
2 changed files
with
61 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { test, expect, _electron, } from '@playwright/test'; | ||
|
||
import { createDefaultSettings, packageLogs, startRancherDesktop } from './utils/TestUtils'; | ||
|
||
/** | ||
* Using test.describe.serial make the test execute step by step, as described on each `test()` order | ||
* Playwright executes test in parallel by default and it will not work for our app backend loading process. | ||
* */ | ||
test.describe.serial('quitOnClose setting', () => { | ||
test.afterAll(async() => { | ||
await packageLogs(__filename); | ||
}); | ||
|
||
test('should quit when quitOnClose is true and window is closed', async() => { | ||
createDefaultSettings({ window: { quitOnClose: true } }); | ||
const {app, page} = await startRancherDesktop(__filename); | ||
const browserWindowHandle = await app.browserWindow(page); | ||
browserWindowHandle.evaluate((browserWindow: Electron.BrowserWindow) => browserWindow.close()); | ||
// Rancher Desktop should be closed by this point. This means that | ||
// app.close() will throw an error, which we consider to be success | ||
// for this test. | ||
await expect(app.close()).rejects.toThrow(); | ||
}); | ||
|
||
test('should not quit when quitOnClose is false and window is closed', async() => { | ||
createDefaultSettings({ window: { quitOnClose: false } }); | ||
const {app, page} = await startRancherDesktop(__filename); | ||
const browserWindowHandle = await app.browserWindow(page); | ||
browserWindowHandle.evaluate((browserWindow: Electron.BrowserWindow) => browserWindow.close()); | ||
// Rancher Desktop should not be closed, because quitOnClose is false. | ||
// So, calling app.close() should succeed, which we consider to be success | ||
// for this test. | ||
await expect(app.close()).resolves.not.toThrow(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters