Skip to content

Commit

Permalink
#126 added basic tests for valuations, claims, payments
Browse files Browse the repository at this point in the history
  • Loading branch information
nvernooy committed Sep 29, 2015
1 parent 8a43c91 commit 3a66f28
Show file tree
Hide file tree
Showing 6 changed files with 141 additions and 6 deletions.
4 changes: 2 additions & 2 deletions theme/modal_templates/saveClaimModal.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ <h3 class="modal-title">{{modalState}} a {{formData.NodeType}}</h3>
</select>
</div>
<div class="form-group">
<label for="inputClaimDate" class="col-sm-2 control-label">Claim Date:</label>
<div id="inputClaimDate"
<label for="inputDate" class="col-sm-2 control-label">Claim Date:</label>
<div id="inputDate"
class="dropdown">
<a class="dropdown-toggle"
id="dateClaimDropdown"
Expand Down
4 changes: 2 additions & 2 deletions theme/modal_templates/savePaymentModal.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ <h3 class="modal-title">{{modalState}} an {{formData.NodeType}}</h3>
</select>
</div>
<div class="form-group">
<label for="inputPaymentDate" class="col-sm-2 control-label">Payment Date:</label>
<div id="inputPaymentDate"
<label for="inputDate" class="col-sm-2 control-label">Payment Date:</label>
<div id="inputDate"
class="dropdown">
<a class="dropdown-toggle"
id="datePaymentDropdown"
Expand Down
7 changes: 5 additions & 2 deletions theme/test/conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@ exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',
specs: [
'spec/login-test.js',
// 'spec/projects-test.js',
'spec/projects-test.js',
'spec/orders-test.js',
// 'spec/invoices-test.js'
'spec/invoices-test.js',
'spec/valuations-test.js',
'spec/claims-test.js',
'spec/payments-test.js'
],
capabilities: {
browserName: 'firefox'
Expand Down
49 changes: 49 additions & 0 deletions theme/test/spec/claims-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
describe('Claims page', function() {
beforeEach(function () {
browser.get('http://127.0.0.1:8000/#/claims');
});

// tests its on the claims page
it('should be on the claims page', function() {
expect(browser.driver.getCurrentUrl()).toBe('http://127.0.0.1:8000/#/claims');
});

// add a claim
it('should add a claim', function(){
// open the add claim modal and fill in the form
var addClaimModal = element(by.id('saveClaimModal'));
var projectname = "";
element(by.css('nav ul li a i.fa-plus-square')).click();
expect(addClaimModal.isDisplayed()).toBe(true);
var projectselect = addClaimModal.element(by.id('inputProject_chosen'))
projectselect.click();
projectselect.all(by.css('.chosen-results li')).then(function(items) {
items[1].getText().then(function(name){projectname = name;});
items[1].click();
});

var valselect = addClaimModal.element(by.id('inputValuation_chosen'))
valselect.click();
valselect.all(by.css('.chosen-results li')).then(function(items) {
items[1].click();
})

addClaimModal.element(by.css('#inputDate i.fa-calendar')).click();
addClaimModal.element(by.css('#inputDate ul table tbody tr td.day.active')).click()
addClaimModal.element(by.buttonText('Save')).click();

// check the claim was added
element(by.repeater('obj in jsonclaims').row(0).column('obj.Project')).getText().then(function(name){
expect(name).toBe(projectname);
});
});

// delete claim
it('should delete a claim', function(){
// click the claim
element(by.repeater('obj in jsonclaims').row(0)).click();
// delete
element(by.css('nav ul li a i.fa-trash')).click();
element(by.buttonText('Delete')).click();
});
});
49 changes: 49 additions & 0 deletions theme/test/spec/payments-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// run test on the payments page
describe('Payments Page', function () {
beforeEach(function () {
browser.get('http://127.0.0.1:8000/#/payments');
});

// tests its on the payments page
it('should be on the payments page', function() {
expect(browser.driver.getCurrentUrl()).toBe('http://127.0.0.1:8000/#/payments');
});

// add a payment
it('should add a new payment', function () {
// open the add payment modal and fill in the form
var paymentModal = element(by.id('savePaymentModal'));
element(by.css('nav ul li a i.fa-plus-square')).click();
expect(paymentModal.isDisplayed()).toBe(true);
paymentModal.element(by.model('formData.ReferenceNumber')).sendKeys('TEST');

var projectname = "";
var projectselect = paymentModal.element(by.id('inputProject_chosen'))
projectselect.click();
projectselect.all(by.css('.chosen-results li')).then(function(items) {
items[1].getText().then(function(name){projectname = name;});
items[1].click();
});
paymentModal.element(by.css('#inputDate i.fa-calendar')).click();
paymentModal.element(by.css('#inputDate ul table tbody tr td.day.active')).click()

paymentModal.element(by.model('formData.Amount')).sendKeys('1000');

expect(paymentModal.element(by.buttonText('Save')).isEnabled()).toBe(true);
paymentModal.element(by.buttonText('Save')).click();

// check the claim was added
element(by.repeater('obj in jsonpayments').row(0).column('obj.Project')).getText().then(function(name){
expect(name).toBe(projectname);
});
});

// delete payment
it('should delete a payment', function(){
// click the payment
element(by.repeater('obj in jsonpayments').row(0)).click();
// delete
element(by.css('nav ul li a i.fa-trash')).click();
element(by.buttonText('Delete')).click();
});
});
34 changes: 34 additions & 0 deletions theme/test/spec/valuations-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
describe('Valuations page', function() {
beforeEach(function () {
browser.get('http://127.0.0.1:8000/#/valuations');
});

// tests its on the valuations page
it('should be on the valuations page', function() {
expect(browser.driver.getCurrentUrl()).toBe('http://127.0.0.1:8000/#/valuations');
});

// add a valuation
it('should add a valuation', function(){
// open the add valuation modal and fill in the form
var addValuationModal = element(by.id('saveValuationModal'));
var projectname = "";
element(by.css('nav ul li a i.fa-plus-square')).click();
expect(addValuationModal.isDisplayed()).toBe(true);
var projectselect = addValuationModal.element(by.id('inputProject_chosen'))
projectselect.click();
projectselect.all(by.css('.chosen-results li')).then(function(items) {
items[1].getText().then(function(name){projectname = name;});
items[1].click();
});

addValuationModal.element(by.css('#inputDate i.fa-calendar')).click();
addValuationModal.element(by.css('#inputDate ul table tbody tr td.day.active')).click()
addValuationModal.element(by.buttonText('Save')).click();

// check the valuation was added
element(by.repeater('obj in jsonvaluations').row(0).column('obj.Project')).getText().then(function(name){
expect(name).toBe(projectname);
});
});
});

0 comments on commit 3a66f28

Please sign in to comment.