mirror of
https://github.com/Elvanos/fantasia-archive.git
synced 2024-05-22 21:23:10 +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
|
// Create the app window in the normal way
|
||||||
app.whenReady().then(mainWindowCreation)
|
app.whenReady().then(mainWindowCreation)
|
||||||
|
|
||||||
// Create the app window
|
// Create the app window, if it still doesn't exist yet
|
||||||
app.on('activate', () => {
|
app.on('activate', () => {
|
||||||
mainWindowCreation()
|
mainWindowCreation()
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,11 +1,14 @@
|
||||||
import { BrowserWindow, app } from 'electron'
|
import { BrowserWindow, app } from 'electron'
|
||||||
import { enable } from '@electron/remote/main'
|
import { enable } from '@electron/remote/main'
|
||||||
import path from 'path'
|
import path from 'path'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prevent app to launch a secondary instance
|
* Prevent app to launch a secondary instance
|
||||||
*/
|
*/
|
||||||
const preventSecondaryAppInstance = (appWindow: BrowserWindow | undefined) => {
|
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
|
* Determines if the app is the primary instance
|
||||||
* - This exists as a variable due to the app bugging out if used directly from "app"
|
* - 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
|
// Check if we are on the primary or secondary instance of the app
|
||||||
preventSecondaryAppInstance(appWindow)
|
preventSecondaryAppInstance(appWindow)
|
||||||
|
|
||||||
|
return appWindow
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,11 +76,18 @@ test('Click resize button - "maximize"', async () => {
|
||||||
|
|
||||||
// Check if the tested element exists
|
// Check if the tested element exists
|
||||||
if (resizeButton !== null) {
|
if (resizeButton !== null) {
|
||||||
// Click twice
|
let isMaximized = await appWindow.evaluate(() => window.faWindowControlAPI.checkWindowMaximized())
|
||||||
await resizeButton.click()
|
|
||||||
await resizeButton.click()
|
|
||||||
|
|
||||||
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)
|
expect(isMaximized).toBe(true)
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue