-
-
Notifications
You must be signed in to change notification settings - Fork 219
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update tests (standard config): pregnancy
- Loading branch information
1 parent
7b8e54b
commit 45efba6
Showing
3 changed files
with
83 additions
and
107 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
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
106 changes: 24 additions & 82 deletions
106
tests/page-objects/standard/enketo/pregnancy.wdio.page.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 |
---|---|---|
@@ -1,108 +1,50 @@ | ||
const genericForm = require('@page-objects/default/enketo/generic-form.wdio.page'); | ||
const commonPage = require('@page-objects/default/common/common.wdio.page'); | ||
const enketoCommonPage = require('@page-objects/standard/enketo/enketo.wdio.page.js'); | ||
|
||
const APROX_LMP = { up2Months: 61, up3Months: 91, up4Months: 122, b5To6Months: 183, b7To8Months: 244 }; | ||
|
||
const FORM = enketoCommonPage.form('pregnancy'); | ||
const { ACTIVE } = enketoCommonPage; | ||
|
||
const knowLMP = (value) => $(`${FORM} input[name="/pregnancy/group_lmp/g_lmp_method"][value="${value}"]`); | ||
const aproxLMP = (value) => $(`${FORM} input[name="/pregnancy/group_lmp/g_lmp_approx"][value="${value}"]`); | ||
const getEstDeliveryDate = () => { | ||
return $(`${FORM} span[data-itext-id="/pregnancy/group_lmp/g_display_edd:label"]${ACTIVE}`); | ||
}; | ||
const risksFac = () => $$(`${FORM} [name="/pregnancy/group_risk_factors"] label:not(:first-child) > [type="checkbox"]`); | ||
const dangerSigns = () => $$(`${FORM} input[name="/pregnancy/group_danger_signs/g_danger_signs"]`); | ||
const smsNote = () => $(`${FORM} ${enketoCommonPage.smsNote('pregnancy')}`); | ||
const patientNameSummary = () => { | ||
const nameSum = enketoCommonPage.patientNameSummary('pregnancy'); | ||
return $(`${FORM} span[data-itext-id="/pregnancy/group_review/r_pregnancy_details:label"]${ACTIVE} ${nameSum}`); | ||
}; | ||
const patientIdSummary = () => { | ||
const idSum = enketoCommonPage.patientIdSummary('pregnancy', 'review'); | ||
return $(`${FORM} span[data-itext-id="/pregnancy/group_review/r_pregnancy_details:label"]${ACTIVE} ${idSum}`); | ||
}; | ||
const riskFactorsSummary = () => { | ||
const parent = ':not(label.disabled):not(label.or-appearance-yellow)'; | ||
return $$(`${FORM} ${parent} > span[data-itext-id*="/pregnancy/group_review/r_risk_factor"]${ACTIVE}`); | ||
}; | ||
const dangerSignsSummary = () => { | ||
return $$(`${FORM} span[data-itext-id*="/pregnancy/group_review/r_danger_sign"]${ACTIVE}`); | ||
}; | ||
const followUpSmsNote1 = () => $(`${FORM} ${enketoCommonPage.followUpSmsNote1('pregnancy', 'review')}`); | ||
const followUpSmsNote2 = () => $(`${FORM} ${enketoCommonPage.followUpSmsNote2('pregnancy', 'review')}`); | ||
|
||
const selectKnowLMP = async (value = 'approx') => { | ||
const lmpOption = await knowLMP(value); | ||
await lmpOption.waitForDisplayed(); | ||
await lmpOption.click(); | ||
}; | ||
|
||
const selectAproxLMP = async (value = APROX_LMP.up2Months) => { | ||
const aproxLMPOption = await aproxLMP(value); | ||
await aproxLMPOption.waitForDisplayed(); | ||
await aproxLMPOption.click(); | ||
}; | ||
const commonEnketoPage = require('@page-objects/default/enketo/common-enketo.wdio.page'); | ||
|
||
// Select all the risk factors except the first one, because there is a constraint in the code. | ||
const selectAllRiskFactors = async () => { | ||
const riskFactors = await risksFac(); | ||
for (const rfactor of riskFactors) { | ||
await rfactor.click(); | ||
} | ||
return riskFactors; | ||
const dangerSignsQuestion = 'Does the woman have any of the following risk factors?'; | ||
await commonEnketoPage.selectCheckBox(dangerSignsQuestion, 'More than 4 children'); | ||
await commonEnketoPage.selectCheckBox(dangerSignsQuestion, 'Last baby born less than 1 year before'); | ||
await commonEnketoPage.selectCheckBox(dangerSignsQuestion, | ||
'Had previous miscarriages or previous difficulties in childbirth'); | ||
await commonEnketoPage.selectCheckBox(dangerSignsQuestion, 'Has any of the following conditions:'); | ||
await commonEnketoPage.selectCheckBox(dangerSignsQuestion, 'HIV positive'); | ||
}; | ||
|
||
const selectAllDangerSigns = async () => { | ||
const dangerSig = await dangerSigns(); | ||
for (const dangerSign of dangerSig) { | ||
await dangerSign.click(); | ||
} | ||
return dangerSig; | ||
}; | ||
|
||
const setNote = async (text = 'Test note') => { | ||
const note = await smsNote(); | ||
await note.waitForDisplayed(); | ||
await note.setValue(text); | ||
}; | ||
|
||
const getSummaryDetails = async () => { | ||
return { | ||
patientName: await patientNameSummary().getText(), | ||
patientId: await patientIdSummary().getText(), | ||
countRiskFactors: await riskFactorsSummary().length, | ||
countDangerSigns: await dangerSignsSummary().length, | ||
followUpSmsNote1: await followUpSmsNote1().getText(), | ||
followUpSmsNote2: await followUpSmsNote2().getText(), | ||
}; | ||
const riskFactorsQuestion = 'Does the woman have any of the following danger signs?'; | ||
await commonEnketoPage.selectCheckBox(riskFactorsQuestion, 'Pain or cramping in abdomen'); | ||
await commonEnketoPage.selectCheckBox(riskFactorsQuestion, | ||
'Bleeding or fluid leaking from vagina or vaginal discharge with bad odour'); | ||
await commonEnketoPage.selectCheckBox(riskFactorsQuestion, 'Severe nausea or vomiting'); | ||
await commonEnketoPage.selectCheckBox(riskFactorsQuestion, 'Fever of 38 degrees or higher'); | ||
await commonEnketoPage.selectCheckBox(riskFactorsQuestion, 'Severe headache or new, blurry vision problems'); | ||
await commonEnketoPage.selectCheckBox(riskFactorsQuestion, | ||
'Sudden weight gain or severe swelling of feet, ankles, face, or hands'); | ||
await commonEnketoPage.selectCheckBox(riskFactorsQuestion, | ||
'Less movement and kicking from the baby (after week 20 of pregnancy)'); | ||
await commonEnketoPage.selectCheckBox(riskFactorsQuestion, 'Blood in the urine or painful, burning urination'); | ||
await commonEnketoPage.selectCheckBox(riskFactorsQuestion, 'Diarrhea that doesn\'t go away'); | ||
}; | ||
|
||
const submitPregnancy = async () => { | ||
await commonPage.openFastActionReport('pregnancy'); | ||
await selectKnowLMP(); | ||
await selectAproxLMP(APROX_LMP.b7To8Months); | ||
await commonEnketoPage.selectRadioButton('Does the woman know the date of the last cycle?', 'No'); | ||
await commonEnketoPage.selectRadioButton('Approximate start date of last cycle', 'between 7 to 8 months ago'); | ||
await genericForm.nextPage(); | ||
await selectAllRiskFactors(); | ||
await genericForm.nextPage(); | ||
await selectAllDangerSigns(); | ||
await genericForm.nextPage(); | ||
await setNote('Test note'); | ||
await commonEnketoPage.setTextareaValue('You can add a personal note to the SMS here:', 'Test note'); | ||
await genericForm.nextPage(); | ||
await genericForm.submitForm(); | ||
}; | ||
|
||
module.exports = { | ||
APROX_LMP, | ||
selectKnowLMP, | ||
selectAproxLMP, | ||
getEstDeliveryDate, | ||
selectAllRiskFactors, | ||
selectAllDangerSigns, | ||
setNote, | ||
riskFactorsSummary, | ||
dangerSignsSummary, | ||
getSummaryDetails, | ||
submitPregnancy, | ||
}; |