Skip to content

Commit

Permalink
fix await issue
Browse files Browse the repository at this point in the history
  • Loading branch information
kapelo committed Nov 13, 2024
1 parent 833ad61 commit 6031576
Show file tree
Hide file tree
Showing 12 changed files with 39 additions and 9 deletions.
18 changes: 9 additions & 9 deletions tests/page-objects/default/enketo/common-enketo.wdio.page.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,24 @@ const getCorrectFieldsetSection = async (section) => {
};

const isElementDisplayed = async (type, text) => {
return await getCurrentPageSection().$(`${type}*=${text}`).isDisplayed();
return await (await getCurrentPageSection()).$(`${type}*=${text}`).isDisplayed();
};

const selectRadioButton = async (question, value) => {
await radioButtonElement(question, value).click();
await (await radioButtonElement(question, value)).click();
};

const selectCheckBox = async (question, value) => {
const page = await getCurrentPageSection();
const checkbox = await getCorrectFieldsetSection(page)
const checkbox = await (await getCorrectFieldsetSection(page))
.$(`legend*=${question}`)
.nextElement()
.$(`label*=${value}`);
await checkbox.click();
};

const setValue = async (typeSelector, question, value) => {
const element = await getCurrentPageSection()
const element = await (await getCurrentPageSection())
.$(`label*=${question}`)
.$(typeSelector);
await element.setValue(value);
Expand All @@ -64,7 +64,7 @@ const setTextareaValue = async (question, value) => {
};

const addFileInputValue = async (question, value, { repeatIndex = 0 } = {}) => {
const element = await getCurrentPageSection()
const element = await (await getCurrentPageSection())
.$$(`label*=${question}`)[repeatIndex]
.$('input[type=file]');
await element.addValue(value);
Expand Down Expand Up @@ -102,7 +102,7 @@ const uploadForm = async (formName, saveDoc = true) => {
};

const getValue = async (typeSelector, question) => {
return await getCurrentPageSection()
return await (await getCurrentPageSection())
.$(`label*=${question}`)
.$(typeSelector)
.getValue();
Expand All @@ -118,15 +118,15 @@ const getTextareaValue = async (question) => {

const isRequiredMessageDisplayed = async (question) => {
await formTitle().click();
const requiredMsg = (await getCurrentPageSection())
const requiredMsg = await (await getCurrentPageSection())
.$(`label*=${question}`)
.$('.or-required-msg.active');
return await requiredMsg.isDisplayed();
};

const isConstraintMessageDisplayed = async (question) => {
await formTitle().click();
const requiredMsg = (await getCurrentPageSection())
const requiredMsg = await (await getCurrentPageSection())
.$(`label*=${question}`)
.$('.or-constraint-msg.active');
return await requiredMsg.isDisplayed();
Expand All @@ -138,7 +138,7 @@ const addRepeatSection = async () => {
};

const drawShapeOnCanvas = async (question) => {
const canvas = await getCurrentPageSection()
const canvas = await (await getCurrentPageSection())
.$(`label*=${question}`)
.$('canvas');
await canvas.waitForDisplayed();
Expand Down
1 change: 1 addition & 0 deletions tests/utils/config-temp/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"env":{"node":true,"es6":true},"parserOptions":{"ecmaVersion":6},"root":true}
13 changes: 13 additions & 0 deletions tests/utils/config-temp/app_settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"forms": {},
"schedules": [],
"contact_summary": "var ContactSummary = {}; !function(e,t){if('object'==typeof exports&&'object'==typeof module)module.exports=t();else if('function'==typeof define&&define.amd)define([],t);else{var n=t();for(var r in n)('object'==typeof exports?exports:e)[r]=n[r]}}(ContactSummary,(function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){'undefined'!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:'Module'}),Object.defineProperty(e,'__esModule',{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&'object'==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,'default',{enumerable:!0,value:e}),2&t&&'string'!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,'a',t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p='',n(n.s=0)}([function(e,t,n){var r=n(1),o=n(2);e.exports=o(r,contact,reports)},function(e,t){e.exports={cards:[],fields:[],context:{nbr_reports:reports.length}}},function(e,t){function n(e){return e?Array.isArray(e)?e:[e]:[]}function r(e,t){switch(typeof e){case'undefined':return!0;case'function':return e(t);default:return e}}function o(e,t,n){if(r(e.appliesIf,n)){var o='function'==typeof e.fields?e.fields(n):e.fields.filter((function(e){return r(e.appliesIf,n)})).map((function(e){var t={};return i(e,t,'label'),i(e,t,'value'),i(e,t,'translate'),i(e,t,'filter'),i(e,t,'width'),i(e,t,'icon'),e.context&&(t.context={},i(e.context,t.context,'count'),i(e.context,t.context,'total')),t}));return e.modifyContext&&e.modifyContext(t,n),{label:e.label,fields:o}}function i(e,t,r){switch(typeof e[r]){case'undefined':return;case'function':t[r]=e[r](n);break;default:t[r]=e[r]}}}e.exports=function(e,t,r){var i=e.fields||[],f=e.context||{},u=e.cards||[],c=t&&('contact'===t.type?t.contact_type:t.type),l={cards:[],fields:i.filter((function(e){var t=n(e.appliesToType),r=t.filter((function(e){return e&&'!'===e.charAt(0)}));if((0===t.length||t.includes(c)||r.length>0&&!r.includes('!'+c))&&(!e.appliesIf||e.appliesIf()))return delete e.appliesToType,delete e.appliesIf,!0}))};return u.forEach((function(e){var t,i,u,a,p=n(e.appliesToType);if(p.includes('report')&&p.length>1)throw new Error('You cannot set appliesToType to an array which includes the type \\'report\\' and another type.');if(p.includes('report'))for(t=0;t<r.length;++t)i=r[t],!(a=i)||a.errors&&a.errors.length||(u=o(e,f,i))&&l.cards.push(u);else{if(!p.includes(c)&&p.length>0)return;(u=o(e,f))&&l.cards.push(u)}})),l.context=f,l}}])})); return ContactSummary;",
"tasks": {
"rules": "!function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){'undefined'!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:'Module'}),Object.defineProperty(e,'__esModule',{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&'object'==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,'default',{enumerable:!0,value:e}),2&t&&'string'!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,'a',t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p='',n(n.s=1)}([function(e,t){e.exports=function(e){var t={};!function e(t,n){var r=Object.keys(t);for(var o in r){var a=r[o];switch(typeof t[a]){case'object':e(t[a],n);break;case'function':t[a]=t[a].bind(n)}}}(e,t),t.definition=function e(t){var n=Object.assign({},t),r=Object.keys(n);for(var o in r){var a=r[o];if(Array.isArray(n[a])){n[a]=n[a].slice(0);for(var i=0;i<n[a].length;++i)'object'==typeof n[a][i]&&(n[a][i]=e(n[a][i]))}else'object'==typeof n[a]&&(n[a]=e(n[a]))}return n}(e)}},function(e,t,n){var r=n(2),o=n(3),a=n(4);n(6)(o,c,Utils,Target,emit),a(r,c,Utils,Task,emit),emit('_complete',{_id:!0})},function(e,t){e.exports=[]},function(e,t){e.exports=[]},function(e,t,n){var r=n(0),o=n(5);function a(e,t,n,r,o,a){var i;if(e.appliesToType){var c;if('contacts'===e.appliesTo){if(!o.contact)return;c='contact'===o.contact.type?o.contact.contact_type:o.contact.type}else{if(!a)return;c=a.form}if(-1===e.appliesToType.indexOf(c))return}if('scheduled_tasks'===e.appliesTo||!e.appliesIf||e.appliesIf(o,a))if('scheduled_tasks'===e.appliesTo){if(a&&e.appliesIf){if(!a.scheduled_tasks)return;for(i=0;i<a.scheduled_tasks.length;i++)e.appliesIf(o,a,i)&&d(i)}}else d();function s(e,t,n){var r;return(r='function'==typeof e.contactLabel?e.contactLabel(t,n):e.contactLabel)?{name:r}:t.contact}function d(i){var c,d,p,u,l=null;for(c=0;c<e.events.length;c++){if((d=e.events[c]).dueDate)l=d.dueDate(d,o,a,i);else if(a)l=void 0!==i?new Date(t.addDate(new Date(a.scheduled_tasks[i].due),d.days)):new Date(t.addDate(new Date(a.reported_date),d.days));else if(d.dueDate)l=d.dueDate(d,o);else{var y=o.contact&&o.contact.reported_date?new Date(o.contact.reported_date):new Date;l=new Date(t.addDate(y,d.days))}t.isTimely(l,d)&&(u={_id:(a?a._id:o.contact&&o.contact._id)+'~'+(d.id||c)+'~'+e.name,deleted:!(!(o.contact&&o.contact.deleted||a)||!a.deleted),doc:o,contact:s(e,o,a),icon:e.icon,date:l,readyStart:d.start||0,readyEnd:d.end||0,title:e.title,resolved:e.resolvedIf(o,a,d,l,i),actions:f(e.actions,d)},void 0!==i&&(u._id+='-'+i),'function'==typeof(p=e.priority)&&(p=p(o,a)),p&&(u.priority=p.level,u.priorityLabel=p.label),r('task',new n(u)))}}function f(t,n){return e.actions.map((function(e){return function(e,t){var n={source:'task',source_id:a?a._id:o.contact&&o.contact._id,contact:o.contact};e.modifyContent&&e.modifyContent(n,o,a,t);return{type:e.type||'report',form:e.form,label:e.label||'Follow up',content:n}}(e,n)}))}}e.exports=function(e,t,n,i,c){if(e)for(var s,d,f=0;f<e.length;++f)switch('function'!=typeof(s=Object.assign({},e[f],o)).resolvedIf&&(s.resolvedIf=function(e,t,r,o){return s.defaultResolvedIf(e,t,r,o,n)}),r(s),s.appliesTo){case'reports':case'scheduled_tasks':for(var p=0;p<t.reports.length;++p)d=t.reports[p],a(s,n,i,c,t,d);break;case'contacts':t.contact&&a(s,n,i,c,t);break;default:throw new Error('Unrecognised task.appliesTo: '+s.appliesTo)}}},function(e,t){e.exports={defaultResolvedIf:function(e,t,n,r,o){var a,i;o||(o=Utils);var c=function(e){var t;if(!e||!e.actions)return;return(t=e.actions.find((function(e){return!e.type||'report'===e.type})))&&t.form}(this.definition);if(!c)throw new Error('Could not find the default resolving form!');return a=0,a=t?Math.max(o.addDate(r,-n.start).getTime(),t.reported_date+1):o.addDate(r,-n.start).getTime(),i=o.addDate(r,n.end+1).getTime(),o.isFormSubmittedInWindow(e.reports,c,a,i)}}},function(e,t,n){var r=n(0);function o(e,t,n,r,o,a){var i=!!a;if(o.contact){var c='contact'===o.contact.type?o.contact.contact_type:o.contact.type,s=i?a.form:c;if(!(e.appliesToType&&e.appliesToType.indexOf(s)<0)&&(!e.appliesIf||e.appliesIf(o,a)))for(var d=i?a:o.contact,f=function(e,t,n){var r;return r='function'==typeof e.idType?e.idType(t,n):'report'===e.idType?n&&n._id:t.contact&&t.contact._id,Array.isArray(r)||(r=[r]),r}(e,o,a),p=!e.passesIf||!!e.passesIf(o,a),u=function(e,t,n,r){if('function'==typeof e.date)return e.date(n,r)||t.now().getTime();if(void 0===e.date||null===e.date||'now'===e.date)return t.now().getTime();if('reported'===e.date)return r?r.reported_date:n.contact.reported_date;throw new Error('Unrecognised value for target.date: '+e.date)}(e,n,o,a),l=e.groupBy&&e.groupBy(o,a),y=0;y<f.length;++y){var v=new t({_id:f[y]+'~'+e.id,contact:o.contact,deleted:!!d.deleted,type:e.id,pass:p,groupBy:l,date:u});e.emitCustom?e.emitCustom(b,v,o,a):b(v)}}function b(e){r('target',e)}}e.exports=function(e,t,n,a,i){for(var c=0;c<e.length;++c){var s=e[c];switch(r(s),s.appliesTo){case'contacts':o(s,a,n,i,t);break;case'reports':for(var d=0;d<t.reports.length;++d){o(s,a,n,i,t,t.reports[d])}break;default:throw new Error('Unrecognised target.appliesTo: '+s.appliesTo)}}}}]);",
"isDeclarative": true,
"targets": {
"enabled": true,
"items": []
}
}
}
1 change: 1 addition & 0 deletions tests/utils/config-temp/app_settings/base_settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
1 change: 1 addition & 0 deletions tests/utils/config-temp/app_settings/forms.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
1 change: 1 addition & 0 deletions tests/utils/config-temp/app_settings/schedules.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
8 changes: 8 additions & 0 deletions tests/utils/config-temp/contact-summary.templated.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
cards: [],
fields: [],
context: {
// eslint-disable-next-line no-undef
nbr_reports: reports.length,
}
};
1 change: 1 addition & 0 deletions tests/utils/config-temp/harness.defaults.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
1 change: 1 addition & 0 deletions tests/utils/config-temp/privacy-policies.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
1 change: 1 addition & 0 deletions tests/utils/config-temp/resources.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
1 change: 1 addition & 0 deletions tests/utils/config-temp/targets.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = [];
1 change: 1 addition & 0 deletions tests/utils/config-temp/tasks.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = [];

0 comments on commit 6031576

Please sign in to comment.