Files
flipper/desktop/e2e/open.ts
Pascal Hartig b24b6110fa Set up E2E workspace
Summary:
To be very clear, this is not the final layout of this in any way
but it already automates at least testing that the app starts
up and the changelog shows.

This sets up the annoyingly verbose setup for this. One
of the downsides of workspaces is that we need to be able
to install all dependencies at once, including the chrome-webdriver
which means we need to install the full electron cache now for linting, too.

Reviewed By: nikoant

Differential Revision: D21204578

fbshipit-source-id: b3403ab62b799228976a651620ea360e0bb1cf99
2020-04-28 07:04:11 -07:00

75 lines
1.7 KiB
TypeScript

/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*/
import {Application} from 'spectron';
import assert from 'assert';
import path from 'path';
const app = new Application({
path: path.join(
__dirname,
'..',
'..',
'dist',
'mac',
'Flipper.app',
'Contents',
'MacOS',
'Flipper',
),
args: ['--no-launcher'],
});
async function testSuite(app: Application) {
await app.client.waitUntilWindowLoaded();
app.browserWindow.focus();
await app.client.waitUntilTextExists('html', 'Changelog');
await app.client.$('div[type="primary"]=Close').click();
await app.client.$('div=Manage Plugins').click();
}
export default function test() {
return app
.start()
.then(async function () {
await app.client.waitUntilWindowLoaded();
})
.then(function () {
// Check if the window is visible
return app.browserWindow.isVisible();
})
.then(function (isVisible) {
// Verify the window is visible
assert.equal(isVisible, true);
})
.then(function () {
// Get the window's title
return app.client.getTitle();
})
.then(function (title) {
// Verify the window's title
assert.equal(title, 'Flipper');
})
.then(async function () {
await testSuite(app);
})
.then(function () {
// Stop the application
return app.stop();
})
.catch(function (error) {
// Log any failures
console.error('Test failed', error.message);
process.exit(1);
})
.then(function () {
console.log('Test suite succeeded.');
});
}