Skip to content
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 exceptions from form filling #142

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions dist/all-chts-bundle.dev.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/all-chts-bundle.dev.js.map

Large diffs are not rendered by default.

34 changes: 17 additions & 17 deletions docs/Harness.html
Original file line number Diff line number Diff line change
Expand Up @@ -886,7 +886,7 @@ <h4 class="name" id="consoleErrors"><span class="type-signature"></span>consoleE

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="harness.js.html">harness.js</a>, <a href="harness.js.html#line501">line 501</a>
<a href="harness.js.html">harness.js</a>, <a href="harness.js.html#line513">line 513</a>
</li></ul></dd>


Expand Down Expand Up @@ -953,7 +953,7 @@ <h4 class="name" id="content"><span class="type-signature"></span>content<span c

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="harness.js.html">harness.js</a>, <a href="harness.js.html#line527">line 527</a>
<a href="harness.js.html">harness.js</a>, <a href="harness.js.html#line539">line 539</a>
</li></ul></dd>


Expand Down Expand Up @@ -1015,7 +1015,7 @@ <h4 class="name" id="coreVersion"><span class="type-signature"></span>coreVersio

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="harness.js.html">harness.js</a>, <a href="harness.js.html#line522">line 522</a>
<a href="harness.js.html">harness.js</a>, <a href="harness.js.html#line534">line 534</a>
</li></ul></dd>


Expand Down Expand Up @@ -1077,7 +1077,7 @@ <h4 class="name" id="state"><span class="type-signature"></span>state<span class

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="harness.js.html">harness.js</a>, <a href="harness.js.html#line576">line 576</a>
<a href="harness.js.html">harness.js</a>, <a href="harness.js.html#line588">line 588</a>
</li></ul></dd>


Expand Down Expand Up @@ -1139,7 +1139,7 @@ <h4 class="name" id="user"><span class="type-signature"></span>user<span class="

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="harness.js.html">harness.js</a>, <a href="harness.js.html#line510">line 510</a>
<a href="harness.js.html">harness.js</a>, <a href="harness.js.html#line522">line 522</a>
</li></ul></dd>


Expand Down Expand Up @@ -1207,7 +1207,7 @@ <h4 class="name" id="userSettingsDoc"><span class="type-signature"></span>userSe

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="harness.js.html">harness.js</a>, <a href="harness.js.html#line545">line 545</a>
<a href="harness.js.html">harness.js</a>, <a href="harness.js.html#line557">line 557</a>
</li></ul></dd>


Expand Down Expand Up @@ -1585,7 +1585,7 @@ <h6>Properties</h6>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="harness.js.html">harness.js</a>, <a href="harness.js.html#line375">line 375</a>
<a href="harness.js.html">harness.js</a>, <a href="harness.js.html#line387">line 387</a>
</li></ul></dd>


Expand Down Expand Up @@ -1969,7 +1969,7 @@ <h5>Parameters:</h5>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="harness.js.html">harness.js</a>, <a href="harness.js.html#line289">line 289</a>
<a href="harness.js.html">harness.js</a>, <a href="harness.js.html#line295">line 295</a>
</li></ul></dd>


Expand Down Expand Up @@ -2144,7 +2144,7 @@ <h5>Parameters:</h5>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="harness.js.html">harness.js</a>, <a href="harness.js.html#line269">line 269</a>
<a href="harness.js.html">harness.js</a>, <a href="harness.js.html#line275">line 275</a>
</li></ul></dd>


Expand Down Expand Up @@ -2365,7 +2365,7 @@ <h5>Parameters:</h5>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="harness.js.html">harness.js</a>, <a href="harness.js.html#line632">line 632</a>
<a href="harness.js.html">harness.js</a>, <a href="harness.js.html#line644">line 644</a>
</li></ul></dd>


Expand Down Expand Up @@ -2475,7 +2475,7 @@ <h4 class="name" id="getNow"><span class="type-signature"></span>getNow<span cla

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="harness.js.html">harness.js</a>, <a href="harness.js.html#line258">line 258</a>
<a href="harness.js.html">harness.js</a>, <a href="harness.js.html#line264">line 264</a>
</li></ul></dd>


Expand Down Expand Up @@ -2710,7 +2710,7 @@ <h6>Properties</h6>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="harness.js.html">harness.js</a>, <a href="harness.js.html#line411">line 411</a>
<a href="harness.js.html">harness.js</a>, <a href="harness.js.html#line423">line 423</a>
</li></ul></dd>


Expand Down Expand Up @@ -3061,7 +3061,7 @@ <h6>Properties</h6>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="harness.js.html">harness.js</a>, <a href="harness.js.html#line329">line 329</a>
<a href="harness.js.html">harness.js</a>, <a href="harness.js.html#line341">line 341</a>
</li></ul></dd>


Expand Down Expand Up @@ -3220,7 +3220,7 @@ <h5>Parameters:</h5>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="harness.js.html">harness.js</a>, <a href="harness.js.html#line457">line 457</a>
<a href="harness.js.html">harness.js</a>, <a href="harness.js.html#line469">line 469</a>
</li></ul></dd>


Expand Down Expand Up @@ -3722,7 +3722,7 @@ <h5>Parameters:</h5>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="harness.js.html">harness.js</a>, <a href="harness.js.html#line582">line 582</a>
<a href="harness.js.html">harness.js</a>, <a href="harness.js.html#line594">line 594</a>
</li></ul></dd>


Expand Down Expand Up @@ -3868,7 +3868,7 @@ <h5>Parameters:</h5>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="harness.js.html">harness.js</a>, <a href="harness.js.html#line244">line 244</a>
<a href="harness.js.html">harness.js</a>, <a href="harness.js.html#line250">line 250</a>
</li></ul></dd>


Expand Down Expand Up @@ -4150,7 +4150,7 @@ <h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="mock.cht-
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a> on Wed Jul 21 2021 09:45:25 GMT-0500 (Central Daylight Time)
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a> on Wed Sep 29 2021 23:25:41 GMT+0300 (East Africa Time)
</footer>

<script> prettyPrint(); </script>
Expand Down
2 changes: 1 addition & 1 deletion docs/core-adapter.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ <h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="mock.cht-
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a> on Wed Jul 21 2021 09:45:25 GMT-0500 (Central Daylight Time)
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a> on Wed Sep 29 2021 23:25:41 GMT+0300 (East Africa Time)
</footer>

<script> prettyPrint(); </script>
Expand Down
2 changes: 1 addition & 1 deletion docs/dev-mode_mock.cht-conf.contact-summary-lib.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ <h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="mock.cht-
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a> on Wed Jul 21 2021 09:45:25 GMT-0500 (Central Daylight Time)
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a> on Wed Sep 29 2021 23:25:41 GMT+0300 (East Africa Time)
</footer>

<script> prettyPrint(); </script>
Expand Down
2 changes: 1 addition & 1 deletion docs/dev-mode_mock.cht-conf.nools-lib.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ <h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="mock.cht-
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a> on Wed Jul 21 2021 09:45:25 GMT-0500 (Central Daylight Time)
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a> on Wed Sep 29 2021 23:25:41 GMT+0300 (East Africa Time)
</footer>

<script> prettyPrint(); </script>
Expand Down
2 changes: 1 addition & 1 deletion docs/dev-mode_mock.rules-engine.rules-emitter.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ <h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="mock.cht-
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a> on Wed Jul 21 2021 09:45:25 GMT-0500 (Central Daylight Time)
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a> on Wed Sep 29 2021 23:25:41 GMT+0300 (East Africa Time)
</footer>

<script> prettyPrint(); </script>
Expand Down
2 changes: 1 addition & 1 deletion docs/form-host_form-filler.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ <h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="mock.cht-
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a> on Wed Jul 21 2021 09:45:25 GMT-0500 (Central Daylight Time)
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a> on Wed Sep 29 2021 23:25:41 GMT+0300 (East Africa Time)
</footer>

<script> prettyPrint(); </script>
Expand Down
6 changes: 3 additions & 3 deletions docs/global.html
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ <h5 class="subsection-title">Properties:</h5>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="harness.js.html">harness.js</a>, <a href="harness.js.html#line617">line 617</a>
<a href="harness.js.html">harness.js</a>, <a href="harness.js.html#line629">line 629</a>
</li></ul></dd>


Expand Down Expand Up @@ -1020,7 +1020,7 @@ <h5 class="subsection-title">Properties:</h5>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="harness.js.html">harness.js</a>, <a href="harness.js.html#line565">line 565</a>
<a href="harness.js.html">harness.js</a>, <a href="harness.js.html#line577">line 577</a>
</li></ul></dd>


Expand Down Expand Up @@ -1633,7 +1633,7 @@ <h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="mock.cht-
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a> on Wed Jul 21 2021 09:45:25 GMT-0500 (Central Daylight Time)
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a> on Wed Sep 29 2021 23:25:41 GMT+0300 (East Africa Time)
</footer>

<script> prettyPrint(); </script>
Expand Down
18 changes: 15 additions & 3 deletions docs/harness.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,13 @@ <h1 class="page-title">Source: harness.js</h1>
this._state.pageContent = await this.page.content();

this.log(`Filling ${answers.length} pages with answer: ${JSON.stringify(answers)}`);
const fillResult = await this.page.evaluate(async (innerContactType, innerAnswer) => await window.formFiller.fillContactForm(innerContactType, innerAnswer), contactType, answers);
const fillResult = await this.page.evaluate(async (innerContactType, innerAnswer) => {
try {
return await window.formFiller.fillContactForm(innerContactType, innerAnswer);
} catch (err) {
throw new Error(`Error encountered while filling form: ${err.toString()}`);
}
}, contactType, answers);
this.log(`Result of fill is: ${JSON.stringify(fillResult, null, 2)}`);

// https://github.com/medic/cht-conf-test-harness/issues/105
Expand Down Expand Up @@ -328,7 +334,13 @@ <h1 class="page-title">Source: harness.js</h1>
}

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);
} catch (err) {
throw new Error(`Error encountered while filling form: ${err.toString()}`);
}
}, answers);
this.log(`Result of fill is: ${JSON.stringify(fillResult, null, 2)}`);

if (this.options.logFormErrors &amp;&amp; fillResult.errors &amp;&amp; fillResult.errors.length > 0) {
Expand Down Expand Up @@ -800,7 +812,7 @@ <h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="mock.cht-
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a> on Wed Jul 21 2021 09:45:25 GMT-0500 (Central Daylight Time)
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a> on Wed Sep 29 2021 23:25:41 GMT+0300 (East Africa Time)
</footer>

<script> prettyPrint(); </script>
Expand Down
2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ <h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="mock.cht-
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a> on Wed Jul 21 2021 09:45:25 GMT-0500 (Central Daylight Time)
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a> on Wed Sep 29 2021 23:25:41 GMT+0300 (East Africa Time)
</footer>

<script> prettyPrint(); </script>
Expand Down
2 changes: 1 addition & 1 deletion docs/jsdocs.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ <h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="mock.cht-
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a> on Wed Jul 21 2021 09:45:25 GMT-0500 (Central Daylight Time)
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a> on Wed Sep 29 2021 23:25:41 GMT+0300 (East Africa Time)
</footer>

<script> prettyPrint(); </script>
Expand Down
2 changes: 1 addition & 1 deletion docs/mock.cht-conf.module_contact-summary-lib.html
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ <h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="mock.cht-
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a> on Wed Jul 21 2021 09:45:25 GMT-0500 (Central Daylight Time)
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a> on Wed Sep 29 2021 23:25:41 GMT+0300 (East Africa Time)
</footer>

<script> prettyPrint(); </script>
Expand Down
2 changes: 1 addition & 1 deletion docs/mock.cht-conf.module_nools-lib.html
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ <h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="mock.cht-
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a> on Wed Jul 21 2021 09:45:25 GMT-0500 (Central Daylight Time)
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a> on Wed Sep 29 2021 23:25:41 GMT+0300 (East Africa Time)
</footer>

<script> prettyPrint(); </script>
Expand Down
2 changes: 1 addition & 1 deletion docs/mock.rules-engine.module_rules-emitter.html
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,7 @@ <h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="mock.cht-
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a> on Wed Jul 21 2021 09:45:25 GMT-0500 (Central Daylight Time)
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a> on Wed Sep 29 2021 23:25:41 GMT+0300 (East Africa Time)
</footer>

<script> prettyPrint(); </script>
Expand Down
2 changes: 1 addition & 1 deletion docs/module-core-adapter.html
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ <h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="mock.cht-
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a> on Wed Jul 21 2021 09:45:25 GMT-0500 (Central Daylight Time)
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a> on Wed Sep 29 2021 23:25:41 GMT+0300 (East Africa Time)
</footer>

<script> prettyPrint(); </script>
Expand Down
16 changes: 14 additions & 2 deletions src/harness.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,13 @@ class Harness {
this._state.pageContent = await this.page.content();

this.log(`Filling ${answers.length} pages with answer: ${JSON.stringify(answers)}`);
const fillResult = await this.page.evaluate(async (innerContactType, innerAnswer) => await window.formFiller.fillContactForm(innerContactType, innerAnswer), contactType, answers);
const fillResult = await this.page.evaluate(async (innerContactType, innerAnswer) => {
try {
return await window.formFiller.fillContactForm(innerContactType, innerAnswer);
} catch (err) {
throw new Error(`Error encountered while filling form: ${err.toString()}`);
}
}, contactType, answers);
this.log(`Result of fill is: ${JSON.stringify(fillResult, null, 2)}`);

// https://github.com/medic/cht-conf-test-harness/issues/105
Expand Down Expand Up @@ -300,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);
} catch (err) {
throw new Error(`Error encountered while filling form: ${err.toString()}`);
}
}, answers);
this.log(`Result of fill is: ${JSON.stringify(fillResult, null, 2)}`);

if (this.options.logFormErrors && fillResult.errors && fillResult.errors.length > 0) {
Expand Down