From ea6367bb0f4f78351fdb3905b60a1ea31885019e Mon Sep 17 00:00:00 2001 From: Elvanos Date: Fri, 8 Sep 2023 23:54:44 +0200 Subject: [PATCH] finished integrating component testing + cleanup --- package.json | 2 +- .../extraEnvVariablesAPI.ts | 9 ++ .../faWindowControlAPI.ts | 40 +++++++ src-electron/electron-preload.ts | 41 +------ src/App.vue | 33 +++++- src/boot/i18n.ts | 1 + src/components/EssentialLink.vue | 51 -------- src/components/ExampleComponent.vue | 68 ----------- .../GlobalWindowButtons.playwright.test.ts | 111 ++++++++++++++---- .../GlobalWindowButtons.vitest.test.ts | 55 +++++++-- .../GlobalWindowButtons.vue | 56 +++++---- src/components/models.ts | 8 -- src/globals.d.ts | 4 +- src/i18n/de/index.ts | 16 ++- src/i18n/en-US/index.ts | 18 +-- src/interfaces/I_extraEnvVariablesAPI.ts | 27 +++++ src/interfaces/I_faWindowControlAPI.ts | 19 +++ src/layouts/ComponentTestingLayout.vue | 15 +++ src/layouts/MainLayout.vue | 55 +-------- src/pages/ComponentTesting.vue | 47 ++++++++ src/pages/IndexPage.vue | 43 +------ src/router/routes.ts | 20 +++- .../appWindowControls.playwright.spec.ts | 90 -------------- test/playwright-e2e/someTest.spec.ts | 1 + 24 files changed, 407 insertions(+), 423 deletions(-) create mode 100644 src-electron/customContentBridgeAPIs/extraEnvVariablesAPI.ts create mode 100644 src-electron/customContentBridgeAPIs/faWindowControlAPI.ts delete mode 100644 src/components/EssentialLink.vue delete mode 100644 src/components/ExampleComponent.vue delete mode 100644 src/components/models.ts create mode 100644 src/interfaces/I_extraEnvVariablesAPI.ts create mode 100644 src/layouts/ComponentTestingLayout.vue create mode 100644 src/pages/ComponentTesting.vue delete mode 100644 test/playwright-e2e/appWindowControls.playwright.spec.ts create mode 100644 test/playwright-e2e/someTest.spec.ts diff --git a/package.json b/package.json index 6620a15..456166c 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "dev:electron": "quasar dev -m electron", "build": "quasar build -m electron --publish never", "test:unit:ui": "vitest --ui", - "test:unit:ci": "vitest run", + "test:unit:ci": "vitest run --reporter verbose", "test:component": "node \"node_modules/@playwright/test/cli.js\" test src/components/", "test:e2e": "node \"node_modules/@playwright/test/cli.js\" test test/playwright-e2e/" }, diff --git a/src-electron/customContentBridgeAPIs/extraEnvVariablesAPI.ts b/src-electron/customContentBridgeAPIs/extraEnvVariablesAPI.ts new file mode 100644 index 0000000..7b5894c --- /dev/null +++ b/src-electron/customContentBridgeAPIs/extraEnvVariablesAPI.ts @@ -0,0 +1,9 @@ +import { I_extraEnvVariablesAPI } from 'src/interfaces/I_extraEnvVariablesAPI' +import appRoot from 'app-root-path' + +export const extraEnvVariablesAPI: I_extraEnvVariablesAPI = { + ELECTRON_MAIN_FILEPATH: appRoot + '/dist/electron/UnPackaged/electron-main.js', + FA_FRONTEND_RENDER_TIMER: 1000, + TEST_ENV: (process.env.TEST_ENV) ? process.env.TEST_ENV : false, + COMPONENT_NAME: (process.env.COMPONENT_NAME) ? process.env.COMPONENT_NAME : false +} diff --git a/src-electron/customContentBridgeAPIs/faWindowControlAPI.ts b/src-electron/customContentBridgeAPIs/faWindowControlAPI.ts new file mode 100644 index 0000000..37ee7bd --- /dev/null +++ b/src-electron/customContentBridgeAPIs/faWindowControlAPI.ts @@ -0,0 +1,40 @@ +import { BrowserWindow } from '@electron/remote' +import { I_faWindowControlAPI } from 'src/interfaces/I_faWindowControlAPI' + +export const faWindowControlAPI: I_faWindowControlAPI = { + + checkWindowMaximized () { + const currentWindow = BrowserWindow.getFocusedWindow() + if (currentWindow !== null) { + return currentWindow.isMaximized() + } + return false + }, + + minimizeWindow () { + const currentWindow = BrowserWindow.getFocusedWindow() + + if (currentWindow !== null) { + currentWindow.minimize() + } + }, + + resizeWindow () { + const currentWindow = BrowserWindow.getFocusedWindow() + + if (currentWindow !== null) { + if (currentWindow.isMaximized()) { + currentWindow.unmaximize() + } else { + currentWindow.maximize() + } + } + }, + + closeWindow () { + const currentWindow = BrowserWindow.getFocusedWindow() + if (currentWindow !== null) { + currentWindow.close() + } + } +} diff --git a/src-electron/electron-preload.ts b/src-electron/electron-preload.ts index 4416348..d72d657 100644 --- a/src-electron/electron-preload.ts +++ b/src-electron/electron-preload.ts @@ -29,44 +29,9 @@ */ import { contextBridge } from 'electron' -import { BrowserWindow } from '@electron/remote' -import { I_faWindowControlAPI } from 'src/interfaces/I_faWindowControlAPI' -const faWindowControlAPI: I_faWindowControlAPI = { - - checkWindowMaximized () { - const currentWindow = BrowserWindow.getFocusedWindow() - if (currentWindow !== null) { - return currentWindow.isMaximized() - } - return false - }, - minimizeWindow () { - const currentWindow = BrowserWindow.getFocusedWindow() - - if (currentWindow !== null) { - currentWindow.minimize() - } - }, - - resizeWindow () { - const currentWindow = BrowserWindow.getFocusedWindow() - - if (currentWindow !== null) { - if (currentWindow.isMaximized()) { - currentWindow.unmaximize() - } else { - currentWindow.maximize() - } - } - }, - - closeWindow () { - const currentWindow = BrowserWindow.getFocusedWindow() - if (currentWindow !== null) { - currentWindow.close() - } - } -} +import { faWindowControlAPI } from 'src-electron/customContentBridgeAPIs/faWindowControlAPI' +import { extraEnvVariablesAPI } from 'src-electron/customContentBridgeAPIs/extraEnvVariablesAPI' contextBridge.exposeInMainWorld('faWindowControlAPI', faWindowControlAPI) +contextBridge.exposeInMainWorld('extraEnvVariables', extraEnvVariablesAPI) diff --git a/src/App.vue b/src/App.vue index a3c6751..c7c45e9 100644 --- a/src/App.vue +++ b/src/App.vue @@ -4,8 +4,39 @@ diff --git a/src/boot/i18n.ts b/src/boot/i18n.ts index 7ae1c8d..19bb614 100644 --- a/src/boot/i18n.ts +++ b/src/boot/i18n.ts @@ -24,6 +24,7 @@ declare module 'vue-i18n' { export default boot(({ app }) => { const i18n = createI18n({ locale: 'en-US', + fallbackLocale: 'en-US', legacy: false, messages }) diff --git a/src/components/EssentialLink.vue b/src/components/EssentialLink.vue deleted file mode 100644 index 6609891..0000000 --- a/src/components/EssentialLink.vue +++ /dev/null @@ -1,51 +0,0 @@ - - - diff --git a/src/components/ExampleComponent.vue b/src/components/ExampleComponent.vue deleted file mode 100644 index 8872f57..0000000 --- a/src/components/ExampleComponent.vue +++ /dev/null @@ -1,68 +0,0 @@ - - - diff --git a/src/components/GlobalWindowButtons/GlobalWindowButtons.playwright.test.ts b/src/components/GlobalWindowButtons/GlobalWindowButtons.playwright.test.ts index 29f5fbd..2a12082 100644 --- a/src/components/GlobalWindowButtons/GlobalWindowButtons.playwright.test.ts +++ b/src/components/GlobalWindowButtons/GlobalWindowButtons.playwright.test.ts @@ -1,88 +1,155 @@ -import appRoot from 'app-root-path' import { _electron as electron } from 'playwright' import { test, expect } from '@playwright/test' +import { extraEnvVariablesAPI } from 'app/src-electron/customContentBridgeAPIs/extraEnvVariablesAPI' -const electronMainFilePath = appRoot + '/dist/electron/UnPackaged/electron-main.js' -const faFrontendRenderTimer = 1000 +/** + * Extra env settings too trigger component testing via Playwright + */ +const extraEnvSettings = { + TEST_ENV: 'components', + COMPONENT_NAME: 'GlobalWindowButtons' +} + +/** + * Electron main filepath + */ +const electronMainFilePath:string = extraEnvVariablesAPI.ELECTRON_MAIN_FILEPATH + +/** + * Extra rended timer buffer for tests to start after loading the app + * - Change here in order manually adjust this component's wait times + */ +const faFrontendRenderTimer:number = extraEnvVariablesAPI.FA_FRONTEND_RENDER_TIMER + +/** + * Object of string data selectors for the component + */ +const selectorList = { + buttonMinimize: 'globalWindowButtons-button-minimize', + buttonResize: 'globalWindowButtons-button-resize', + buttonClose: 'globalWindowButtons-button-close' +} + +/** + * Test if the Electron launches to begin with. + */ +test('Should launch app', async () => { + const electronApp = await electron.launch({ + env: extraEnvSettings, + args: [electronMainFilePath] + }) -test('launch app', async () => { - const electronApp = await electron.launch({ args: [electronMainFilePath] }) - // close app await electronApp.close() }) -test('click resize button - smallify', async () => { - const electronApp = await electron.launch({ args: [electronMainFilePath] }) +/** + * Attempt to click the resize button + */ +test('Click resize button - "smallify"', async () => { + const electronApp = await electron.launch({ + env: extraEnvSettings, + args: [electronMainFilePath] + }) + const appWindow = await electronApp.firstWindow() await appWindow.waitForTimeout(faFrontendRenderTimer) - const resizeButton = await appWindow.$('.globalWindowButtons__resize') + const resizeButton = await appWindow.$(`[data-test="${selectorList.buttonResize}"]`) if (resizeButton !== null) { await resizeButton.click() + const isMaximized = await appWindow.evaluate(() => window.faWindowControlAPI.checkWindowMaximized()) + expect(isMaximized).toBe(false) } else { test.fail() } - // close app await electronApp.close() }) -test('click resize button - maximize', async () => { - const electronApp = await electron.launch({ args: [electronMainFilePath] }) +/** + * Attempt to click the resize button, twice + */ +test('Click resize button - "maximize"', async () => { + const electronApp = await electron.launch({ + env: extraEnvSettings, + args: [electronMainFilePath] + }) + const appWindow = await electronApp.firstWindow() await appWindow.waitForTimeout(faFrontendRenderTimer) - const resizeButton = await appWindow.$('.globalWindowButtons__resize') + const resizeButton = await appWindow.$(`[data-test="${selectorList.buttonResize}"]`) if (resizeButton !== null) { + // Click twice await resizeButton.click() await resizeButton.click() + const isMaximized = await appWindow.evaluate(() => window.faWindowControlAPI.checkWindowMaximized()) + expect(isMaximized).toBe(true) } else { test.fail() } - // close app await electronApp.close() }) -test('click minimize button', async () => { - const electronApp = await electron.launch({ args: [electronMainFilePath] }) +/** + * Attempt to click the minimize button + */ +test('Click minimize button', async () => { + const electronApp = await electron.launch({ + env: extraEnvSettings, + args: [electronMainFilePath] + }) + const appWindow = await electronApp.firstWindow() await appWindow.waitForTimeout(faFrontendRenderTimer) - const minimizeButton = await appWindow.$('.globalWindowButtons__minimize') + const minimizeButton = await appWindow.$(`[data-test="${selectorList.buttonMinimize}"]`) if (minimizeButton !== null) { await minimizeButton.click() + const isMaximized = await appWindow.evaluate(() => window.faWindowControlAPI.checkWindowMaximized()) + expect(isMaximized).toBe(false) } else { test.fail() } - // close app await electronApp.close() }) -/* This test can VERY occasionally fail when the window takes too long to close on weaker PCs. Simply rerunning the tests generally fixes this. */ -test('click close button', async () => { - const electronApp = await electron.launch({ args: [electronMainFilePath] }) +/** + * Attempt to click the close button + * - This test can VERY occasionally fail when the window takes too long to close on weaker PCs. Simply rerunning the tests generally fixes this. + */ +test('Click close button', async () => { + const electronApp = await electron.launch({ + env: extraEnvSettings, + args: [electronMainFilePath] + }) + const appWindow = await electronApp.firstWindow() await appWindow.waitForTimeout(faFrontendRenderTimer) - const closeButton = await appWindow.$('.globalWindowButtons__close') + const closeButton = await appWindow.$(`[data-test="${selectorList.buttonClose}"]`) if (closeButton !== null) { let windowIsClosed = false + + // Listen to window close event appWindow.on('close', () => { windowIsClosed = true }) + await closeButton.click() + expect(windowIsClosed).toBe(true) } else { test.fail() diff --git a/src/components/GlobalWindowButtons/GlobalWindowButtons.vitest.test.ts b/src/components/GlobalWindowButtons/GlobalWindowButtons.vitest.test.ts index 0d339d5..8f5dfbc 100644 --- a/src/components/GlobalWindowButtons/GlobalWindowButtons.vitest.test.ts +++ b/src/components/GlobalWindowButtons/GlobalWindowButtons.vitest.test.ts @@ -5,24 +5,61 @@ import GlobalWindowButtons from './GlobalWindowButtons.vue' installQuasar() -describe('Unit test - GlobalWindowButtons component', () => { - it('should mount three buttons', () => { +describe('Component - "GlobalWindowButtons"', () => { + /** + * Object of string data selectors for the component + */ + const selectorList = { + buttonMinimize: 'globalWindowButtons-button-minimize', + buttonResize: 'globalWindowButtons-button-resize', + buttonClose: 'globalWindowButtons-button-close' + } + + /** + * Test if the component has three specific HTML element buttons properly mounted in it: + * - Minimize button + * - Resize button + * - Close button + */ + it('Wrapper should contain three buttons', () => { const wrapper = mount(GlobalWindowButtons) - expect(wrapper.findAll('.q-btn')).toHaveLength(3) + + const buttonList = [] + + buttonList.push(wrapper.get(`[data-test="${selectorList.buttonMinimize}"]`)) + buttonList.push(wrapper.get(`[data-test="${selectorList.buttonResize}"]`)) + buttonList.push(wrapper.get(`[data-test="${selectorList.buttonClose}"]`)) + + expect(buttonList).toHaveLength(3) }) - it('should have `minimize` button', () => { + /** + * Test if the component has a specific HTML element button properly mounted in it. + * - Minimize button + */ + it('Wrapper should contain "minimize" button', () => { const wrapper = mount(GlobalWindowButtons) - expect(wrapper.findAll('.globalWindowButtons__minimize')).toHaveLength(1) + + expect(wrapper.get(`[data-test="${selectorList.buttonMinimize}"]`)) }) - it('should have `resize` button', () => { + /** + * Test if the component has a specific HTML element button properly mounted in it. + * - Resize button + */ + it('Wrapper should contain "resize" button', () => { const wrapper = mount(GlobalWindowButtons) - expect(wrapper.findAll('.globalWindowButtons__minimize')).toHaveLength(1) + + expect(wrapper.get(`[data-test="${selectorList.buttonResize}"]`)) }) - it('should have `close` button', () => { + /** + * Test if the component has a specific HTML element button properly mounted in it. + * - Close button + */ + it('Wrapper should contain "close" button', () => { const wrapper = mount(GlobalWindowButtons) - expect(wrapper.findAll('.globalWindowButtons__minimize')).toHaveLength(1) + + expect(wrapper.get(`[data-test="${selectorList.buttonClose}"]`)) }) }) diff --git a/src/components/GlobalWindowButtons/GlobalWindowButtons.vue b/src/components/GlobalWindowButtons/GlobalWindowButtons.vue index c9c8340..e18014d 100644 --- a/src/components/GlobalWindowButtons/GlobalWindowButtons.vue +++ b/src/components/GlobalWindowButtons/GlobalWindowButtons.vue @@ -11,13 +11,14 @@ dark size="xs" class="globalWindowButtons__minimize" + data-test="globalWindowButtons-button-minimize" @click="minimizeWindow()" > - {{ $t('globalWindowButtons_minimizeButton') }} + {{ $t('GlobalWindowButtons.minimizeButton') }} @@ -29,13 +30,14 @@ dark size="xs" class="globalWindowButtons__resize" + data-test="globalWindowButtons-button-resize" @click="[resizeWindow(),checkIfWindowMaximized()]" > - {{ isMaximized ? $t('globalWindowButtons_resizeButton') : $t('globalWindowButtons_maximizeButton') }} + {{ isMaximized ? $t('GlobalWindowButtons.resizeButton') : $t('GlobalWindowButtons.maximizeButton') }} @@ -47,13 +49,14 @@ dark size="xs" class="globalWindowButtons__close" + data-test="globalWindowButtons-button-close" @click="tryCloseWindow()" > - {{ $t('globalWindowButtons_close') }} + {{ $t('GlobalWindowButtons.close') }} @@ -64,33 +67,34 @@ import { onMounted, ref } from 'vue' import type { Ref } from 'vue' -/* -Triggers minimize of the window by the minimize button click -*/ +/** + * Triggers minimize of the window by the minimize button click + */ const minimizeWindow = () => { - console.log(process.env.MODE) if (process.env.MODE === 'electron') { window.faWindowControlAPI.minimizeWindow() } } -/* -Triggers resize of the window by the min/max button click -*/ +/** + * Triggers resize of the window by the min/max button click + */ const resizeWindow = () => { if (process.env.MODE === 'electron') { window.faWindowControlAPI.resizeWindow() } } -/* -Triggers checking of the current app state by the close button click -This functionality checks the following: - 1. If the app has any projects opened to begin with at the moment - 2. If the project has any pending chnages to it -If both is found to be true, then an appropriate dialog is opened -Otherwise, the app simply closes -*/ +/** + * Triggers checking of the current app state by the close button click. + * This functionality checks the following: + + * 1. If the app has any projects opened to begin with at the moment + * 2. If the project has any pending chnages to it + + * If both is found to be true, then an appropriate dialog is opened. + * Otherwise, the app simply closes. + */ const tryCloseWindow = () => { // TODO add project close checking if (process.env.MODE === 'electron') { @@ -98,8 +102,8 @@ const tryCloseWindow = () => { } } -/* -Checks if the window is maximized and sets local ref +/** +Checks if the window is maximized and sets local variable accordingly */ const checkIfWindowMaximized = () => { if (process.env.MODE === 'electron') { @@ -107,14 +111,14 @@ const checkIfWindowMaximized = () => { } } -/* -Determines if the window is currently maximized or not -*/ +/** + * Determines if the window is currently maximized or not + */ const isMaximized: Ref = ref(false) -/* -Check on component mount if the windows if maximized or not -*/ +/** + * Check on component mount if the windows if maximized or not + */ onMounted(() => { checkIfWindowMaximized() }) diff --git a/src/components/models.ts b/src/components/models.ts deleted file mode 100644 index 6945920..0000000 --- a/src/components/models.ts +++ /dev/null @@ -1,8 +0,0 @@ -export interface Todo { - id: number; - content: string; -} - -export interface Meta { - totalCount: number; -} diff --git a/src/globals.d.ts b/src/globals.d.ts index 632f04a..cac2d91 100644 --- a/src/globals.d.ts +++ b/src/globals.d.ts @@ -1,9 +1,11 @@ import { I_faWindowControlAPI } from './interfaces/I_faWindowControlAPI' +import { I_extraEnvVariablesAPI } from './interfaces/I_extraEnvVariablesAPI' export {} declare global{ interface Window { - faWindowControlAPI: I_faWindowControlAPI + faWindowControlAPI: I_faWindowControlAPI, + extraEnvVariables: I_extraEnvVariablesAPI } } diff --git a/src/i18n/de/index.ts b/src/i18n/de/index.ts index 51f1d71..63f119c 100644 --- a/src/i18n/de/index.ts +++ b/src/i18n/de/index.ts @@ -1,6 +1,14 @@ -// This is just an example, -// so you can safely delete all default props below - export default { - appName: 'FA - but in german!' + // GLOBAL - APP TEXTS + app: { + name: 'FA - but in german!' + }, + + // COMPONENT - GLOBAL WINDOW BUTTONS + GlobalWindowButtons: { + minimizeButton: 'Minimize', + resizeButton: 'Resize Down', + maximizeButton: 'Maximize', + close: 'Close' + } } diff --git a/src/i18n/en-US/index.ts b/src/i18n/en-US/index.ts index 5f31acd..b8658ce 100644 --- a/src/i18n/en-US/index.ts +++ b/src/i18n/en-US/index.ts @@ -1,12 +1,14 @@ -// This is just an example, -// so you can safely delete all default props below - export default { - appName: 'FA - but in english!', + // GLOBAL - APP TEXTS + app: { + name: 'FA - but in english!' + }, // COMPONENT - GLOBAL WINDOW BUTTONS - globalWindowButtons_minimizeButton: 'Minimize', - globalWindowButtons_resizeButton: 'Resize Down', - globalWindowButtons_maximizeButton: 'Maximize', - globalWindowButtons_close: 'Close' + GlobalWindowButtons: { + minimizeButton: 'Minimize', + resizeButton: 'Resize Down', + maximizeButton: 'Maximize', + close: 'Close' + } } diff --git a/src/interfaces/I_extraEnvVariablesAPI.ts b/src/interfaces/I_extraEnvVariablesAPI.ts new file mode 100644 index 0000000..abcfe7c --- /dev/null +++ b/src/interfaces/I_extraEnvVariablesAPI.ts @@ -0,0 +1,27 @@ +export interface I_extraEnvVariablesAPI { + + /** + * Full path to "electron-main.js" file in the dist, unpackaged form + */ + ELECTRON_MAIN_FILEPATH: string + + /** + * Extra rended timer buffer for tests to start after loading the app. + * - Increase if your machine isn't keeping up with the render times and tests are randomly failing. + * - Lower if your machine is quick and the tests are waiting for no reason at all. + * - Can be set manually for each component/e2e test inside the test file. + */ + FA_FRONTEND_RENDER_TIMER: number + + /** + * Type of test environment to load. + */ + TEST_ENV?: 'components'|'e2e'|false + + /** + * Name of the component being tested. + * - MUST match the file name of the vue file being tested (including the capital letter at the start). + */ + COMPONENT_NAME?: string|false + +} diff --git a/src/interfaces/I_faWindowControlAPI.ts b/src/interfaces/I_faWindowControlAPI.ts index e7a31e8..1292783 100644 --- a/src/interfaces/I_faWindowControlAPI.ts +++ b/src/interfaces/I_faWindowControlAPI.ts @@ -1,6 +1,25 @@ export interface I_faWindowControlAPI { + + /** + * Check the current visual sizing of the current window + */ checkWindowMaximized: () => boolean + + /** + * Minimizes the current window + */ minimizeWindow: () => void + + /** + * Resizes the current window. + * - If the window is maximized, smallifies it + * - If the window is smallified, maximizes it + */ resizeWindow: () => void + + /** + * Closes the current window + */ closeWindow: () => void + } diff --git a/src/layouts/ComponentTestingLayout.vue b/src/layouts/ComponentTestingLayout.vue new file mode 100644 index 0000000..1452a8a --- /dev/null +++ b/src/layouts/ComponentTestingLayout.vue @@ -0,0 +1,15 @@ + + + diff --git a/src/layouts/MainLayout.vue b/src/layouts/MainLayout.vue index 20388e1..bb40de3 100644 --- a/src/layouts/MainLayout.vue +++ b/src/layouts/MainLayout.vue @@ -13,7 +13,7 @@ /> - {{ $t('appName') }} + {{ $t('app.name') }}
Quasar v{{ $q.version }}
@@ -31,12 +31,6 @@ > Essential Links - - @@ -48,58 +42,12 @@ diff --git a/src/pages/IndexPage.vue b/src/pages/IndexPage.vue index 06804d5..42a19f8 100644 --- a/src/pages/IndexPage.vue +++ b/src/pages/IndexPage.vue @@ -1,49 +1,12 @@ diff --git a/src/router/routes.ts b/src/router/routes.ts index a3c4911..6d8cf79 100644 --- a/src/router/routes.ts +++ b/src/router/routes.ts @@ -1,14 +1,30 @@ import { RouteRecordRaw } from 'vue-router' const routes: RouteRecordRaw[] = [ + + /** + * Default pathing + */ { path: '/', component: () => import('layouts/MainLayout.vue'), children: [{ path: '', component: () => import('pages/IndexPage.vue') }] }, - // Always leave this as last one, - // but you can also remove it + /** + * Component testing pathing + */ + { + path: '/componentTesting/:componentName', + component: () => import('layouts/ComponentTestingLayout.vue'), + children: [ + { path: '', component: () => import('pages/ComponentTesting.vue') } + ] + }, + + /** + * Always leave this as last one, but you can also remove it + */ { path: '/:catchAll(.*)*', component: () => import('pages/ErrorNotFound.vue') diff --git a/test/playwright-e2e/appWindowControls.playwright.spec.ts b/test/playwright-e2e/appWindowControls.playwright.spec.ts deleted file mode 100644 index 29f5fbd..0000000 --- a/test/playwright-e2e/appWindowControls.playwright.spec.ts +++ /dev/null @@ -1,90 +0,0 @@ -import appRoot from 'app-root-path' -import { _electron as electron } from 'playwright' -import { test, expect } from '@playwright/test' - -const electronMainFilePath = appRoot + '/dist/electron/UnPackaged/electron-main.js' -const faFrontendRenderTimer = 1000 - -test('launch app', async () => { - const electronApp = await electron.launch({ args: [electronMainFilePath] }) - // close app - await electronApp.close() -}) - -test('click resize button - smallify', async () => { - const electronApp = await electron.launch({ args: [electronMainFilePath] }) - const appWindow = await electronApp.firstWindow() - await appWindow.waitForTimeout(faFrontendRenderTimer) - - const resizeButton = await appWindow.$('.globalWindowButtons__resize') - - if (resizeButton !== null) { - await resizeButton.click() - const isMaximized = await appWindow.evaluate(() => window.faWindowControlAPI.checkWindowMaximized()) - expect(isMaximized).toBe(false) - } else { - test.fail() - } - - // close app - await electronApp.close() -}) - -test('click resize button - maximize', async () => { - const electronApp = await electron.launch({ args: [electronMainFilePath] }) - const appWindow = await electronApp.firstWindow() - await appWindow.waitForTimeout(faFrontendRenderTimer) - - const resizeButton = await appWindow.$('.globalWindowButtons__resize') - - if (resizeButton !== null) { - await resizeButton.click() - await resizeButton.click() - const isMaximized = await appWindow.evaluate(() => window.faWindowControlAPI.checkWindowMaximized()) - expect(isMaximized).toBe(true) - } else { - test.fail() - } - - // close app - await electronApp.close() -}) - -test('click minimize button', async () => { - const electronApp = await electron.launch({ args: [electronMainFilePath] }) - const appWindow = await electronApp.firstWindow() - await appWindow.waitForTimeout(faFrontendRenderTimer) - - const minimizeButton = await appWindow.$('.globalWindowButtons__minimize') - - if (minimizeButton !== null) { - await minimizeButton.click() - const isMaximized = await appWindow.evaluate(() => window.faWindowControlAPI.checkWindowMaximized()) - expect(isMaximized).toBe(false) - } else { - test.fail() - } - - // close app - await electronApp.close() -}) - -/* This test can VERY occasionally fail when the window takes too long to close on weaker PCs. Simply rerunning the tests generally fixes this. */ -test('click close button', async () => { - const electronApp = await electron.launch({ args: [electronMainFilePath] }) - const appWindow = await electronApp.firstWindow() - await appWindow.waitForTimeout(faFrontendRenderTimer) - - const closeButton = await appWindow.$('.globalWindowButtons__close') - - if (closeButton !== null) { - let windowIsClosed = false - appWindow.on('close', () => { - windowIsClosed = true - }) - await closeButton.click() - expect(windowIsClosed).toBe(true) - } else { - test.fail() - } -}) diff --git a/test/playwright-e2e/someTest.spec.ts b/test/playwright-e2e/someTest.spec.ts new file mode 100644 index 0000000..47177c2 --- /dev/null +++ b/test/playwright-e2e/someTest.spec.ts @@ -0,0 +1 @@ +// TODO ADD SOME TESTS