Skip to content

Commit

Permalink
Add test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
KicaRonaldOkello committed Apr 28, 2023
1 parent eb29deb commit 5a453ff
Show file tree
Hide file tree
Showing 4 changed files with 125 additions and 0 deletions.
7 changes: 7 additions & 0 deletions test/app-forms.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,4 +276,11 @@ describe('forms that have caused bugs', () => {
const bikramDate = await harness.page.evaluate(() => window.$$('[data-itext-id="/pregnancy/summary/r_pregnancy_details:label"]').text());
expect(bikramDate).to.include('महिनावारी भएको अन्तिम मिति : १५ कारà¥');
});
it('should log error thrown during filling an app form', async () => {
try {
await harness.fillForm('mother_name', ['Jane"s']);
} catch(error) {
expect(error.message).to.contain('Error encountered while filling form');
}
});
});
44 changes: 44 additions & 0 deletions test/collateral/forms/app/mother_name.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?xml version="1.0"?>
<h:html xmlns="http://www.w3.org/2002/xforms" xmlns:h="http://www.w3.org/1999/xhtml" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:jr="http://openrosa.org/javarosa" xmlns:orx="http://openrosa.org/xforms">
<h:head>
<h:title>Add household</h:title>
<model>
<itext>
<translation lang="en">
<text id="/mother_name/contact/mother_name:label">
<value>Whose baby is it ?</value>
</text>
<text id="/mother_name/contact/name:label">
<value>Baby mother</value>
</text>
<text id="/mother_name/contact:label">
<value>Baby mother</value>
</text>
</translation>
</itext>
<instance>
<mother_name id="contact:clinic:create" prefix="J1!contact:clinic:create!" delimiter="#" version="2023-04-18 04:46:19">
<contact>
<name/>
<mother_name/>
</contact>
<meta tag="hidden">
<instanceID/>
</meta>
</mother_name>
</instance>
<instance id="contact-summary"/>
<bind nodeset="/mother_name/contact/name" type="string" required="true()" calculate="concat(../mother_name, ' baby')"/>
<bind nodeset="/mother_name/contact/mother_name" type="string" required="true()"/>
<bind nodeset="/mother_name/meta/instanceID" type="string" readonly="true()" calculate="concat('uuid:', uuid())"/>
</model>
</h:head>
<h:body class="pages">
<group appearance="field-list" ref="/mother_name/contact">
<label ref="jr:itext('/mother_name/contact:label')"/>
<input ref="/mother_name/contact/mother_name">
<label ref="jr:itext('/mother_name/contact/mother_name:label')"/>
</input>
</group>
</h:body>
</h:html>
67 changes: 67 additions & 0 deletions test/collateral/forms/contact/household-create.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?xml version="1.0"?>
<h:html xmlns="http://www.w3.org/2002/xforms" xmlns:h="http://www.w3.org/1999/xhtml" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:jr="http://openrosa.org/javarosa" xmlns:orx="http://openrosa.org/xforms">
<h:head>
<h:title>Add household</h:title>
<model>
<itext>
<translation lang="en">
<text id="/data/contact/contact_name:hint">
<value>Please include both names</value>
</text>
<text id="/data/contact/contact_name:jr:constraintMsg">
<value>Enter a valid name consisting of only letters starting with a capital letter</value>
</text>
<text id="/data/contact/contact_name:label">
<value>Names</value>
</text>
<text id="/data/contact/name:label">
<value>Household Head</value>
</text>
<text id="/data/contact:label">
<value>Household Head</value>
</text>
</translation>
<translation lang="lg">
<text id="/data/contact/contact_name:hint">
<value>Osabibwa oteekewo amannya gombi</value>
</text>
<text id="/data/contact/contact_name:jr:constraintMsg">
<value>Yingizaamu erinnya ettuufu nga likolebwa nnukuta zokka ate nga litandisa nnukuta nnene</value>
</text>
<text id="/data/contact/contact_name:label">
<value>Amannya</value>
</text>
<text id="/data/contact/name:label">
<value>Akulira amaka</value>
</text>
<text id="/data/contact:label">
<value>Akulira amaka</value>
</text>
</translation>
</itext>
<instance>
<data id="contact:clinic:create" prefix="J1!contact:clinic:create!" delimiter="#" version="2023-04-18 03:47:20">
<contact>
<name/>
<contact_name/>
</contact>
<meta tag="hidden">
<instanceID/>
</meta>
</data>
</instance>
<bind nodeset="/data/contact/name" type="string" calculate="concat(../contact_name, ' Household')" required="true()"/>
<bind nodeset="/data/contact/contact_name" type="string" required="true()" jr:constraintMsg="jr:itext('/data/contact/contact_name:jr:constraintMsg')"/>
<bind nodeset="/data/meta/instanceID" type="string" readonly="true()" calculate="concat('uuid:', uuid())"/>
</model>
</h:head>
<h:body class="pages">
<group appearance="field-list" ref="/data/contact">
<label ref="jr:itext('/data/contact:label')"/>
<input ref="/data/contact/contact_name">
<label ref="jr:itext('/data/contact/contact_name:label')"/>
<hint ref="jr:itext('/data/contact/contact_name:hint')"/>
</input>
</group>
</h:body>
</h:html>
7 changes: 7 additions & 0 deletions test/contact-forms.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,4 +188,11 @@ describe('contact forms', () => {
reported_date: now.valueOf()
});
});
it('should log error thrown during filling a contact form', async () => {
try {
await harness.fillContactCreateForm('household', ['Peter"s']);
} catch(error) {
expect(error.message).to.contain('Error encountered while filling form');
}
});
});

0 comments on commit 5a453ff

Please sign in to comment.