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

Report export name #855

Merged
merged 2 commits into from
Dec 12, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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`);
});
});
});
}