Skip to content

Commit

Permalink
Updated integration tests to run chrome when tested locally
Browse files Browse the repository at this point in the history
  • Loading branch information
bxjx committed Sep 19, 2012
1 parent 91f281c commit eea946e
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 50 deletions.
9 changes: 6 additions & 3 deletions integration.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
#!/bin/bash
npm install
./server.sh devserver &
# for local testing
# For local testing, download and install selenium and the chrome driver and
# then make sure the dev server is running
# java -Dwebdriver.chrome.driver=/path/to/chromedriver -jar ~/path/to/selenium-server-standalone-2.25.0.jar
#./node_modules/.bin/mocha -R spec -t 40000 tests/integration/CreateBudget.js
# for sauce testing

# For sauce testing. This tests using the budget2012-dev site. This will be
# deployed to after a push and should be up to date before this is triggerd by jenkins
./node_modules/.bin/mocha -R spec -t 1200000 tests/integration/CreateBudget.js --with-sauce
89 changes: 48 additions & 41 deletions tests/integration/CreateBudget.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,66 +3,73 @@ var should = require('should');
var async = require('async');
var browser;

describe('Loading the home page and clicking SAVE & SHARE', function(){
async.forEachSeries(helper.config.browsers, function(browserEnv, suiteDone){

before(function(done){
helper.startBrowser(function(err, webdriver){
browser = webdriver;
browser.elementByCssSelector('a[href="/budget/save"]', function(err, el){
should.exist(el);
browser.clickElement(el, function(err){
setTimeout(function(){ done(); }, 500);
describe('In ' + browserEnv.browserName + ' load the home page and clicking SAVE & SHARE', function(){

before(function(done){
helper.startBrowser('Create Budget', browserEnv, function(err, webdriver){
browser = webdriver;
browser.elementByCssSelector('a[href="/budget/save"]', function(err, el){
should.exist(el);
browser.clickElement(el, function(err){
setTimeout(function(){ done(); }, 500);
});
});
});
});
});

it("should display the 'Save your budget form'", function(done){
browser.active(function(err, input){
if (err) return next(err);
browser.getAttribute(input, 'name', function(err, value){
value.should.equal('yourName');
done();
it("should display the 'Save your budget form' and focus on 'Your Name'", function(done){
browser.active(function(err, input){
if (err) return next(err);
browser.getAttribute(input, 'name', function(err, value){
value.should.equal('yourName');
done();
});
});
});
});

describe('with the form filled out and save clicked', function(){
describe('with the form filled out and save clicked', function(){

var details = [
['yourName', 'B.J. Rossiter' ],
['yourState', 'NSW' ],
['yourEmail', '[email protected]' ],
['budgetDescription', 'testing!' ]
];
var details = [
['yourName', 'B.J. Rossiter' ],
['yourState', 'NSW' ],
['yourEmail', '[email protected]' ],
['budgetDescription', 'testing!' ]
];

var budgetUrlSel = 'input[name="budget-url"]';
var budgetUrlSel = 'input[name="budget-url"]';

before(function(done){
async.forEachSeries(details, function(detail, next){
helper.inputText(browser, detail[0], detail[1], next);
}, function(err){
should.not.exist(err);
helper.click(browser, 'submit-save-budget', function(err){
browser.waitForConditionInBrowser("$('" + budgetUrlSel + "').length", function(err, met){
done();
before(function(done){
async.forEachSeries(details, function(detail, next){
helper.inputText(browser, detail[0], detail[1], next);
}, function(err){
should.not.exist(err);
helper.click(browser, 'submit-save-budget', function(err){
browser.waitForConditionInBrowser("$('" + budgetUrlSel + ":visible').length > 0", 3000, 100, function(err, met){
done();
});
});
});
});
});

it('should display a link to share', function(done){
browser.elementByCssSelector(budgetUrlSel, function(err, el){
el.text(function(err, text){
text.should.match(/^http:.*\/budget\/\S+/);
done();
it('should display a link to share', function(done){
browser.elementByCssSelector(budgetUrlSel, function(err, el){
el.getValue(function(err, text){
console.log("got text: " + text);
text.should.match(/^http:.*\/budget\/\S+/);
text.should.not.match(/undefined/);
done();
});
});
});

});

after(function(done){
browser.quit(done);
suiteDone();
});
});

after(function(done){
browser.quit(done);
});
});
16 changes: 10 additions & 6 deletions tests/integration/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ var args = nopt(null, null, process.argv, 2);

var configs = {
'local': {
desired: [
{browserName: "firefox"}
browsers: [
{browserName: "firefox"},
{browserName: "chrome"}
],
url: 'http://localhost:5000'
},
Expand All @@ -17,7 +18,7 @@ var configs = {
processes: 23,
maxTests: false,
serviceName: 'sauce',
desired: [
browsers: [
{browserName: "internet explorer", version: '8', platform: "XP", proxy: {proxyType: 'direct'}, 'selenium-version': '2.21.0'},
{browserName: "firefox", version: '10', platform: "Windows 2003", proxy: {proxyType: 'direct'}},
{browserName: "chrome", version: '', platform: "VISTA", proxy: {proxyType: 'direct'}}
Expand All @@ -26,13 +27,14 @@ var configs = {
}
};

var conf = exports.config = args['with-sauce'] ? configs.sauce : configs.local;

/*
* Return a webdriver browser. The browser will either connect to a local
* selenium server or sauce depending on arguments
*/
exports.startBrowser = function(cb){
exports.startBrowser = function(name, browserEnv, cb){

var conf = args['with-sauce'] ? configs.sauce : configs.local;
var browser = webdriver.remote(conf.host, conf.port, conf.username, conf.accessKey);

if (args['debug-wd']){
Expand All @@ -45,7 +47,9 @@ exports.startBrowser = function(cb){
});
}

browser.init(conf.desired, function(){
browserEnv.tags = ['budget2012'];
browserEnv.name = name;
browser.init(browserEnv, function(){
browser.get(conf.url, function(err){
cb(err, browser);
});
Expand Down

0 comments on commit eea946e

Please sign in to comment.