Skip to content

Commit

Permalink
tests: update
Browse files Browse the repository at this point in the history
  • Loading branch information
Aetherinox committed Jul 24, 2024
1 parent 69b05a7 commit e0fb28b
Showing 1 changed file with 21 additions and 47 deletions.
68 changes: 21 additions & 47 deletions tests/main.spec.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable no-unused-vars */
/* eslint-disable no-console */
// @ts-check

/*
Expand All @@ -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()
} )

0 comments on commit e0fb28b

Please sign in to comment.