-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
run e2e tests specific to an application
- Loading branch information
1 parent
c3678d6
commit f0c4aa1
Showing
9 changed files
with
203 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
const Application = require('spectron').Application; | ||
// const fs = require('fs'); | ||
const electronPath = require('../../insomnia-app/node_modules/electron'); | ||
const path = require('path'); | ||
const debug = require('../modules/debug'); | ||
const client = require('../modules/client'); | ||
|
||
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/com.insomnia.app/mac/Insomnia.app/Contents/MacOS/Insomnia'), | ||
|
||
// Run after app-build | ||
path: electronPath, | ||
args: [path.join(__dirname, '../../insomnia-app/build/com.insomnia.app')], | ||
|
||
// 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 client.correctlyLaunched(app); | ||
await debug.workspaceDropdownExists(app); | ||
}); | ||
|
||
it('create and send a request', async () => { | ||
await debug.workspaceDropdownExists(app); | ||
|
||
// 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 input.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); | ||
// }); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
const onboarding = require('../modules/onboarding'); | ||
const client = require('../modules/client'); | ||
const home = require('../modules/home'); | ||
|
||
const Application = require('spectron').Application; | ||
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/com.insomnia.app/mac/Insomnia.app/Contents/MacOS/Insomnia'), | ||
|
||
// Run after app-build | ||
path: electronPath, | ||
args: [path.join(__dirname, '../../insomnia-app/build/com.insomnia.designer')], | ||
|
||
// 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('can reset to and proceed through onboarding flow', async () => { | ||
await client.correctlyLaunched(app); | ||
await client.resetToOnboarding(app); | ||
|
||
await onboarding.welcomeMessageShown(app); | ||
await onboarding.clickDontShare(app); | ||
await onboarding.clickSkipImport(app); | ||
|
||
await home.documentListingShown(app); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
const correctlyLaunched = async app => { | ||
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); | ||
}; | ||
|
||
const resetToOnboarding = async app => { | ||
await app.webContents.executeJavaScript("localStorage['insomnia::meta::activity'] = null;"); | ||
await app.browserWindow.reload(); // reload for local storage clearing to take effect | ||
}; | ||
|
||
module.exports = { | ||
correctlyLaunched, | ||
resetToOnboarding, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
const workspaceDropdownExists = async (app, workspaceName = 'Insomnia') => { | ||
await app.client.waitUntilTextExists('.workspace-dropdown', workspaceName); | ||
}; | ||
|
||
module.exports = { | ||
workspaceDropdownExists, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
const documentListingShown = async app => { | ||
const item = await app.client.$('.document-listing'); | ||
await item.waitForExist(); | ||
}; | ||
|
||
module.exports = { | ||
documentListingShown, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
const welcomeMessageShown = async app => { | ||
await app.client.waitUntilTextExists( | ||
'.onboarding__content__header h1', | ||
'Welcome to Insomnia Designer', | ||
); | ||
}; | ||
|
||
const clickDontShare = async app => { | ||
await app.client | ||
.$('.onboarding__content__body') | ||
.then(e => e.$(`button=Don't share usage analytics`)) | ||
.then(e => e.click()); | ||
}; | ||
|
||
const clickSkipImport = async app => { | ||
await app.client | ||
.$('.onboarding__content__body') | ||
.then(e => e.$(`button=Skip`)) | ||
.then(e => e.click()); | ||
}; | ||
|
||
module.exports = { | ||
welcomeMessageShown, | ||
clickDontShare, | ||
clickSkipImport, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.