From e0fb28bc1bb622e626b6d8076d52397dcf8c43aa Mon Sep 17 00:00:00 2001 From: Aetherinox Date: Wed, 24 Jul 2024 10:10:00 -0700 Subject: [PATCH] tests: update --- tests/main.spec.js | 68 ++++++++++++++-------------------------------- 1 file changed, 21 insertions(+), 47 deletions(-) diff --git a/tests/main.spec.js b/tests/main.spec.js index 7369b9c..745b563 100644 --- a/tests/main.spec.js +++ b/tests/main.spec.js @@ -1,3 +1,5 @@ +/* eslint-disable no-unused-vars */ +/* eslint-disable no-console */ // @ts-check /* @@ -14,61 +16,33 @@ Examples available at: https://github.com/spaceagetv/electron-playwright-example */ -const { test, expect, _electron: electron } = require('@playwright/test') -const eph = require('electron-playwright-helpers') +const { test, expect, _electron: electron } = require( '@playwright/test' ) +const eph = require( 'electron-playwright-helpers' ) import jimp from 'jimp' - /* Test > ensure ntfy-desktop launches */ -test('launch ntfy-desktop', async () => { - const app = await electron.launch({ - args: ['index.js', '--quit'], - env: { - ...process.env, - NODE_ENV: 'development', - }, - }); - - await app.close() -}) - -/* - Test > full loadup and screenshot -*/ - -test('full load', async () => { - const app = await electron.launch({ - args: ['index.js', '--quit'], +test( 'launch ntfy-desktop', async () => +{ + const app = await electron.launch( { + args: [ + 'index.js', + '--quit', + '--url https://google.com' + ], env: { - ...process.env, - NODE_ENV: 'development', - }, - }); - - const timestamp = Date.now().toString(); - - const appPath = await app.evaluate(async ({ app }) => { - return app.getAppPath(); - }); - - console.log(appPath); - - const window = await app.firstWindow() - console.log(await window.title()); - window.on('console', console.log); - - // wait for #root div before taking screenshot - await window.waitForSelector('#root', { state: 'visible' }); + ...process.env, + NODE_ENV: 'development' + } + } ) /* - path: `e2e/screenshots/test-${timestamp}.png`, + const appInfo = eph.parseElectronApp('./build/ntfy-electron-win32-x64') + console.log(appInfo.name); */ - const ss1 = await window.screenshot({ path: './test-results/1.png' }) - - // close app - await eph.clickMenuItemById(app, 'quit'); -}) + await eph.clickMenuItemById( app, 'quit' ) + await app.close() +} )