SymphonyElectron/spectron/notification.spec.ts

55 lines
1.2 KiB
TypeScript
Raw Normal View History

import test from 'ava';
import { Application } from 'spectron';
2021-01-29 00:25:40 -06:00
import {
getDemoFilePath,
loadURL,
sleep,
startApplication,
stopApplication,
Timeouts,
} from './fixtures/spectron-setup';
let app;
test.before(async (t) => {
2021-01-29 00:25:40 -06:00
app = (await startApplication(true)) as Application;
t.true(app.isRunning());
});
test.after.always(async () => {
2021-01-29 00:25:40 -06:00
await stopApplication(app);
});
test('Verify is the application is running', async (t) => {
2021-01-29 00:25:40 -06:00
t.true(app.isRunning());
});
test('Verify notification window is created', async (t) => {
2021-01-29 00:25:40 -06:00
await loadURL(app, getDemoFilePath());
await app.client.waitUntilWindowLoaded(Timeouts.fiveSec);
await app.client.click('#notf');
await sleep(Timeouts.oneSec);
t.timeout(10000);
t.is(await app.client.getWindowCount(), 2);
await app.client.windowByIndex(1);
await app.client.click('.close');
await sleep(2000);
await app.client.windowByIndex(0);
});
test('Verify notification window is hidden', async (t) => {
2021-01-29 00:25:40 -06:00
await app.client.click('#notf');
2021-01-29 00:25:40 -06:00
await sleep(Timeouts.oneSec);
t.timeout(Timeouts.fiveSec);
await app.client.windowByIndex(1);
await app.client.click('.close');
2021-01-29 00:25:40 -06:00
await sleep(2000);
await app.client.windowByIndex(0);
t.is(await app.client.getWindowCount(), 2);
});