-
-
Notifications
You must be signed in to change notification settings - Fork 218
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
25d027a
commit 806b590
Showing
7 changed files
with
123 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module.exports = { | ||
cards: [], | ||
fields: [], | ||
context: { | ||
// eslint-disable-next-line no-undef | ||
nbr_reports: reports.length, | ||
} | ||
}; |
46 changes: 46 additions & 0 deletions
46
tests/e2e/default/enketo/contact-summary-reports.wdio-spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
const commonPage = require('@page-objects/default/common/common.wdio.page'); | ||
const utils = require('@utils'); | ||
const { cookieLogin } = require('@page-objects/default/login/login.wdio.page'); | ||
const commonEnketoPage = require('@page-objects/default/enketo/common-enketo.wdio.page'); | ||
const chtConfUtils = require('@utils/cht-conf'); | ||
const path = require('path'); | ||
const placeFactory = require('@factories/cht/contacts/place'); | ||
const personFactory = require('@factories/cht/contacts/person'); | ||
const reportsFactory = require('@factories/cht/reports/generic-report'); | ||
|
||
describe('Contact summary', () => { | ||
|
||
const places = placeFactory.generateHierarchy(); | ||
const clinic = places.get('clinic'); | ||
const patient = personFactory.build({ | ||
name: 'Patient', | ||
phone: '+50683444444', | ||
patient_id: '12345', | ||
parent: { _id: clinic._id, parent: clinic.parent } | ||
}); | ||
const reports = Array | ||
.from({ length: 100 }) | ||
.map(() => reportsFactory.report().build( | ||
{ form: 'home_visit', content_type: 'xml' }, | ||
{ patient } | ||
)); | ||
|
||
before(async () => { | ||
await commonEnketoPage.uploadForm('contact-summary-reports'); | ||
await chtConfUtils.initializeConfigDir(); | ||
const contactSummaryFile = path.join(__dirname, 'config/contact-summary-reports.js'); | ||
const { contactSummary } = await chtConfUtils.compileNoolsConfig({ contactSummary: contactSummaryFile }); | ||
await utils.updateSettings({ contact_summary: contactSummary }, true); | ||
|
||
await utils.saveDocs([...places.values(), patient, ...reports]); | ||
|
||
await cookieLogin(); | ||
}); | ||
|
||
it('should load all reports', async () => { | ||
await commonPage.goToPeople(patient._id); | ||
await commonPage.openFastActionReport('contact-summary-reports', true); | ||
|
||
expect(await commonEnketoPage.getInputValue('Number of reports')).to.equal(reports.length.toString()); | ||
}); | ||
}); |
51 changes: 51 additions & 0 deletions
51
tests/e2e/default/enketo/forms/contact-summary-reports.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?xml version="1.0"?> | ||
<h:html xmlns="http://www.w3.org/2002/xforms" xmlns:h="http://www.w3.org/1999/xhtml"> | ||
<h:head> | ||
<h:title>Just a form</h:title> | ||
<model> | ||
<instance> | ||
<contact-summary-reports id="contact-summary-reports" prefix="J1!contact-summary-reports!" delimiter="#" version="2020-08-14_10-05"> | ||
<inputs> | ||
<meta> | ||
<location> | ||
<lat/> | ||
<long/> | ||
<error/> | ||
<message/> | ||
</location> | ||
</meta> | ||
<user> | ||
<contact_id/> | ||
<facility_id/> | ||
</user> | ||
</inputs> | ||
<contact> | ||
<parent>PARENT</parent> | ||
<type>person</type> | ||
<name/> | ||
<phone/> | ||
<role/> | ||
<external_id/> | ||
<notes/> | ||
<meta tag="hidden"> | ||
<created_by/> | ||
<created_by_person_uuid/> | ||
<created_by_place_uuid/> | ||
</meta> | ||
</contact> | ||
<nbr_reports/> | ||
<meta tag="hidden"> | ||
<instanceID/> | ||
</meta> | ||
</contact-summary-reports> | ||
</instance> | ||
<instance id="contact-summary"/> | ||
<bind nodeset="/contact-summary-reports/nbr_reports" type="string" calculate="instance('contact-summary')/context/nbr_reports"/> | ||
</model> | ||
</h:head> | ||
<h:body class="pages"> | ||
<input ref="/contact-summary-reports/nbr_reports"> | ||
<label>Number of reports:</label> | ||
</input> | ||
</h:body> | ||
</h:html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters