-
-
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
Showing
16 changed files
with
663 additions
and
228 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
Binary file not shown.
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
Binary file not shown.
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,60 @@ | ||
<?xml version="1.0"?> | ||
<h:html xmlns="http://www.w3.org/2002/xforms" xmlns:cht="https://communityhealthtoolkit.org" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:h="http://www.w3.org/1999/xhtml" xmlns:jr="http://openrosa.org/javarosa" xmlns:orx="http://openrosa.org/xforms" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> | ||
<h:head> | ||
<h:title>Phone Widget</h:title> | ||
<model> | ||
<itext> | ||
<translation lang="en"> | ||
<text id="/phone_widget/phone_widgets/deprecated_phone:jr:constraintMsg"> | ||
<value>Please enter a valid local number, or use the standard international format, which includes a plus sign (+) and country code. For example: +254712345678</value> | ||
</text> | ||
<text id="/phone_widget/phone_widgets/deprecated_phone:label"> | ||
<value>Deprecated Phone</value> | ||
</text> | ||
<text id="/phone_widget/phone_widgets/phone:jr:constraintMsg"> | ||
<value>Please enter a valid local number, or use the standard international format, which includes a plus sign (+) and country code. For example: +254712345678</value> | ||
</text> | ||
<text id="/phone_widget/phone_widgets/phone:label"> | ||
<value>Phone – allow duplicates</value> | ||
</text> | ||
<text id="/phone_widget/phone_widgets/phone_unique:jr:constraintMsg"> | ||
<value>Please enter a valid local number, or use the standard international format, which includes a plus sign (+) and country code. For example: +254712345678</value> | ||
</text> | ||
<text id="/phone_widget/phone_widgets/phone_unique:label"> | ||
<value>Phone – unique</value> | ||
</text> | ||
</translation> | ||
</itext> | ||
<instance> | ||
<phone_widget delimiter="#" id="phone_widget" prefix="J1!phone_widget!" version="2024-08-16 00:00:00"> | ||
<phone_widgets> | ||
<deprecated_phone/> | ||
<phone/> | ||
<phone_unique cht:unique_tel="true"/> | ||
</phone_widgets> | ||
<meta tag="hidden"> | ||
<instanceID/> | ||
</meta> | ||
</phone_widget> | ||
</instance> | ||
<instance id="contact-summary"/> | ||
<bind constraint="true()" jr:constraintMsg="jr:itext('/phone_widget/phone_widgets/deprecated_phone:jr:constraintMsg')" nodeset="/phone_widget/phone_widgets/deprecated_phone" required="true()" type="tel"/> | ||
<bind constraint="true()" jr:constraintMsg="jr:itext('/phone_widget/phone_widgets/phone:jr:constraintMsg')" nodeset="/phone_widget/phone_widgets/phone" type="string"/> | ||
<bind constraint="true()" jr:constraintMsg="jr:itext('/phone_widget/phone_widgets/phone_unique:jr:constraintMsg')" nodeset="/phone_widget/phone_widgets/phone_unique" required="true()" type="string"/> | ||
<bind calculate="concat('uuid:', uuid())" nodeset="/phone_widget/meta/instanceID" readonly="true()" type="string"/> | ||
</model> | ||
</h:head> | ||
<h:body class="pages"> | ||
<group appearance="field-list" ref="/phone_widget/phone_widgets"> | ||
<input ref="/phone_widget/phone_widgets/deprecated_phone"> | ||
<label ref="jr:itext('/phone_widget/phone_widgets/deprecated_phone:label')"/> | ||
</input> | ||
<input appearance="numbers tel" ref="/phone_widget/phone_widgets/phone"> | ||
<label ref="jr:itext('/phone_widget/phone_widgets/phone:label')"/> | ||
</input> | ||
<input appearance="numbers tel" ref="/phone_widget/phone_widgets/phone_unique"> | ||
<label ref="jr:itext('/phone_widget/phone_widgets/phone_unique:label')"/> | ||
</input> | ||
</group> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
const commonPage = require('@page-objects/default/common/common.wdio.page'); | ||
const reportsPage = require('@page-objects/default/reports/reports.wdio.page'); | ||
const utils = require('@utils'); | ||
const loginPage = require('@page-objects/default/login/login.wdio.page'); | ||
const genericForm = require('@page-objects/default/enketo/generic-form.wdio.page'); | ||
const contactsPage = require('@page-objects/default/contacts/contacts.wdio.page'); | ||
const commonEnketoPage = require('@page-objects/default/enketo/common-enketo.wdio.page'); | ||
const personFactory = require('@factories/cht/contacts/person'); | ||
const { expect } = require('chai'); | ||
|
||
describe('Phone widget', () => { | ||
const phone = '+254712345678'; | ||
const person0 = personFactory.build({ phone }); | ||
const person1 = personFactory.build({ phone: '+254712345679' }); | ||
|
||
before(async () => { | ||
await commonEnketoPage.uploadForm('phone_widget'); | ||
await utils.saveDocs([person0, person1]); | ||
await loginPage.cookieLogin(); | ||
await commonPage.hideSnackbar(); | ||
}); | ||
|
||
// Only testing the duplicate checking logic here. | ||
// The rest of the phone widget logic is covered by the cht-form integration tests | ||
|
||
it('duplicate phone numbers violate constraint when configured in app form', async () => { | ||
await commonPage.goToReports(); | ||
|
||
await commonPage.openFastActionReport('phone_widget', false); | ||
|
||
await commonEnketoPage.setInputValue('Deprecated Phone', phone); | ||
await commonEnketoPage.setInputValue('Phone – allow duplicates', phone); | ||
await commonEnketoPage.setInputValue('Phone – unique', phone); | ||
|
||
expect(await commonEnketoPage.isConstraintMessageDisplayed('Deprecated Phone')).to.be.true; | ||
expect(await commonEnketoPage.isConstraintMessageDisplayed('Phone – allow duplicates')).to.be.false; | ||
expect(await commonEnketoPage.isConstraintMessageDisplayed('Phone – unique')).to.be.true; | ||
|
||
await commonEnketoPage.setInputValue('Deprecated Phone', '+254712345671'); | ||
await commonEnketoPage.setInputValue('Phone – unique', '+254712345674'); | ||
|
||
expect(await commonEnketoPage.isConstraintMessageDisplayed('Deprecated Phone')).to.be.false; | ||
expect(await commonEnketoPage.isConstraintMessageDisplayed('Phone – unique')).to.be.false; | ||
|
||
await genericForm.submitForm(); | ||
|
||
const reportId = await reportsPage.getCurrentReportId(); | ||
const { fields } = await utils.getDoc(reportId); | ||
expect(fields).excluding(['meta']).to.deep.equal({ | ||
phone_widgets: { | ||
deprecated_phone: '+254712345671', | ||
phone, | ||
phone_unique: '+254712345674', | ||
} | ||
}); | ||
}); | ||
|
||
it('can use duplicate phone number when editing contact with same number', async () => { | ||
await commonPage.goToPeople(person1._id); | ||
await contactsPage.openEditContactForm(); | ||
|
||
await (await genericForm.nextPage()); | ||
// Try setting phone to number of the other person | ||
await commonEnketoPage.setInputValue('Phone Number', person0.phone); | ||
|
||
expect(await commonEnketoPage.isConstraintMessageDisplayed('Phone Number')).to.be.true; | ||
|
||
// Reset phone back to original value for this person | ||
await commonEnketoPage.setInputValue('Phone Number', person1.phone); | ||
|
||
expect(await commonEnketoPage.isConstraintMessageDisplayed('Phone Number')).to.be.false; | ||
|
||
await genericForm.submitForm(); | ||
|
||
const editedPerson = await utils.getDoc(person1._id); | ||
expect(editedPerson.phone).to.equal(person1.phone); | ||
}); | ||
}); |
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
Oops, something went wrong.