From d15562c00ccd850009feff34b40f7f0338deff24 Mon Sep 17 00:00:00 2001 From: Jonathan Niles Date: Wed, 30 Sep 2020 12:21:44 +0100 Subject: [PATCH] fix(test): fix bh-date-editor tests Cherry picked the bh-date-editor changes from #4837 and add the critical await call to prevent test failures. Closes #4919. --- client/src/js/components/bhDateEditor.js | 1 + .../modules/offdays/modals/offday.modal.html | 11 ++++++----- .../src/modules/offdays/modals/offday.modal.js | 18 ++++++++++++------ .../modules/templates/bhDateEditor.tmpl.html | 4 ++-- test/end-to-end/offdays/offdays.page.js | 4 ++-- test/end-to-end/offdays/offdays.spec.js | 4 ++-- .../shared/components/bhDateEditor.js | 4 ++-- 7 files changed, 27 insertions(+), 19 deletions(-) diff --git a/client/src/js/components/bhDateEditor.js b/client/src/js/components/bhDateEditor.js index a3820d6799..de507c0437 100644 --- a/client/src/js/components/bhDateEditor.js +++ b/client/src/js/components/bhDateEditor.js @@ -6,6 +6,7 @@ angular.module('bhima.components') dateValue : '<', // one-way binding onChange : '&', minDate : ' - - + +
(%) diff --git a/client/src/modules/offdays/modals/offday.modal.js b/client/src/modules/offdays/modals/offday.modal.js index 3a06d623eb..5e71afd5ca 100644 --- a/client/src/modules/offdays/modals/offday.modal.js +++ b/client/src/modules/offdays/modals/offday.modal.js @@ -5,6 +5,12 @@ OffdayModalController.$inject = [ '$state', 'OffdayService', 'NotifyService', 'appcache', 'moment', 'params', ]; +/** + * @function OffdayModalController + * + * @description + * This modal sets the offdays for the payroll module. + */ function OffdayModalController($state, Offdays, Notify, AppCache, moment, params) { const vm = this; vm.offday = {}; @@ -13,11 +19,9 @@ function OffdayModalController($state, Offdays, Notify, AppCache, moment, params if (params.isCreateState || params.id) { cache.stateParams = params; - vm.stateParams = cache.stateParams; - } else { - vm.stateParams = cache.stateParams; } + vm.stateParams = cache.stateParams; vm.isCreateState = vm.stateParams.isCreateState; // update the date @@ -41,11 +45,13 @@ function OffdayModalController($state, Offdays, Notify, AppCache, moment, params function submit(offdayForm) { if (offdayForm.$invalid) { return 0; } - vm.offday.date = moment(vm.offday.date).format('YYYY-MM-DD'); + const data = { ...vm.offday }; + + data.date = moment(data.date).format('YYYY-MM-DD'); const promise = (vm.isCreateState) - ? Offdays.create(vm.offday) - : Offdays.update(vm.offday.id, vm.offday); + ? Offdays.create(data) + : Offdays.update(vm.offday.id, data); return promise .then(() => { diff --git a/client/src/modules/templates/bhDateEditor.tmpl.html b/client/src/modules/templates/bhDateEditor.tmpl.html index d8d269bb7b..3a62978eba 100644 --- a/client/src/modules/templates/bhDateEditor.tmpl.html +++ b/client/src/modules/templates/bhDateEditor.tmpl.html @@ -15,7 +15,7 @@ ng-class="{ 'has-error' : DateEditorForm.$submitted && DateEditorForm.$invalid } " data-date-editor> -