Skip to content

Commit

Permalink
test: end-to-end record deletion
Browse files Browse the repository at this point in the history
This commit implements end-to-end tests for record deletions.  It also
reworks the 'actions' menus on the cash and invoice registries to use a
similar layout, and builds the 'GridRow' shared class to harness those
menus.  This makes selection of each grid row explicit - the record
human readable reference is passed in to select it.

Closes #2044.
  • Loading branch information
jniles committed Oct 13, 2017
1 parent 226b075 commit f3632fb
Show file tree
Hide file tree
Showing 17 changed files with 935 additions and 266 deletions.
28 changes: 15 additions & 13 deletions client/src/modules/cash/payments/templates/action.cell.html
Original file line number Diff line number Diff line change
@@ -1,37 +1,41 @@
<div class="ui-grid-cell-contents text-action" uib-dropdown dropdown-append-to-body>
<div class="ui-grid-cell-contents text-action" uib-dropdown dropdown-append-to-body data-row="{{ row.entity.reference }}">
<a href uib-dropdown-toggle>
<span data-method="action" translate>FORM.BUTTONS.ACTIONS</span>
<span data-action="open-dropdown-menu" translate>FORM.BUTTONS.ACTIONS</span>
<span class="caret"></span>
</a>

<ul data-action="{{ row.entity.reference }}" class="dropdown-menu-right" uib-dropdown-menu>
<ul data-row-menu="{{ row.entity.reference }}"class="dropdown-menu-right" uib-dropdown-menu>
<li class="dropdown-header">{{row.entity.reference}}</li>
<li>
<a href data-method="receipt" ng-click="grid.appScope.openReceiptModal(row.entity.uuid)">
<i class="fa fa-file-pdf-o"></i> <span translate>TABLE.COLUMNS.RECEIPT</span>
</a>
</li>

<li class="divider"></li>

<!-- view linked records -->
<li>
<a ui-sref="patientRegistry({ filters : { key : 'display_name', value : row.entity.patientName }})" data-method="viewPatient" href>
<a data-method="view-patient" href ui-sref="patientRegistry({ filters : { key : 'display_name', value : row.entity.patientName }})">
<i class="fa fa-user"></i> <span translate>REPORT.VIEW_PATIENT</span>
</a>
</li>
<li ng-show="!row.entity.is_caution">
<a data-method="viewInvoice" ui-sref="invoiceRegistry({ filters : { key : 'cash_uuid', value : row.entity.uuid }})" href>
<a data-method="view-invoice" href ui-sref="invoiceRegistry({ filters : { key : 'cash_uuid', value : row.entity.uuid }})">
<span class="fa fa-file-text-o"></span> <span translate>REPORT.VIEW_INVOICE</span>
</a>
</li>
<li>
<a data-method="viewTransactions" ui-sref="journal({ filters : [{ key: 'record_uuid', value : row.entity.uuid, displayValue: row.entity.reference}, { key : 'period', value : 'allTime' }, { key : 'includeNonPosted', value : 1 }]})" href>
<a data-method="view-transaction" href ui-sref="journal({ filters : [{ key: 'record_uuid', value : row.entity.uuid, displayValue: row.entity.reference}, { key : 'period', value : 'allTime' }, { key : 'includeNonPosted', value : 1 }]})">
<span class="fa fa-file-text-o"></span> <span translate>TRANSACTIONS.VIEW_TRANSACTIONS</span>
</a>
</li>

<li class="divider"></li>

<!-- reverse or remove records -->
<li>
<a href
data-method="cancel"
ng-click="grid.appScope.cancelCash(row.entity)"
ng-hide="row.entity._hasCreditNote">
<a data-method="reverse-record" href ng-click="grid.appScope.cancelCash(row.entity)" ng-hide="row.entity._hasCreditNote">
<span class="text-danger"><i class="fa fa-clone"></i> <span translate>TABLE.COLUMNS.CANCEL_CASH</span></span>
</a>

Expand All @@ -41,9 +45,7 @@
</li>

<li ng-hide="row.entity._hasCreditNote">
<a href
data-method="delete"
ng-click="grid.appScope.deleteCashPayment(row.entity)">
<a data-method="delete-record" href ng-click="grid.appScope.deleteCashPayment(row.entity)">
<span class="text-danger"><i class="fa fa-trash"></i> <span translate>FORM.BUTTONS.DELETE_RECORD</span></span>
</a>
</li>
Expand Down
23 changes: 12 additions & 11 deletions client/src/modules/invoices/registry/templates/action.cell.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
<div class="ui-grid-cell-contents" uib-dropdown dropdown-append-to-body>
<div class="ui-grid-cell-contents text-action" uib-dropdown dropdown-append-to-body data-row="{{ row.entity.reference }}">

<a uib-dropdown-toggle href>
<span data-method="action" translate>FORM.BUTTONS.ACTIONS</span>
<a uib-dropdown-toggle href data-action="open-dropdown-menu">
<span translate>FORM.BUTTONS.ACTIONS</span>
<span class="caret"></span>
</a>

<ul class="dropdown-menu-right" data-list="{{ rowRenderIndex }}" uib-dropdown-menu>
<ul data-row-menu="{{ row.entity.reference }}" class="dropdown-menu-right" uib-dropdown-menu>
<li class="dropdown-header">{{row.entity.reference}}</li>
<li>
<a ng-click="grid.appScope.openReceiptModal(row.entity.uuid, false, grid.appScope.receiptOptions)" data-method="invoiceReceipt" href>
<a data-method="receipt" href ng-click="grid.appScope.openReceiptModal(row.entity.uuid, false)">
<i class="fa fa-file-pdf-o"></i> <span translate>REPORT.VIEW_RECEIPT</span>
</a>
</li>
Expand All @@ -16,17 +17,17 @@

<!-- view linked records -->
<li>
<a ui-sref="patientRegistry({ filters : { key : 'display_name', value : row.entity.patientName }})" data-method="viewPatient" href>
<a data-method="view-patient" href ui-sref="patientRegistry({ filters : { key : 'display_name', value : row.entity.patientName }})">
<i class="fa fa-user"></i> <span translate>REPORT.VIEW_PATIENT</span>
</a>
</li>
<li>
<a data-method="viewPayment" ui-sref="cashRegistry({ filters : { key : 'invoice_uuid', value : row.entity.uuid }})" href>
<a data-method="view-payment" href ui-sref="cashRegistry({ filters : { key : 'invoice_uuid', value : row.entity.uuid }})">
<span class="fa fa-money"></span> <span translate>REPORT.VIEW_PAYMENTS</span>
</a>
</li>
<li>
<a data-method="viewInvoice" ui-sref="journal({ filters : [{ key: 'record_uuid', value : row.entity.uuid, displayValue: row.entity.reference}, { key : 'period', value : 'allTime' }, { key : 'includeNonPosted', value : 1 }]})" href>
<a data-method="view-transaction" href ui-sref="journal({ filters : [{ key: 'record_uuid', value : row.entity.uuid, displayValue: row.entity.reference}, { key : 'period', value : 'allTime' }, { key : 'includeNonPosted', value : 1 }]})">
<span class="fa fa-file-text-o"></span> <span translate>TRANSACTIONS.VIEW_TRANSACTIONS</span>
</a>
</li>
Expand All @@ -35,19 +36,19 @@
<li class="divider"></li>

<li ng-show="row.entity._is_cancelled">
<a ng-click="grid.appScope.creditNoteReceipt(row.entity.uuid)" data-method="creditNoteReceipt" href>
<a data-method="reverse-receipt" href ng-click="grid.appScope.creditNoteReceipt(row.entity.uuid)">
<i class="fa fa-file-pdf-o"></i> <span translate>REPORT.VIEW_CREDIT_NOTE</span>
</a>
</li>

<li ng-hide="row.entity._is_cancelled">
<a ng-click="grid.appScope.creditNote(row.entity)" data-method="createCreditNote" href>
<a data-method="reverse-record" href ng-click="grid.appScope.creditNote(row.entity)">
<span class="text-danger"><i class="fa fa-clone"></i> <span translate>FORM.LABELS.CREATE_CREDIT_NOTE</span></span>
</a>
</li>

<li ng-hide="row.entity._is_cancelled">
<a href ng-click="grid.appScope.deleteInvoice(row.entity)" data-method="delete">
<a data-method="delete-record" href ng-click="grid.appScope.deleteInvoice(row.entity)">
<span class="text-danger"><i class="fa fa-trash"></i> <span translate>FORM.BUTTONS.DELETE_RECORD</span></span>
</a>
</li>
Expand Down
32 changes: 16 additions & 16 deletions client/src/modules/vouchers/templates/action.cell.html
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
<div class="ui-grid-cell-contents text-action" uib-dropdown dropdown-append-to-body ng-if="!row.groupHeader">
<a href uib-dropdown-toggle>
<span data-method="action" translate>FORM.BUTTONS.ACTIONS</span>
<div class="ui-grid-cell-contents text-action" uib-dropdown dropdown-append-to-body ng-if="!row.groupHeader" data-row="{{ row.entity.reference }}">
<a uib-dropdown-toggle href data-action="open-dropdown-menu">
<span translate>FORM.BUTTONS.ACTIONS</span>
<span class="caret"></span>
</a>

<ul data-action="{{ rowRenderIndex}}" uib-dropdown-menu>
<ul data-row-menu="{{ row.entity.reference }}" class="dropdown-menu-right" uib-dropdown-menu>
<li class="dropdown-header">{{row.entity.reference}}</li>
<li>
<a href
data-method="receipt"
ng-if="row.entity.uuid"
ng-click="grid.appScope.showReceipt(row.entity.uuid)"
data-link-receipt="{{ ::row.entity.uuid }}">
<a data-method="receipt" href ng-click="grid.appScope.showReceipt(row.entity.uuid)">
<i class="fa fa-file-pdf-o"></i> <span translate>TABLE.COLUMNS.RECEIPT</span>
</a>
</li>

<li class="divider"></li>

<!-- view linked records -->
<li>
<a href data-method="delete" ng-click="grid.appScope.deleteVoucher(row.entity)">
<span class="text-danger"><span class="fa fa-file-text-o"></span> <span translate>FORM.BUTTONS.DELETE_RECORD</span></span>
<a data-method="view-transaction" href ui-sref="journal({ filters : [{ key : 'period', value : 'allTime' },{ key: 'record_uuid', value : row.entity.uuid, displayValue: row.entity.reference}, { key : 'includeNonPosted', value : 1 }]})">
<span class="fa fa-file-text-o"></span> <span translate>TRANSACTIONS.VIEW_TRANSACTIONS</span>
</a>
</li>

<li class="divider"></li>

<!-- delete voucher record -->
<li>
<a
data-method="viewVoucher"
ui-sref="journal({ filters : [{ key : 'period', value : 'allTime' },{ key: 'record_uuid', value : row.entity.uuid, displayValue: row.entity.reference}, { key : 'includeNonPosted', value : 1 }]})"
href>
<span class="fa fa-file-text-o"></span> <span translate>TRANSACTIONS.VIEW_TRANSACTIONS</span>
<a data-method="delete-record" href ng-click="grid.appScope.deleteVoucher(row.entity)">
<span class="text-danger"><span class="fa fa-file-text-o"></span> <span translate>FORM.BUTTONS.DELETE_RECORD</span></span>
</a>
</li>
</ul>
Expand Down
2 changes: 1 addition & 1 deletion test/data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ SET @fourth_voucher = HUID('8fefadec-c036-48ce-bc4e-e307d1301960');
INSERT INTO invoice (project_id, reference, uuid, cost, debtor_uuid, service_id, user_id, date, description, created_at) VALUES
(1,2,@first_invoice,75.0000,HUID('3be232f9-a4b9-4af6-984c-5d3f87d5c107'),1,1,'2016-01-07 14:35:55','TPA_VENTE/Thu Jan 07 2016 15:35:46 GMT+0100 (WAT)/Test 2 Patient','2016-01-07 14:35:55'),
(1,1,@second_invoice,25.0000,HUID('3be232f9-a4b9-4af6-984c-5d3f87d5c107'),1,1,'2016-01-07 14:34:35','TPA_VENTE/Thu Jan 07 2016 15:30:59 GMT+0100 (WAT)/Test 2 Patient','2016-01-07 14:31:14'),
(1,3,@third_invoice,5.1300,HUID('3be232f9-a4b9-4af6-984c-5d3f87d5c107'),1,1,'2016-02-02 14:34:35','TPA_VENTE/Thu Jan 07 2016 15:30:59 GMT+0100 (WAT)/Test 2 Patient','2016-01-7 14:31:14');
(1,3,@third_invoice,5.1300,HUID('3be232f9-a4b9-4af6-984c-5d3f87d5c107'),1,1,'2016-01-02 09:34:35','TPA_VENTE/Thu Jan 02 2016 09:30:59 GMT+0100 (WAT)/Test 2 Patient','2016-01-02 09:31:14');

INSERT INTO invoice_item VALUES
(@first_invoice,HUID('2e1332a7-3e63-411e-827d-42ad585ff518'),HUID('cf05da13-b477-11e5-b297-023919d3d5b0'),3,25.0000,25.0000,0.0000,75.0000),
Expand Down
39 changes: 34 additions & 5 deletions test/end-to-end/cash/cash.spec.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
/* global browser, element, by */
const chai = require('chai');

const expect = chai.expect;
const { expect } = require('chai');

// import testing utilities
const helpers = require('../shared/helpers');

helpers.configure(chai);

const components = require('../shared/components');
const GU = require('../shared/gridTestUtils.spec.js');
const FU = require('../shared/FormUtils');
Expand Down Expand Up @@ -213,6 +209,8 @@ describe('Cash Payments', () => {
});

describe('Cash Transfer ', CashTransfer);

describe('Credit Notes', CreditNoteTests);
});


Expand Down Expand Up @@ -251,3 +249,34 @@ function CashTransfer() {
components.notification.hasSuccess();
});
}

const SearchModal = require('../shared/search.page');
const GridRow = require('../shared/GridRow');

function CreditNoteTests() {
before(() => helpers.navigate('#/payments'));

it('cancels a payment with a credit note', () => {
const row = new GridRow('CP.TPA.3');
row.dropdown().click();
row.reverse().click();

FU.input('ModalCtrl.creditNote.description', 'Cancel This Payment');
FU.modal.submit();
components.notification.hasSuccess();
});

it('deletes a cash payment from the database', () => {
SearchModal.open();
const modal = new SearchModal('cash-payment-search');
modal.switchToDefaultFilterTab();
modal.setPeriod('allTime');
modal.setLimit(1000);
modal.submit();

const row = new GridRow('CP.TPA.4');
row.dropdown().click();
row.remove().click();
components.notification.hasSuccess();
});
}
17 changes: 0 additions & 17 deletions test/end-to-end/cash/credit-note.spec.js

This file was deleted.

5 changes: 3 additions & 2 deletions test/end-to-end/cash/registry.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ const components = require('../shared/components');
describe('Payments Registry', CashPaymentsRegistryTests);

function CashPaymentsRegistryTests() {
const PAYMENT_INSIDE_REGISTRY = 4;
const PAYMENT_INSIDE_REGISTRY = 3;
const PAYMENT_PRIMARY_CASHBOX = 0;
const DEBTOR_GROUP = 'First Test Debtor Group';
let modal;
let filters;

before(() => helpers.navigate('#/payments'));
before(() => helpers.navigate('!#/payments'));

beforeEach(() => {
SearchModal.open();
Expand Down Expand Up @@ -42,6 +42,7 @@ function CashPaymentsRegistryTests() {
GU.expectRowCount('payment-registry', DEFAULT_PAYMENTS_FOR_TODAY);
});


it(`finds ${PAYMENT_INSIDE_REGISTRY} payments for all time`, () => {
modal.switchToDefaultFilterTab();
modal.setPeriod('allTime');
Expand Down
36 changes: 16 additions & 20 deletions test/end-to-end/employees/searchModal.page.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,27 @@
/* global element */
/* global element, by */

/**
* This class represents a modal search page
* behaviour so it is a modal search page object
**/

*/
const FU = require('../shared/FormUtils');
const components = require('../shared/components');
const grid = require('../shared/GridUtils');

class SearchModalPage{

setDisplayName(displayName){
FU.input('ModalCtrl.searchQueries.display_name', displayName);
}
class SearchModalPage {
setDisplayName(displayName) {
FU.input('ModalCtrl.searchQueries.display_name', displayName);
}

submit (){
FU.modal.submit();
}
submit() {
FU.modal.submit();
}

selectSex (sex){
return element(by.id(`${sex}`)).click();
}
selectSex(sex) {
return element(by.id(`${sex}`)).click();
}

setDateRange (range){
return $(`[data-date-range="${range}"]`).click();
}
setDateRange(range) {
return $(`[data-date-range="${range}"]`).click();
}
}

module.exports = SearchModalPage;
module.exports = SearchModalPage;
Loading

0 comments on commit f3632fb

Please sign in to comment.