-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixes #12 making it easy to do full app testing which includes being able to spin up a browser and verify you can run various juttle programs through outrigger
- Loading branch information
rodney
committed
Jan 14, 2016
1 parent
6dc2195
commit a92d703
Showing
11 changed files
with
238 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
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,53 @@ | ||
# Test | ||
|
||
## Running Unit Tests | ||
|
||
To run the built in unit tests simply run: | ||
|
||
``` | ||
gulp test | ||
``` | ||
|
||
## Running App Tests | ||
|
||
To run the unit tests and app tests that uses your local `google-chrome` browser | ||
to run the tests: | ||
|
||
``` | ||
gulp test --app | ||
``` | ||
|
||
The above relies on you having the right version of chrome. To avoid version | ||
problems with chrome you can use docker for testing like so: | ||
|
||
``` | ||
docker run -d -p 4444:4444 --name selenium-hub selenium/hub | ||
docker run -d --link selenium-hub:hub selenium/node-chrome | ||
``` | ||
|
||
Then when running the tests you have to tell selenium to hit the selenium | ||
hub running on the `selenium-hub` container and the tests to hit the | ||
host ip address which is usually `172.17.42.1` but you can check what your | ||
host ip address is with: | ||
|
||
``` | ||
docker network inspect bridge | grep Gateway | ||
``` | ||
|
||
That `Gateway` is your host ip that should be used with the following command: | ||
|
||
``` | ||
OUTRIGGER_HOST=172.17.42.1 SELENIUM_REMOTE_URL='http://localhost:4444/wd/hub' gulp test --app | ||
``` | ||
|
||
That will run the same app tests through the docker selenium setup and verify | ||
everything is working as expected. | ||
|
||
## Helper Scripts | ||
|
||
To simplify bringing up the selenium setup and tearing it down you can use | ||
the helper scripts under `test/scripts`: | ||
|
||
* `test/scripts/start_selenium_setup.sh` | ||
* `test/scripts/stop_selenium_setup.sh` | ||
|
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 |
---|---|---|
@@ -1,11 +1,6 @@ | ||
These tests test the full flow of loading a juttle file into outriggerd, filling out inputs if there are any, and verifying that the program output is correct. | ||
# Outrigger App Tests | ||
|
||
They are not fully automated yet and require some manual startup of services. | ||
|
||
* Install [ChromeDriver](https://sites.google.com/a/chromium.org/chromedriver/downloads) and start it (starts on default port 9515) | ||
* Make sure outriggerd is running | ||
|
||
To run the tests: | ||
``` | ||
mocha app.spec.js | ||
``` | ||
These tests verify the integration of all juttle components within the outrigger | ||
application and are not executed when you do the regular `gulp test` but instead | ||
you have to run `gulp test:app` to run these since they will take over your | ||
desktop with a chrome browser and run the end to end tests. |
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 |
---|---|---|
@@ -1,56 +1,59 @@ | ||
"use strict"; | ||
'use strict'; | ||
|
||
let DemoAppTester = require('./lib/demo-app-tester'); | ||
let webdriver = require('selenium-webdriver'); | ||
let expect = require('chai').expect; | ||
let path = require('path'); | ||
|
||
const TEST_TIMEOUT = 10000; | ||
const BROWSER = "from"; | ||
const WEBDRIVER_URL = "http://localhost:9515/"; | ||
const TEST_TIMEOUT = 30000; | ||
|
||
|
||
// skipped while webdriver is not properly configured in travis | ||
describe.skip("demo-app", function() { | ||
describe('demo-app', function() { | ||
this.timeout(TEST_TIMEOUT); | ||
let driver; | ||
let demoAppTester; | ||
beforeEach(() => { | ||
driver = new webdriver.Builder() | ||
.forBrowser(BROWSER) | ||
.usingServer(WEBDRIVER_URL) | ||
.build(); | ||
demoAppTester = new DemoAppTester(driver); | ||
|
||
before(function(done) { | ||
demoAppTester = new DemoAppTester(); | ||
demoAppTester.start(done); | ||
}); | ||
|
||
it("open juttle program with no inputs", () => { | ||
return demoAppTester.loadFile(path.join(__dirname, "juttle", "no-inputs.juttle")) | ||
.then(() => { | ||
return demoAppTester.getLoggerOutput('myLogger'); | ||
}) | ||
.then((value) => { | ||
expect(JSON.parse(value)).to.deep.equal([{time: new Date(0).toISOString(), v: 10}]); | ||
}); | ||
after(() => { | ||
demoAppTester.stop(); | ||
}); | ||
|
||
it("open juttle program with an input, fill it out, and run", () => { | ||
return demoAppTester.loadFile(path.join(__dirname, "juttle", "one-input.juttle")) | ||
.then(() => { | ||
return demoAppTester.findInputControl("a"); | ||
}) | ||
.then((inputElem) => { | ||
inputElem.sendKeys("AAA"); | ||
}) | ||
.then(demoAppTester.clickPlay) | ||
.then(() => { | ||
return demoAppTester.getLoggerOutput('myLogger'); | ||
}) | ||
.then((value) => { | ||
expect(JSON.parse(value)).to.deep.equal([{time: new Date(0).toISOString(), v: "AAA"}]); | ||
}); | ||
it('open juttle program with no inputs', () => { | ||
return demoAppTester.run({ | ||
path: path.join(__dirname, 'juttle', 'no-inputs.juttle') | ||
}) | ||
.then(() => { | ||
return demoAppTester.getTextOutput('output'); | ||
}) | ||
.then((value) => { | ||
expect(JSON.parse(value)).to.deep.equal([ | ||
{ time: new Date(0).toISOString(), value: 10 } | ||
]); | ||
}); | ||
}); | ||
|
||
afterEach(() => { | ||
driver.quit(); | ||
it('open juttle program with an input, fill it out, and run', () => { | ||
return demoAppTester.run({ | ||
path: path.join(__dirname, 'juttle', 'one-input.juttle') | ||
}) | ||
.then(() => { | ||
return demoAppTester.findInputControl('a'); | ||
}) | ||
.then((inputElem) => { | ||
inputElem.sendKeys('AAA'); | ||
}) | ||
.then(() => { | ||
demoAppTester.clickPlay(); | ||
}) | ||
.then(() => { | ||
return demoAppTester.getTextOutput('myLogger'); | ||
}) | ||
.then((value) => { | ||
expect(JSON.parse(value)).to.deep.equal([ | ||
{ time: new Date(0).toISOString(), value: 'AAA' } | ||
]); | ||
}); | ||
}); | ||
|
||
}); |
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
emit -from :0: -limit 1 | ||
| put v = 10 | ||
| @logger -display.style 'json' -title 'myLogger' | ||
| put value = 10 | ||
| view text -format 'json' -title 'output' |
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
input a: text -label 'a'; | ||
|
||
emit -from :0: -limit 1 | ||
| put v = a | ||
| @logger -display.style 'json' -title 'myLogger' | ||
| put value = a | ||
| view text -format 'json' -title 'myLogger' |
Oops, something went wrong.