mirror of
https://github.com/Elvanos/fantasia-archive.git
synced 2024-05-04 12:23:18 +12:00
fixed multi-instance allowing during testing
This commit is contained in:
parent
565bf34bde
commit
2afc156986
|
@ -16,7 +16,7 @@ export const openAppWindowManager = () => {
|
|||
// Create the app window in the normal way
|
||||
app.whenReady().then(mainWindowCreation)
|
||||
|
||||
// Create the app window
|
||||
// Create the app window, if it still doesn't exist yet
|
||||
app.on('activate', () => {
|
||||
mainWindowCreation()
|
||||
})
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
import { BrowserWindow, app } from 'electron'
|
||||
import { enable } from '@electron/remote/main'
|
||||
import path from 'path'
|
||||
|
||||
/**
|
||||
* Prevent app to launch a secondary instance
|
||||
*/
|
||||
const preventSecondaryAppInstance = (appWindow: BrowserWindow | undefined) => {
|
||||
// Do not limit the window amount if we are in auto-test mode
|
||||
if (process.env.TEST_ENV && (process.env.TEST_ENV === 'components' || process.env.TEST_ENV === 'e2e')) {
|
||||
return
|
||||
}
|
||||
/**
|
||||
* Determines if the app is the primary instance
|
||||
* - This exists as a variable due to the app bugging out if used directly from "app"
|
||||
|
@ -76,4 +79,6 @@ export const mainWindowCreation = () => {
|
|||
|
||||
// Check if we are on the primary or secondary instance of the app
|
||||
preventSecondaryAppInstance(appWindow)
|
||||
|
||||
return appWindow
|
||||
}
|
||||
|
|
|
@ -76,11 +76,18 @@ test('Click resize button - "maximize"', async () => {
|
|||
|
||||
// Check if the tested element exists
|
||||
if (resizeButton !== null) {
|
||||
// Click twice
|
||||
await resizeButton.click()
|
||||
await resizeButton.click()
|
||||
let isMaximized = await appWindow.evaluate(() => window.faWindowControlAPI.checkWindowMaximized())
|
||||
|
||||
const isMaximized = await appWindow.evaluate(() => window.faWindowControlAPI.checkWindowMaximized())
|
||||
// Check if the window if maximized of not, react accordingly
|
||||
if (isMaximized) {
|
||||
// Click twice
|
||||
await resizeButton.click()
|
||||
await resizeButton.click()
|
||||
} else {
|
||||
await resizeButton.click()
|
||||
}
|
||||
|
||||
isMaximized = await appWindow.evaluate(() => window.faWindowControlAPI.checkWindowMaximized())
|
||||
|
||||
expect(isMaximized).toBe(true)
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue