Created
April 25, 2013 17:50
-
-
Save cvega/5461650 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// external/public order testing (requires casperjs, and conf.js) | |
// | |
// we have a json file (conf.js) that contains all of our services, the tiers | |
// related to those services and litle & co certification billing/transaction | |
// data. We use this data to drive the tests and loop over each tier of service | |
// with each type of card transaction data. | |
casper.options.waitTimeout = 60000; | |
casper.start(); | |
casper.then(function() { | |
var rand = Math.floor(Math.random()*1000); | |
var data = new function() { | |
this.url = conf.ac.url; | |
this.issuers = function () { | |
var issuers = new Array(); | |
for(issuer in conf.issuers) { | |
issuers.push(conf.issuers[issuer]); | |
} | |
return issuers; | |
}; | |
this.tiers = function () { | |
var tiers = new Array(); | |
for(var service in conf.services) { | |
for(var tier in conf.services[service]) { | |
tiers.push(conf.services[service][tier]); | |
} | |
} | |
return tiers; | |
}; | |
}; | |
this.each(data.tiers(), function(self, tier) { | |
this.each(data.issuers(), function(self, issuer) { | |
this.thenOpen(data.url + '/order/?plan=' + tier, function() { | |
this.test.comment('test: ' + tier + '/' + issuer.type); | |
}); | |
// Grid ordering requires a customer purchased or specified domain. For | |
// testing purposes we have elected to purchase a new domain. | |
if(tier == 'grid') { | |
function cont() { | |
this.then(function() { | |
this.waitForSelector('a.continue-order', function () { | |
this.thenClick('a.continue-order'); | |
}); | |
this.test.comment('click continue order link'); | |
}); | |
} | |
this.then(function() { | |
this.waitForSelector('form#mainform', function(){ | |
this.fill('form#mainform',{ | |
domain: 'tylerdurden-'+rand+'.com', | |
action: 'register' | |
}); | |
}); | |
this.test.comment('enter domain configuration details'); | |
}); | |
cont(); | |
this.then(function() { | |
cont(); | |
this.waitForText('is Available!', function() { | |
this.fill('form[action="domain_available.mt"]', { | |
action: 'register' | |
}); | |
}); | |
this.test.comment('register domain'); | |
}); | |
cont(); | |
} | |
// this portion | |
this.then(function () { | |
this.waitForText('Contact Info', function () { | |
this.fill('form[action="contact_info.mt"]', { | |
'fname': issuer.first_name, | |
'lname': issuer.last_name, | |
'country': issuer.country, | |
'addr1': issuer.address, | |
'city': issuer.city, | |
'statename': issuer.state, | |
'zip': issuer.zip, | |
'ccnum': issuer.ccnumber, | |
'cvv': issuer.cvv2, | |
'ccexp_month': issuer.exp_month, | |
'ccexp_year': issuer.exp_year, | |
'ccsameaddr': 'on', | |
'company': 'test company', | |
'email1': '[email protected]', | |
'phone1': '888-555-1212', | |
'reason': '1', | |
'paytype': '1-1', | |
'terms-and-conditions': true | |
}); | |
this.test.comment('enter transaction details'); | |
}); | |
}); | |
this.then(function() { | |
this.waitForSelector('a.complete-order', function () { | |
this.click('a.complete-order'); | |
this.test.comment('click complete order link'); | |
}); | |
}); | |
this.then(function () { | |
this.waitForText('Just a few more seconds', function () { | |
this.test.comment('wait for order processing popup'); | |
}); | |
}); | |
this.then(function () { | |
this.waitForText('Order Complete!', function () { | |
this.test.assertTextExists('Order Complete!', 'order created'); | |
}); | |
}); | |
}); | |
}); | |
}); | |
casper.run(function() { | |
this.test.done(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment