Permalink
Browse files

add test skeleton

  • Loading branch information...
pfrazee committed Oct 25, 2016
1 parent 82d69ea commit c9f52af841b828f8ec8455f261760a6ec0a156f6
Showing with 47 additions and 4 deletions.
  1. +2 −4 build-notes.md
  2. +23 −0 tests/browser-test.js
  3. +8 −0 tests/lib/browser-actions.js
  4. +14 −0 tests/package.json
View
@@ -23,10 +23,8 @@ Sits on path: `beaker-browser/app/package.json`. This is **real** manifest of th
- `app/shell-window` - the ui controls code (tabs, addressbar, etc).
- `app/stylesheets` - styles shared across the app.
- `app/webview-preload` - scripts injected into web pages.
- `config` - environment-specific config options.
- `build` - in this folder lands built, runnable application.
- `releases` - ready for distribution installers will land here.
- `resources` - resources needed for particular operating system.
- `dist` - in this folder lands built, runnable application.
- `build` - resources needed for building the app.
- `tasks` - build and development environment scripts.
View
@@ -0,0 +1,23 @@
import test from 'ava'
import {Application} from 'spectron'
import electron from '../node_modules/electron'
import * as browserActions from './lib/browser-actions'
const app = new Application({
path: electron,
args: ['../app']
})
test.before(async t => {
await app.start()
await app.client.waitUntilWindowLoaded()
})
test.after.always('cleanup', async t => await app.stop())
test('window loaded', async t => t.true(await app.browserWindow.isVisible()))
test('can open https pages', async t => {
await browserActions.navigateTo(app, 'https://beakerbrowser.com')
await app.client.windowByIndex(1)
await app.client.waitForExist('.hero')
t.deepEqual(await app.client.getUrl(), 'https://beakerbrowser.com/')
})
@@ -0,0 +1,8 @@
exports.navigateTo = function (app, url) {
app.client.windowByIndex(0)
return app.client.waitForExist('.nav-location-input')
.then(() => app.client.click('.nav-location-input'))
.then(() => app.client.setValue('.nav-location-input', url))
.then(() => app.client.pause(500)) // need to wait a sec for the UI to catch up
.then(() => app.client.keys('\uE007')) // enter
}
View
@@ -0,0 +1,14 @@
{
"name": "beaker-browser-test",
"productName": "Beaker Tests",
"version": "0.0.0",
"devDependencies": {},
"optionalDependencies": {},
"dependencies": {
"ava": "^0.16.0",
"spectron": "^3.4.0"
},
"scripts": {
"test": "ava ./*-test.js"
}
}

0 comments on commit c9f52af

Please sign in to comment.