Skip to content

Commit

Permalink
Acceptance tests!! Runs automatically with pushes/pull requests
Browse files Browse the repository at this point in the history
Uses Sauce Labs integration within Travis. Next we will use the
  npm module so that we can run the tests via Grunt.
Documentation to come.
  • Loading branch information
MusikAnimal committed Mar 16, 2016
1 parent 30f9f02 commit 891c75a
Show file tree
Hide file tree
Showing 7 changed files with 122 additions and 3 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Expand Up @@ -8,4 +8,6 @@ config.php
composer.lock
vendor/composer
vendor/krinkle
vendor/autoload.php
vendor/autoload.php
reports/
*.jar
16 changes: 14 additions & 2 deletions .travis.yml
@@ -1,10 +1,22 @@
language: php
php:
- 5.5
node_js:
- 4.3.0
before_script:
- nvm install 5.6.0
- nvm use 5.6.0
- npm install -g grunt-cli
- npm install
- sudo apt-get install apache2
- sudo a2enmod actions
- sudo a2enmod rewrite
- echo "export PATH=/home/vagrant/.phpenv/bin:$PATH" | sudo tee -a /etc/apache2/envvars > /dev/null
- echo "$(curl -fsSL https://gist.github.com/roderik/16d751c979fdeb5a14e3/raw/gistfile1.txt)" | sudo tee /etc/apache2/conf.d/phpconfig > /dev/null
- echo "$(curl -fsSL https://gist.github.com/roderik/2eb301570ed4a1f4c33d/raw/gistfile1.txt)" | sed -e "s,PATH,`pwd`/public_html,g" | sudo tee /etc/apache2/sites-available/default > /dev/null
- sudo service apache2 restart
script:
- eslint -c .eslintrc javascripts/
- ./nightwatch --env saucelabs
addons:
sauce_connect:
username: "MusikAnimal"
access_key: "71bb4995-3679-4b53-89d3-9d1516da1089"
2 changes: 2 additions & 0 deletions nightwatch
@@ -0,0 +1,2 @@
#!/usr/bin/env node
require('nightwatch/bin/runner.js');
54 changes: 54 additions & 0 deletions nightwatch.json
@@ -0,0 +1,54 @@
{
"src_folders" : ["tests"],
"output_folder" : "reports",
"custom_commands_path" : "",
"custom_assertions_path" : "",
"page_objects_path" : "",
"globals_path" : "",

"selenium" : {
"start_process" : false,
"server_path" : "",
"log_path" : "",
"host" : "127.0.0.1",
"port" : 4444,
"cli_args" : {
"webdriver.chrome.driver" : ""
}
},

"test_settings" : {
"default" : {
"launch_url" : "http://localhost/pageviews",
"selenium_port" : 4444,
"selenium_host" : "localhost",
"silent": true,
"screenshots" : {
"enabled" : false,
"path" : ""
},
"desiredCapabilities": {
"browserName": "firefox",
"javascriptEnabled": true,
"acceptSslCerts": true
}
},
"saucelabs" : {
"launch_url" : "http://127.0.0.1/pageviews",
"selenium_host": "ondemand.saucelabs.com",
"selenium_port": 80,
"username": "MusikAnimal",
"access_key": "71bb4995-3679-4b53-89d3-9d1516da1089",
"use_ssl" : false,
"silent": true,
"output" : true,
"desiredCapabilities": {
"name": "test-example",
"browserName": "firefox"
},
"selenium" : {
"start_process" : false
}
}
}
}
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -23,6 +23,7 @@
"gruntify-eslint": "*",
"jquery": "2.1.1",
"moment": "2.11.2",
"nightwatch": "*",
"underscore": "*"
},
"scripts": {
Expand Down
35 changes: 35 additions & 0 deletions tests/initialize.js
@@ -0,0 +1,35 @@
const moment = require('moment');
const _ = require('underscore');

module.exports = {
'Page loads with defaults when given no params' : function (client) {
client
.url('http://localhost/pageviews')
.waitForElementPresent('canvas', 10000);

const startDate = moment().subtract(20, 'days').format('M/D/YYYY'),
endDate = moment().subtract(1, 'days').format('M/D/YYYY'),
dateStr = `${startDate} - ${endDate}`;

client.expect.element('#range-input').to.have.value.that.equals(dateStr);
client.expect.element('.aqs-project-input').to.have.value.that.equals('en.wikipedia.org');
client.expect.element('#platform-select').to.have.value.that.equals('all-access');
client.expect.element('#agent-select').to.have.value.that.equals('user');
client.expect.element('.select2-selection__rendered').to.have.text.that.matches(/×Cat\n.*×Dog/m);
client.expect.element('#chart-legend').to.have.text.that.matches(/\bCat\b.*\bDog\b/);
client.end();
},
'Page loads with values and text matching given params' : function(client) {
client
.url('http://localhost/pageviews#start=2016-01-01&end=2016-01-10&project=en.wikivoyage.org&pages=Europe|Asia&platform=desktop&agent=spider')
.waitForElementPresent('canvas', 10000);

client.expect.element('#range-input').to.have.value.that.equals('1/1/2016 - 1/10/2016');
client.expect.element('.aqs-project-input').to.have.value.that.equals('en.wikivoyage.org');
client.expect.element('#platform-select').to.have.value.that.equals('desktop');
client.expect.element('#agent-select').to.have.value.that.equals('spider');
client.expect.element('.select2-selection__rendered').to.have.text.that.matches(/Europe\n.*Asia/m);
client.expect.element('#chart-legend').to.have.text.that.matches(/\bEurope\b.*\bAsia\b/);
client.end();
}
};
13 changes: 13 additions & 0 deletions tests/validations.js
@@ -0,0 +1,13 @@
module.exports = {
'Invalid project shows error and disables form' : function (browser) {
browser
.url('http://localhost/pageviews')
.waitForElementVisible('body', 1000)
.setValue('.aqs-project-input', ['en.nonexistent.org', browser.Keys.TAB])
.pause(1000)
.assert.containsText('.error-message', 'en.nonexistent.org')
.assert.cssClassPresent('.select2-selection--multiple', 'disabled')
.assert.elementNotPresent('canvas')
.end();
}
};

0 comments on commit 891c75a

Please sign in to comment.