Skip to content
This repository has been archived by the owner on Jan 9, 2023. It is now read-only.

Commit

Permalink
Merge pull request #1534 from jackcmeyer/master
Browse files Browse the repository at this point in the history
Fixes #1527
  • Loading branch information
MatthewDorner authored Oct 23, 2018
2 parents d55cbc9 + b7a93e1 commit 3adb6cc
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/incident/reports/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export default AbstractReportController.extend(UserSession, NumberFormat, {
let maxValue = get(this, 'maxValue');
return new RSVP.Promise(function(resolve, reject) {
if (isEmpty(filterStartDate)) {
reject();
reject('Start date cannot be an empty value.');
}
findParams.options.startkey = [filterStartDate.getTime(), null];

Expand Down
10 changes: 6 additions & 4 deletions app/incident/reports/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
<div class="panel-body">
{{#em-form model=this submitButton=false as |form|}}
<div class="row">
{{date-picker model=model property="startDate" label=(t 'incident.labels.startDate') class="col-sm-4"}}
{{date-picker model=model property="endDate" label=(t 'incident.labels.endDate') class="col-sm-4"}}
{{date-picker model=this property="startDate" label=(t 'incident.labels.startDate')
class="col-sm-4 test-start-date"}}
{{date-picker model=this property="endDate" label=(t 'incident.labels.endDate')
class="col-sm-4 test-end-date"}}
</div>
<div class="row" data-test-selector="select-report-type">
{{form.select
Expand All @@ -20,7 +22,7 @@
{{/em-form}}
</div>
<div class="panel-footer">
<button class="btn btn-default" {{action 'generateReport'}}>{{t 'incident.buttons.generateRep'}}</button>
<button class="btn btn-primary" {{action 'generateReport'}}>{{t 'incident.buttons.generateRep'}}</button>
</div>
{{/if}}
</div>
Expand All @@ -46,7 +48,7 @@
</table>
</div>
<div class="panel-footer">
<a href={{csvExport}} target="_blank" download="{{reportTitle}}.csv" class="btn btn-default">{{t 'incident.buttons.export'}}</a>
<a href={{csvExport}} target="_blank" download="{{reportTitle}}.csv" class="btn btn-primary">{{t 'incident.buttons.export'}}</a>
</div>
</div>
{{/if}}
27 changes: 27 additions & 0 deletions tests/acceptance/incident-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import select from 'hospitalrun/tests/helpers/select';
import typeAheadFillIn from 'hospitalrun/tests/helpers/typeahead-fillin';
import { waitToAppear, waitToDisappear } from 'hospitalrun/tests/helpers/wait-to-appear';
import { authenticateUser } from 'hospitalrun/tests/helpers/authenticate-user';
import selectDate from 'hospitalrun/tests/helpers/select-date';

const DATE_FORMAT = 'l';
const DATE_TIME_FORMAT = 'l h:mm A';
Expand Down Expand Up @@ -207,6 +208,32 @@ test('Incident deletion', function(assert) {
});
});

testSimpleReportForm('Incidents By Department');
testSimpleReportForm('Incidents By Category');

function testSimpleReportForm(reportName) {
test(`${reportName} report can be generated`, function(assert) {
return runWithPouchDump('default', async function() {
await authenticateUser();
await visit('/incident/reports');
assert.equal(currentURL(), '/incident/reports');

let startDate = moment('2015-10-01');
let endDate = moment('2015-10-31');
await selectDate('.test-start-date input', startDate.toDate());
await selectDate('.test-end-date input', endDate.toDate());
await select('#report-type', `${reportName}`);
await click('button:contains(Generate Report)');
await waitToAppear('.panel-title');

let reportTitle = `${reportName} Report ${startDate.format('l')} - ${endDate.format('l')}`;
assert.dom('.panel-title').hasText(reportTitle, `${reportName} Report generated`);
let exportLink = findWithAssert('a:contains(Export Report)');
assert.equal($(exportLink).attr('download'), `${reportTitle}.csv`);
});
});
}

async function addItem(assert, itemName) {
await click('button:contains(Add Item)');
await waitToAppear('.modal-dialog');
Expand Down

0 comments on commit 3adb6cc

Please sign in to comment.