diff --git a/app/incident/reports/controller.js b/app/incident/reports/controller.js
index bb3ebc8490..83144e1513 100644
--- a/app/incident/reports/controller.js
+++ b/app/incident/reports/controller.js
@@ -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];
diff --git a/app/incident/reports/template.hbs b/app/incident/reports/template.hbs
index 5fee99e14c..b0c67ff760 100644
--- a/app/incident/reports/template.hbs
+++ b/app/incident/reports/template.hbs
@@ -3,8 +3,10 @@
{{#em-form model=this submitButton=false as |form|}}
- {{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"}}
{{form.select
@@ -20,7 +22,7 @@
{{/em-form}}
{{/if}}
@@ -46,7 +48,7 @@
{{/if}}
diff --git a/tests/acceptance/incident-test.js b/tests/acceptance/incident-test.js
index 215412c765..69c7159d60 100644
--- a/tests/acceptance/incident-test.js
+++ b/tests/acceptance/incident-test.js
@@ -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';
@@ -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');