Skip to content

Commit

Permalink
add acceptance test for editing existing invoice
Browse files Browse the repository at this point in the history
  • Loading branch information
paulcpk committed Nov 14, 2017
1 parent a0cb6d4 commit 83eb0ab
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 15 deletions.
17 changes: 9 additions & 8 deletions app/components/invoice-table.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,41 +7,42 @@ export default Component.extend({
return [{
title: 'Status',
propertyName: 'status',
template: "components/models-table/cell-label"
template: 'components/models-table/cell-label'
}, {
title: 'Invoice Nr.',
propertyName: 'invoiceNumber',
className: 'invoice-number'
}, {
title: 'Customer',
propertyName: 'recipientAddress',
template: "components/models-table/cell-text"
template: 'components/models-table/cell-text',
className: 'recipient-address'
}, {
title: 'Issued',
propertyName: 'issuedDate',
template: "components/models-table/cell-date"
template: 'components/models-table/cell-date'
}, {
title: 'Due',
propertyName: 'paymentDueDate',
template: "components/models-table/cell-date",
template: 'components/models-table/cell-date',
className: 'payment-due-date'
}, {
title: 'Total',
propertyName: 'total',
template: "components/models-table/cell-amount",
template: 'components/models-table/cell-amount',
className: 'total'
},{
title: 'Edit',
template: "components/models-table/button-edit",
template: 'components/models-table/button-edit',
className: 'Edit'
},{
title: 'Delete',
template: "components/models-table/button-delete"
template: 'components/models-table/button-delete'
},{
title: 'Overdue',
propertyName: 'isOverdue',
isHidden: true,
template: "components/models-table/cell-boolean"
template: 'components/models-table/cell-boolean'
}];
}),

Expand Down
8 changes: 4 additions & 4 deletions app/templates/components/invoice-form.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,13 @@
</div>
<div class="panel-footer">
{{#if isProcessing}}
<button type="button" class="btn btn-success"><i class="fa fa-cog fa-spin fa-fw"></i> Saving...</button>
<button type="button" class="btn btn-success save-button"><i class="fa fa-cog fa-spin fa-fw"></i> Saving...</button>
{{else}}
<button type="button" class="btn btn-success" {{action (route-action "save" model)}}><i class="fa fa-floppy-o" aria-hidden="true"></i> Save</button>
<button type="button" class="btn btn-success save-button" {{action (route-action "save" model)}}><i class="fa fa-floppy-o" aria-hidden="true"></i> Save</button>
{{/if}}
<button type="button" class="btn btn-default" {{action (route-action "cancel" model)}}><i class="fa fa-ban" aria-hidden="true"></i> Cancel</button>
<button type="button" class="btn btn-default cancel-button" {{action (route-action "cancel" model)}}><i class="fa fa-ban" aria-hidden="true"></i> Cancel</button>
{{#if isEditRoute}}
<button type="button" class="btn btn-danger pull-right" {{action (route-action "delete" model)}}><i class="fa fa-trash" aria-hidden="true"></i> Delete</button>
<button type="button" class="btn btn-danger delete-button pull-right" {{action (route-action "delete" model)}}><i class="fa fa-trash" aria-hidden="true"></i> Delete</button>
{{/if}}
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/templates/components/models-table/button-edit.hbs
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<button {{action (route-action "editInvoice" record)}} class="btn btn-success btn-block button-edit"><i class="fa fa-pencil" aria-hidden="true"></i> Edit</button>
<button {{action (route-action "editInvoice" record)}} class="btn btn-success btn-block edit-button"><i class="fa fa-pencil" aria-hidden="true"></i> Edit</button>
14 changes: 12 additions & 2 deletions tests/acceptance/invoices-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,19 @@ test("I can click an invoice's edit button to be redirected", function(assert) {
server.createList('invoice', 25);
visit('/invoices');

click('.invoice-row .button-edit');

click('.invoice-row:first-child .edit-button');
andThen(function() {
assert.equal(currentPath(), 'invoices.edit');
});
});

test("I can edit the invoice, save it and the changes will be reflected in the table", function(assert) {
server.createList('invoice', 1);
visit('/invoices/edit/1');
fillIn('textarea[name="recipientAddress"]', 'Donnie Darko');
click('.save-button');

andThen(() => {
assert.equal(find('.invoice-row:first-child .recipient-address').text().trim(), 'Donnie Darko');
});
});

0 comments on commit 83eb0ab

Please sign in to comment.