Skip to content

Commit

Permalink
fix(balance): fix end to end tests
Browse files Browse the repository at this point in the history
This commit updates the balance report end to end tests to work
correctly with the new configuration page.
  • Loading branch information
jniles committed Apr 9, 2018
1 parent b37808c commit abe68cc
Show file tree
Hide file tree
Showing 9 changed files with 64 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ <h3 class="text-capitalize" translate>REPORT.BALANCE_REPORT.TITLE</h3>

<bh-yes-no-radios
label="REPORT.OPTIONS.SEPARATE_DEBITS_AND_CREDITS"
id="useSeparateDebitsAndCredits"
help-text="REPORT.OPTIONS.SEPARATE_DEBITS_AND_CREDITS_HELP"
name="useSeparateDebitsAndCredits"
value="ReportConfigCtrl.reportDetails.useSeparateDebitsAndCredits"
Expand All @@ -40,6 +41,7 @@ <h3 class="text-capitalize" translate>REPORT.BALANCE_REPORT.TITLE</h3>
label="REPORT.OPTIONS.REMOVE_ZERO_ROWS"
help-text="REPORT.OPTIONS.REMOVE_ZERO_ROWS_HELP"
name="shouldPruneEmptyRows"
id="shouldPruneEmptyRows"
value="ReportConfigCtrl.reportDetails.shouldPruneEmptyRows"
on-change-callback="ReportConfigCtrl.onChangeEmptyRows(value)">
</bh-yes-no-radios>
Expand Down
2 changes: 1 addition & 1 deletion client/src/modules/templates/bhYesNoRadios.tmpl.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="form-group">
<div class="form-group" data-bh-yes-no-radios>
<label class="control-label" translate>
{{$ctrl.label}}
</label>
Expand Down
30 changes: 15 additions & 15 deletions server/controllers/finance/reports/balance/report.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -143,39 +143,39 @@
<th>{{translate "FORM.LABELS.TOTAL"}}</th>
{{#if useSeparateDebitsAndCredits}}
{{#gt totals.before 0}}
<th>{{currency totals.before totals.currencyId }}</th>
<th></th>
<th class="text-right">{{currency totals.before totals.currencyId }}</th>
<th class="text-right">{{currency 0 totals.currencyId }}</th>
{{else}}
<th></th>
<th>{{currency totals.before totals.currencyId }}</th>
<th class="text-right">{{currency 0 totals.currencyId }}</th>
<th class="text-right">{{currency totals.before totals.currencyId }}</th>
{{/gt}}
{{else}}
<th>{{debcred totals.before totals.currencyId }}</th>
<th class="text-right">{{debcred totals.before totals.currencyId }}</th>
{{/if}}

{{#if useSeparateDebitsAndCredits}}
{{#gt totals.during 0}}
<th>{{currency totals.during totals.currencyId }}</th>
<th></th>
<th class="text-right">{{currency totals.during totals.currencyId }}</th>
<th class="text-right">{{currency 0 totals.currencyId }}</th>
{{else}}
<th></th>
<th>{{currency totals.during totals.currencyId }}</th>
<th class="text-right">{{currency 0 totals.currencyId }}</th>
<th class="text-right">{{currency totals.during totals.currencyId }}</th>
{{/gt}}
{{else}}
<th>{{debcred totals.during totals.currencyId }}</th>
<th class="text-right">{{debcred totals.during totals.currencyId }}</th>
{{/if}}


{{#if useSeparateDebitsAndCredits}}
{{#gt totals.after 0}}
<th>{{currency totals.after totals.currencyId }}</th>
<th></th>
<th class="text-right">{{currency totals.after totals.currencyId }}</th>
<th class="text-right">{{currency 0 totals.currencyId }}</th>
{{else}}
<th></th>
<th>{{currency totals.after totals.currencyId }}</th>
<th class="text-right">{{currency 0 totals.currencyId }}</th>
<th class="text-right">{{currency totals.after totals.currencyId }}</th>
{{/gt}}
{{else}}
<th>{{debcred totals.after totals.currencyId }}</th>
<th class="text-right">{{debcred totals.after totals.currencyId }}</th>
{{/if}}
</tr>
</tfoot>
Expand Down
17 changes: 6 additions & 11 deletions test/end-to-end/reports/balance_report/balance_report.page.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
/* global browser, element, by */

const chai = require('chai');
const helpers = require('../../shared/helpers');

helpers.configure(chai);

const FU = require('../../shared/FormUtils');
const ReportPage = require('../page');
const components = require('../../shared/components');
Expand All @@ -15,14 +8,16 @@ class BalanceReportPage {
}

// preview an account report
showBalanceReportPreview(date) {
components.dateEditor.set(date);
showBalanceReportPreview(period) {
components.reportPeriodSelect.set(period);
components.yesNoRadios.set('yes', 'useSeparateDebitsAndCredits');
components.yesNoRadios.set('yes', 'shouldPruneEmptyRows');
this.page.preview();
}

// save an account report
saveBalanceReport(date, reportName, reportFormat) {
this.showBalanceReportPreview(date);
saveBalanceReport(period, reportName, reportFormat) {
this.showBalanceReportPreview(period);

// save report as PDF
this.page.saveAs();
Expand Down
23 changes: 7 additions & 16 deletions test/end-to-end/reports/balance_report/balance_report.spec.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,14 @@
/* global browser, element, by */

const chai = require('chai');
const helpers = require('../../shared/helpers');

helpers.configure(chai);

const BalanceReportPage = require('./balance_report.page');

describe('Balance report ::', () => {
describe('Balance Report', () => {
let Page;
const key = 'balance_report';

const dataset = {
dateFrom : '01/01/2016',
dateTo : '31/12/2016',
date : new Date('2016-12-31 12:00'),
dateOption : 0,
classe : '*',
report_name : 'Balance Report Saved by E2E',
period : '2018',
reportName : 'Balance Report Saved by E2E',
renderer : 'PDF',
};

Expand All @@ -27,22 +18,22 @@ describe('Balance report ::', () => {
});

it('preview a new balance report', () => {
Page.showBalanceReportPreview(dataset.date);
Page.showBalanceReportPreview(dataset.period);
});

it('close the previewed report', () => {
Page.closeBalanceReportPreview();
});

it('save a previewed report', () => {
Page.saveBalanceReport(dataset.date, dataset.report_name, dataset.renderer);
Page.saveBalanceReport(dataset.period, dataset.reportName, dataset.renderer);
});

it('report has been saved into archive', () => {
Page.checkSavedBalanceReport(dataset.report_name);
Page.checkSavedBalanceReport(dataset.reportName);
});

it('print the previewed report', () => {
Page.printBalanceReport(dataset.date);
Page.printBalanceReport(dataset.period);
});
});
22 changes: 8 additions & 14 deletions test/end-to-end/shared/components/bhFiscalPeriodSelect.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,19 @@
/* global browser, element, by */

const FU = require('../FormUtils');
/* global element, by */

module.exports = {
mainSelector : '[bh-fiscal-period-select]',
set : function set(fiscal_year_id, periodFrom_id, periodTo_id, id) {
var opts;
/** return selector for an option element */
function getValue(id) {
return by.css('option[value="number:?"]'.replace('?', id));
}
set : function set(fiscalYearId, periodFromId, periodToId, id) {
const getValue = ident => by.css(`option[value="number:${ident}"]`);

const bhFiscalPeriod = (id) ? element(by.id(id)) : element(by.css(this.mainSelector));

opts = bhFiscalPeriod.element(by.model('$ctrl.selectedFiscal'));
opts.element(getValue(fiscal_year_id)).click();
let opts = bhFiscalPeriod.element(by.model('$ctrl.selectedFiscal'));
opts.element(getValue(fiscalYearId)).click();

opts = bhFiscalPeriod.element(by.model('$ctrl.selectedPeriodFrom'));
opts.element(getValue(periodFrom_id)).click();
opts.element(getValue(periodFromId)).click();

opts = bhFiscalPeriod.element(by.model('$ctrl.selectedPeriodTo'));
opts.element(getValue(periodTo_id)).click();
opts.element(getValue(periodToId)).click();
},
};
};
4 changes: 2 additions & 2 deletions test/end-to-end/shared/components/bhReportPeriodSelect.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* global browser, element, by */
/* global element, by */

const FU = require('../FormUtils');

Expand All @@ -14,4 +14,4 @@ module.exports = {

FU.uiSelect('$ctrl.periodId', period, target);
},
};
};
21 changes: 21 additions & 0 deletions test/end-to-end/shared/components/bhYesNoRadios.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/* global element, by */

module.exports = {
selector : '[data-bh-yes-no-radios]',

set : (value, id) => {

// get the root value of the
const root = element(id ? by.id(id) : by.css(this.selector));

// construct a locator for the value
const locator = `[data-choice="${value}"]`;

// get the appropriate option by the locator
const option = root.element(by.css(locator));

// click it!
option.click();
},
};

3 changes: 2 additions & 1 deletion test/end-to-end/shared/components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,6 @@ module.exports = {
iprConfigSelect : require('./bhIprConfigSelect'),
rubricConfigSelect : require('./bhRubricConfigSelect'),
accountConfigSelect : require('./bhAccountConfigSelect'),
weekConfigSelect : require('./bhWeekConfigSelect'),
weekConfigSelect : require('./bhWeekConfigSelect'),
yesNoRadios : require('./bhYesNoRadios'),
};

0 comments on commit abe68cc

Please sign in to comment.