-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Log errors thrown when filling a form #217
Changes from all commits
f475e03
89e37bb
eb29deb
5a453ff
fa27e99
335dbb1
7afdf15
01a83e3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ on: | |
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 30 | ||
|
||
defaults: | ||
run: | ||
|
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -306,7 +306,13 @@ class Harness { | |
} | ||
|
||
this.log(`Filling ${answers.length} pages with answer: ${JSON.stringify(answers)}`); | ||
const fillResult = await this.page.evaluate(async innerAnswer => await window.formFiller.fillAppForm(innerAnswer), answers); | ||
const fillResult = await this.page.evaluate(async innerAnswer => { | ||
try { | ||
return await window.formFiller.fillAppForm(innerAnswer); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sorry for the late feedback on this one: but i'm a little unsure on the value we are adding here... why catch an exception to just rethrow it? what problem are we solving? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we don't catch the exception, we see a confusing error in the stack trace like
When we catch and rethrow, the error in the stack trace makes more sense for the user like
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can your test also make an assertion about not just the boilerplate you're adding but also the more descriptive error message like 'error.includes('mother_name')`? |
||
} catch (err) { | ||
throw new Error(`Error encountered while filling form: ${err}`); | ||
} | ||
}, answers); | ||
this.log(`Result of fill is: ${JSON.stringify(fillResult, null, 2)}`); | ||
|
||
if (this.options.logFormErrors && fillResult.errors && fillResult.errors.length > 0) { | ||
|
@@ -691,7 +697,13 @@ const fillContactForm = async (self, contactType, action, ...answers) => { | |
self._state.pageContent = await self.page.content(); | ||
|
||
self.log(`Filling ${answers.length} pages with answer: ${JSON.stringify(answers)}`); | ||
const fillResult = await self.page.evaluate(async (innerContactType, innerAnswer) => await window.formFiller.fillContactForm(innerContactType, innerAnswer), contactType, answers); | ||
const fillResult = await self.page.evaluate(async (innerContactType, innerAnswer) => { | ||
try { | ||
return await window.formFiller.fillContactForm(innerContactType, innerAnswer); | ||
} catch (err) { | ||
throw new Error(`Error encountered while filling form: ${err}`); | ||
kennsippell marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
}, contactType, answers); | ||
self.log(`Result of fill is: ${JSON.stringify(fillResult, null, 2)}`); | ||
|
||
// https://github.com/medic/cht-conf-test-harness/issues/105 | ||
|
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> |
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> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice