2021-03-28 07:46:38 -08:00
|
|
|
/* eslint-disable eslint-comments/disable-enable-pair */
|
|
|
|
|
/* eslint-disable @typescript-eslint/await-thenable */
|
2021-01-13 03:25:02 -09:00
|
|
|
// Native
|
|
|
|
|
import path from 'path';
|
2021-01-13 03:31:18 -09:00
|
|
|
import fs from 'fs-extra';
|
2016-09-21 22:08:56 -08:00
|
|
|
|
2021-01-13 03:25:02 -09:00
|
|
|
// Packages
|
|
|
|
|
import test from 'ava';
|
|
|
|
|
import {Application} from 'spectron';
|
2016-09-21 22:08:56 -08:00
|
|
|
|
2021-01-13 03:25:02 -09:00
|
|
|
let app: Application;
|
2016-09-21 22:08:56 -08:00
|
|
|
|
2021-01-13 03:25:02 -09:00
|
|
|
test.before(async () => {
|
|
|
|
|
let pathToBinary;
|
2016-09-30 07:47:07 -08:00
|
|
|
|
2021-01-13 03:25:02 -09:00
|
|
|
switch (process.platform) {
|
|
|
|
|
case 'linux':
|
|
|
|
|
pathToBinary = path.join(__dirname, '../dist/linux-unpacked/hyper');
|
|
|
|
|
break;
|
2016-09-30 07:47:07 -08:00
|
|
|
|
2021-01-13 03:25:02 -09:00
|
|
|
case 'darwin':
|
|
|
|
|
pathToBinary = path.join(__dirname, '../dist/mac/Hyper.app/Contents/MacOS/Hyper');
|
|
|
|
|
break;
|
2016-09-30 07:47:07 -08:00
|
|
|
|
2021-01-13 03:25:02 -09:00
|
|
|
case 'win32':
|
|
|
|
|
pathToBinary = path.join(__dirname, '../dist/win-unpacked/Hyper.exe');
|
|
|
|
|
break;
|
2016-11-11 08:18:04 -09:00
|
|
|
|
2021-01-13 03:25:02 -09:00
|
|
|
default:
|
|
|
|
|
throw new Error('Path to the built binary needs to be defined for this platform in test/index.js');
|
|
|
|
|
}
|
2016-09-30 07:47:07 -08:00
|
|
|
|
2021-01-13 03:25:02 -09:00
|
|
|
app = new Application({
|
|
|
|
|
path: pathToBinary
|
|
|
|
|
});
|
2016-09-21 22:08:56 -08:00
|
|
|
|
2021-01-13 03:25:02 -09:00
|
|
|
await app.start();
|
|
|
|
|
});
|
2016-09-21 22:08:56 -08:00
|
|
|
|
2021-01-13 03:25:02 -09:00
|
|
|
test.after(async () => {
|
2021-01-13 03:31:18 -09:00
|
|
|
await new Promise((resolve) => setTimeout(resolve, 5000));
|
|
|
|
|
await app.browserWindow.capturePage().then(async (imageBuffer) => {
|
|
|
|
|
await fs.writeFile(`dist/tmp/${process.platform}_test.png`, imageBuffer);
|
|
|
|
|
});
|
2021-01-13 03:25:02 -09:00
|
|
|
await app.stop();
|
|
|
|
|
});
|
2016-09-21 22:08:56 -08:00
|
|
|
|
2021-01-13 03:25:02 -09:00
|
|
|
test('see if dev tools are open', async (t) => {
|
|
|
|
|
await app.client.waitUntilWindowLoaded();
|
|
|
|
|
t.false(await app.webContents.isDevToolsOpened());
|
|
|
|
|
});
|