antares/tests/app.spec.ts

51 lines
1.8 KiB
TypeScript
Raw Normal View History

import { expect, test } from '@playwright/test';
import { _electron as electron, Page } from 'playwright';
2022-04-25 18:26:11 +02:00
import { ElectronApplication } from 'playwright-core';
let appWindow: Page;
let electronApp: ElectronApplication;
test.beforeAll(async () => {
electronApp = await electron.launch({ args: ['dist/main.js'] });
appWindow = await electronApp.firstWindow();
await appWindow.waitForEvent('load');
});
test('launch app', async () => {
const isPackaged = await electronApp.evaluate(async ({ app }) => {
return app.isPackaged;
});
expect(isPackaged, 'expect is unpacked').toBe(false);
});
test('main window elements visibility', async () => {
const visibleSelectors = [
// '#titlebar',
2022-04-25 18:26:11 +02:00
'#window-content',
2022-08-07 19:00:12 +02:00
'#settingbar',
'#footer'
2022-04-25 18:26:11 +02:00
];
2022-08-07 19:00:12 +02:00
setTimeout(async () => {
for (const selector of visibleSelectors)
expect(await appWindow.isVisible(selector), `expect ${selector} visible`).toBe(true);
}, 3000);
2022-04-25 18:26:11 +02:00
});
// test('SQLite connection', async () => {// FIXME: not working on GitHub Actions
// await appWindow.selectOption('#connection-client', 'sqlite');// Select connection client
// await appWindow.click('#connection-test');// Press test button
// await new Promise(resolve => setTimeout(resolve, 50)); // Small toast wait
// await appWindow.isVisible('.toast-primary');// If success toast
// await appWindow.click('#connection-save');// Save connection
// await appWindow.isVisible('.settingbar-top-elements .settingbar-element .dbi-sqlite');// If new connection in settingbar
// await appWindow.click('#connection-connect');// Connect
// // TODO: continue test chain
// });
test.afterAll(async () => {
// await new Promise(resolve => setTimeout(resolve, 10000));
await electronApp.close();
});