diff --git a/tests/e2e/default/enketo/death-report.wdio-spec.js b/tests/e2e/default/enketo/death-report.wdio-spec.js index 6b3c1ee7c7d..2d9af122298 100644 --- a/tests/e2e/default/enketo/death-report.wdio-spec.js +++ b/tests/e2e/default/enketo/death-report.wdio-spec.js @@ -49,7 +49,7 @@ describe('Submit a death report', () => { expect(await (await contactPage.deathCard()).isDisplayed()).to.be.true; const deathCardInfo = await contactPage.getDeathCardInfo(); - expect(deathCardInfo.deathDate).to.equal(deathDate.format('D MMM, YYYY')); + expect(Date.parse(deathCardInfo.deathDate)).to.equal(Date.parse(deathDate.format('D MMM, YYYY'))); expect(deathCardInfo.deathPlace).to.equal('Health facility'); }); diff --git a/tests/e2e/default/enketo/enketo-widgets.wdio-spec.js b/tests/e2e/default/enketo/enketo-widgets.wdio-spec.js new file mode 100644 index 00000000000..905f8c92ff5 --- /dev/null +++ b/tests/e2e/default/enketo/enketo-widgets.wdio-spec.js @@ -0,0 +1,193 @@ +const fs = require('fs'); +const placeFactory = require('@factories/cht/contacts/place'); +const userFactory = require('@factories/cht/users/users'); +const utils = require('@utils'); +const loginPage = require('@page-objects/default/login/login.wdio.page'); +const commonPage = require('@page-objects/default/common/common.wdio.page'); +const enketoWidgetsPage = require('@page-objects/default/enketo/enketo-widgets.wdio.page'); +const genericForm = require('@page-objects/default/enketo/generic-form.wdio.page'); +const reportsPage = require('@page-objects/default/reports/reports.wdio.page'); +const contactPage = require('@page-objects/default/contacts/contacts.wdio.page'); + + +describe('Enketo Widgets', () => { + const districtHospital = placeFactory.place().build({ _id: 'dist1', type: 'district_hospital' }); + const phoneNumber = '+40766565656'; + const offlineUser = userFactory.build({ + place: districtHospital._id, + roles: ['chw'], + //The "name" value is deliberately <4 characters to violate the inputs constraint in the form + contact: {_id: '987 654 321', name: 'Ben', phone: '+50689999999'} + }); + const formDoc = { + _id: 'form:enketo_widgets_test', + internalId: 'enketo_widgets_test', + title: 'Enketo Widgets Test', + type: 'form', + _attachments: { + xml: { + content_type: 'application/octet-stream', + data: Buffer + .from(fs.readFileSync(`${__dirname}/forms/enketo_widgets.xml`, 'utf8')) + .toString('base64'), + }, + }, + }; + + let medicId; + + const fillCascadingWidgetsSection = async (country, city, neighborhood, countCities, countNeighborhood) => { + await enketoWidgetsPage.selectCountryRadio(country); + await enketoWidgetsPage.selectCityRadio(city); + await enketoWidgetsPage.selectNeighborhoodRadio(neighborhood); + await enketoWidgetsPage.openDropdown(await enketoWidgetsPage.countryDropdown()); + await enketoWidgetsPage.selectDropdownOptions(await enketoWidgetsPage.countryDropdown(), 'radio', country); + await enketoWidgetsPage.openDropdown(await enketoWidgetsPage.cityDropdown()); + expect(await enketoWidgetsPage.getDropdownTotalOptions(await enketoWidgetsPage.cityDropdown())) + .to.equal(countCities); + await enketoWidgetsPage.selectDropdownOptions(await enketoWidgetsPage.cityDropdown(), 'radio', city); + await enketoWidgetsPage.openDropdown(await enketoWidgetsPage.neighborhoodDropdown()); + expect(await enketoWidgetsPage.getDropdownTotalOptions(await enketoWidgetsPage.neighborhoodDropdown())) + .to.equal(countNeighborhood); + await enketoWidgetsPage.selectDropdownOptions( + await enketoWidgetsPage.neighborhoodDropdown(), 'radio', neighborhood + ); + }; + + const verifyReport = async (selectMultiple, selectOne, country, city, neighborhood, uuid, id, name, phoneNumber) => { + const firstReport = await reportsPage.firstReport(); + const firstReportInfo = await reportsPage.getListReportInfo(firstReport); + + expect(firstReportInfo.heading).to.equal(name); + expect(firstReportInfo.form).to.equal('Enketo Widgets Test'); + + await reportsPage.openSelectedReport(firstReport); + await commonPage.waitForPageLoaded(); + + const { senderName, senderPhone, reportName } = await reportsPage.getOpenReportInfo(); + expect(senderName).to.equal(`Submitted by ${offlineUser.contact.name} `); + expect(senderPhone).to.equal(offlineUser.contact.phone); + expect(reportName).to.equal('Enketo Widgets Test'); + + expect((await reportsPage.getDetailReportRowContent('select_spinner')).rowValues[0]).to.equal(selectMultiple); + expect((await reportsPage.getDetailReportRowContent('select1_spinner')).rowValues[0]).to.equal(selectOne); + expect((await reportsPage.getDetailReportRowContent('country')).rowValues[0]).to.equal(country); + expect((await reportsPage.getDetailReportRowContent('city')).rowValues[0]).to.equal(city); + expect((await reportsPage.getDetailReportRowContent('neighborhood')).rowValues[0]).to.equal(neighborhood); + expect((await reportsPage.getDetailReportRowContent('country2')).rowValues[0]).to.equal(country); + expect((await reportsPage.getDetailReportRowContent('city2')).rowValues[0]).to.equal(city); + expect((await reportsPage.getDetailReportRowContent('neighborhood2')).rowValues[0]).to.equal(neighborhood); + expect((await reportsPage.getDetailReportRowContent('patient_uuid')).rowValues[0]).to.equal(uuid); + expect((await reportsPage.getDetailReportRowContent('patient_id')).rowValues[0]).to.equal(id); + expect((await reportsPage.getDetailReportRowContent('patient_name')).rowValues[0]).to.equal(name); + expect((await reportsPage.getDetailReportRowContent('phone')).rowValues[0]).to.equal(phoneNumber); + }; + + before(async () => { + await utils.saveDocs([formDoc, districtHospital]); + await utils.createUsers([offlineUser]); + await loginPage.login(offlineUser); + await commonPage.waitForPageLoaded(); + }); + + it('should submit Enketo Widgets form - People\'s tab', async () => { + await commonPage.goToPeople(offlineUser.contact._id); + medicId = await contactPage.getContactMedicID(); + await commonPage.openFastActionReport('enketo_widgets_test'); + await commonPage.waitForPageLoaded(); + expect(await enketoWidgetsPage.getFormTitle()).to.equal('Enketo Widgets Test'); + + await enketoWidgetsPage.openDropdown(await enketoWidgetsPage.selectMultipleDropdown()); + await enketoWidgetsPage.selectDropdownOptions(await enketoWidgetsPage.selectMultipleDropdown(), 'checkbox', 'a'); + await enketoWidgetsPage.selectDropdownOptions(await enketoWidgetsPage.selectMultipleDropdown(), 'checkbox', 'c'); + expect(await enketoWidgetsPage.getDropdownValue(await enketoWidgetsPage.selectMultipleDropdown())) + .to.equal('2 selected'); + + await enketoWidgetsPage.openDropdown(await enketoWidgetsPage.selectOneDropdown()); + await enketoWidgetsPage.selectDropdownOptions(await enketoWidgetsPage.selectOneDropdown(), 'radio', 'd'); + expect(await enketoWidgetsPage.getDropdownValue(await enketoWidgetsPage.selectOneDropdown())) + .to.equal('option d'); + + // try to move to next page without filling the mandatory phone number field + await genericForm.nextPage(); + expect(await enketoWidgetsPage.phoneFieldRequiredMessage().getAttribute('data-i18n')) + .to.equal('constraint.required'); + + // try to move to next page with an invalid phone number + await enketoWidgetsPage.setPhoneNumber('+4076'); + await genericForm.nextPage(); + expect(await enketoWidgetsPage.phoneFieldConstraintMessage().getAttribute('data-itext-id')) + .to.equal('/enketo_widgets/enketo_test_select/phone:jr:constraintMsg'); + + // finally set a valid phone number and continue + await enketoWidgetsPage.setPhoneNumber(phoneNumber); + + await genericForm.nextPage(); + await fillCascadingWidgetsSection('usa', 'nyc', 'bronx', 3, 2); + await genericForm.submitForm(); + await commonPage.waitForPageLoaded(); + + await commonPage.goToReports(); + await verifyReport( + 'a c', + 'd', + 'usa', + 'nyc', + 'bronx', + offlineUser.contact._id, + medicId, + offlineUser.contact.name, + phoneNumber, + ); + }); + + it('should submit Enketo Widgets form - Report\'s tab', async () => { + await commonPage.goToReports(); + await commonPage.openFastActionReport('enketo_widgets_test', false); + await commonPage.waitForPageLoaded(); + expect(await enketoWidgetsPage.getFormTitle()).to.equal('Enketo Widgets Test'); + + await enketoWidgetsPage.openDropdown(await enketoWidgetsPage.selectMultipleDropdown()); + await enketoWidgetsPage.selectDropdownOptions(await enketoWidgetsPage.selectMultipleDropdown(), 'checkbox', 'b'); + await enketoWidgetsPage.selectDropdownOptions(await enketoWidgetsPage.selectMultipleDropdown(), 'checkbox', 'c'); + await enketoWidgetsPage.selectDropdownOptions(await enketoWidgetsPage.selectMultipleDropdown(), 'checkbox', 'd'); + expect(await enketoWidgetsPage.getDropdownValue(await enketoWidgetsPage.selectMultipleDropdown())) + .to.equal('3 selected'); + + await enketoWidgetsPage.openDropdown(await enketoWidgetsPage.selectOneDropdown()); + await enketoWidgetsPage.selectDropdownOptions(await enketoWidgetsPage.selectOneDropdown(), 'radio', 'a'); + expect(await enketoWidgetsPage.getDropdownValue(await enketoWidgetsPage.selectOneDropdown())) + .to.equal('option a'); + await enketoWidgetsPage.setPhoneNumber(phoneNumber); + + await genericForm.nextPage(); + await fillCascadingWidgetsSection('nl', 'dro', 'havendr', 3, 1); + await genericForm.nextPage(); + await enketoWidgetsPage.setPatientName('Eli'); + await enketoWidgetsPage.setPatientUuid('123 456 789'); + + expect(await (await enketoWidgetsPage.patientNameErrorLabel()).isExisting()).to.be.true; + + await enketoWidgetsPage.setPatientName('Elias'); + await enketoWidgetsPage.setPatientId('12345'); + + expect(await (await enketoWidgetsPage.patientNameErrorLabel()).isExisting()).to.be.false; + + await genericForm.submitForm(); + await commonPage.waitForPageLoaded(); + + await commonPage.goToReports(); + await verifyReport( + 'b c d', + 'a', + 'nl', + 'dro', + 'havendr', + '123 456 789', + '12345', + 'Elias', + phoneNumber, + ); + }); + +}); diff --git a/tests/e2e/default/enketo/forms/enketo_widgets.xlsx b/tests/e2e/default/enketo/forms/enketo_widgets.xlsx new file mode 100644 index 00000000000..5c1afc9895a Binary files /dev/null and b/tests/e2e/default/enketo/forms/enketo_widgets.xlsx differ diff --git a/tests/e2e/default/enketo/forms/enketo_widgets.xml b/tests/e2e/default/enketo/forms/enketo_widgets.xml new file mode 100644 index 00000000000..ee1950b444e --- /dev/null +++ b/tests/e2e/default/enketo/forms/enketo_widgets.xml @@ -0,0 +1,491 @@ + + + + Enketo Widgets + + + + + City + + + The Netherlands + + + United States + + + Country + + + Neighborhood + + + Cascading Selects with Radio Buttons + + + City + + + The Netherlands + + + United States + + + Country + + + Neighborhood + + + Cascading Selects with Pulldowns + + + Cascading Select widgets + + + Please enter a valid local number, or use the standard international format, which includes a plus sign (+) and country code. For example: +254712345678 + + + Phone Number + + + option a + + + option b + + + option c + + + option d + + + Select one: pulldown + + + option a + + + option b + + + option c + + + option d + + + Select multiple: pulldown + + + Select widgets + + + What is the patient's uuid? + + + Name should contain more than 4 characters + + + What is the patient's name? + + + What is the patient's id? + + + Patient + + + Patient ID + + + Patient Name + + + Patient UUID + + + Amsterdam + + + Denver + + + New York City + + + Los Angeles + + + Rotterdam + + + Dronten + + + The Netherlands + + + United States + + + option a + + + option b + + + option c + + + option d + + + Bronx + + + Harlem + + + Bel Air + + + Westerpark + + + Park Hill + + + Harbor + + + Dam + + + Downtown + + + Harbor + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + user + + + <_id/> + + + + + + + + + + + + + + + + + static_instance-cities-0 + nl + ams + + + static_instance-cities-1 + usa + den + + + static_instance-cities-2 + usa + nyc + + + static_instance-cities-3 + usa + la + + + static_instance-cities-4 + nl + rot + + + static_instance-cities-5 + nl + dro + + + + + + + static_instance-list-0 + a + + + static_instance-list-1 + b + + + static_instance-list-2 + c + + + static_instance-list-3 + d + + + + + + + static_instance-neighborhoods-0 + usa + bronx + nyc + + + static_instance-neighborhoods-1 + usa + harlem + nyc + + + static_instance-neighborhoods-2 + usa + belair + la + + + static_instance-neighborhoods-3 + nl + wes + ams + + + static_instance-neighborhoods-4 + usa + parkhill + den + + + static_instance-neighborhoods-5 + nl + haven + rot + + + static_instance-neighborhoods-6 + nl + dam + ams + + + static_instance-neighborhoods-7 + nl + centrum + rot + + + static_instance-neighborhoods-8 + nl + havendr + dro + + + + + + + static_instance-countries-0 + nl + + + static_instance-countries-1 + usa + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/e2e/default/enketo/pregnancy-complete-a-delivery.wdio-spec.js b/tests/e2e/default/enketo/pregnancy-complete-a-delivery.wdio-spec.js index c13a60e2fe1..d9b544ba319 100644 --- a/tests/e2e/default/enketo/pregnancy-complete-a-delivery.wdio-spec.js +++ b/tests/e2e/default/enketo/pregnancy-complete-a-delivery.wdio-spec.js @@ -1,8 +1,5 @@ -const fs = require('fs'); const moment = require('moment'); -const expect = require('chai').expect; const utils = require('@utils'); -const sentinelUtils = require('@utils/sentinel'); const analyticsPage = require('@page-objects/default/analytics/analytics.wdio.page'); const loginPage = require('@page-objects/default/login/login.wdio.page'); const commonPage = require('@page-objects/default/common/common.wdio.page'); @@ -10,147 +7,104 @@ const contactPage = require('@page-objects/default/contacts/contacts.wdio.page') const reportPage = require('@page-objects/default/reports/reports.wdio.page'); const genericForm = require('@page-objects/default/enketo/generic-form.wdio.page'); const deliveryForm = require('@page-objects/default/enketo/delivery.wdio.page'); +const placeFactory = require('@factories/cht/contacts/place'); +const userFactory = require('@factories/cht/users/users'); +const personFactory = require('@factories/cht/contacts/person'); +const pregnancyForm = require('@page-objects/default/enketo/pregnancy.wdio.page'); -const DEFAULT_LOCALE = 'en'; -const BABYS_NAME = 'Benja'; -const MOTHERS_NAME = 'Woman'; -const BABYS_DOB = moment().format('YYYY-MM-DD'); -const BABYS_SEX = 'male'; -const YES = 'yes'; -const NO = 'no'; - -const chw = { - username: 'bob', - password: 'medic.123', - place: 'fixture:center', - contact: { _id: 'fixture:user:bob', name: 'Bob' }, - roles: ['chw'], -}; - -const contacts = [ - { - _id: 'fixture:district', - type: 'district_hospital', - name: 'District', - place_id: 'district', - reported_date: new Date().getTime(), - }, - { - _id: 'fixture:center', - type: 'health_center', - name: 'Health Center', - parent: { _id: 'fixture:district' }, - place_id: 'health_center', - reported_date: new Date().getTime(), - }, - { - _id: 'fixture:woman', - type: 'person', - name: MOTHERS_NAME, - sex: 'female', - date_of_birth: '1994-05-12', - date_of_birth_method: 'approx', - phone: '+64274444444', - alternate_phone: '', - notes: '', - role: 'patient', - ephemeral_dob: { - age_label: '', - age_years: '28', - age_months: '', - dob_method: 'approx', - ephemeral_months: '5', - ephemeral_years: '1994', - dob_approx: '1994-05-12', - dob_raw: '1994-05-12', - dob_iso: '1994-05-12' - }, - parent: { _id: 'fixture:center' }, - reported_date: new Date().getTime(), - }, -]; - -const deliveryXml = fs.readFileSync(`${__dirname}/forms/delivery.xml`, 'utf8'); +describe('Contact Delivery Form', () => { + const BABY_NAME = 'Benja'; + const BABY_DOB = moment().format('YYYY-MM-DD'); + const BABY_SEX = 'male'; -const formDocument = { - _id: 'form:delivery2', - internalId: 'delivery', - title: 'Delivery', - type: 'form', - _attachments: { - xml: { - content_type: 'application/octet-stream', - data: Buffer.from(deliveryXml).toString('base64') - } - } -}; + const places = placeFactory.generateHierarchy(); + const healthCenter = places.get('health_center'); + const offlineUser = userFactory.build({ place: healthCenter._id, roles: ['chw'] }); + const pregnantWoman = personFactory.build({ + date_of_birth: moment().subtract(25, 'years').format('YYYY-MM-DD'), + parent: { _id: healthCenter._id, parent: healthCenter.parent } + }); -describe('Contact Delivery Form', () => { before(async () => { - await utils.saveDoc(formDocument); - await utils.saveDocs(contacts); - await utils.createUsers([chw]); - await sentinelUtils.waitForSentinel(); - await loginPage.login({ username: chw.username, password: chw.password, locale: DEFAULT_LOCALE }); - await commonPage.goToPeople('fixture:woman', true); + await utils.saveDocs([...places.values(), pregnantWoman]); + await utils.createUsers([offlineUser]); + await loginPage.login(offlineUser); + await commonPage.waitForPageLoaded(); + await commonPage.goToPeople(pregnantWoman._id); + + await pregnancyForm.submitPregnancy(); + await commonPage.waitForPageLoaded(); }); it('Complete a delivery: Process a delivery with a live child and facility birth.', async () => { await commonPage.openFastActionReport('delivery'); await deliveryForm.selectDeliveryConditionWomanOutcome('alive_well'); await genericForm.nextPage(); - await deliveryForm.selectDeliveryPosnatalDangerSignsFever(NO); - await deliveryForm.selectDeliveryPosnatalDangerSevereFever(NO); - await deliveryForm.selectDeliveryPosnatalDangerVaginalBleeding(NO); - await deliveryForm.selectDeliveryPosnatalDangerVaginalDischarge(NO); - await deliveryForm.selectDeliveryPosnatalDangerConvulsion(NO); + await deliveryForm.selectDeliveryPostnatalDangerSignsFever('no'); + await deliveryForm.selectDeliveryPostnatalDangerSevereHeadache('no'); + await deliveryForm.selectDeliveryPostnatalDangerVaginalBleeding('no'); + await deliveryForm.selectDeliveryPostnatalDangerVaginalDischarge('no'); + await deliveryForm.selectDeliveryPostnatalDangerConvulsion('no'); await genericForm.nextPage(); await deliveryForm.selectDeliveryOutcomeBabiesDelivered('1'); await deliveryForm.selectDeliveryOutcomeBabiesAlive('1'); await deliveryForm.selectDeliveryOutcomeDeliveryPlace('health_facility'); await deliveryForm.selectDeliveryOutcomeDeliveryMode('vaginal'); - await deliveryForm.setDeliveryOutcomeDateOfDelivery(BABYS_DOB); + await deliveryForm.setDeliveryOutcomeDateOfDelivery(BABY_DOB); await genericForm.nextPage(); - await deliveryForm.selectDeliveryBabysCondition('alive_well'); - await deliveryForm.setDeliveryBabysName(BABYS_NAME); - await deliveryForm.selectDeliveryBabysSex(BABYS_SEX); - await deliveryForm.selectDeliveryBabysBirthWeightKnow(NO); - await deliveryForm.selectDeliveryBabysBirthLengthKnow(NO); - await deliveryForm.selectDeliveryBabysVaccinesReveived('none'); - await deliveryForm.selectDeliveryBabyBreastfeeding(YES); - await deliveryForm.selectDeliveryBabyBreastfeedingWithin1Hour(YES); - await deliveryForm.selectDeliveryBabyInfectedUmbilicalCord(NO); - await deliveryForm.selectDeliveryBabyConvulsion(NO); - await deliveryForm.selectDeliveryBabyDifficultyFeeding(NO); - await deliveryForm.selectDeliveryBabyVomit(NO); - await deliveryForm.selectDeliveryBabyDrowsy(NO); - await deliveryForm.selectDeliveryBabyStiff(NO); - await deliveryForm.selectDeliveryBabyYellowSkin(NO); - await deliveryForm.selectDeliveryBabyFever(NO); - await deliveryForm.selectDeliveryBabyBlueSkin(NO); + await deliveryForm.selectDeliveryBabyCondition('alive_well'); + await deliveryForm.setDeliveryBabyName(BABY_NAME); + await deliveryForm.selectDeliveryBabySex(BABY_SEX); + await deliveryForm.selectDeliveryBabyBirthWeightKnown('no'); + await deliveryForm.selectDeliveryBabyBirthLengthKnown('no'); + await deliveryForm.selectDeliveryBabyVaccinesReceived('none'); + await deliveryForm.selectDeliveryBabyBreastfeeding('yes'); + await deliveryForm.selectDeliveryBabyBreastfeedingWithin1Hour('yes'); + await deliveryForm.selectDeliveryBabyInfectedUmbilicalCord('no'); + await deliveryForm.selectDeliveryBabyConvulsion('no'); + await deliveryForm.selectDeliveryBabyDifficultyFeeding('no'); + await deliveryForm.selectDeliveryBabyVomit('no'); + await deliveryForm.selectDeliveryBabyDrowsy('no'); + await deliveryForm.selectDeliveryBabyStiff('no'); + await deliveryForm.selectDeliveryBabyYellowSkin('no'); + await deliveryForm.selectDeliveryBabyFever('no'); + await deliveryForm.selectDeliveryBabyBlueSkin('no'); await genericForm.nextPage(); await genericForm.nextPage(); await deliveryForm.selectDeliveryPncVisits('none'); await genericForm.nextPage(); - await deliveryForm.submitForm(); + + const summaryInfo = await deliveryForm.getSummaryInfo(); + expect(summaryInfo.patientName).to.equal(pregnantWoman.name); + expect(summaryInfo.patientAge).to.equal('25'); + expect(summaryInfo.womanCondition).to.equal('Alive and well'); + expect(summaryInfo.deliveryDate).to.equal(BABY_DOB); + expect(summaryInfo.deliveryPlace).to.equal('Health facility'); + expect(summaryInfo.deliveredBabies).to.equal('1'); + expect(summaryInfo.deceasedBabies).to.equal('0'); + expect(summaryInfo.pncVisits).to.equal('None'); + + await genericForm.submitForm(); + await commonPage.waitForPageLoaded(); + await contactPage.openReport(); await (await reportPage.reportBodyDetails()).waitForDisplayed(); const { patientName, reportName } = await reportPage.getOpenReportInfo(); - expect(patientName).to.equal(MOTHERS_NAME); - expect(reportName).to.equal(formDocument.title); + expect(patientName).to.equal(pregnantWoman.name); + expect(reportName).to.equal('Delivery'); }); it('The past pregnancy card should show', async () => { - await commonPage.goToPeople('fixture:woman', true); + await commonPage.goToPeople(pregnantWoman._id); await contactPage.getContactCardTitle(); expect((await contactPage.getContactCardTitle())).to.equal('Past pregnancy'); }); it('The child registered during birth should be created and should display the proper information', async () => { - await contactPage.selectLHSRowByText(BABYS_NAME); - expect((await contactPage.getContactInfoName())).to.equal(BABYS_NAME); + await contactPage.selectLHSRowByText(BABY_NAME); + expect((await contactPage.getContactInfoName())).to.equal(BABY_NAME); expect((await contactPage.getContactSummaryField('contact.sex')).toLocaleUpperCase()) - .to.equal(BABYS_SEX.toLocaleUpperCase()); + .to.equal(BABY_SEX.toLocaleUpperCase()); }); it('The targets page should be updated', async () => { @@ -160,7 +114,7 @@ describe('Contact Delivery Form', () => { expect(targets).to.have.deep.members([ { title: 'Deaths', goal: '0', count: '0' }, - { title: 'New pregnancies', goal: '20', count: '0' }, + { title: 'New pregnancies', goal: '20', count: '1' }, { title: 'Live births', count: '1' }, { title: 'Active pregnancies', count: '0' }, { title: 'Active pregnancies with 1+ routine facility visits', count: '0' }, diff --git a/tests/e2e/default/enketo/pregnancy-facility-visit-reminder.wdio-spec.js b/tests/e2e/default/enketo/pregnancy-facility-visit-reminder.wdio-spec.js new file mode 100644 index 00000000000..bf5a0dae212 --- /dev/null +++ b/tests/e2e/default/enketo/pregnancy-facility-visit-reminder.wdio-spec.js @@ -0,0 +1,63 @@ +const moment = require('moment/moment'); +const utils = require('@utils'); +const placeFactory = require('@factories/cht/contacts/place'); +const userFactory = require('@factories/cht/users/users'); +const personFactory = require('@factories/cht/contacts/person'); +const loginPage = require('@page-objects/default/login/login.wdio.page'); +const commonPage = require('@page-objects/default/common/common.wdio.page'); +const taskPage = require('@page-objects/default/tasks/tasks.wdio.page'); +const pregnancyForm = require('@page-objects/default/enketo/pregnancy.wdio.page'); +const reportsPage = require('@page-objects/default/reports/reports.wdio.page'); +const pregnancyFacilityVisitReminderPage = require( + '@page-objects/default/enketo/pregnancy-facility-visit-reminder.wdio.page' +); + +describe('Health Facility ANC Reminder task', () => { + const places = placeFactory.generateHierarchy(); + const healthCenter = places.get('health_center'); + const offlineUser = userFactory.build({ place: healthCenter._id, roles: ['chw'] }); + const pregnantWoman = personFactory.build({ + date_of_birth: moment().subtract(25, 'years').format('YYYY-MM-DD'), + parent: {_id: healthCenter._id, parent: healthCenter.parent} + }); + const ancDate = moment().add(2, 'day'); + let pregnancyId; + + before(async () => { + await utils.saveDocs([...places.values(), pregnantWoman]); + await utils.createUsers([offlineUser]); + await loginPage.login(offlineUser); + await commonPage.waitForPageLoaded(); + await commonPage.goToPeople(pregnantWoman._id); + + await pregnancyForm.submitPregnancy({futureVisitDate: ancDate.format('YYYY-MM-DD')}); + await commonPage.waitForPageLoaded(); + + await commonPage.goToReports(); + await reportsPage.openSelectedReport(await reportsPage.firstReport()); + pregnancyId = await reportsPage.getCurrentReportId(); + }); + + it('should submit the health facility ANC reminder task', async () => { + await commonPage.goToTasks(); + await taskPage.openTaskById(pregnancyId, '~pregnancy-facility-visit-reminder~anc.facility_reminder'); + + const {title, visitDate} = await pregnancyFacilityVisitReminderPage.getAncReminderInfo(); + expect(title).to.equal('Health facility ANC reminder'); + expect(Date.parse(visitDate)).to.equal(Date.parse(ancDate.format('D MMM, YYYY'))); + + await pregnancyFacilityVisitReminderPage.submitAncReminder(); + await commonPage.waitForPageLoaded(); + + await commonPage.goToReports(); + await reportsPage.openSelectedReport(await reportsPage.firstReport()); + await commonPage.waitForPageLoaded(); + + //The pregnancyId value should be loaded into the "pregnancy_facility_visit_reminder" form via the "contact-summary" + expect((await reportsPage.getDetailReportRowContent('pregnancy_uuid_ctx')).rowValues[0]).to.equal(pregnancyId); + expect(Date.parse((await reportsPage.getDetailReportRowContent('visit_date_for_task')).rowValues[0])) + .to.equal(Date.parse(ancDate.format('D MMM, YYYY'))); + expect((await reportsPage.getDetailReportRowContent('remind_method')).rowValues[0]).to.equal('in_person'); + }); + +}); diff --git a/tests/e2e/default/enketo/pregnancy.wdio-spec.js b/tests/e2e/default/enketo/pregnancy.wdio-spec.js index 04374de53a6..ce0f6c1e4dd 100644 --- a/tests/e2e/default/enketo/pregnancy.wdio-spec.js +++ b/tests/e2e/default/enketo/pregnancy.wdio-spec.js @@ -41,7 +41,7 @@ describe('Pregnancy registration', () => { await genericForm.nextPage(); const confirmationDetails = await pregnancyForm.getConfirmationDetails(); - expect(confirmationDetails.eddConfirm).to.equal(edd.format('D MMM, YYYY')); + expect(Date.parse(confirmationDetails.eddConfirm)).to.equal(Date.parse(edd.format('D MMM, YYYY'))); await genericForm.nextPage(); await pregnancyForm.setANCVisitsPast(); @@ -80,7 +80,7 @@ describe('Pregnancy registration', () => { const summaryDetails = await pregnancyForm.getSummaryDetails(); expect(summaryDetails.patientNameSumm).to.equal(pregnantWoman.name); expect(summaryDetails.weeksPregnantSumm).to.equal(confirmationDetails.weeksPregnantConfirm); - expect(summaryDetails.eddSumm).to.equal(edd.format('D MMM, YYYY')); + expect(Date.parse(summaryDetails.eddSumm)).to.equal(Date.parse(edd.format('D MMM, YYYY'))); expect(summaryDetails.riskFactorsSumm).to.equal(countRiskFactors); expect(summaryDetails.dangerSignsSumm).to.equal(countDangerSigns); @@ -91,9 +91,9 @@ describe('Pregnancy registration', () => { const pregnancyCardInfo = await contactPage.getPregnancyCardInfo(); expect(pregnancyCardInfo.weeksPregnant).to.equal(confirmationDetails.weeksPregnantConfirm); - expect(pregnancyCardInfo.deliveryDate).to.equal(edd.format('D MMM, YYYY')); + expect(Date.parse(pregnancyCardInfo.deliveryDate)).to.equal(Date.parse(edd.format('D MMM, YYYY'))); expect(pregnancyCardInfo.risk).to.equal('High risk'); - expect(pregnancyCardInfo.ancVisit).to.equal(nextANCVisit.format('D MMM, YYYY')); + expect(Date.parse(pregnancyCardInfo.ancVisit)).to.equal(Date.parse(nextANCVisit.format('D MMM, YYYY'))); }); diff --git a/tests/e2e/standard/enketo/immunization-visit.wdio-spec.js b/tests/e2e/standard/enketo/immunization-visit.wdio-spec.js index 83a532a83c1..6e25397b179 100644 --- a/tests/e2e/standard/enketo/immunization-visit.wdio-spec.js +++ b/tests/e2e/standard/enketo/immunization-visit.wdio-spec.js @@ -22,12 +22,17 @@ describe('Immunization Visit', () => { await utils.saveDocs([...places.values()]); await utils.createUsers([user]); await loginPage.cookieLogin(); - await commonPage.goToPeople(healthCenter._id); await contactPage.addHealthPrograms('imm'); + await commonPage.logout(); }); + afterEach(async () => await commonPage.logout()); + it('Add a new child under 2 years old - SMS CW form', async () => { + await loginPage.cookieLogin(); + await commonPage.waitForPageLoaded(); + const messageValue = `CW 60 ${babyName}`; await gatewayApiUtils.api.postMessage({ @@ -47,7 +52,10 @@ describe('Immunization Visit', () => { expect(firstReport.form).to.equal('New Child Registration (SMS)'); }); - it('Submit immunization visit - webapp', async () => { + it('Submit immunization visit - webapp', async () => { + await loginPage.login(user); + await commonPage.waitForPageLoaded(); + await commonPage.goToPeople(); await contactPage.contactPageDefault.selectLHSRowByText(babyName); babyMedicID = await contactPage.contactPageDefault.getContactMedicID(); @@ -101,9 +109,9 @@ describe('Immunization Visit', () => { expect(await immVisitForm.getFollowUpSMS()).to.include(await immVisitForm.getNotes()); await genericForm.submitForm(); - }); + await commonPage.waitForPageLoaded(); - it('Verify immunization card', async () => { + //Verify immunization card const vaccinesValues = await contactPage.getImmCardVaccinesValues(); for (const value of vaccinesValues) { if (value.includes('of')) { @@ -113,17 +121,37 @@ describe('Immunization Visit', () => { expect(value).to.equal('Yes'); } } - }); - it('Verify immunization report', async () => { + //Verify immunization report await commonPage.goToReports(); - const firstReport = await reportsPage.getListReportInfo(await reportsPage.firstReport()); + const firstReport = await reportsPage.firstReport(); + const firstReportInfo = await reportsPage.getListReportInfo(firstReport); - expect(firstReport.heading).to.equal(babyName); - expect(firstReport.form).to.equal('Immunization Visit'); + expect(firstReportInfo.heading).to.equal(babyName); + expect(firstReportInfo.form).to.equal('Immunization Visit'); + + await reportsPage.openSelectedReport(firstReport); + await commonPage.waitForPageLoaded(); + + const openReportInfo = await reportsPage.getOpenReportInfo(); + expect(openReportInfo.patientName).to.equal(babyName); + expect(openReportInfo.reportName).to.equal('Immunization Visit'); + expect(openReportInfo.senderName).to.equal(`Submitted by ${user.contact.name} `); + expect(openReportInfo.senderPhone).to.equal(user.contact.phone); + + expect((await reportsPage.getDetailReportRowContent('chw_sms')).rowValues[0]).to.equal('Nice work, ! ' + + `${babyName} (${babyMedicID}) attended their immunizations visit at the health facility. ` + + 'Keep up the good work. Thank you! Test notes'); + + const { rowValues } = await reportsPage.getDetailReportRowContent('vaccines_received.'); + rowValues.forEach(value => expect(value).to.equal('yes')); }); + it('Submit immunization visit - SMS IMM form', async () => { + await loginPage.cookieLogin(); + await commonPage.waitForPageLoaded(); + const messageValue = `IMM ${babyMedicID}`; await gatewayApiUtils.api.postMessage({ @@ -139,9 +167,10 @@ describe('Immunization Visit', () => { }); it('Verify the targets page', async () => { - await commonPage.logout(); await loginPage.login(user); await commonPage.waitForPageLoaded(); + await commonPage.sync(); + await commonPage.goToAnalytics(); const targets = await analyticsPage.getTargets(); @@ -154,7 +183,7 @@ describe('Immunization Visit', () => { { title: 'Deliveries at facility', percent: '0%', percentCount: '(0 of 0)' }, { title: 'Children under 5', count: '1' }, { title: 'Children registered', count: '1' }, - { title: 'Vaccines given', count: '2' }, + { title: 'Vaccines given', count: '2' }, { title: 'Children vaccinated', count: '1' }, { title: 'Children with no vaccines reported', count: '0' }, { title: 'Children with BCG reported', percent: '100%', percentCount: '(1 of 1)' }, diff --git a/tests/page-objects/default/enketo/delivery.wdio.page.js b/tests/page-objects/default/enketo/delivery.wdio.page.js index 6329a4959a7..9e302ec5fbc 100644 --- a/tests/page-objects/default/enketo/delivery.wdio.page.js +++ b/tests/page-objects/default/enketo/delivery.wdio.page.js @@ -1,14 +1,14 @@ const deliveryConditionWomanOutcomeField = (value) => $(`input[type="radio"][name="/delivery/condition/woman_outcome"][value="${value}"]`); -const deliveryPosnatalDangerFeverField = (value) => +const deliveryPostnatalDangerFeverField = (value) => $(`input[type="radio"][name="/delivery/pnc_danger_sign_check/fever"][value="${value}"]`); -const deliveryPosnatalDangerSevereFeverField = (value) => +const deliveryPostnatalDangerSevereHeadacheField = (value) => $(`input[type="radio"][name="/delivery/pnc_danger_sign_check/severe_headache"][value="${value}"]`); -const deliveryPosnatalDangerVaginalBleedingField = (value) => +const deliveryPostnatalDangerVaginalBleedingField = (value) => $(`input[type="radio"][name="/delivery/pnc_danger_sign_check/vaginal_bleeding"][value="${value}"]`); -const deliveryPosnatalDangerVaginalDischargeField = (value) => +const deliveryPostnatalDangerVaginalDischargeField = (value) => $(`input[type="radio"][name="/delivery/pnc_danger_sign_check/vaginal_discharge"][value="${value}"]`); -const deliveryPosnatalDangerConvulsionField = (value) => +const deliveryPostnatalDangerConvulsionField = (value) => $(`input[type="radio"][name="/delivery/pnc_danger_sign_check/convulsion"][value="${value}"]`); const deliveryOutcomeBabiesDeliveredField = (value) => $(`input[type="radio"][name="/delivery/delivery_outcome/babies_delivered"][value="${value}"]`); @@ -23,17 +23,17 @@ const deliveryModeField = (value) => const babyConditionField = (value) => $(`input[type="radio"]` + `[data-name="/delivery/babys_condition/baby_repeat/baby_details/baby_condition"][value="${value}"]`); -const babysNameField = () => +const babyNameField = () => $(`input[type="text"][name="/delivery/babys_condition/baby_repeat/baby_details/baby_name"]`); -const babysSexField = (value) => +const babySexField = (value) => $(`input[type="radio"][data-name="/delivery/babys_condition/baby_repeat/baby_details/baby_sex"][value="${value}"]`); -const babysBirthWeightKnowField = (value) => +const babyBirthWeightKnowField = (value) => $(`input[type="radio"]` + `[data-name="/delivery/babys_condition/baby_repeat/baby_details/birth_weight_know"][value="${value}"]`); -const babysBirthLengthKnowField = (value) => +const babyBirthLengthKnowField = (value) => $(`input[type="radio"]` + `[data-name="/delivery/babys_condition/baby_repeat/baby_details/birth_length_know"][value="${value}"]`); -const babysVaccinesReveivedField = (value) => +const babyVaccinesReveivedField = (value) => $(`input[type="radio"]` + `[data-name="/delivery/babys_condition/baby_repeat/baby_details/vaccines_received"][value="${value}"]`); const babyBreastfeedingField = (value) => @@ -72,147 +72,225 @@ const babyBlueSkinField = (value) => const deliveryPncVisitsField = (value) => $(`input[type="checkbox"]` + `[name="/delivery/pnc_visits/pnc_visits_attended"][value="${value}"]`); -const submitButton = () => $('#contact-report .form-footer .btn.submit.btn-primary'); + +const SUMMARY_SECTION = 'section[name="/delivery/summary"]'; +const sumPatientName = () => $(`${SUMMARY_SECTION} span[data-value=" /delivery/patient_name "]`); +const sumPatientAge = () => $(`${SUMMARY_SECTION} span[data-value=" /delivery/patient_age_in_years "]`); +const sumWomanCondition = () => $(`${SUMMARY_SECTION} span[data-itext-id="/delivery/summary/r_condition_well:label"]`); +const sumDeliveryDate = () => $(`${SUMMARY_SECTION} span[data-value=" /delivery/delivery_outcome/delivery_date "]`); +const sumDeliveryPlace = () => $(SUMMARY_SECTION + + ' span[data-value=" /delivery/summary/custom_translations/delivery_place_label "]'); +const sumDeliveredBabies = () => $(SUMMARY_SECTION + + ' span[data-value=" /delivery/delivery_outcome/babies_delivered_num "]'); +const sumDeceasedBabies = () => $(SUMMARY_SECTION + + ' span[data-value=" /delivery/delivery_outcome/babies_deceased_num "]'); +const sumPncVisits = () => $(`${SUMMARY_SECTION} span[data-itext-id="/delivery/summary/r_pnc_visit_none:label"]`); const selectDeliveryConditionWomanOutcome = async (value) => { - return (await deliveryConditionWomanOutcomeField(value)).click(); + const womanOutcome = await deliveryConditionWomanOutcomeField(value); + await womanOutcome.waitForClickable(); + await womanOutcome.click(); }; -const selectDeliveryPosnatalDangerSignsFever = async (value) => { - return (await deliveryPosnatalDangerFeverField(value)).click(); +const selectDeliveryPostnatalDangerSignsFever = async (value) => { + const fever = await deliveryPostnatalDangerFeverField(value); + await fever.waitForClickable(); + await fever.click(); }; -const selectDeliveryPosnatalDangerSevereFever = async (value) => { - return (await deliveryPosnatalDangerSevereFeverField(value)).click(); +const selectDeliveryPostnatalDangerSevereHeadache = async (value) => { + const severeHeadache = await deliveryPostnatalDangerSevereHeadacheField(value); + await severeHeadache.waitForClickable(); + await severeHeadache.click(); }; -const selectDeliveryPosnatalDangerVaginalBleeding = async (value) => { - return (await deliveryPosnatalDangerVaginalBleedingField(value)).click(); +const selectDeliveryPostnatalDangerVaginalBleeding = async (value) => { + const vaginalBleeding = await deliveryPostnatalDangerVaginalBleedingField(value); + await vaginalBleeding.waitForClickable(); + await vaginalBleeding.click(); }; -const selectDeliveryPosnatalDangerVaginalDischarge = async (value) => { - return (await deliveryPosnatalDangerVaginalDischargeField(value)).click(); +const selectDeliveryPostnatalDangerVaginalDischarge = async (value) => { + const vaginalDischarge = await deliveryPostnatalDangerVaginalDischargeField(value); + await vaginalDischarge.waitForClickable(); + await vaginalDischarge.click(); }; -const selectDeliveryPosnatalDangerConvulsion = async (value) => { - return (await deliveryPosnatalDangerConvulsionField(value)).click(); +const selectDeliveryPostnatalDangerConvulsion = async (value) => { + const convulsion = await deliveryPostnatalDangerConvulsionField(value); + await convulsion.waitForClickable(); + await convulsion.click(); }; const selectDeliveryOutcomeBabiesDelivered = async (value) => { - return (await deliveryOutcomeBabiesDeliveredField(value)).click(); + const babiesDelivered = await deliveryOutcomeBabiesDeliveredField(value); + await babiesDelivered.waitForClickable(); + await babiesDelivered.click(); }; const selectDeliveryOutcomeBabiesAlive = async (value) => { - return (await deliveryOutcomeBabiesAliveField(value)).click(); + const babiesAlive = await deliveryOutcomeBabiesAliveField(value); + await babiesAlive.waitForClickable(); + await babiesAlive.click(); }; const setDeliveryOutcomeDateOfDelivery = async (value) => { - return (await dateOfDeliveryField()).addValue(value); + const dateOfDelivery = await dateOfDeliveryField(); + await dateOfDelivery.waitForDisplayed(); + await dateOfDelivery.setValue(value); }; const selectDeliveryOutcomeDeliveryPlace = async (value) => { - return (await deliveryPlaceField(value)).click(); + const deliveryPlace = await deliveryPlaceField(value); + await deliveryPlace.waitForClickable(); + await deliveryPlace.click(); }; const selectDeliveryOutcomeDeliveryMode = async (value) => { - await (await deliveryModeField(value)).waitForDisplayed(); - return (await deliveryModeField(value)).click(); + const deliveryMode = await deliveryModeField(value); + await deliveryMode.waitForClickable(); + await deliveryMode.click(); }; -const selectDeliveryBabysCondition = async (value) => { - return (await babyConditionField(value)).click(); +const selectDeliveryBabyCondition = async (value) => { + const babyCondition = await babyConditionField(value); + await babyCondition.waitForClickable(); + await babyCondition.click(); }; -const setDeliveryBabysName = async (value) => { - return (await babysNameField(value)).addValue(value); +const setDeliveryBabyName = async (value) => { + const babyName = await babyNameField(value); + await babyName.waitForDisplayed(); + await babyName.setValue(value); }; -const selectDeliveryBabysSex = async (value) => { - return (await babysSexField(value)).click(); +const selectDeliveryBabySex = async (value) => { + const babySex = await babySexField(value); + await babySex.waitForClickable(); + await babySex.click(); }; -const selectDeliveryBabysBirthWeightKnow = async (value) => { - return (await babysBirthWeightKnowField(value)).click(); +const selectDeliveryBabyBirthWeightKnown = async (value) => { + const birthWeight = await babyBirthWeightKnowField(value); + await birthWeight.waitForClickable(); + await birthWeight.click(); }; -const selectDeliveryBabysBirthLengthKnow = async (value) => { - return (await babysBirthLengthKnowField(value)).click(); +const selectDeliveryBabyBirthLengthKnown = async (value) => { + const birthLength = await babyBirthLengthKnowField(value); + await birthLength.waitForClickable(); + await birthLength.click(); }; -const selectDeliveryBabysVaccinesReveived = async (value) => { - return (await babysVaccinesReveivedField(value)).click(); +const selectDeliveryBabyVaccinesReceived = async (value) => { + const vaccinesReceived = await babyVaccinesReveivedField(value); + await vaccinesReceived.waitForClickable(); + await vaccinesReceived.click(); }; const selectDeliveryBabyBreastfeeding = async (value) => { - return (await babyBreastfeedingField(value)).click(); + const babyBreastfeeding = await babyBreastfeedingField(value); + await babyBreastfeeding.waitForClickable(); + await babyBreastfeeding.click(); }; const selectDeliveryBabyBreastfeedingWithin1Hour = async (value) => { - return (await babyBreastfeedingWithin1HourField(value)).click(); + const breastfeedingWithin1Hour = await babyBreastfeedingWithin1HourField(value); + await breastfeedingWithin1Hour.waitForClickable(); + await breastfeedingWithin1Hour.click(); }; const selectDeliveryBabyInfectedUmbilicalCord = async (value) => { - return (await babyInfectedUmbilicalCordField(value)).click(); + const infectedUmbilicalCord = await babyInfectedUmbilicalCordField(value); + await infectedUmbilicalCord.waitForClickable(); + await infectedUmbilicalCord.click(); }; const selectDeliveryBabyConvulsion = async (value) => { - return (await babyConvulsionField(value)).click(); + const convulsion = await babyConvulsionField(value); + await convulsion.waitForClickable(); + await convulsion.click(); }; const selectDeliveryBabyDifficultyFeeding = async (value) => { - return (await babyDifficultyFeedingField(value)).click(); + const difficultyFeeding = await babyDifficultyFeedingField(value); + await difficultyFeeding.waitForClickable(); + await difficultyFeeding.click(); }; const selectDeliveryBabyVomit = async (value) => { - return (await babyVomitField(value)).click(); + const vomit = await babyVomitField(value); + await vomit.waitForClickable(); + await vomit.click(); }; const selectDeliveryBabyDrowsy = async (value) => { - return (await babyDrowsyField(value)).click(); + const drowsy = await babyDrowsyField(value); + await drowsy.waitForClickable(); + await drowsy.click(); }; const selectDeliveryBabyStiff = async (value) => { - return (await babyStiffField(value)).click(); + const stiff = await babyStiffField(value); + await stiff.waitForClickable(); + await stiff.click(); }; const selectDeliveryBabyYellowSkin = async (value) => { - return (await babyYellowSkinField(value)).click(); + const yellowSkin = await babyYellowSkinField(value); + await yellowSkin.waitForClickable(); + await yellowSkin.click(); }; const selectDeliveryBabyFever = async (value) => { - return (await babyFeverField(value)).click(); + const fever = await babyFeverField(value); + await fever.waitForClickable(); + await fever.click(); }; const selectDeliveryBabyBlueSkin = async (value) => { - return (await babyBlueSkinField(value)).click(); + const blueSkin = await babyBlueSkinField(value); + await blueSkin.waitForClickable(); + await blueSkin.click(); }; const selectDeliveryPncVisits = async (value) => { - return (await deliveryPncVisitsField(value)).click(); + const pncVisits = await deliveryPncVisitsField(value); + await pncVisits.waitForClickable(); + await pncVisits.click(); }; -const submitForm = async () => { - await (await submitButton()).click(); +const getSummaryInfo = async () => { + return { + patientName: await sumPatientName().getText(), + patientAge: await sumPatientAge().getText(), + womanCondition: await sumWomanCondition().getText(), + deliveryDate: await sumDeliveryDate().getText(), + deliveryPlace: await sumDeliveryPlace().getText(), + deliveredBabies: await sumDeliveredBabies().getText(), + deceasedBabies: await sumDeceasedBabies().getText(), + pncVisits: await sumPncVisits().getText(), + }; }; module.exports = { selectDeliveryConditionWomanOutcome, - selectDeliveryPosnatalDangerSignsFever, - selectDeliveryPosnatalDangerSevereFever, - selectDeliveryPosnatalDangerVaginalBleeding, - selectDeliveryPosnatalDangerVaginalDischarge, - selectDeliveryPosnatalDangerConvulsion, + selectDeliveryPostnatalDangerSignsFever, + selectDeliveryPostnatalDangerSevereHeadache, + selectDeliveryPostnatalDangerVaginalBleeding, + selectDeliveryPostnatalDangerVaginalDischarge, + selectDeliveryPostnatalDangerConvulsion, selectDeliveryOutcomeBabiesDelivered, selectDeliveryOutcomeBabiesAlive, selectDeliveryOutcomeDeliveryPlace, setDeliveryOutcomeDateOfDelivery, selectDeliveryOutcomeDeliveryMode, - selectDeliveryBabysCondition, - setDeliveryBabysName, - selectDeliveryBabysSex, - selectDeliveryBabysBirthWeightKnow, - selectDeliveryBabysBirthLengthKnow, - selectDeliveryBabysVaccinesReveived, + selectDeliveryBabyCondition, + setDeliveryBabyName, + selectDeliveryBabySex, + selectDeliveryBabyBirthWeightKnown, + selectDeliveryBabyBirthLengthKnown, + selectDeliveryBabyVaccinesReceived, selectDeliveryBabyBreastfeeding, selectDeliveryBabyBreastfeedingWithin1Hour, selectDeliveryBabyInfectedUmbilicalCord, @@ -225,5 +303,5 @@ module.exports = { selectDeliveryBabyFever, selectDeliveryBabyBlueSkin, selectDeliveryPncVisits, - submitForm + getSummaryInfo, }; diff --git a/tests/page-objects/default/enketo/enketo-widgets.wdio.page.js b/tests/page-objects/default/enketo/enketo-widgets.wdio.page.js new file mode 100644 index 00000000000..37cf0619fac --- /dev/null +++ b/tests/page-objects/default/enketo/enketo-widgets.wdio.page.js @@ -0,0 +1,119 @@ +const FORM = 'form[data-form-id="enketo_widgets"]'; + +const formTitle = () => $(`${FORM} #form-title`); +const selectMultipleDropdown = () => $(`${FORM} select[name="/enketo_widgets/enketo_test_select/select_spinner"]`); +const selectOneDropdown = () => $(`${FORM} select[name="/enketo_widgets/enketo_test_select/select1_spinner"]`); +const countryRadio = (value) => $(FORM + + ` input[name="/enketo_widgets/cascading_widgets/group1/country"][value="${value}"]`); +const cityRadio = (value) => $(FORM + + ` input[name="/enketo_widgets/cascading_widgets/group1/city"][value="${value}"]`); +const neighborhoodRadio = (value) => $(FORM + + ` input[name="/enketo_widgets/cascading_widgets/group1/neighborhood"][value="${value}"]`); +const countryDropdown = () => $(`${FORM} select[name="/enketo_widgets/cascading_widgets/group2/country2"]`); +const cityDropdown = () => $(`${FORM} select[name="/enketo_widgets/cascading_widgets/group2/city2"]`); +const neighborhoodDropdown = () => $(`${FORM} select[name="/enketo_widgets/cascading_widgets/group2/neighborhood2"]`); +const patientUuid = () => $(`${FORM} input[name="/enketo_widgets/inputs/contact/_id"]`); +const patientId = () => $(`${FORM} input[name="/enketo_widgets/inputs/contact/patient_id"]`); +const patientName = () => $(`${FORM} input[name="/enketo_widgets/inputs/contact/name"]`); +const patientNameErrorLabel = () => $(`${FORM} label.invalid-constraint`); +const phoneField = () => $('input.ignore[type="tel"]:has(+ input[name="/enketo_widgets/enketo_test_select/phone"])'); +const phoneFieldRequiredMessage = () => + $('input[name="/enketo_widgets/enketo_test_select/phone"] ~ .or-required-msg.active'); +const phoneFieldConstraintMessage = () => + $('input[name="/enketo_widgets/enketo_test_select/phone"] ~ .or-constraint-msg.active'); + +const getFormTitle = async () => { + const title = await formTitle(); + await title.waitForDisplayed(); + return await title.getText(); +}; + +const selectCountryRadio = async (value = 'nl') => { + const country = await countryRadio(value); + await country.waitForDisplayed(); + await country.waitForClickable(); + await country.click(); +}; + +const selectCityRadio = async (value = 'rot') => { + const city = await cityRadio(value); + await city.waitForDisplayed(); + await city.waitForClickable(); + await city.click(); +}; + +const selectNeighborhoodRadio = async (value = 'centrum') => { + const neighborhood = await neighborhoodRadio(value); + await neighborhood.waitForDisplayed(); + await neighborhood.waitForClickable(); + await neighborhood.click(); +}; + +const openDropdown = async (element) => { + const dropdownButton = element.nextElement().$('.dropdown-toggle'); + await dropdownButton.waitForClickable(); + await dropdownButton.click(); +}; + +const getDropdownValue = async (element) => { + const dropdownValue = element.nextElement().$('.dropdown-toggle .selected'); + await dropdownValue.waitForDisplayed(); + return dropdownValue.getText(); +}; + +const getDropdownTotalOptions = async (element) => { + const dropdownOptions = element.nextElement().$$('.dropdown-menu > li'); + return await dropdownOptions.length; +}; + +const selectDropdownOptions = async (element, type, value) => { + const dropdownOption = element.nextElement().$(`.dropdown-menu input[type="${type}"][value="${value}"]`); + await dropdownOption.waitForClickable(); + await dropdownOption.click(); +}; + +const setPatientUuid = async (value = '123 456 789') => { + const uuid = await patientUuid(); + await uuid.waitForDisplayed(); + await uuid.setValue(value); +}; + +const setPatientId = async (value = '12345') => { + const id = await patientId(); + await id.waitForDisplayed(); + await id.setValue(value); +}; + +const setPatientName = async (value = 'Emilio') => { + const name = await patientName(); + await name.waitForDisplayed(); + await name.setValue(value); +}; + +const setPhoneNumber = async (value) => { + await phoneField().waitForDisplayed(); + await (await phoneField()).setValue(value); +}; + +module.exports = { + getFormTitle, + selectMultipleDropdown, + selectOneDropdown, + countryDropdown, + cityDropdown, + neighborhoodDropdown, + selectCountryRadio, + selectCityRadio, + selectNeighborhoodRadio, + openDropdown, + getDropdownValue, + getDropdownTotalOptions, + selectDropdownOptions, + setPatientUuid, + setPatientId, + setPatientName, + patientNameErrorLabel, + setPhoneNumber, + phoneFieldRequiredMessage, + phoneFieldConstraintMessage, +}; diff --git a/tests/page-objects/default/enketo/pregnancy-facility-visit-reminder.wdio.page.js b/tests/page-objects/default/enketo/pregnancy-facility-visit-reminder.wdio.page.js new file mode 100644 index 00000000000..78c53fd8336 --- /dev/null +++ b/tests/page-objects/default/enketo/pregnancy-facility-visit-reminder.wdio.page.js @@ -0,0 +1,28 @@ +const genericForm = require('@page-objects/default/enketo/generic-form.wdio.page'); + +const FORM = 'form[data-form-id="pregnancy_facility_visit_reminder"]'; + +const formTitle = () => $(`${FORM} #form-title`); +const ancVisitDate = () => $(FORM + + ' span[data-value=" /pregnancy_facility_visit_reminder/visit_date_for_task "]'); +const reminderMethod = (value) => $(FORM + + ` input[name="/pregnancy_facility_visit_reminder/facility_visit_reminder/remind_method"][value="${value}"]`); + +const getAncReminderInfo = async () => { + return { + title: await formTitle().getText(), + visitDate: await ancVisitDate().getText(), + }; +}; + +const submitAncReminder = async (method = 'in_person') => { + const reminderAnc = await reminderMethod(method); + await reminderAnc.waitForClickable(); + await reminderAnc.click(); + await genericForm.submitForm(); +}; + +module.exports = { + getAncReminderInfo, + submitAncReminder, +}; diff --git a/tests/page-objects/default/reports/reports.wdio.page.js b/tests/page-objects/default/reports/reports.wdio.page.js index 35a20764baa..e2aeaf2a779 100644 --- a/tests/page-objects/default/reports/reports.wdio.page.js +++ b/tests/page-objects/default/reports/reports.wdio.page.js @@ -8,7 +8,7 @@ const SELECT_ALL_CHECKBOX = `${REPORTS_LIST_ID} .select-all input[type="checkbox const REPORT_BODY_DETAILS_SELECTOR = '#reports-content .report-body .details'; const reportBodyDetails = () => $(REPORT_BODY_DETAILS_SELECTOR); const reportTasks = () => $(`${REPORT_BODY_DETAILS_SELECTOR} .scheduled-tasks`); -const reportCaseIdFilter = () => $(`${REPORT_BODY_DETAILS_SELECTOR} [test-id*=".case_id"]`); +const reportCaseIdFilter = () => $(`${REPORT_BODY_DETAILS_SELECTOR} span[test-id*=".case_id"]`); const REPORT_BODY = '#reports-content .report-body'; const reportBody = () => $(REPORT_BODY); const noReportSelectedLabel = () => $('.empty-selection'); @@ -47,6 +47,9 @@ const automaticReplyMessage = () => $(`${AUTOMATIC_REPLY_SECTION} p[test-id='mes const automaticReplyState = () => $(`${AUTOMATIC_REPLY_SECTION} .state`); const automaticReplyRecipient = () => $(`${AUTOMATIC_REPLY_SECTION} .recipient`); +const detailReportRowContent = (row, type) => + $$(`${REPORT_BODY_DETAILS_SELECTOR} li[test-id*='${row}'] span[test-id='${type}']`); + const deleteAllButton = () => $('.desktop.multiselect-bar-container .bulk-delete'); const selectedReportsCount = () => $('.desktop.multiselect-bar-container .count-label'); const bulkDeleteModal = () => $('#bulk-delete-confirm'); @@ -329,6 +332,15 @@ const getAutomaticReply = async () => { }; }; +const getDetailReportRowContent = async (row) => { + const labels = await detailReportRowContent(row, 'label').map(async label => await label.getText()); + const values = await detailReportRowContent(row, 'value').map(async label => await label.getText()); + return { + rowLabels: labels, + rowValues: values, + }; +}; + const getOpenReportInfo = async () => { return { patientName: await getElementText(patientName()), @@ -462,6 +474,7 @@ module.exports = { getReportDetailFieldValueByLabel, getRawReportContent, getAutomaticReply, + getDetailReportRowContent, getOpenReportInfo, getListReportInfo, resetFilter, diff --git a/tests/page-objects/default/tasks/tasks.wdio.page.js b/tests/page-objects/default/tasks/tasks.wdio.page.js index 0900be117b7..131462bf8a2 100644 --- a/tests/page-objects/default/tasks/tasks.wdio.page.js +++ b/tests/page-objects/default/tasks/tasks.wdio.page.js @@ -98,6 +98,11 @@ const waitForTasksGroupLoaded = async () => { const getTasksInGroup = () => $$(`${tasksGroupSelector} li`); const noSelectedTask = () => $(noSelectedTaskSelector); +const openTaskById = async (id, taskType) => { + await getTaskById(`${id}${taskType}`).click(); + await $(taskFormSelector).waitForDisplayed(); +}; + module.exports = { tasksList, getTasks, @@ -111,5 +116,6 @@ module.exports = { waitForTasksGroupLoaded, getTasksInGroup, noSelectedTask, - getErrorLog + getErrorLog, + openTaskById, }; diff --git a/webapp/src/ts/modules/reports/reports-content.component.html b/webapp/src/ts/modules/reports/reports-content.component.html index 62797f43cba..f8e081a402e 100644 --- a/webapp/src/ts/modules/reports/reports-content.component.html +++ b/webapp/src/ts/modules/reports/reports-content.component.html @@ -63,20 +63,20 @@
  • + class="indent-{{field.depth || 0}}" [attr.test-id]="field?.label">

    {{field.value}} - + {{field.value}} - {{field.value}} + {{field.value}}