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

Commit

Permalink
Report export name (#855)
Browse files Browse the repository at this point in the history
* make patients report export file name contain report name and date

* make inventory report exports file name contain report name and date
  • Loading branch information
mqchau authored and jkleinsc committed Dec 12, 2016
1 parent 269098c commit 152377f
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 10 deletions.
2 changes: 1 addition & 1 deletion app/inventory/reports/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
</table>
</div>
<div class="panel-footer">
<a href={{csvExport}} target="_blank" download="report.csv" class="btn btn-default">{{t 'inventory.reports.export'}}</a>
<a href={{csvExport}} target="_blank" download="{{reportTitle}}.csv" class="btn btn-default">{{t 'inventory.reports.export'}}</a>

</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/patients/reports/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
</table>
</div>
<div class="panel-footer">
<a href={{csvExport}} target="_blank" download="report.csv" class="btn btn-default">{{t 'inventory.reports.export'}}</a>
<a href={{csvExport}} target="_blank" download="{{reportTitle}}.csv" class="btn btn-default">{{t 'inventory.reports.export'}}</a>

</div>
</div>
Expand Down
9 changes: 6 additions & 3 deletions tests/acceptance/inventory-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,8 @@ function testSimpleReportForm(reportName) {
andThen(() => {
let reportTitle = `${reportName} Report ${startDate.format('l')} - ${endDate.format('l')}`;
assert.equal(find('.panel-title').text().trim(), reportTitle, `${reportName} Report generated`);
findWithAssert('a:contains(Export Report)');
let exportLink = findWithAssert('a:contains(Export Report)');
assert.equal($(exportLink).attr('download'), `${reportTitle}.csv`);
});
});
});
Expand All @@ -288,8 +289,10 @@ function testSingleDateReportForm(reportName) {
waitToAppear('.panel-title');

andThen(() => {
assert.equal(find('.panel-title').text().trim(), `${reportName} Report ${moment().format('l')}`, `${reportName} Report generated`);
findWithAssert('a:contains(Export Report)');
let reportTitle = `${reportName} Report ${moment().format('l')}`;
assert.equal(find('.panel-title').text().trim(), reportTitle, `${reportName} Report generated`);
let exportLink = findWithAssert('a:contains(Export Report)');
assert.equal($(exportLink).attr('download'), `${reportTitle}.csv`);
});
});
});
Expand Down
42 changes: 37 additions & 5 deletions tests/acceptance/patients-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,18 @@ test('View reports tab', function(assert) {
});
});

testSimpleReportForm('Admissions Summary');
testSimpleReportForm('Diagnostic Testing');
testSimpleReportForm('Discharges Detail');
testSimpleReportForm('Discharges Summary');
testSimpleReportForm('Procedures Detail');
let reportNames = [
'Admissions Summary',
'Diagnostic Testing',
'Discharges Detail',
'Discharges Summary',
'Procedures Detail'
];

reportNames.forEach((reportName) => {
testSimpleReportForm(reportName);
testExportReportName(reportName);
});

test('View reports tab | Patient Status', function(assert) {
runWithPouchDump('default', function() {
Expand Down Expand Up @@ -116,3 +123,28 @@ function testSimpleReportForm(reportName) {
});
});
}

function testExportReportName(reportName) {
test(`View reports tab | Export reports name for ${reportName} shows report name, start and end dates`, (assert) => {
runWithPouchDump('default', () => {
authenticateUser();
visit('/patients/reports');
select('[data-test-selector="select-report-type"] select', reportName);

andThen(() => {
assert.equal(currentURL(), '/patients/reports');
});

fillIn('[data-test-selector="select-report-start-date"] input', '12/11/2016');
fillIn('[data-test-selector="select-report-end-date"] input', '12/31/2016');

click('button:contains(Generate Report)');
waitToAppear('.panel-title');

andThen(() => {
let exportReportButton = findWithAssert('a:contains(Export Report)');
assert.equal($(exportReportButton).attr('download'), `${reportName} Report 12/11/2016 - 12/31/2016.csv`);
});
});
});
}

0 comments on commit 152377f

Please sign in to comment.