Permalink
Browse files

add some simple selenium tests

  • Loading branch information...
1 parent fb54d0c commit f8a20c29a55197446f14984eafd9151b74bfe782 @philschatz committed Dec 29, 2016
Showing with 98 additions and 4 deletions.
  1. +1 −0 .gitignore
  2. +1 −0 .nvmrc
  3. +3 −0 .travis.yml
  4. +10 −1 package.json
  5. +7 −0 script/run-build-and-then-test.sh
  6. +10 −0 script/run-test.sh
  7. +3 −1 src/components/board.jsx
  8. +2 −1 src/components/dashboard.jsx
  9. +2 −1 src/router.jsx
  10. +59 −0 test/index.js
View
@@ -1,2 +1,3 @@
/node_modules/
/dist/
+/selenium-screenshot.png
View
@@ -0,0 +1 @@
+v6.9
View
@@ -0,0 +1,3 @@
+# `sudo:false` for faster builds.
+sudo: false
+language: node_js
View
@@ -5,11 +5,16 @@
"main": "index.js",
"scripts": {
"start": "webpack-dev-server --progress --colors --display-chunks --display-modules --display-origins",
- "build": "eslint src; NODE_ENV=production webpack --optimize-minimize --progress --colors"
+ "build": "eslint src; NODE_ENV=production webpack --optimize-minimize --progress --colors",
+ "dev-build": "eslint src; webpack --progress --colors",
+ "start-webdriver": "webdriver-manager update && webdriver-manager start",
+ "run-ava": "ava --verbose --serial",
+ "test": "./script/run-test.sh"
},
"author": "Philip Schatz",
"license": "AGPL3.0",
"devDependencies": {
+ "ava": "^0.17.0",
"babel-core": "^6.3.17",
"babel-eslint": "^7.1.0",
"babel-loader": "^6.2.0",
@@ -22,12 +27,16 @@
"extract-text-webpack-plugin": "^1.0.1",
"favico.js": "^0.3.10",
"file-loader": "^0.9.0",
+ "http-server": "^0.9.0",
"json-loader": "^0.5.4",
"less": "^2.5.3",
"less-loader": "^2.2.2",
"node-libs-browser": "^1.0.0",
+ "parallelshell": "^2.0.0",
"react-hot-loader": "^1.3.0",
"url-loader": "^0.5.6",
+ "webdriver-manager": "^11.1.0",
+ "webdriverio": "^4.5.2",
"webpack": "^1.9.10",
"webpack-dev-server": "^1.9.0"
},
@@ -0,0 +1,7 @@
+#!/bin/bash
+npm run-script dev-build || exit 1
+
+npm run-script run-ava || exit 1
+
+# This script returns 42 if successful so that parallelshell shuts down selenium-manager
+exit 42
View
@@ -0,0 +1,10 @@
+#!/bin/bash
+$(npm bin)/parallelshell --verbose "npm run-script start-webdriver" "http-server ." "./script/run-build-and-then-test.sh"
+
+statusCode=$?
+if [[ ${statusCode} -eq 42 ]]
+then
+ exit 0
+else
+ exit ${statusCode}
+fi
@@ -36,8 +36,10 @@ const ProgressView = React.createClass({
const {ticks, max} = this.state;
const {message} = this.state;
const label = `${ticks}/${max}`;
+
+ // TODO: Use Loadable component
return (
- <div>
+ <div className="is-loading">
<BS.ProgressBar now={ticks} max={max} label={label}/>
<i className='octicon octicon-sync icon-spin'/> {message}
</div>
@@ -354,8 +354,9 @@ const DashboardShell = React.createClass({
})
.then((allRepos) => this.setState({repos: allRepos}))
.catch(() => this.setState({repos: []}));
+ // TODO: Use Loadable component
myRepos = (
- <span className='custom-loading'>
+ <span className='custom-loading is-loading'>
<i className='octicon octicon-sync icon-spin'/>
{' Loading List of Repositories...'}
</span>
View
@@ -42,7 +42,8 @@ const routes = [
childRoutes: [
// Redirect from `/r/.../kanban` to `/r/...` . keep 'kanban' in the code so it is clear where the link is going
{ path: 'kanban',
- onEnter: (state, replace) => replace(null, buildRoute('', parseRoute(state)))
+ component: RepoKanban
+ // onEnter: (state, replace) => replace(null, buildRoute('', parseRoute(state)))
},
{ path: 'since', component: MergedSinceFormShell},
{ path: 'compare', component: MergedSinceFormShell},
View
@@ -0,0 +1,59 @@
+import test from 'ava'
+const webdriverio = require('webdriverio') // Does not support ES6 imports yet
+
+const browser = webdriverio.remote({
+ // use the default driver (Travis-CI has Firefox)
+ desiredCapabilities: {browserName: process.env['CI'] ? 'firefox' : 'chrome'}
+})
+
+const waitUntilDoneLoading = async () => {
+ await browser.waitUntil(async ()=> {
+ const isLoading = await browser.isExisting('.is-loading')
+ return !isLoading
+ }, 60 * 1000) // May take a long time to fetch the issues
+}
+
+
+test.before(async t => {
+ await browser.init()
+ .url('http://localhost:8080')
+
+ // Set a GitHub token if one is defined
+ if(process.env['GH_TOKEN']) {
+ await browser.execute(function(token) {
+ window.localStorage['gh-token'] = token
+ }, process.env['GH_TOKEN'])
+ // Refresh so the JS loads the token
+ await browser.refresh()
+ }
+})
+
+test.after.always(async t => {
+ browser.saveScreenshot('./selenium-screenshot.png')
+ await browser.end()
+})
+
+
+test.beforeEach(async t => {
+ await browser.url('http://localhost:8080')
+ await browser.refresh()
+})
+
+
+test('shows a repo', async t => {
+ await browser.click('.list-group > .repo-item > a')
+ await waitUntilDoneLoading(browser)
+ // Verify that an Issue exists
+ // FIXME: When loading is done then the issues should be listed (now it has to wait for 10 seconds)
+ // await browser.waitForExist('a.issue-title', 10 * 1000)
+ await browser.getText('a.issue-title')
+})
+
+
+test('shows the label-editing screen', async t => {
+ await browser.click('.list-group > .repo-item > a')
+ await waitUntilDoneLoading(browser)
+ await browser.click('#display-settings')
+ await browser.click('.octicon-tag') // HACK: Should use a class name or something
+ // await browser.waitForExist('.batch-label')
+})

0 comments on commit f8a20c2

Please sign in to comment.