mirror of
https://github.com/Kong/insomnia.git
synced 2026-10-25 08:09:06 -04:00
Add spectron with basic tests (#2531)
This commit is contained in:
1 parent
5ecb69a8e5
commit
694217dbb1
3 files changed
+6201
No files matched your search
+6092
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"name": "insomnia-smoke-test",
|
||||
"version": "1.0.0",
|
||||
"scripts": {
|
||||
"test:build:core": "jest",
|
||||
"test:package:core": "cross-env PACKAGE=Insomnia jest"
|
||||
},
|
||||
"devDependencies": {
|
||||
"cross-env": "^7.0.2",
|
||||
"jest": "^26.4.0",
|
||||
"spectron": "^11.1.0",
|
||||
"spectron-keys": "0.0.1"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
const Application = require('spectron').Application;
|
||||
// const fs = require('fs');
|
||||
const electronPath = require('../insomnia-app/node_modules/electron');
|
||||
const path = require('path');
|
||||
|
||||
describe('Application launch', function() {
|
||||
jest.setTimeout(50000);
|
||||
let app = null;
|
||||
|
||||
beforeEach(async () => {
|
||||
app = new Application({
|
||||
// Run installed app
|
||||
// path: '/Applications/Insomnia.app/Contents/MacOS/Insomnia',
|
||||
|
||||
// Run after app-package
|
||||
// path: path.join(__dirname, '../insomnia-app/dist/mac/Insomnia.app/Contents/MacOS/Insomnia'),
|
||||
|
||||
// Run after app-build
|
||||
path: electronPath,
|
||||
args: [path.join(__dirname, '../insomnia-app/build')],
|
||||
|
||||
// Don't ask why, but don't remove chromeDriverArgs
|
||||
// https://github.com/electron-userland/spectron/issues/353#issuecomment-522846725
|
||||
chromeDriverArgs: ['remote-debugging-port=9222'],
|
||||
});
|
||||
await app.start();
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
if (app && app.isRunning()) {
|
||||
await app.stop();
|
||||
}
|
||||
});
|
||||
|
||||
it('shows an initial window', async () => {
|
||||
await expect(app.browserWindow.isDevToolsOpened()).resolves.toBe(false);
|
||||
await expect(app.client.getWindowCount()).resolves.toBe(1);
|
||||
await expect(app.browserWindow.isMinimized()).resolves.toBe(false);
|
||||
await expect(app.browserWindow.isFocused()).resolves.toBe(true);
|
||||
await app.client.waitUntilTextExists('.workspace-dropdown', 'Insomnia');
|
||||
});
|
||||
|
||||
// it('create and send a request', async () => {
|
||||
// await app.client.waitUntilTextExists('.workspace-dropdown', 'Insomnia');
|
||||
//
|
||||
// // Create a new request
|
||||
// await app.client.$('.sidebar .dropdown .fa-plus-circle').then(e => e.click());
|
||||
//
|
||||
// await app.client
|
||||
// .$('[aria-hidden=false]')
|
||||
// .then(e => e.$('button*=New Request'))
|
||||
// .then(e => e.click());
|
||||
//
|
||||
// // Wait for modal to open
|
||||
// await app.client.waitUntilTextExists('.modal__header', 'New Request');
|
||||
//
|
||||
// // Set name and create request
|
||||
// const input = await app.client.$('.modal input');
|
||||
// await app.client.waitUntil(() => input.isFocused());
|
||||
// const requestName = 'Request from test';
|
||||
// await input.keys(requestName);
|
||||
//
|
||||
// await app.client
|
||||
// .$('.modal .modal__footer')
|
||||
// .then(e => e.$('button=Create'))
|
||||
// .then(e => e.click());
|
||||
//
|
||||
// // Ensure first item is the one we created and is selected
|
||||
// const requests = await app.client.$$('.sidebar__item');
|
||||
// const firstRequest = requests[0];
|
||||
// const firstRequestName = await firstRequest.$('span.editable').then(e => e.getText());
|
||||
// const firstRequestClasses = await firstRequest.getAttribute('class');
|
||||
//
|
||||
// expect(firstRequestName).toBe(requestName);
|
||||
// expect(firstRequestClasses).toContain('sidebar__item--active');
|
||||
//
|
||||
// // Type into url bar
|
||||
// const urlEditor = await app.client.$('.urlbar .editor');
|
||||
// await urlEditor.click();
|
||||
// await urlEditor.keys('https://petstore.swagger.io/v2/pet/findByStatus?status=available');
|
||||
//
|
||||
// // Send request
|
||||
// await app.client.$('.urlbar__send-btn').then(e => e.click());
|
||||
//
|
||||
// // Expect 200
|
||||
// await app.client
|
||||
// .$('.response-pane .pane__header .tag.bg-success')
|
||||
// .then(e => e.getText())
|
||||
// .then(e => expect(e).toBe('200 OK'));
|
||||
//
|
||||
// await app.browserWindow.capturePage().then(function(imageBuffer) {
|
||||
// fs.writeFileSync('page.png', imageBuffer);
|
||||
// });
|
||||
// });
|
||||
});
|
||||
Reference in new issue
Block a user