fixed multi-instance allowing during testing

This commit is contained in:
Elvanos 2023-09-13 23:58:02 +02:00
parent 565bf34bde
commit 2afc156986
3 changed files with 18 additions and 6 deletions

View file

@ -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()
})

View file

@ -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
}

View file

@ -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 {