From eb0276183fe80d8e3aaf083bab4e6ac3065b6147 Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Tue, 20 Feb 2018 10:00:19 +0100 Subject: [PATCH] E2E refactor, Snackbar with hide button, Dialog, bugs solved --- client/auth/src/login/login.js | 13 +- .../client/src/billing-data/billing-data.html | 18 +- client/client/src/billing-data/locale/en.yml | 15 + client/client/src/billing-data/locale/es.yml | 2 +- .../core/src/components/confirm/confirm.html | 33 +- client/core/src/components/confirm/confirm.js | 16 +- client/core/src/components/confirm/style.scss | 5 - client/core/src/components/dialog/dialog.html | 9 +- client/core/src/components/dialog/dialog.js | 84 ++-- .../core/src/components/dialog/dialog.spec.js | 157 +------- client/core/src/components/dialog/style.scss | 81 ++-- .../core/src/components/drop-down/style.scss | 2 +- client/core/src/components/icon/style.css | 6 +- .../src/components/snackbar/snackbar.html | 6 +- .../core/src/components/snackbar/snackbar.js | 83 +++- .../core/src/components/snackbar/style.scss | 48 +++ .../core/src/components/textfield/style.scss | 26 +- client/core/src/directives/id.js | 7 +- .../core/src/directives/specs/dialog.spec.js | 2 +- client/core/src/lib/app.js | 10 +- client/core/src/lib/component.js | 5 +- client/core/src/locale/en.yml | 5 +- client/core/src/locale/es.yml | 3 +- client/core/src/styles/mdl-override.css | 35 -- e2e/helpers/extensions.js | 76 +++- e2e/helpers/helpers.js | 19 + e2e/helpers/nightmare.js | 2 + e2e/helpers/nightmareModifiers.js | 2 - e2e/helpers/selectors.js | 6 +- .../client-module/01_create_client.spec.js | 189 +++------ .../client-module/02_edit_basic_data.spec.js | 197 +++------ .../client-module/03_edit_fiscal_data.spec.js | 378 ++++++------------ .../client-module/04_edit_pay_method.spec.js | 188 +++------ .../client-module/05_add_address.spec.js | 222 ++++------ .../06_add_address_notes.spec.js | 76 +--- .../client-module/07_edit_web_access.spec.js | 97 ++--- e2e/paths/client-module/08_add_notes.spec.js | 85 ++-- e2e/paths/client-module/09_add_credit.spec.js | 85 ++-- e2e/paths/client-module/10_add_greuge.spec.js | 129 ++---- e2e/paths/client-module/11_mandate.spec.js | 65 +-- gulpfile.js | 4 +- webpack.config.js | 6 +- 42 files changed, 944 insertions(+), 1553 deletions(-) create mode 100644 client/client/src/billing-data/locale/en.yml delete mode 100644 client/core/src/components/confirm/style.scss create mode 100644 client/core/src/components/snackbar/style.scss create mode 100644 e2e/helpers/helpers.js diff --git a/client/auth/src/login/login.js b/client/auth/src/login/login.js index 7f587e58c7..47ab77baff 100644 --- a/client/auth/src/login/login.js +++ b/client/auth/src/login/login.js @@ -1,6 +1,9 @@ import ngModule from '../module'; import './style.scss'; +/** + * A simple login form. + */ export default class Controller { constructor($element, $scope, $window, $http) { this.$element = $element; @@ -9,9 +12,9 @@ export default class Controller { this.$http = $http; } submit() { - if (!(this.user && this.password)) { + if (!this.user) { this.focusUser(); - this.showMessage('Please insert your user and password'); + this.showError('Please insert your user and password'); return; } @@ -62,15 +65,15 @@ export default class Controller { message = 'Something went wrong'; } - this.showMessage(message); + this.showError(message); this.focusUser(); } focusUser() { this.$.userField.select(); this.$.userField.focus(); } - showMessage(message) { - this.$.snackbar.show({message: message}); + showError(message) { + this.$.snackbar.showError({message: message}); } } Controller.$inject = ['$element', '$scope', '$window', '$http']; diff --git a/client/client/src/billing-data/billing-data.html b/client/client/src/billing-data/billing-data.html index b4d307856e..0fa5b523f5 100644 --- a/client/client/src/billing-data/billing-data.html +++ b/client/client/src/billing-data/billing-data.html @@ -39,17 +39,9 @@ - - - - Changed terms - Notify customer? - - - - - - - \ No newline at end of file + on-response="$ctrl.returnDialog(response)" + question="Changed terms" + message="Notify customer?"> + \ No newline at end of file diff --git a/client/client/src/billing-data/locale/en.yml b/client/client/src/billing-data/locale/en.yml new file mode 100644 index 0000000000..20f5272b63 --- /dev/null +++ b/client/client/src/billing-data/locale/en.yml @@ -0,0 +1,15 @@ +Changed terms: Payment terms have changed +Notify customer?: Do you want to notify customer? +No: No +Yes, notify: Yes, notify +Notification sent!: Notification sent! +Notification error: Error while sending notification +Yes, propagate: Yes, propagate +Equivalent tax spreaded: Equivalent tax spreaded +Invoice by address: Invoice by address +Equalization tax: Equalization tax +Due day: Due day +Received core VNH: VNH core received +Received core VNL: VNL core received +Received B2B VNL: VNL B2B received +Save: Save \ No newline at end of file diff --git a/client/client/src/billing-data/locale/es.yml b/client/client/src/billing-data/locale/es.yml index cc32fc52ee..ed4725ac27 100644 --- a/client/client/src/billing-data/locale/es.yml +++ b/client/client/src/billing-data/locale/es.yml @@ -12,4 +12,4 @@ Due day: Vencimiento Received core VNH: Recibido core VNH Received core VNL: Recibido core VNL Received B2B VNL: Recibido B2B VNL -SAVE: GUARDAR \ No newline at end of file +Save: Guardar \ No newline at end of file diff --git a/client/core/src/components/confirm/confirm.html b/client/core/src/components/confirm/confirm.html index 34fdb43214..3cdbb4a346 100644 --- a/client/core/src/components/confirm/confirm.html +++ b/client/core/src/components/confirm/confirm.html @@ -1,23 +1,10 @@ -
- -
-
- -
- {{::$ctrl.question}} -
- - {{::$ctrl.message}} - -
-
-
- - - - -
-
-
+ + +
{{::$ctrl.question}}
+ {{::$ctrl.message}} +
+ + + + +
\ No newline at end of file diff --git a/client/core/src/components/confirm/confirm.js b/client/core/src/components/confirm/confirm.js index cc9f56db4c..1431cf28a2 100644 --- a/client/core/src/components/confirm/confirm.js +++ b/client/core/src/components/confirm/confirm.js @@ -1,13 +1,21 @@ import ngModule from '../../module'; import Dialog from '../dialog/dialog'; -import './style.scss'; +import template from './confirm.html'; -export default class Confirm extends Dialog {} -Dialog.$inject = ['$element']; +export default class Confirm extends Dialog { + constructor($element, $scope, $compile) { + super($element); + let cTemplate = $compile(template)($scope)[0]; + this.body = cTemplate.querySelector('tpl-body'); + this.buttons = cTemplate.querySelector('tpl-buttons'); + } +} +Confirm.$inject = ['$element', '$scope', '$compile']; ngModule.component('vnConfirm', { - template: require('./confirm.html'), + template: require('../dialog/dialog.html'), bindings: { + onOpen: '&?', onResponse: '&', question: '@', message: '@?' diff --git a/client/core/src/components/confirm/style.scss b/client/core/src/components/confirm/style.scss deleted file mode 100644 index b19288ecbb..0000000000 --- a/client/core/src/components/confirm/style.scss +++ /dev/null @@ -1,5 +0,0 @@ - -vn-confirm .dialog-title { - color:#424242; - font-family: vn-font-bold; -} diff --git a/client/core/src/components/dialog/dialog.html b/client/core/src/components/dialog/dialog.html index 4ccb39e008..98223d6e51 100644 --- a/client/core/src/components/dialog/dialog.html +++ b/client/core/src/components/dialog/dialog.html @@ -1,12 +1,13 @@
-
+
+
diff --git a/client/core/src/components/dialog/dialog.js b/client/core/src/components/dialog/dialog.js index 77873b3807..c4adcfbb3a 100644 --- a/client/core/src/components/dialog/dialog.js +++ b/client/core/src/components/dialog/dialog.js @@ -4,44 +4,44 @@ import './style.scss'; /** * Dialog component. + * + * @property {HTMLElement} body The dialog HTML body + * @property {HTMLElement} buttons The dialog HTML buttons */ export default class Dialog extends Component { - /** - * Contructor. - * - * @param {HTMLElement} $element The HTML element object - */ - constructor($element) { + constructor($element, $transclude) { super($element); - $element.addClass('vn-dialog'); - this.dialog = $element[0].firstChild; - this.element.addEventListener('mousedown', event => this.onBackgroundMouseDown(event)); + this.shown = false; + this.$element.addClass('vn-dialog'); + this.element.addEventListener('mousedown', + e => this.onBackgroundMouseDown(e)); + + if ($transclude) { + $transclude(tClone => { + this.body = tClone[0]; + }, null, 'body'); + $transclude(tClone => { + this.buttons = tClone[0]; + }, null, 'buttons'); + } + } + set body(value) { + this.element.querySelector('.body').appendChild(value); + } + set buttons(value) { + this.element.querySelector('.buttons').appendChild(value); } /** * Displays the dialog to the user. */ show() { - let style = this.dialog.style; - let window = this.window; - let innerWidth = window.innerWidth; - let innerHeight = window.innerHeight; - let width = this.dialog.offsetWidth; - let height = this.dialog.offsetHeight; - let screenMargin = 20; - let dblMargin = screenMargin * 2; - - if (width + screenMargin > innerWidth) { - width = innerWidth - dblMargin; - style.width = width + 'px'; - } - if (height + screenMargin > innerHeight) { - height = innerHeight - dblMargin; - style.height = height + 'px'; - } - - this.keypressHandler = event => this.onKeypress(event); + if (this.shown) return; + this.shown = true; + this.keypressHandler = e => this.onKeypress(e); this.document.addEventListener('keypress', this.keypressHandler); - this.element.style.display = 'block'; + this.element.style.display = 'flex'; + this.transitionTimeout = + setTimeout(() => this.$element.addClass('shown'), 30); if (this.onOpen) this.onOpen(); @@ -65,19 +65,21 @@ export default class Dialog extends Component { cancel = this.onResponse({response: response}); return cancel; } - realHide() { + if (!this.shown) return; this.element.style.display = 'none'; this.document.removeEventListener('keypress', this.keypressHandler); this.lastEvent = null; + this.shown = false; + this.transitionTimeout = + setTimeout(() => this.$element.removeClass('shown'), 30); } - onButtonClick(event) { - let buttonBar = this.element.querySelector('.button-bar'); - let buttons = buttonBar.querySelector('tpl-buttons'); + let buttons = this.element.querySelector('.buttons'); + let tplButtons = buttons.querySelector('tpl-buttons'); let node = event.target; - while (node.parentNode != buttons) { - if (node == buttonBar) return; + while (node.parentNode != tplButtons) { + if (node == buttons) return; node = node.parentNode; } @@ -85,28 +87,28 @@ export default class Dialog extends Component { let cancel = this.fireResponse(response); if (cancel !== false) this.realHide(); } - onDialogMouseDown(event) { this.lastEvent = event; } - onBackgroundMouseDown(event) { if (event != this.lastEvent) this.hide(); } - onKeypress(event) { if (event.keyCode == 27) // Esc this.hide(); } + $onDestroy() { + clearTimeout(this.transitionTimeout); + } } -Dialog.$inject = ['$element']; +Dialog.$inject = ['$element', '$transclude']; ngModule.component('vnDialog', { template: require('./dialog.html'), transclude: { - tplBody: 'tplBody', - tplButtons: 'tplButtons' + body: 'tplBody', + buttons: 'tplButtons' }, bindings: { onOpen: '&?', diff --git a/client/core/src/components/dialog/dialog.spec.js b/client/core/src/components/dialog/dialog.spec.js index e13242d6bf..e81eb64453 100644 --- a/client/core/src/components/dialog/dialog.spec.js +++ b/client/core/src/components/dialog/dialog.spec.js @@ -9,168 +9,45 @@ describe('Component vnDialog', () => { beforeEach(angular.mock.inject(_$componentController_ => { $componentController = _$componentController_; - $element = angular.element('
'); - controller = $componentController('vnDialog', {$element}); + $element = angular.element(''); + controller = $componentController('vnDialog', {$element: $element, $transclude: null}); })); describe('show()', () => { - it(`should define keypressHandler function, call addEventListener function and define element.style.display to block then call onOpen function`, () => { + it(`should handle escape keypress event, define element.style.display to not none and call onOpen function`, () => { window.innerHeight = 600; window.innerWidth = 800; + controller.dialog = {style: {display: 'none'}}; controller.onOpen = () => {}; - controller.dialog = {style: {}, offsetWidth: 780, offsetHeight: 581}; - spyOn(controller.document, 'addEventListener'); spyOn(controller, 'onOpen'); controller.show(); - expect(controller.keypressHandler).toBeDefined(); - expect(controller.document.addEventListener).toHaveBeenCalledWith('keypress', controller.keypressHandler); - expect(controller.element.style.display).toEqual('block'); + expect(controller.element.style.display).not.toEqual('none'); expect(controller.onOpen).toHaveBeenCalledWith(); }); - - it(`should define keypressHandler function, call addEventListener function and define element.style.display to block and never call onOpen function`, () => { - window.innerHeight = 600; - window.innerWidth = 800; - controller.dialog = {style: {}, offsetWidth: 781, offsetHeight: 581}; - spyOn(controller.document, 'addEventListener'); - controller.show(); - - expect(controller.keypressHandler).toBeDefined(); - expect(controller.document.addEventListener).toHaveBeenCalledWith('keypress', controller.keypressHandler); - expect(controller.element.style.display).toEqual('block'); - expect(controller.onOpen).not.toBeDefined(); - }); }); describe('hide()', () => { - it(`should call fireResponse() and realHide()`, () => { - spyOn(controller, 'fireResponse'); - spyOn(controller, 'realHide'); + it(`should call onResponse()`, () => { + controller.onResponse = () => {}; + spyOn(controller, 'onResponse'); controller.hide(); - expect(controller.fireResponse).toHaveBeenCalledWith(); - expect(controller.realHide).toHaveBeenCalledWith(); + expect(controller.onResponse).toHaveBeenCalled(); }); }); describe('fireResponse()', () => { - it(`should return cancel as false`, () => { - let result = controller.fireResponse('I am the answer!'); - - expect(controller.onResponse).not.toBeDefined(); - expect(result).toEqual(false); - }); - - it(`should return onResponse()`, () => { - let text = 'I am the answer!'; - controller.onResponse = () => { - return {response: text}; + it(`should call onResponse()`, () => { + let resposneRes; + controller.onResponse = response => { + resposneRes = response; + return false; }; - let result = controller.fireResponse(text); + let responseRet = controller.fireResponse('answer'); - expect(result.response).toEqual(text); - }); - }); - - describe('realHide()', () => { - it(`should set element.style.display and lastEvent properties and call removeEvenListener()`, () => { - spyOn(controller.document, 'removeEventListener'); - - expect(controller.element.style.display).not.toEqual('none'); - expect(controller.lastEvent).not.toBeDefined(); - controller.realHide(); - - expect(controller.element.style.display).toEqual('none'); - expect(controller.document.removeEventListener).toHaveBeenCalledWith('keypress', controller.keypressHandler); - expect(controller.lastEvent).toEqual(null); - }); - }); - - describe('onButtonClick()', () => { - it(`should call realHide if cancel isn't false`, () => { - controller.element = document.createElement('div'); - controller.element.className = 'tpl-buttons'; - let childElement = document.createElement('div'); - childElement.className = 'button-bar'; - controller.element.appendChild(childElement); - let event = {target: controller.element, attribute: true}; - spyOn(controller, 'realHide'); - spyOn(controller, 'fireResponse').and.returnValue(true); - controller.onButtonClick(event); - - expect(controller.realHide).toHaveBeenCalledWith(); - }); - - it(`should call fireResponse with the value of response`, () => { - controller.element = document.createElement('div'); - controller.element.className = 'tpl-buttons'; - let childElement = document.createElement('div'); - childElement.className = 'button-bar'; - controller.element.appendChild(childElement); - let attribute = document.createAttribute('response'); - attribute.value = 'I am the response!'; - controller.element.setAttributeNode(attribute); - spyOn(controller, 'fireResponse'); - let event = {target: controller.element}; - controller.onButtonClick(event); - - expect(controller.fireResponse).toHaveBeenCalledWith('I am the response!'); - }); - }); - - describe('onDialogMouseDown()', () => { - it(`should set controller's lastEvent property`, () => { - controller.element = document.createElement('div'); - let event = {target: controller.element}; - controller.onDialogMouseDown(event); - - expect(controller.lastEvent).toEqual(event); - }); - }); - - describe('onBackgroundMouseDown()', () => { - it(`shouldn't call hide() function as event equals lastEvent`, () => { - controller.element = document.createElement('div'); - let event = {target: controller.element}; - controller.lastEvent = event; - spyOn(controller, 'hide'); - controller.onBackgroundMouseDown(event); - - expect(controller.hide).not.toHaveBeenCalledWith(); - }); - - it(`should call hide() function as event doesn't equal lastEvent`, () => { - controller.element = document.createElement('div'); - let event = {target: controller.element}; - controller.lastEvent = event; - controller.lastEvent = 'the singularity event!'; - spyOn(controller, 'hide'); - controller.onBackgroundMouseDown(event); - - expect(controller.hide).toHaveBeenCalledWith(); - }); - }); - - describe('onKeypress()', () => { - it(`should call hide() if the key pressed equal the code 27`, () => { - controller.element = document.createElement('div'); - let event = {target: controller.element}; - event.keyCode = 27; - spyOn(controller, 'hide'); - controller.onKeypress(event); - - expect(controller.hide).toHaveBeenCalledWith(); - }); - - it(`should't call hide() as the key pressed equal the code 999`, () => { - controller.element = document.createElement('div'); - let event = {target: controller.element}; - event.keyCode = 999; - spyOn(controller, 'hide'); - controller.onKeypress(event); - - expect(controller.hide).not.toHaveBeenCalledWith(); + expect(resposneRes).toEqual({response: 'answer'}); + expect(responseRet).toEqual(false); }); }); }); diff --git a/client/core/src/components/dialog/style.scss b/client/core/src/components/dialog/style.scss index 73bd5ba190..d05a587cd5 100644 --- a/client/core/src/components/dialog/style.scss +++ b/client/core/src/components/dialog/style.scss @@ -1,33 +1,19 @@ .vn-dialog { display: none; - z-index: 100; + justify-content: center; + align-items: center; + z-index: 50; position: fixed; left: 0; top: 0; height: 100%; width: 100%; - background-color: rgba(1,1,1,.4); + background-color: rgba(1, 1, 1, .6); + opacity: 0; + transition: opacity 300ms ease-in-out; - button.close { - position: absolute; - top: 0; - right: 0; - border-style: none; - background-color: transparent; - padding: .3em; - cursor: pointer; - - vn-icon { - display: block; - - i { - display: block; - } - } - - &:hover { - background-color: rgba(0, 0, 0, .1); - } + &.shown { + opacity: 1; } & > div { position: relative; @@ -35,34 +21,47 @@ background-color: white; border-radius: .2em; overflow: auto; - top: 50%; - left: 50%; padding: 2em; box-sizing: border-box; - width: 28em; - margin-top: -10em; - margin-left: -14em; - } - .button-bar { - margin-top: 1.5em; - text-align: right; - + tpl-body { + display: block; + width: 20em; + } button { - background: none; - border: none; text-transform: uppercase; - font-size: 1.1em; - color: #ffa410; - font-family: vn-font-bold; + background-color: transparent; + border: none; cursor: pointer; - padding: .5em; - margin: -0.5em; - margin-left: .5em; - + transition: background-color 250ms; + border-radius: .1em; + &:hover { background-color: rgba(1,1,1,.1); } } + & > button.close { + position: absolute; + top: 0; + right: 0; + padding: .3em; + + & > vn-icon { + display: block; + color: #666; + } + } + & > form > .buttons { + margin-top: 1.5em; + text-align: right; + + button { + color: #ffa410; + font-family: vn-font-bold; + padding: .7em; + margin: -0.7em; + margin-left: .7em; + } + } } } diff --git a/client/core/src/components/drop-down/style.scss b/client/core/src/components/drop-down/style.scss index d4c28f734f..c348241954 100644 --- a/client/core/src/components/drop-down/style.scss +++ b/client/core/src/components/drop-down/style.scss @@ -1,6 +1,6 @@ vn-drop-down { position: absolute; - z-index: 9999; + z-index: 10; padding: 0 15px; margin-left: -15px; background: transparent; diff --git a/client/core/src/components/icon/style.css b/client/core/src/components/icon/style.css index 881f6d3041..c49350de3a 100644 --- a/client/core/src/components/icon/style.css +++ b/client/core/src/components/icon/style.css @@ -1,8 +1,8 @@ vn-icon { - display: inline; + display: inline-block; font-size: 18pt; } -vn-icon > i { +vn-icon > i.material-icons { display: block; - font-size: inherit !important; + font-size: inherit; } diff --git a/client/core/src/components/snackbar/snackbar.html b/client/core/src/components/snackbar/snackbar.html index 6f99d5fdbb..60eff1e46d 100644 --- a/client/core/src/components/snackbar/snackbar.html +++ b/client/core/src/components/snackbar/snackbar.html @@ -1,4 +1,4 @@ -
-
- +
+ +
diff --git a/client/core/src/components/snackbar/snackbar.js b/client/core/src/components/snackbar/snackbar.js index 89ab60ec38..18a4b516f9 100644 --- a/client/core/src/components/snackbar/snackbar.js +++ b/client/core/src/components/snackbar/snackbar.js @@ -1,12 +1,19 @@ import ngModule from '../../module'; +import Component from '../../lib/component'; +import './style.scss'; /** * A simple component to show non-obstructive notifications to the user. */ -export default class Controller { - constructor($element) { +export default class Controller extends Component { + constructor($element, $translate) { + super($element); + this.$translate = $translate; + this.shown = false; this.snackbar = $element[0].firstChild; - componentHandler.upgradeElement(this.snackbar); + this.$snackbar = angular.element(this.snackbar); + this.button = $element[0].querySelector('button'); + this.textNode = this.snackbar.querySelector('.text'); } /** * Shows a notification. @@ -14,10 +21,76 @@ export default class Controller { * @param {Object} data The message data */ show(data) { - this.snackbar.MaterialSnackbar.showSnackbar(data); + this.clearTimeouts(); + this.shown = true; + this.textNode.textContent = data.message; + this.actionHandler = data.actionHandler; + + this.button.textContent = + data.actionText || this.$translate.instant('Hide'); + + this.documentClickHandler = e => this.onDocumentClick(e); + document.addEventListener('click', this.documentClickHandler); + this.timeoutId = setTimeout(() => this.hide(), + data.timeout || 6000); + + this.transitionTimeout = + setTimeout(() => this.$snackbar.addClass('shown'), 30); + } + /** + * Shows an error. + * + * @param {Object} data The message data + */ + showError(data) { + this.$snackbar.addClass('error'); + this.show(data); + } + /** + * Hides the snackbar. + */ + hide() { + if (!this.shown) return; + clearTimeout(this.timeoutId); + document.removeEventListener('click', this.documentClickHandler); + this.shown = false; + this.hideTimeout = setTimeout(() => this.onTransitionEnd(), 250); + + this.transitionTimeout = + setTimeout(() => this.$snackbar.removeClass('shown'), 30); + } + onTransitionEnd() { + this.$snackbar.removeClass('error'); + this.textNode.textContent = ''; + this.button.textContent = ''; + this.actionHandler = null; + } + onDocumentClick(event) { + if (event === this.event) return; + this.hide(); + } + onSnackbarClick(event) { + this.event = event; + } + onButtonClick() { + if (this.actionHandler) + this.actionHandler(); + else + this.hide(); + } + clearTimeouts() { + clearTimeout(this.timeoutId); + clearTimeout(this.hideTimeout); + clearTimeout(this.transitionTimeout); + this.timeoutId = null; + this.hideTimeout = null; + this.transitionTimeout = null; + } + $onDestroy() { + this.clearTimeouts(); } } -Controller.$inject = ['$element']; +Controller.$inject = ['$element', '$translate']; ngModule.component('vnSnackbar', { template: require('./snackbar.html'), diff --git a/client/core/src/components/snackbar/style.scss b/client/core/src/components/snackbar/style.scss new file mode 100644 index 0000000000..5132802433 --- /dev/null +++ b/client/core/src/components/snackbar/style.scss @@ -0,0 +1,48 @@ +vn-snackbar > div { + box-sizing: border-box; + background-color: #333; + color: white; + position: fixed; + bottom: 0; + left: 50%; + width: 20em; + margin-left: -10em; + padding: 1em; + border-top-left-radius: .2em; + border-top-right-radius: .2em; + transform: translateY(10em); + transition: transform 300ms ease-in-out; + z-index: 100; + box-shadow: 0 0 .4em rgba(1,1,1,.4); + + &.shown { + transform: translateY(0); + } + &.notice { + background-color: #1e88e5; + + & > button { + color: rgba(1, 1, 1, 0.6); + } + } + &.error { + background-color: #c62828; + + & > button { + color: rgba(1, 1, 1, 0.6); + } + } + & > button { + cursor: pointer; + float: right; + text-transform: uppercase; + border: none; + background-color: transparent; + font-weight: bold; + color: #ffab40; + padding: 1em; + margin: -1em; + padding-left: 1.5em; + margin-left: 0; + } +} \ No newline at end of file diff --git a/client/core/src/components/textfield/style.scss b/client/core/src/components/textfield/style.scss index 0f9d95c8ec..81e5ca74ce 100644 --- a/client/core/src/components/textfield/style.scss +++ b/client/core/src/components/textfield/style.scss @@ -10,9 +10,33 @@ vn-textfield { margin: 21px 0px; background: white; opacity: 1; - z-index: 9999; + z-index: 1; color: #aaa; } + .mdl-textfield { + width: 100%; + } + .mdl-textfield__error { + visibility: visible; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + width: 100%; + } + .mdl-textfield.invalid { + .mdl-textfield__input { + border-color: #d50000; + box-shadow: none; + } + .mdl-textfield__label::after { + background-color: #d50000; + } + } + .mdl-textfield--floating-label.invalid .mdl-textfield__label { + color: #d50000; + font-size: 12px; + top: 4px; + } .material-icons { font-size: 18px; float: right; diff --git a/client/core/src/directives/id.js b/client/core/src/directives/id.js index 75865751bb..193d84781a 100644 --- a/client/core/src/directives/id.js +++ b/client/core/src/directives/id.js @@ -2,8 +2,8 @@ import ngModule from '../module'; import {kebabToCamel} from '../lib/string'; /** - * Registers the element controller into its scope as a - * property whose name is the directive value. + * Registers the element controller into the scope as a property whose name is + * the directive value transformed to lowerCamelCase. * * @return {Object} The directive */ @@ -12,7 +12,8 @@ export function directive() { restrict: 'A', link: function($scope, $element, $attrs) { let id = kebabToCamel($attrs.vnId); - let controller = $element.controller($element[0].tagName.toLowerCase()); + let controller = $element[0].$ctrl ? + $element[0].$ctrl : $element.controller($element[0].tagName.toLowerCase()); if (!id) throw new Error(`vnId: Attribute can't be null`); diff --git a/client/core/src/directives/specs/dialog.spec.js b/client/core/src/directives/specs/dialog.spec.js index f2d20ae0e2..12616fc195 100644 --- a/client/core/src/directives/specs/dialog.spec.js +++ b/client/core/src/directives/specs/dialog.spec.js @@ -24,7 +24,7 @@ describe('Directive dialog', () => { $componentController = _$componentController_; _$httpBackend_.when('GET', /\/locale\/\w+\/[a-z]{2}\.json/).respond({}); $element = angular.element('
'); - controller = $componentController('vnDialog', {$element}); + controller = $componentController('vnDialog', {$element: $element, $transclude: null}); })); it('should call show() function if dialog is a instance of vnDialog', () => { diff --git a/client/core/src/lib/app.js b/client/core/src/lib/app.js index 7cbcb3b138..5a41d209cf 100644 --- a/client/core/src/lib/app.js +++ b/client/core/src/lib/app.js @@ -11,15 +11,13 @@ export default class App { this.loaderStatus = 0; this.$rootScope = $rootScope; } - show(message) { - this.timeout = window.snackbarTimeout || 2000; - if (this.snackbar) this.snackbar.show({message: message, timeout: this.timeout}); - } showMessage(message) { - this.show(message); + if (this.snackbar) + this.snackbar.show({message: message}); } showError(message) { - this.show(`Error: ${message}`); + if (this.snackbar) + this.snackbar.showError({message: `Error: ${message}`}); } pushLoader() { this.loaderStatus++; diff --git a/client/core/src/lib/component.js b/client/core/src/lib/component.js index 2184b72fd5..36380a5ed6 100644 --- a/client/core/src/lib/component.js +++ b/client/core/src/lib/component.js @@ -21,9 +21,10 @@ export default class Component { * @param {$rootScope.Scope} $scope The element scope */ constructor($element, $scope) { - this.$ = $scope; - this.$element = $element; this.element = $element[0]; + this.element.$ctrl = this; + this.$element = $element; + this.$ = $scope; } } Component.$inject = ['$element', '$scope']; diff --git a/client/core/src/locale/en.yml b/client/core/src/locale/en.yml index 3fe077dcbc..a89a8ca8dd 100644 --- a/client/core/src/locale/en.yml +++ b/client/core/src/locale/en.yml @@ -4,4 +4,7 @@ Close: Close Clear: Clear Save: Save Add: Add -Search: Search \ No newline at end of file +Search: Search +Show More: Show More +No more results: No more results +Hide: Hide \ No newline at end of file diff --git a/client/core/src/locale/es.yml b/client/core/src/locale/es.yml index bd2e3ee866..2b63865702 100644 --- a/client/core/src/locale/es.yml +++ b/client/core/src/locale/es.yml @@ -6,4 +6,5 @@ Save: Guardar Add: Añadir Search: Buscar Show More: Ver más -No more results : No hay más resultados \ No newline at end of file +No more results: No hay más resultados +Hide: Ocultar \ No newline at end of file diff --git a/client/core/src/styles/mdl-override.css b/client/core/src/styles/mdl-override.css index d9c0fcf873..d781e5817d 100644 --- a/client/core/src/styles/mdl-override.css +++ b/client/core/src/styles/mdl-override.css @@ -6,11 +6,6 @@ body { line-height: initial; font-size: 12pt; } - -.mdl-textfield { - width: 100%; -} - .mdl-button { font-weight: bolder; color: #ffa410; @@ -32,33 +27,3 @@ body { background-color: #ff9400 !important; } -.mdl-dialog__actions--full-width>*{ - text-align: center; -} - -.mdl-dialog{ - width: 400px; - font-family: vn-font; - line-height: 60px; - text-align: center; -} - -.mdl-textfield__error { - visibility: visible; - white-space: nowrap; - overflow: hidden; - text-overflow: ellipsis; - width: 100%; -} -.mdl-textfield.invalid .mdl-textfield__input { - border-color: #d50000; - box-shadow: none; -} -.mdl-textfield.invalid .mdl-textfield__label::after { - background-color: #d50000; -} -.mdl-textfield--floating-label.invalid .mdl-textfield__label { - color: #d50000; - font-size: 12px; - top: 4px; -} diff --git a/e2e/helpers/extensions.js b/e2e/helpers/extensions.js index d8e3151571..273d4fdd24 100644 --- a/e2e/helpers/extensions.js +++ b/e2e/helpers/extensions.js @@ -1,6 +1,7 @@ import config from './config.js'; import Nightmare from 'nightmare'; import selectors from './selectors.js'; +import {URL} from 'url'; function child(selector, childNumber) { let aux = selector.split(' '); @@ -17,6 +18,37 @@ Nightmare.action('login', function(done) { .then(done); }); +Nightmare.action('changeLanguageToEnglish', function(done) { + this.wait('#lang-button') + .evaluate(selector => { + return document.querySelector(selector).title; + }, '#lang-button') + .then(title => { + if (title === 'Change language') { + this.then(done); + } else { + this.click('#lang-button') + .click('#langs > li[name="en"]') + .then(done); + } + }); +}); + +Nightmare.action('waitForLogin', function(done) { + this.login() + .waitForURL('#!/') + .url() + .changeLanguageToEnglish() + .then(done); +}); + +Nightmare.action('urlParsed', function(done) { + this.url() + .then(url => { + done(null, new URL(url)); + }); +}); + Nightmare.action('getInnerText', function(selector, done) { this.wait(selector) .evaluate_now(function(elementToSelect) { @@ -134,29 +166,39 @@ Nightmare.action('waitForTextInInput', function(selector, name, done) { .then(done); }); -Nightmare.action('changeLanguageToEnglish', function(done) { - this.wait('#lang-button') - .evaluate(selector => { - return document.querySelector(selector).title; - }, '#lang-button') - .then(title => { - if (title === 'Change language') { - this.then(done); - } else { - this.click('#lang-button') - .click('#langs > li[name="en"]') - .then(done); - } - }); +Nightmare.action('waitForInnerText', function(selector, done) { + this.wait(selector) + .wait(selector => { + let innerText = document.querySelector(selector).innerText; + return innerText != null && innerText != ''; + }, selector) + .evaluate_now(selector => { + return document.querySelector(selector).innerText; + }, done, selector); +}); + +Nightmare.action('waitForEmptyInnerText', function(selector, done) { + this.wait(selector => { + return document.querySelector(selector).innerText == ''; + }, selector) + .then(done); }); Nightmare.action('waitForSnackbarReset', function(done) { - this.wait(() => { - return document.querySelector('vn-snackbar').innerText === ''; - }) + this.click('vn-snackbar button') + .waitForEmptyInnerText('vn-snackbar .text') .then(done); }); +Nightmare.action('waitForSnackbar', function(done) { + this.wait(200) + .waitForInnerText('vn-snackbar .text') + .then(value => { + this.waitForSnackbarReset() + .then(() => done(null, value)); + }); +}); + Nightmare.action('waitForURL', function(hashURL, done) { this.wait(hash => { return document.location.hash.includes(hash); diff --git a/e2e/helpers/helpers.js b/e2e/helpers/helpers.js new file mode 100644 index 0000000000..d2d0b4af99 --- /dev/null +++ b/e2e/helpers/helpers.js @@ -0,0 +1,19 @@ +import createNightmare from './nightmare'; +export default myCreateNightmare; + +function myCreateNightmare() { + let nightmare = createNightmare(); + nightmare.header('Accept-Language', 'en'); + + beforeAll(() => { + return nightmare + .waitForLogin(); + }); + + afterAll(() => { + return nightmare + .end(); + }); + + return nightmare; +} diff --git a/e2e/helpers/nightmare.js b/e2e/helpers/nightmare.js index 4b524eb022..9f28d01514 100644 --- a/e2e/helpers/nightmare.js +++ b/e2e/helpers/nightmare.js @@ -22,3 +22,5 @@ export default function createNightmare(width = 1280, height = 720) { }); return nightmare; } + +jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000; diff --git a/e2e/helpers/nightmareModifiers.js b/e2e/helpers/nightmareModifiers.js index 3636533d8d..e69de29bb2 100644 --- a/e2e/helpers/nightmareModifiers.js +++ b/e2e/helpers/nightmareModifiers.js @@ -1,2 +0,0 @@ -// snackbar default 2500 and jasmine timeout should be 10000 -window.snackbarTimeout = 400; diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 38d312ffb2..d8a99d5740 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -10,7 +10,7 @@ export default { globalItems: { topBar: `${components.vnTopbar}`, logOutButton: `${components.vnIcon}[icon="exit_to_app"]`, - snackbarIsActive: '.mdl-snackbar--active > .mdl-snackbar__text', + snackbarIsActive: 'vn-snackbar .text', applicationsMenuButton: `${components.vnIcon}[icon="apps"]`, applicationsMenuVisible: `${components.vnMainMenu} .is-visible > div`, clientsButton: `${components.vnMainMenu} > div > ul > li:nth-child(1)` @@ -54,7 +54,7 @@ export default { socialNameInput: `${components.vnTextfield}[name="socialName"]`, fiscalIdInput: `${components.vnTextfield}[name="fi"]`, equalizationTaxCheckboxLabel: `${components.vnCheck}[label='Is equalizated'] > label > input`, - acceptPropagationButton: `body > vn-app > vn-vertical > vn-vertical > vn-client-card > vn-main-block > vn-horizontal > vn-one > vn-vertical > vn-client-fiscal-data > vn-confirm > div > form > div.button-bar > tpl-buttons > button:nth-child(2)`, + acceptPropagationButton: `vn-client-fiscal-data > vn-confirm button[response=ACCEPT]`, addressInput: `${components.vnTextfield}[name="street"]`, cityInput: `${components.vnTextfield}[name="city"]`, postcodeInput: `${components.vnTextfield}[name="postcode"]`, @@ -77,7 +77,7 @@ export default { payMethodOptionOne: `${components.vnAutocomplete}[field="$ctrl.client.payMethodFk"] > vn-vertical > vn-drop-down > vn-vertical:not(.ng-hide) > vn-auto:nth-child(2) > ul > li:nth-child(2)`, IBANInput: `${components.vnTextfield}[name="iban"]`, dueDayInput: `${components.vnTextfield}[name="dueDay"]`, - cancelNotificationButton: 'vn-client-billing-data > vn-dialog tpl-buttons > button:nth-child(1)', + cancelNotificationButton: 'vn-client-billing-data > vn-confirm button[response=CANCEL]', receivedCoreVNHCheckbox: `${components.vnCheck}[label='Received core VNH'] > label > input`, receivedCoreVNLCheckbox: `${components.vnCheck}[label='Received core VNL'] > label > input`, receivedB2BVNLCheckbox: `${components.vnCheck}[label='Received B2B VNL'] > label > input`, diff --git a/e2e/paths/client-module/01_create_client.spec.js b/e2e/paths/client-module/01_create_client.spec.js index f8a32a1faa..78a521ecec 100644 --- a/e2e/paths/client-module/01_create_client.spec.js +++ b/e2e/paths/client-module/01_create_client.spec.js @@ -1,48 +1,21 @@ -import config from '../../helpers/config.js'; -import createNightmare from '../../helpers/nightmare'; -import selectors from '../../helpers/selectors.js'; -import {catchErrors} from '../../../services/utils/jasmineHelpers'; -const nightmare = createNightmare(); -const moduleAccessViewHashURL = '#!/'; - -jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000; +import selectors from '../../helpers/selectors'; +import createNightmare from '../../helpers/helpers'; describe('create client path', () => { - it('should log in', done => { - nightmare - .login() - .waitForURL(moduleAccessViewHashURL) - .url() - .then(url => { - expect(url).toEqual(config.url + moduleAccessViewHashURL); - done(); - }) - .catch(catchErrors(done)); - }); + let nightmare = createNightmare(); - it('should make sure the language is English', done => { - nightmare - .changeLanguageToEnglish() - .then(() => { - done(); - }) - .catch(catchErrors(done)); - }); - - it('should access to the clients index by clicking the clients button', done => { - nightmare + it('should access to the clients index by clicking the clients button', () => { + return nightmare .click(selectors.moduleAccessView.clientsSectionButton) .wait(selectors.clientsIndex.createClientButton) - .url() + .urlParsed() .then(url => { - expect(url).toEqual(config.url + '#!/clients'); - done(); - }) - .catch(catchErrors(done)); + expect(url.hash).toEqual('#!/clients'); + }); }); - it(`should search for the user Carol Danvers to confirm it isn't created yet`, done => { - nightmare + it(`should search for the user Carol Danvers to confirm it isn't created yet`, () => { + return nightmare .wait(selectors.clientsIndex.searchResult) .type(selectors.clientsIndex.searchClientInput, 'Carol Danvers') .click(selectors.clientsIndex.searchButton) @@ -50,142 +23,107 @@ describe('create client path', () => { .countSearchResults(selectors.clientsIndex.searchResult) .then(result => { expect(result).toEqual(0); - done(); - }) - .catch(catchErrors(done)); + }); }); - it('should access to the create client view by clicking the create-client floating button', done => { - nightmare + it('should access to the create client view by clicking the create-client floating button', () => { + return nightmare .click(selectors.clientsIndex.createClientButton) .wait(selectors.createClientView.createButton) - .url() + .urlParsed() .then(url => { - expect(url).toEqual(config.url + '#!/create'); - done(); - }) - .catch(catchErrors(done)); + expect(url.hash).toEqual('#!/create'); + }); }); - it('should receive an error when clicking the create button having all the form fields empty', done => { - nightmare + it('should receive an error when clicking the create button having all the form fields empty', () => { + return nightmare .click(selectors.createClientView.createButton) - .wait(selectors.globalItems.snackbarIsActive) - .getInnerText(selectors.globalItems.snackbarIsActive) + .waitForSnackbar() .then(result => { expect(result).toEqual('Some fields are invalid'); - done(); - }) - .catch(catchErrors(done)); + }); }); - it('should receive an error when clicking the create button having all the form fields empty but name', done => { - nightmare - .waitForSnackbarReset() + it('should receive an error when clicking the create button having all the form fields empty but name', () => { + return nightmare .type(selectors.createClientView.name, 'Carol Danvers') .click(selectors.createClientView.createButton) - .wait(selectors.globalItems.snackbarIsActive) - .getInnerText(selectors.globalItems.snackbarIsActive) + .waitForSnackbar() .then(result => { expect(result).toContain('Some fields are invalid'); - done(); - }) - .catch(catchErrors(done)); + }); }); - it('should receive an error when clicking the create button having all the form fields empty but Tax Number', done => { - nightmare - .waitForSnackbarReset() + it('should receive an error when clicking the create button having all the form fields empty but Tax Number', () => { + return nightmare .clearInput(selectors.createClientView.name) .type(selectors.createClientView.taxNumber, 'AVG tax') .click(selectors.createClientView.createButton) - .wait(selectors.globalItems.snackbarIsActive) - .getInnerText(selectors.globalItems.snackbarIsActive) + .waitForSnackbar() .then(result => { expect(result).toContain('Some fields are invalid'); - done(); - }) - .catch(catchErrors(done)); + }); }); - it('should receive an error when clicking the create button having all the form fields empty but Business Name', done => { - nightmare - .waitForSnackbarReset() + it('should receive an error when clicking the create button having all the form fields empty but Business Name', () => { + return nightmare .clearInput(selectors.createClientView.taxNumber) .type(selectors.createClientView.socialName, 'Avengers team') .click(selectors.createClientView.createButton) - .wait(selectors.globalItems.snackbarIsActive) - .getInnerText(selectors.globalItems.snackbarIsActive) + .waitForSnackbar() .then(result => { expect(result).toContain('Some fields are invalid'); - done(); - }) - .catch(catchErrors(done)); + }); }); - it('should receive an error when clicking the create button having all the form fields empty but User Name', done => { - nightmare - .waitForSnackbarReset() + it('should receive an error when clicking the create button having all the form fields empty but User Name', () => { + return nightmare .clearInput(selectors.createClientView.socialName) .type(selectors.createClientView.userName, 'CaptainMarvel') .click(selectors.createClientView.createButton) - .wait(selectors.globalItems.snackbarIsActive) - .getInnerText(selectors.globalItems.snackbarIsActive) + .waitForSnackbar() .then(result => { expect(result).toContain('Some fields are invalid'); - done(); - }) - .catch(catchErrors(done)); + }); }); - it('should receive an error when clicking the create button having all the form fields empty but email while email have incorrect format', done => { - nightmare - .waitForSnackbarReset() + it('should receive an error when clicking the create button having all the form fields empty but email while email have incorrect format', () => { + return nightmare .clearInput(selectors.createClientView.userName) .type(selectors.createClientView.email, 'I will save the Avengers!') .click(selectors.createClientView.createButton) - .wait(selectors.globalItems.snackbarIsActive) - .getInnerText(selectors.globalItems.snackbarIsActive) + .waitForSnackbar() .then(result => { expect(result).toEqual('Some fields are invalid'); - done(); - }) - .catch(catchErrors(done)); + }); }); - it('should receive an error when clicking the create button having all the form fields empty but email', done => { - nightmare - .waitForSnackbarReset() + it('should receive an error when clicking the create button having all the form fields empty but email', () => { + return nightmare .clearInput(selectors.createClientView.email) .type(selectors.createClientView.email, 'CarolDanvers@verdnatura.es') .click(selectors.createClientView.createButton) - .wait(selectors.globalItems.snackbarIsActive) - .getInnerText(selectors.globalItems.snackbarIsActive) + .waitForSnackbar() .then(result => { expect(result).toContain('Some fields are invalid'); - done(); - }) - .catch(catchErrors(done)); + }); }); - it('should receive an error when clicking the create button having all the form fields empty but sales person', done => { - nightmare + it('should receive an error when clicking the create button having all the form fields empty but sales person', () => { + return nightmare .waitToClick(selectors.createClientView.salesPersonInput) .waitToClick(selectors.createClientView.salesBruceBannerOption) .wait(200) .click(selectors.createClientView.createButton) - .wait(selectors.globalItems.snackbarIsActive) - .getInnerText(selectors.globalItems.snackbarIsActive) + .waitForSnackbar() .then(result => { expect(result).toContain('Some fields are invalid'); - done(); - }) - .catch(catchErrors(done)); + }); }); - it(`should create a new user with all it's data`, done => { - nightmare - .waitForSnackbarReset() + it(`should create a new user with all it's data`, () => { + return nightmare .wait(selectors.createClientView.email) .clearInput(selectors.createClientView.email) .type(selectors.createClientView.name, 'Carol Danvers') @@ -194,31 +132,26 @@ describe('create client path', () => { .type(selectors.createClientView.userName, 'CaptainMarvel') .type(selectors.createClientView.email, 'CarolDanvers@verdnatura.es') .click(selectors.createClientView.createButton) - .wait(selectors.globalItems.snackbarIsActive) - .getInnerText(selectors.globalItems.snackbarIsActive) + .waitForSnackbar() .then(result => { expect(result).toContain('Data saved!'); - done(); - }) - .catch(catchErrors(done)); + }); }); - it('should click on the Clients button of the top bar menu', done => { - nightmare + it('should click on the Clients button of the top bar menu', () => { + return nightmare .waitToClick(selectors.globalItems.applicationsMenuButton) .wait(selectors.globalItems.applicationsMenuVisible) .waitToClick(selectors.globalItems.clientsButton) .wait(selectors.clientsIndex.createClientButton) - .url() + .urlParsed() .then(url => { - expect(url).toEqual(config.url + '#!/clients'); - done(); - }) - .catch(catchErrors(done)); + expect(url.hash).toEqual('#!/clients'); + }); }); - it(`should search for the user Carol Danvers to confirm it exists`, done => { - nightmare + it(`should search for the user Carol Danvers to confirm it exists`, () => { + return nightmare .wait(selectors.clientsIndex.searchResult) .type(selectors.clientsIndex.searchClientInput, 'Carol Danvers') .click(selectors.clientsIndex.searchButton) @@ -226,8 +159,6 @@ describe('create client path', () => { .countSearchResults(selectors.clientsIndex.searchResult) .then(result => { expect(result).toEqual(1); - done(); - }) - .catch(catchErrors(done)); + }); }); }); diff --git a/e2e/paths/client-module/02_edit_basic_data.spec.js b/e2e/paths/client-module/02_edit_basic_data.spec.js index 1a96498446..82bef943ad 100644 --- a/e2e/paths/client-module/02_edit_basic_data.spec.js +++ b/e2e/paths/client-module/02_edit_basic_data.spec.js @@ -1,50 +1,23 @@ -import config from '../../helpers/config.js'; -import createNightmare from '../../helpers/nightmare'; import selectors from '../../helpers/selectors.js'; -import {catchErrors} from '../../../services/utils/jasmineHelpers'; -const nightmare = createNightmare(); -const moduleAccessViewHashURL = '#!/'; - -jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000; +import createNightmare from '../../helpers/helpers'; describe('Edit basicData path', () => { - it('should log in', done => { - nightmare - .login() - .waitForURL(moduleAccessViewHashURL) - .url() - .then(url => { - expect(url).toEqual(config.url + moduleAccessViewHashURL); - done(); - }) - .catch(catchErrors(done)); - }); + const nightmare = createNightmare(); - it('should make sure the language is English', done => { - nightmare - .changeLanguageToEnglish() - .then(() => { - done(); - }) - .catch(catchErrors(done)); - }); - - it('should click on the Clients button of the top bar menu', done => { - nightmare + it('should click on the Clients button of the top bar menu', () => { + return nightmare .waitToClick(selectors.globalItems.applicationsMenuButton) .wait(selectors.globalItems.applicationsMenuVisible) .waitToClick(selectors.globalItems.clientsButton) .wait(selectors.clientsIndex.createClientButton) - .url() + .urlParsed() .then(url => { - expect(url).toEqual(config.url + '#!/clients'); - done(); - }) - .catch(catchErrors(done)); + expect(url.hash).toEqual('#!/clients'); + }); }); - it('should search for the user Bruce Wayne', done => { - nightmare + it('should search for the user Bruce Wayne', () => { + return nightmare .wait(selectors.clientsIndex.searchResult) .type(selectors.clientsIndex.searchClientInput, 'Bruce Wayne') .click(selectors.clientsIndex.searchButton) @@ -52,42 +25,34 @@ describe('Edit basicData path', () => { .countSearchResults(selectors.clientsIndex.searchResult) .then(result => { expect(result).toEqual(1); - done(); - }) - .catch(catchErrors(done)); + }); }); - it('should click on the search result to access to the clients basic data', done => { - nightmare + it('should click on the search result to access to the clients basic data', () => { + return nightmare .waitForTextInElement(selectors.clientsIndex.searchResult, 'Bruce Wayne') .waitToClick(selectors.clientsIndex.searchResult) .waitForURL('basic-data') .url() .then(url => { expect(url).toContain('basic-data'); - done(); - }) - .catch(catchErrors(done)); + }); }); - it('should edit the name', done => { - nightmare + it('should edit the name', () => { + return nightmare .wait(selectors.clientBasicData.nameInput) .clearInput(selectors.clientBasicData.nameInput) .type(selectors.clientBasicData.nameInput, 'Ororo Munroe') .click(selectors.clientBasicData.saveButton) - .wait(selectors.globalItems.snackbarIsActive) - .getInnerText(selectors.globalItems.snackbarIsActive) + .waitForSnackbar() .then(result => { expect(result).toEqual('Data saved!'); - done(); - }) - .catch(catchErrors(done)); + }); }); - it('should confirm the name have been edited', done => { - nightmare - .waitForSnackbarReset() + it('should confirm the name have been edited', () => { + return nightmare .click(selectors.clientFiscalData.fiscalDataButton) .wait(selectors.clientFiscalData.addressInput) .click(selectors.clientBasicData.basicDataButton) @@ -95,29 +60,23 @@ describe('Edit basicData path', () => { .getInputValue(selectors.clientBasicData.nameInput) .then(result => { expect(result).toEqual('Ororo Munroe'); - done(); - }) - .catch(catchErrors(done)); + }); }); - it('should edit the contact name', done => { - nightmare + it('should edit the contact name', () => { + return nightmare .wait(selectors.clientBasicData.contactInput) .clearInput(selectors.clientBasicData.contactInput) .type(selectors.clientBasicData.contactInput, 'Black Panther') .click(selectors.clientBasicData.saveButton) - .wait(selectors.globalItems.snackbarIsActive) - .getInnerText(selectors.globalItems.snackbarIsActive) + .waitForSnackbar() .then(result => { expect(result).toEqual('Data saved!'); - done(); - }) - .catch(catchErrors(done)); + }); }); - it('should confirm the contact name have been edited', done => { - nightmare - .waitForSnackbarReset() + it('should confirm the contact name have been edited', () => { + return nightmare .click(selectors.clientFiscalData.fiscalDataButton) .wait(selectors.clientFiscalData.addressInput) .click(selectors.clientBasicData.basicDataButton) @@ -125,29 +84,23 @@ describe('Edit basicData path', () => { .getInputValue(selectors.clientBasicData.contactInput) .then(result => { expect(result).toEqual('Black Panther'); - done(); - }) - .catch(catchErrors(done)); + }); }); - it('should add the landline phone number', done => { - nightmare + it('should add the landline phone number', () => { + return nightmare .wait(selectors.clientBasicData.phoneInput) .clearInput(selectors.clientBasicData.phoneInput) .type(selectors.clientBasicData.phoneInput, '123456789') .click(selectors.clientBasicData.saveButton) - .wait(selectors.globalItems.snackbarIsActive) - .getInnerText(selectors.globalItems.snackbarIsActive) + .waitForSnackbar() .then(result => { expect(result).toEqual('Data saved!'); - done(); - }) - .catch(catchErrors(done)); + }); }); - it('should confirm the landline phone number have been added', done => { - nightmare - .waitForSnackbarReset() + it('should confirm the landline phone number have been added', () => { + return nightmare .click(selectors.clientFiscalData.fiscalDataButton) .wait(selectors.clientFiscalData.addressInput) .click(selectors.clientBasicData.basicDataButton) @@ -155,29 +108,23 @@ describe('Edit basicData path', () => { .getInputValue(selectors.clientBasicData.phoneInput) .then(result => { expect(result).toEqual('123456789'); - done(); - }) - .catch(catchErrors(done)); + }); }); - it('should add the mobile phone number', done => { - nightmare + it('should add the mobile phone number', () => { + return nightmare .wait(selectors.clientBasicData.mobileInput) .clearInput(selectors.clientBasicData.mobileInput) .type(selectors.clientBasicData.mobileInput, '987654321') .click(selectors.clientBasicData.saveButton) - .wait(selectors.globalItems.snackbarIsActive) - .getInnerText(selectors.globalItems.snackbarIsActive) + .waitForSnackbar() .then(result => { expect(result).toEqual('Data saved!'); - done(); - }) - .catch(catchErrors(done)); + }); }); - it('should confirm the mobile phone number have been added', done => { - nightmare - .waitForSnackbarReset() + it('should confirm the mobile phone number have been added', () => { + return nightmare .click(selectors.clientFiscalData.fiscalDataButton) .wait(selectors.clientFiscalData.addressInput) .click(selectors.clientBasicData.basicDataButton) @@ -185,29 +132,23 @@ describe('Edit basicData path', () => { .getInputValue(selectors.clientBasicData.mobileInput) .then(result => { expect(result).toEqual('987654321'); - done(); - }) - .catch(catchErrors(done)); + }); }); - it('should edit the email', done => { - nightmare + it('should edit the email', () => { + return nightmare .wait(selectors.clientBasicData.emailInput) .clearInput(selectors.clientBasicData.emailInput) .type(selectors.clientBasicData.emailInput, 'Storm@verdnatura.es') .click(selectors.clientBasicData.saveButton) - .wait(selectors.globalItems.snackbarIsActive) - .getInnerText(selectors.globalItems.snackbarIsActive) + .waitForSnackbar() .then(result => { expect(result).toEqual('Data saved!'); - done(); - }) - .catch(catchErrors(done)); + }); }); - it('should confirm the email have been edited', done => { - nightmare - .waitForSnackbarReset() + it('should confirm the email have been edited', () => { + return nightmare .click(selectors.clientFiscalData.fiscalDataButton) .wait(selectors.clientFiscalData.addressInput) .click(selectors.clientBasicData.basicDataButton) @@ -215,29 +156,23 @@ describe('Edit basicData path', () => { .getInputValue(selectors.clientBasicData.emailInput) .then(result => { expect(result).toEqual('Storm@verdnatura.es'); - done(); - }) - .catch(catchErrors(done)); + }); }); - it('should select the sales person', done => { - nightmare + it('should select the sales person', () => { + return nightmare .waitToClick(selectors.clientBasicData.salesPersonInput) .waitToClick(selectors.clientBasicData.salesBruceBannerOption) .wait(200) .waitToClick(selectors.clientBasicData.saveButton) - .wait(selectors.globalItems.snackbarIsActive) - .getInnerText(selectors.globalItems.snackbarIsActive) + .waitForSnackbar() .then(result => { expect(result).toEqual('Data saved!'); - done(); - }) - .catch(catchErrors(done)); + }); }); - it('should confirm the sales person have been selected', done => { - nightmare - .waitForSnackbarReset() + it('should confirm the sales person have been selected', () => { + return nightmare .waitToClick(selectors.clientFiscalData.fiscalDataButton) .wait(selectors.clientFiscalData.addressInput) .waitToClick(selectors.clientBasicData.basicDataButton) @@ -245,29 +180,23 @@ describe('Edit basicData path', () => { .getInputValue(selectors.clientBasicData.salesPersonInput) .then(result => { expect(result).toEqual('Bruce Banner'); - done(); - }) - .catch(catchErrors(done)); + }); }); - it('should select the channel', done => { - nightmare + it('should select the channel', () => { + return nightmare .waitToClick(selectors.clientBasicData.channelInput) .waitToClick(selectors.clientBasicData.channelMetropolisOption) .wait(400) .waitToClick(selectors.clientBasicData.saveButton) - .wait(selectors.globalItems.snackbarIsActive) - .getInnerText(selectors.globalItems.snackbarIsActive) + .waitForSnackbar() .then(result => { expect(result).toEqual('Data saved!'); - done(); - }) - .catch(catchErrors(done)); + }); }); - it('should confirm the channel have been selected', done => { - nightmare - .waitForSnackbarReset() + it('should confirm the channel have been selected', () => { + return nightmare .waitToClick(selectors.clientFiscalData.fiscalDataButton) .wait(selectors.clientFiscalData.addressInput) .waitToClick(selectors.clientBasicData.basicDataButton) @@ -275,8 +204,6 @@ describe('Edit basicData path', () => { .getInputValue(selectors.clientBasicData.channelInput) .then(result => { expect(result).toEqual('Metropolis newspaper'); - done(); - }) - .catch(catchErrors(done)); + }); }); }); diff --git a/e2e/paths/client-module/03_edit_fiscal_data.spec.js b/e2e/paths/client-module/03_edit_fiscal_data.spec.js index b3b4d416e5..47907a9ca6 100644 --- a/e2e/paths/client-module/03_edit_fiscal_data.spec.js +++ b/e2e/paths/client-module/03_edit_fiscal_data.spec.js @@ -1,50 +1,23 @@ -import config from '../../helpers/config.js'; -import createNightmare from '../../helpers/nightmare'; import selectors from '../../helpers/selectors.js'; -import {catchErrors} from '../../../services/utils/jasmineHelpers'; -const nightmare = createNightmare(); -const moduleAccessViewHashURL = '#!/'; - -jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000; +import createNightmare from '../../helpers/helpers'; describe('Edit fiscalData path', () => { - it('should log in', done => { - nightmare - .login() - .waitForURL(moduleAccessViewHashURL) - .url() - .then(url => { - expect(url).toEqual(config.url + moduleAccessViewHashURL); - done(); - }) - .catch(catchErrors(done)); - }); + const nightmare = createNightmare(); - it('should make sure the language is English', done => { - nightmare - .changeLanguageToEnglish() - .then(() => { - done(); - }) - .catch(catchErrors(done)); - }); - - it('should click on the Clients button of the top bar menu', done => { - nightmare + it('should click on the Clients button of the top bar menu', () => { + return nightmare .waitToClick(selectors.globalItems.applicationsMenuButton) .wait(selectors.globalItems.applicationsMenuVisible) .waitToClick(selectors.globalItems.clientsButton) .wait(selectors.clientsIndex.createClientButton) - .url() + .urlParsed() .then(url => { - expect(url).toEqual(config.url + '#!/clients'); - done(); - }) - .catch(catchErrors(done)); + expect(url.hash).toEqual('#!/clients'); + }); }); - it('should search for the user Bruce Banner', done => { - nightmare + it('should search for the user Bruce Banner', () => { + return nightmare .wait(selectors.clientsIndex.searchResult) .type(selectors.clientsIndex.searchClientInput, 'Bruce Banner') .click(selectors.clientsIndex.searchButton) @@ -52,14 +25,12 @@ describe('Edit fiscalData path', () => { .countSearchResults(selectors.clientsIndex.searchResult) .then(result => { expect(result).toEqual(1); - done(); - }) - .catch(catchErrors(done)); + }); }); describe('Confirm all addresses have EQtax false for future propagation test', () => { - it(`should click on the search result to access to the client's addresses`, done => { - nightmare + it(`should click on the search result to access to the client's addresses`, () => { + return nightmare .waitForTextInElement(selectors.clientsIndex.searchResult, 'Bruce Banner') .waitToClick(selectors.clientsIndex.searchResult) .waitToClick(selectors.clientAddresses.addressesButton) @@ -67,13 +38,11 @@ describe('Edit fiscalData path', () => { .url() .then(url => { expect(url).toContain('/addresses/list'); - done(); - }) - .catch(catchErrors(done)); + }); }); - it(`should click on the 1st edit icon to check EQtax is checked`, done => { - nightmare + it(`should click on the 1st edit icon to check EQtax is checked`, () => { + return nightmare .waitToClick(selectors.clientAddresses.firstEditButton) .wait(selectors.clientAddresses.equalizationTaxCheckboxLabel) .wait(200) @@ -82,13 +51,11 @@ describe('Edit fiscalData path', () => { }, selectors.clientAddresses.equalizationTaxCheckboxLabel) .then(value => { expect(value).toBeFalsy(); - done(); - }) - .catch(catchErrors(done)); + }); }); - it(`should go back to addresses then select the second one and confirm the EQtax is checked`, done => { - nightmare + it(`should go back to addresses then select the second one and confirm the EQtax is checked`, () => { + return nightmare .waitToClick(selectors.clientAddresses.addressesButton) .waitToClick(selectors.clientAddresses.secondEditButton) .wait(selectors.clientAddresses.equalizationTaxCheckboxLabel) @@ -98,42 +65,34 @@ describe('Edit fiscalData path', () => { }, selectors.clientAddresses.equalizationTaxCheckboxLabel) .then(value => { expect(value).toBeFalsy(); - done(); - }) - .catch(catchErrors(done)); + }); }); }); - it(`should click on the fiscal data button to start editing`, done => { - nightmare + it(`should click on the fiscal data button to start editing`, () => { + return nightmare .waitToClick(selectors.clientFiscalData.fiscalDataButton) .waitForURL('fiscal-data') .url() .then(url => { expect(url).toContain('fiscal-data'); - done(); - }) - .catch(catchErrors(done)); + }); }); - it('should edit the social name', done => { - nightmare + it('should edit the social name', () => { + return nightmare .wait(selectors.clientFiscalData.socialNameInput) .clearInput(selectors.clientFiscalData.socialNameInput) .type(selectors.clientFiscalData.socialNameInput, 'Hulk edited') .click(selectors.clientFiscalData.saveButton) - .wait(selectors.globalItems.snackbarIsActive) - .getInnerText(selectors.globalItems.snackbarIsActive) + .waitForSnackbar() .then(result => { expect(result).toEqual('Data saved!'); - done(); - }) - .catch(catchErrors(done)); + }); }); - it('should confirm the social name have been edited', done => { - nightmare - .waitForSnackbarReset() + it('should confirm the social name have been edited', () => { + return nightmare .waitToClick(selectors.clientBasicData.basicDataButton) .wait(selectors.clientBasicData.nameInput) .waitToClick(selectors.clientFiscalData.fiscalDataButton) @@ -141,29 +100,23 @@ describe('Edit fiscalData path', () => { .getInputValue(selectors.clientFiscalData.socialNameInput) .then(result => { expect(result).toEqual('Hulk edited'); - done(); - }) - .catch(catchErrors(done)); + }); }); - it('should edit the fiscal id', done => { - nightmare + it('should edit the fiscal id', () => { + return nightmare .wait(selectors.clientFiscalData.fiscalIdInput) .clearInput(selectors.clientFiscalData.fiscalIdInput) .type(selectors.clientFiscalData.fiscalIdInput, '94980061C') .click(selectors.clientFiscalData.saveButton) - .wait(selectors.globalItems.snackbarIsActive) - .getInnerText(selectors.globalItems.snackbarIsActive) + .waitForSnackbar() .then(result => { expect(result).toEqual('Data saved!'); - done(); - }) - .catch(catchErrors(done)); + }); }); - it('should confirm the fiscal id have been edited', done => { - nightmare - .waitForSnackbarReset() + it('should confirm the fiscal id have been edited', () => { + return nightmare .waitToClick(selectors.clientBasicData.basicDataButton) .wait(selectors.clientBasicData.nameInput) .waitToClick(selectors.clientFiscalData.fiscalDataButton) @@ -171,39 +124,30 @@ describe('Edit fiscalData path', () => { .getInputValue(selectors.clientFiscalData.fiscalIdInput) .then(result => { expect(result).toEqual('94980061C'); - done(); - }) - .catch(catchErrors(done)); + }); }); - it('should check the Equalization tax checkbox', done => { - nightmare + it('should check the Equalization tax checkbox', () => { + return nightmare .waitToClick(selectors.clientFiscalData.equalizationTaxCheckboxLabel) .waitToClick(selectors.clientFiscalData.saveButton) - .wait(selectors.globalItems.snackbarIsActive) - .getInnerText(selectors.globalItems.snackbarIsActive) + .waitForSnackbar() .then(result => { expect(result).toEqual('Data saved!'); - done(); - }) - .catch(catchErrors(done)); + }); }); - it('should propagate the Equalization tax', done => { - nightmare + it('should propagate the Equalization tax', () => { + return nightmare .waitToClick(selectors.clientFiscalData.acceptPropagationButton) - .wait(selectors.globalItems.snackbarIsActive) - .getInnerText(selectors.globalItems.snackbarIsActive) + .waitForSnackbar() .then(result => { - expect(result).toEqual('Data saved!'); - done(); - }) - .catch(catchErrors(done)); + expect(result).toEqual('Equivalent tax spreaded'); + }); }); - it('should confirm Equalization tax checkbox is checked', done => { - nightmare - .waitForSnackbarReset() + it('should confirm Equalization tax checkbox is checked', () => { + return nightmare .waitToClick(selectors.clientBasicData.basicDataButton) .wait(selectors.clientBasicData.nameInput) .waitToClick(selectors.clientFiscalData.fiscalDataButton) @@ -213,26 +157,22 @@ describe('Edit fiscalData path', () => { }, selectors.clientFiscalData.equalizationTaxCheckboxLabel) .then(value => { expect(value).toBeTruthy(); - done(); - }) - .catch(catchErrors(done)); + }); }); describe('Confirm all addresses have now EQtax checked', () => { - it(`should click on the addresses button to access to the client's addresses`, done => { - nightmare + it(`should click on the addresses button to access to the client's addresses`, () => { + return nightmare .waitToClick(selectors.clientAddresses.addressesButton) .waitForURL('/addresses/list') .url() .then(url => { expect(url).toContain('/addresses/list'); - done(); - }) - .catch(catchErrors(done)); + }); }); - it(`should click on the 1st edit icon to confirm EQtax is checked`, done => { - nightmare + it(`should click on the 1st edit icon to confirm EQtax is checked`, () => { + return nightmare .waitToClick(selectors.clientAddresses.firstEditButton) .wait(selectors.clientAddresses.equalizationTaxCheckboxLabel) .wait(200) @@ -241,13 +181,11 @@ describe('Edit fiscalData path', () => { }, selectors.clientAddresses.equalizationTaxCheckboxLabel) .then(value => { expect(value).toBeTruthy(); - done(); - }) - .catch(catchErrors(done)); + }); }); - it(`should go back to addresses then select the second one and confirm the EQtax is checked`, done => { - nightmare + it(`should go back to addresses then select the second one and confirm the EQtax is checked`, () => { + return nightmare .waitToClick(selectors.clientAddresses.addressesButton) .waitToClick(selectors.clientAddresses.secondEditButton) .wait(selectors.clientAddresses.equalizationTaxCheckboxLabel) @@ -257,31 +195,25 @@ describe('Edit fiscalData path', () => { }, selectors.clientAddresses.equalizationTaxCheckboxLabel) .then(value => { expect(value).toBeTruthy(); - done(); - }) - .catch(catchErrors(done)); + }); }); }); - it('should go to fiscal data then edit the address', done => { - nightmare + it('should go to fiscal data then edit the address', () => { + return nightmare .waitToClick(selectors.clientFiscalData.fiscalDataButton) .wait(selectors.clientFiscalData.addressInput) .clearInput(selectors.clientFiscalData.addressInput) .type(selectors.clientFiscalData.addressInput, 'Somewhere edited') .click(selectors.clientFiscalData.saveButton) - .wait(selectors.globalItems.snackbarIsActive) - .getInnerText(selectors.globalItems.snackbarIsActive) + .waitForSnackbar() .then(result => { expect(result).toEqual('Data saved!'); - done(); - }) - .catch(catchErrors(done)); + }); }); - it('should confirm the address have been edited', done => { - nightmare - .waitForSnackbarReset() + it('should confirm the address have been edited', () => { + return nightmare .click(selectors.clientBasicData.basicDataButton) .wait(selectors.clientBasicData.nameInput) .click(selectors.clientFiscalData.fiscalDataButton) @@ -289,29 +221,23 @@ describe('Edit fiscalData path', () => { .getInputValue(selectors.clientFiscalData.addressInput) .then(result => { expect(result).toEqual('Somewhere edited'); - done(); - }) - .catch(catchErrors(done)); + }); }); - it('should edit the city', done => { - nightmare + it('should edit the city', () => { + return nightmare .wait(selectors.clientFiscalData.cityInput) .clearInput(selectors.clientFiscalData.cityInput) .type(selectors.clientFiscalData.cityInput, 'N/A') .click(selectors.clientFiscalData.saveButton) - .wait(selectors.globalItems.snackbarIsActive) - .getInnerText(selectors.globalItems.snackbarIsActive) + .waitForSnackbar() .then(result => { expect(result).toEqual('Data saved!'); - done(); - }) - .catch(catchErrors(done)); + }); }); - it('should confirm the city have been edited', done => { - nightmare - .waitForSnackbarReset() + it('should confirm the city have been edited', () => { + return nightmare .click(selectors.clientBasicData.basicDataButton) .wait(selectors.clientBasicData.nameInput) .click(selectors.clientFiscalData.fiscalDataButton) @@ -319,29 +245,23 @@ describe('Edit fiscalData path', () => { .getInputValue(selectors.clientFiscalData.cityInput) .then(result => { expect(result).toEqual('N/A'); - done(); - }) - .catch(catchErrors(done)); + }); }); - it('should edit the postcode', done => { - nightmare + it('should edit the postcode', () => { + return nightmare .wait(selectors.clientFiscalData.postcodeInput) .clearInput(selectors.clientFiscalData.postcodeInput) .type(selectors.clientFiscalData.postcodeInput, '12345') .click(selectors.clientFiscalData.saveButton) - .wait(selectors.globalItems.snackbarIsActive) - .getInnerText(selectors.globalItems.snackbarIsActive) + .waitForSnackbar() .then(result => { expect(result).toEqual('Data saved!'); - done(); - }) - .catch(catchErrors(done)); + }); }); - it('should confirm the postcode have been edited', done => { - nightmare - .waitForSnackbarReset() + it('should confirm the postcode have been edited', () => { + return nightmare .click(selectors.clientBasicData.basicDataButton) .wait(selectors.clientBasicData.nameInput) .click(selectors.clientFiscalData.fiscalDataButton) @@ -349,29 +269,23 @@ describe('Edit fiscalData path', () => { .getInputValue(selectors.clientFiscalData.postcodeInput) .then(result => { expect(result).toEqual('12345'); - done(); - }) - .catch(catchErrors(done)); + }); }); - it(`should edit the province`, done => { - nightmare + it(`should edit the province`, () => { + return nightmare .waitToClick(selectors.clientFiscalData.provinceInput) .waitToClick(selectors.clientFiscalData.provinceFifthOption) .wait(200) .waitToClick(selectors.clientFiscalData.saveButton) - .wait(selectors.globalItems.snackbarIsActive) - .getInnerText(selectors.globalItems.snackbarIsActive) + .waitForSnackbar() .then(result => { expect(result).toEqual('Data saved!'); - done(); - }) - .catch(catchErrors(done)); + }); }); - it(`should confirm the province have been selected`, done => { - nightmare - .waitForSnackbarReset() + it(`should confirm the province have been selected`, () => { + return nightmare .click(selectors.clientBasicData.basicDataButton) .wait(selectors.clientBasicData.nameInput) .click(selectors.clientFiscalData.fiscalDataButton) @@ -379,27 +293,21 @@ describe('Edit fiscalData path', () => { .getInputValue(selectors.clientFiscalData.provinceInput) .then(result => { expect(result).toEqual('Province two'); - done(); - }) - .catch(catchErrors(done)); + }); }); - it('should uncheck the active checkbox', done => { - nightmare + it('should uncheck the active checkbox', () => { + return nightmare .waitToClick(selectors.clientFiscalData.activeCheckboxLabel) .waitToClick(selectors.clientFiscalData.saveButton) - .wait(selectors.globalItems.snackbarIsActive) - .getInnerText(selectors.globalItems.snackbarIsActive) + .waitForSnackbar() .then(result => { expect(result).toEqual('Data saved!'); - done(); - }) - .catch(catchErrors(done)); + }); }); - it('should confirm active checkbox is unchecked', done => { - nightmare - .waitForSnackbarReset() + it('should confirm active checkbox is unchecked', () => { + return nightmare .waitToClick(selectors.clientBasicData.basicDataButton) .wait(selectors.clientBasicData.nameInput) .waitToClick(selectors.clientFiscalData.fiscalDataButton) @@ -409,27 +317,21 @@ describe('Edit fiscalData path', () => { }, selectors.clientFiscalData.activeCheckboxLabel) .then(value => { expect(value).toBeFalsy(); - done(); - }) - .catch(catchErrors(done)); + }); }); - it('should uncheck the invoice by address checkbox', done => { - nightmare + it('should uncheck the invoice by address checkbox', () => { + return nightmare .waitToClick(selectors.clientFiscalData.invoiceByAddressCheckboxInput) .waitToClick(selectors.clientFiscalData.saveButton) - .wait(selectors.globalItems.snackbarIsActive) - .getInnerText(selectors.globalItems.snackbarIsActive) + .waitForSnackbar() .then(result => { expect(result).toEqual('Data saved!'); - done(); - }) - .catch(catchErrors(done)); + }); }); - it('should confirm invoice by address checkbox is unchecked', done => { - nightmare - .waitForSnackbarReset() + it('should confirm invoice by address checkbox is unchecked', () => { + return nightmare .waitToClick(selectors.clientBasicData.basicDataButton) .wait(selectors.clientBasicData.nameInput) .waitToClick(selectors.clientFiscalData.fiscalDataButton) @@ -439,27 +341,21 @@ describe('Edit fiscalData path', () => { }, selectors.clientFiscalData.invoiceByAddressCheckboxInput) .then(value => { expect(value).toBeFalsy(); - done(); - }) - .catch(catchErrors(done)); + }); }); - it('should check the Verified data checkbox', done => { - nightmare + it('should check the Verified data checkbox', () => { + return nightmare .waitToClick(selectors.clientFiscalData.verifiedDataCheckboxInput) .waitToClick(selectors.clientFiscalData.saveButton) - .wait(selectors.globalItems.snackbarIsActive) - .getInnerText(selectors.globalItems.snackbarIsActive) + .waitForSnackbar() .then(result => { expect(result).toEqual('Data saved!'); - done(); - }) - .catch(catchErrors(done)); + }); }); - it('should confirm Verified data checkbox is unchecked', done => { - nightmare - .waitForSnackbarReset() + it('should confirm Verified data checkbox is unchecked', () => { + return nightmare .waitToClick(selectors.clientBasicData.basicDataButton) .wait(selectors.clientBasicData.nameInput) .waitToClick(selectors.clientFiscalData.fiscalDataButton) @@ -469,27 +365,21 @@ describe('Edit fiscalData path', () => { }, selectors.clientFiscalData.verifiedDataCheckboxInput) .then(value => { expect(value).toBeFalsy(); - done(); - }) - .catch(catchErrors(done)); + }); }); - it('should uncheck the Has to invoice checkbox', done => { - nightmare + it('should uncheck the Has to invoice checkbox', () => { + return nightmare .waitToClick(selectors.clientFiscalData.hasToInvoiceCheckboxLabel) .waitToClick(selectors.clientFiscalData.saveButton) - .wait(selectors.globalItems.snackbarIsActive) - .getInnerText(selectors.globalItems.snackbarIsActive) + .waitForSnackbar() .then(result => { expect(result).toEqual('Data saved!'); - done(); - }) - .catch(catchErrors(done)); + }); }); - it('should confirm Has to invoice checkbox is unchecked', done => { - nightmare - .waitForSnackbarReset() + it('should confirm Has to invoice checkbox is unchecked', () => { + return nightmare .waitToClick(selectors.clientBasicData.basicDataButton) .wait(selectors.clientBasicData.nameInput) .waitToClick(selectors.clientFiscalData.fiscalDataButton) @@ -499,27 +389,21 @@ describe('Edit fiscalData path', () => { }, selectors.clientFiscalData.hasToInvoiceCheckboxLabel) .then(value => { expect(value).toBeFalsy(); - done(); - }) - .catch(catchErrors(done)); + }); }); - it('should uncheck the Invoice by mail checkbox', done => { - nightmare + it('should uncheck the Invoice by mail checkbox', () => { + return nightmare .waitToClick(selectors.clientFiscalData.invoiceByMailCheckboxLabel) .waitToClick(selectors.clientFiscalData.saveButton) - .wait(selectors.globalItems.snackbarIsActive) - .getInnerText(selectors.globalItems.snackbarIsActive) + .waitForSnackbar() .then(result => { expect(result).toEqual('Data saved!'); - done(); - }) - .catch(catchErrors(done)); + }); }); - it('should confirm Invoice by mail checkbox is unchecked', done => { - nightmare - .waitForSnackbarReset() + it('should confirm Invoice by mail checkbox is unchecked', () => { + return nightmare .waitToClick(selectors.clientBasicData.basicDataButton) .wait(selectors.clientBasicData.nameInput) .waitToClick(selectors.clientFiscalData.fiscalDataButton) @@ -529,27 +413,21 @@ describe('Edit fiscalData path', () => { }, selectors.clientFiscalData.invoiceByMailCheckboxLabel) .then(value => { expect(value).toBeFalsy(); - done(); - }) - .catch(catchErrors(done)); + }); }); - it('should check the Vies checkbox', done => { - nightmare + it('should check the Vies checkbox', () => { + return nightmare .waitToClick(selectors.clientFiscalData.viesCheckboxInput) .waitToClick(selectors.clientFiscalData.saveButton) - .wait(selectors.globalItems.snackbarIsActive) - .getInnerText(selectors.globalItems.snackbarIsActive) + .waitForSnackbar() .then(result => { expect(result).toEqual('Data saved!'); - done(); - }) - .catch(catchErrors(done)); + }); }); - it('should confirm Vies checkbox is checked', done => { - nightmare - .waitForSnackbarReset() + it('should confirm Vies checkbox is checked', () => { + return nightmare .waitToClick(selectors.clientBasicData.basicDataButton) .wait(selectors.clientBasicData.nameInput) .waitToClick(selectors.clientFiscalData.fiscalDataButton) @@ -559,8 +437,6 @@ describe('Edit fiscalData path', () => { }, selectors.clientFiscalData.viesCheckboxInput) .then(value => { expect(value).toBeTruthy(); - done(); - }) - .catch(catchErrors(done)); + }); }); }); diff --git a/e2e/paths/client-module/04_edit_pay_method.spec.js b/e2e/paths/client-module/04_edit_pay_method.spec.js index c03934e87e..888050ed19 100644 --- a/e2e/paths/client-module/04_edit_pay_method.spec.js +++ b/e2e/paths/client-module/04_edit_pay_method.spec.js @@ -1,50 +1,23 @@ -import config from '../../helpers/config.js'; -import createNightmare from '../../helpers/nightmare'; import selectors from '../../helpers/selectors.js'; -import {catchErrors} from '../../../services/utils/jasmineHelpers'; -const nightmare = createNightmare(); -const moduleAccessViewHashURL = '#!/'; - -jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000; +import createNightmare from '../../helpers/helpers'; describe('Edit pay method path', () => { - it('should log in', done => { - nightmare - .login() - .waitForURL(moduleAccessViewHashURL) - .url() - .then(url => { - expect(url).toEqual(config.url + moduleAccessViewHashURL); - done(); - }) - .catch(catchErrors(done)); - }); + const nightmare = createNightmare(); - it('should make sure the language is English', done => { - nightmare - .changeLanguageToEnglish() - .then(() => { - done(); - }) - .catch(catchErrors(done)); - }); - - it('should click on the Clients button of the top bar menu', done => { - nightmare + it('should click on the Clients button of the top bar menu', () => { + return nightmare .waitToClick(selectors.globalItems.applicationsMenuButton) .wait(selectors.globalItems.applicationsMenuVisible) .waitToClick(selectors.globalItems.clientsButton) .wait(selectors.clientsIndex.createClientButton) - .url() + .urlParsed() .then(url => { - expect(url).toEqual(config.url + '#!/clients'); - done(); - }) - .catch(catchErrors(done)); + expect(url.hash).toEqual('#!/clients'); + }); }); - it('should search for the user Bruce Banner', done => { - nightmare + it('should search for the user Bruce Banner', () => { + return nightmare .wait(selectors.clientsIndex.searchResult) .type(selectors.clientsIndex.searchClientInput, 'Bruce Banner') .click(selectors.clientsIndex.searchButton) @@ -52,13 +25,11 @@ describe('Edit pay method path', () => { .countSearchResults(selectors.clientsIndex.searchResult) .then(result => { expect(result).toEqual(1); - done(); - }) - .catch(catchErrors(done)); + }); }); - it(`should click on the search result to access to the client's pay method`, done => { - nightmare + it(`should click on the search result to access to the client's pay method`, () => { + return nightmare .waitForTextInElement(selectors.clientsIndex.searchResult, 'Bruce Banner') .waitToClick(selectors.clientsIndex.searchResult) .waitToClick(selectors.clientPayMethod.payMethodButton) @@ -66,30 +37,24 @@ describe('Edit pay method path', () => { .url() .then(url => { expect(url).toContain('billing-data'); - done(); - }) - .catch(catchErrors(done)); + }); }); - it(`should edit the Pay method to any without IBAN`, done => { - nightmare + it(`should edit the Pay method to any without IBAN`, () => { + return nightmare .waitToClick(selectors.clientPayMethod.payMethodInput) .waitToClick(selectors.clientPayMethod.payMethodOptionOne) .wait(200) .waitToClick(selectors.clientPayMethod.saveButton) .waitToClick(selectors.clientPayMethod.cancelNotificationButton) - .wait(selectors.globalItems.snackbarIsActive) - .getInnerText(selectors.globalItems.snackbarIsActive) + .waitForSnackbar() .then(result => { expect(result).toEqual('Data saved!'); - done(); - }) - .catch(catchErrors(done)); + }); }); - it(`should confirm the Pay method have been selected`, done => { - nightmare - .waitForSnackbarReset() + it(`should confirm the Pay method have been selected`, () => { + return nightmare .click(selectors.clientBasicData.basicDataButton) .wait(selectors.clientBasicData.nameInput) .click(selectors.clientPayMethod.payMethodButton) @@ -97,45 +62,36 @@ describe('Edit pay method path', () => { .getInputValue(selectors.clientPayMethod.payMethodInput) .then(result => { expect(result).toEqual('PayMethod one'); - done(); - }) - .catch(catchErrors(done)); + }); }); - it(`should receive an error when changing payMethod to IBAN without an IBAN entered`, done => { - nightmare + it(`should receive an error when changing payMethod to IBAN without an IBAN entered`, () => { + return nightmare .waitToClick(selectors.clientPayMethod.payMethodInput) .waitToClick(selectors.clientPayMethod.payMethodIBANOption) .wait(200) .waitToClick(selectors.clientPayMethod.saveButton) .waitToClick(selectors.clientPayMethod.cancelNotificationButton) - .wait(selectors.globalItems.snackbarIsActive) - .getInnerText(selectors.globalItems.snackbarIsActive) + .waitForSnackbar() .then(result => { expect(result).toContain('Error'); - done(); - }) - .catch(catchErrors(done)); + }); }); - it(`should add the IBAN`, done => { - nightmare + it(`should add the IBAN`, () => { + return nightmare .clearInput(selectors.clientPayMethod.IBANInput) .type(selectors.clientPayMethod.IBANInput, 'ES91 2100 0418 4502 0005 1332') .waitToClick(selectors.clientPayMethod.saveButton) .waitToClick(selectors.clientPayMethod.cancelNotificationButton) - .wait(selectors.globalItems.snackbarIsActive) - .getInnerText(selectors.globalItems.snackbarIsActive) + .waitForSnackbar() .then(result => { expect(result).toEqual('Data saved!'); - done(); - }) - .catch(catchErrors(done)); + }); }); - it(`should confirm the IBAN pay method is sucessfully saved`, done => { - nightmare - .waitForSnackbarReset() + it(`should confirm the IBAN pay method is sucessfully saved`, () => { + return nightmare .click(selectors.clientBasicData.basicDataButton) .wait(selectors.clientBasicData.nameInput) .click(selectors.clientPayMethod.payMethodButton) @@ -143,29 +99,23 @@ describe('Edit pay method path', () => { .getInputValue(selectors.clientPayMethod.payMethodInput) .then(result => { expect(result).toEqual('PayMethod with IBAN'); - done(); - }) - .catch(catchErrors(done)); + }); }); - it(`should edit the due day`, done => { - nightmare + it(`should edit the due day`, () => { + return nightmare .clearInput(selectors.clientPayMethod.dueDayInput) .type(selectors.clientPayMethod.dueDayInput, '60') .waitToClick(selectors.clientPayMethod.saveButton) .waitToClick(selectors.clientPayMethod.cancelNotificationButton) - .wait(selectors.globalItems.snackbarIsActive) - .getInnerText(selectors.globalItems.snackbarIsActive) + .waitForSnackbar() .then(result => { expect(result).toEqual('Data saved!'); - done(); - }) - .catch(catchErrors(done)); + }); }); - it('should confirm the due day have been edited', done => { - nightmare - .waitForSnackbarReset() + it('should confirm the due day have been edited', () => { + return nightmare .waitToClick(selectors.clientBasicData.basicDataButton) .wait(selectors.clientBasicData.nameInput) .waitToClick(selectors.clientPayMethod.payMethodButton) @@ -173,27 +123,21 @@ describe('Edit pay method path', () => { .getInputValue(selectors.clientPayMethod.dueDayInput) .then(result => { expect(result).toEqual('60'); - done(); - }) - .catch(catchErrors(done)); + }); }); - it('should uncheck the Received core VNH checkbox', done => { - nightmare + it('should uncheck the Received core VNH checkbox', () => { + return nightmare .waitToClick(selectors.clientPayMethod.receivedCoreVNHCheckbox) .waitToClick(selectors.clientPayMethod.saveButton) - .wait(selectors.globalItems.snackbarIsActive) - .getInnerText(selectors.globalItems.snackbarIsActive) + .waitForSnackbar() .then(result => { expect(result).toEqual('Data saved!'); - done(); - }) - .catch(catchErrors(done)); + }); }); - it('should confirm Received core VNH checkbox is unchecked', done => { - nightmare - .waitForSnackbarReset() + it('should confirm Received core VNH checkbox is unchecked', () => { + return nightmare .waitToClick(selectors.clientBasicData.basicDataButton) .wait(selectors.clientBasicData.nameInput) .waitToClick(selectors.clientPayMethod.payMethodButton) @@ -203,27 +147,21 @@ describe('Edit pay method path', () => { }, selectors.clientPayMethod.receivedCoreVNHCheckbox) .then(value => { expect(value).toBeFalsy(); - done(); - }) - .catch(catchErrors(done)); + }); }); - it('should uncheck the Received core VNL checkbox', done => { - nightmare + it('should uncheck the Received core VNL checkbox', () => { + return nightmare .waitToClick(selectors.clientPayMethod.receivedCoreVNLCheckbox) .waitToClick(selectors.clientPayMethod.saveButton) - .wait(selectors.globalItems.snackbarIsActive) - .getInnerText(selectors.globalItems.snackbarIsActive) + .waitForSnackbar() .then(result => { expect(result).toEqual('Data saved!'); - done(); - }) - .catch(catchErrors(done)); + }); }); - it('should confirm Received core VNL checkbox is unchecked', done => { - nightmare - .waitForSnackbarReset() + it('should confirm Received core VNL checkbox is unchecked', () => { + return nightmare .waitToClick(selectors.clientBasicData.basicDataButton) .wait(selectors.clientBasicData.nameInput) .waitToClick(selectors.clientPayMethod.payMethodButton) @@ -233,27 +171,21 @@ describe('Edit pay method path', () => { }, selectors.clientPayMethod.receivedCoreVNLCheckbox) .then(value => { expect(value).toBeFalsy(); - done(); - }) - .catch(catchErrors(done)); + }); }); - it('should uncheck the Received B2B VNL checkbox', done => { - nightmare + it('should uncheck the Received B2B VNL checkbox', () => { + return nightmare .waitToClick(selectors.clientPayMethod.receivedB2BVNLCheckbox) .waitToClick(selectors.clientPayMethod.saveButton) - .wait(selectors.globalItems.snackbarIsActive) - .getInnerText(selectors.globalItems.snackbarIsActive) + .waitForSnackbar() .then(result => { expect(result).toEqual('Data saved!'); - done(); - }) - .catch(catchErrors(done)); + }); }); - it('should confirm Received B2B VNL checkbox is unchecked', done => { - nightmare - .waitForSnackbarReset() + it('should confirm Received B2B VNL checkbox is unchecked', () => { + return nightmare .waitToClick(selectors.clientBasicData.basicDataButton) .wait(selectors.clientBasicData.nameInput) .waitToClick(selectors.clientPayMethod.payMethodButton) @@ -263,8 +195,6 @@ describe('Edit pay method path', () => { }, selectors.clientPayMethod.receivedB2BVNLCheckbox) .then(value => { expect(value).toBeFalsy(); - done(); - }) - .catch(catchErrors(done)); + }); }); }); diff --git a/e2e/paths/client-module/05_add_address.spec.js b/e2e/paths/client-module/05_add_address.spec.js index d90f7d7754..02992d12b0 100644 --- a/e2e/paths/client-module/05_add_address.spec.js +++ b/e2e/paths/client-module/05_add_address.spec.js @@ -1,50 +1,23 @@ -import config from '../../helpers/config.js'; -import createNightmare from '../../helpers/nightmare'; import selectors from '../../helpers/selectors.js'; -import {catchErrors} from '../../../services/utils/jasmineHelpers'; -const nightmare = createNightmare(); -const moduleAccessViewHashURL = '#!/'; - -jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000; +import createNightmare from '../../helpers/helpers'; describe('Add address path', () => { - it('should log in', done => { - nightmare - .login() - .waitForURL(moduleAccessViewHashURL) - .url() - .then(url => { - expect(url).toEqual(config.url + moduleAccessViewHashURL); - done(); - }) - .catch(catchErrors(done)); - }); + const nightmare = createNightmare(); - it('should make sure the language is English', done => { - nightmare - .changeLanguageToEnglish() - .then(() => { - done(); - }) - .catch(catchErrors(done)); - }); - - it('should click on the Clients button of the top bar menu', done => { - nightmare + it('should click on the Clients button of the top bar menu', () => { + return nightmare .waitToClick(selectors.globalItems.applicationsMenuButton) .wait(selectors.globalItems.applicationsMenuVisible) .waitToClick(selectors.globalItems.clientsButton) .wait(selectors.clientsIndex.createClientButton) - .url() + .urlParsed() .then(url => { - expect(url).toEqual(config.url + '#!/clients'); - done(); - }) - .catch(catchErrors(done)); + expect(url.hash).toEqual('#!/clients'); + }); }); - it('should search for the user Bruce Banner', done => { - nightmare + it('should search for the user Bruce Banner', () => { + return nightmare .wait(selectors.clientsIndex.searchResult) .type(selectors.clientsIndex.searchClientInput, 'Bruce Banner') .click(selectors.clientsIndex.searchButton) @@ -52,13 +25,11 @@ describe('Add address path', () => { .countSearchResults(selectors.clientsIndex.searchResult) .then(result => { expect(result).toEqual(1); - done(); - }) - .catch(catchErrors(done)); + }); }); - it(`should click on the search result to access to the client addresses`, done => { - nightmare + it(`should click on the search result to access to the client addresses`, () => { + return nightmare .waitForTextInElement(selectors.clientsIndex.searchResult, 'Bruce Banner') .waitToClick(selectors.clientsIndex.searchResult) .waitToClick(selectors.clientAddresses.addressesButton) @@ -66,223 +37,168 @@ describe('Add address path', () => { .url() .then(url => { expect(url).toContain('addresses/list'); - done(); - }) - .catch(catchErrors(done)); + }); }); - it(`should click on the add new address button to access to the new address form`, done => { - nightmare + it(`should click on the add new address button to access to the new address form`, () => { + return nightmare .waitToClick(selectors.clientAddresses.createAddress) .waitForURL('addresses/create') .url() .then(url => { expect(url).toContain('addresses/create'); - done(); - }) - .catch(catchErrors(done)); + }); }); - it('should check the default checkbox then receive an error after clicking save button as the form is empty', done => { - nightmare + it('should check the default checkbox then receive an error after clicking save button as the form is empty', () => { + return nightmare .waitToClick(selectors.clientAddresses.defaultCheckboxInput) .waitToClick(selectors.clientFiscalData.saveButton) - .wait(selectors.globalItems.snackbarIsActive) - .getInnerText(selectors.globalItems.snackbarIsActive) + .waitForSnackbar() .then(result => { expect(result).toContain('Some fields are invalid'); - done(); - }) - .catch(catchErrors(done)); + }); }); - it('should receive an error when clicking the save button having all the form fields empty but consignee', done => { - nightmare - .waitForSnackbarReset() + it('should receive an error when clicking the save button having all the form fields empty but consignee', () => { + return nightmare .type(selectors.clientAddresses.consigneeInput, 'Bruce Bunner') .click(selectors.createClientView.createButton) - .wait(selectors.globalItems.snackbarIsActive) - .getInnerText(selectors.globalItems.snackbarIsActive) + .waitForSnackbar() .then(result => { expect(result).toContain('Some fields are invalid'); - done(); - }) - .catch(catchErrors(done)); + }); }); - it('should receive an error when clicking the save button having all the form fields empty but Street', done => { - nightmare - .waitForSnackbarReset() + it('should receive an error when clicking the save button having all the form fields empty but Street', () => { + return nightmare .clearInput(selectors.clientAddresses.consigneeInput) .type(selectors.clientAddresses.streetAddressInput, '320 Park Avenue New York') .click(selectors.createClientView.createButton) - .wait(selectors.globalItems.snackbarIsActive) - .getInnerText(selectors.globalItems.snackbarIsActive) + .waitForSnackbar() .then(result => { expect(result).toContain('Some fields are invalid'); - done(); - }) - .catch(catchErrors(done)); + }); }); - it('should receive an error when clicking the save button having all the form fields empty but postcode', done => { - nightmare - .waitForSnackbarReset() + it('should receive an error when clicking the save button having all the form fields empty but postcode', () => { + return nightmare .clearInput(selectors.clientAddresses.streetAddressInput) .type(selectors.clientAddresses.postcodeInput, '10022') .click(selectors.createClientView.createButton) - .wait(selectors.globalItems.snackbarIsActive) - .getInnerText(selectors.globalItems.snackbarIsActive) + .waitForSnackbar() .then(result => { expect(result).toContain('Some fields are invalid'); - done(); - }) - .catch(catchErrors(done)); + }); }); - it('should receive an error when clicking the save button having all the form fields empty but city', done => { - nightmare - .waitForSnackbarReset() + it('should receive an error when clicking the save button having all the form fields empty but city', () => { + return nightmare .clearInput(selectors.clientAddresses.postcodeInput) .type(selectors.clientAddresses.cityInput, 'New York') .click(selectors.createClientView.createButton) - .wait(selectors.globalItems.snackbarIsActive) - .getInnerText(selectors.globalItems.snackbarIsActive) + .waitForSnackbar() .then(result => { expect(result).toContain('Some fields are invalid'); - done(); - }) - .catch(catchErrors(done)); + }); }); - it('should receive an error when clicking the save button having all the form fields empty but province', done => { - nightmare - .waitForSnackbarReset() + it('should receive an error when clicking the save button having all the form fields empty but province', () => { + return nightmare .clearInput(selectors.clientAddresses.cityInput) .waitToClick(selectors.clientAddresses.provinceInput) .waitToClick(selectors.clientAddresses.provinceSecondOption) .click(selectors.createClientView.createButton) - .wait(selectors.globalItems.snackbarIsActive) - .getInnerText(selectors.globalItems.snackbarIsActive) + .waitForSnackbar() .then(result => { expect(result).toContain('Some fields are invalid'); - done(); - }) - .catch(catchErrors(done)); + }); }); - it('should receive an error when clicking the save button having all the form fields empty but province and agency', done => { - nightmare - .waitForSnackbarReset() + it('should receive an error when clicking the save button having all the form fields empty but province and agency', () => { + return nightmare .waitToClick(selectors.clientAddresses.agencyInput) .waitToClick(selectors.clientAddresses.agenctySecondOption) .click(selectors.createClientView.createButton) - .wait(selectors.globalItems.snackbarIsActive) - .getInnerText(selectors.globalItems.snackbarIsActive) + .waitForSnackbar() .then(result => { expect(result).toContain('Some fields are invalid'); - done(); - }) - .catch(catchErrors(done)); + }); }); - it('should receive an error when clicking the save button having all the form fields empty but province, agency and phone', done => { - nightmare - .waitForSnackbarReset() + it('should receive an error when clicking the save button having all the form fields empty but province, agency and phone', () => { + return nightmare .type(selectors.clientAddresses.phoneInput, '999887744') .click(selectors.createClientView.createButton) - .wait(selectors.globalItems.snackbarIsActive) - .getInnerText(selectors.globalItems.snackbarIsActive) + .waitForSnackbar() .then(result => { expect(result).toContain('Some fields are invalid'); - done(); - }) - .catch(catchErrors(done)); + }); }); - it('should receive an error when clicking the save button having all the form fields empty but province, agency and mobile', done => { - nightmare - .waitForSnackbarReset() + it('should receive an error when clicking the save button having all the form fields empty but province, agency and mobile', () => { + return nightmare .clearInput(selectors.clientAddresses.phoneInput) .type(selectors.clientAddresses.mobileInput, '999887744') .click(selectors.createClientView.createButton) - .wait(selectors.globalItems.snackbarIsActive) - .getInnerText(selectors.globalItems.snackbarIsActive) + .waitForSnackbar() .then(result => { expect(result).toContain('Some fields are invalid'); - done(); - }) - .catch(catchErrors(done)); + }); }); - it(`should create a new address with all it's data`, done => { - nightmare - .waitForSnackbarReset() + it(`should create a new address with all it's data`, () => { + return nightmare .type(selectors.clientAddresses.consigneeInput, 'Bruce Bunner') .type(selectors.clientAddresses.streetAddressInput, '320 Park Avenue New York') .type(selectors.clientAddresses.postcodeInput, '10022') .type(selectors.clientAddresses.cityInput, 'New York') .type(selectors.clientAddresses.phoneInput, '999887744') .click(selectors.clientAddresses.saveButton) - .wait(selectors.globalItems.snackbarIsActive) - .getInnerText(selectors.globalItems.snackbarIsActive) + .waitForSnackbar() .then(result => { expect(result).toContain('Data saved!'); - done(); - }) - .catch(catchErrors(done)); + }); }); - it(`should click on the addresses button confirm the new address exists and it's the default one`, done => { - nightmare - .waitForSnackbarReset() + it(`should click on the addresses button confirm the new address exists and it's the default one`, () => { + return nightmare .waitToClick(selectors.clientAddresses.addressesButton) .wait(selectors.clientAddresses.defaultAddress) .getInnerText(selectors.clientAddresses.defaultAddress) .then(result => { expect(result).toContain('320 Park Avenue New York'); - done(); - }) - .catch(catchErrors(done)); + }); }); - it(`should click on the make default icon of the second address then confirm it is the default one now`, done => { - nightmare - .waitForSnackbarReset() + it(`should click on the make default icon of the second address then confirm it is the default one now`, () => { + return nightmare .waitToClick(selectors.clientAddresses.secondMakeDefaultStar) .waitForTextInElement(selectors.clientAddresses.defaultAddress, 'Somewhere in Thailand') .getInnerText(selectors.clientAddresses.defaultAddress) .then(result => { expect(result).toContain('Somewhere in Thailand'); - done(); - }) - .catch(catchErrors(done)); + }); }); - it(`should click on the edit icon of the default address`, done => { - nightmare + it(`should click on the edit icon of the default address`, () => { + return nightmare .waitForTextInElement(selectors.clientAddresses.defaultAddress, 'Somewhere in Thailand') .waitToClick(selectors.clientAddresses.firstEditButton) .waitForURL('/edit') .url() .then(result => { expect(result).toContain('/edit'); - done(); - }) - .catch(catchErrors(done)); + }); }); - it(`should click on the active checkbox and receive an error to save it becouse it is the default address`, done => { - nightmare - .waitForSnackbarReset() + it(`should click on the active checkbox and receive an error to save it becouse it is the default address`, () => { + return nightmare .waitToClick(selectors.clientAddresses.activeCheckbox) .waitToClick(selectors.clientAddresses.saveButton) - .wait(selectors.globalItems.snackbarIsActive) - .getInnerText(selectors.globalItems.snackbarIsActive) + .waitForSnackbar() .then(result => { expect(result).toContain('Error'); - done(); - }) - .catch(catchErrors(done)); + }); }); }); diff --git a/e2e/paths/client-module/06_add_address_notes.spec.js b/e2e/paths/client-module/06_add_address_notes.spec.js index dae6b4817d..0fe8a82132 100644 --- a/e2e/paths/client-module/06_add_address_notes.spec.js +++ b/e2e/paths/client-module/06_add_address_notes.spec.js @@ -1,50 +1,23 @@ -import config from '../../helpers/config.js'; -import createNightmare from '../../helpers/nightmare'; import selectors from '../../helpers/selectors.js'; -import {catchErrors} from '../../../services/utils/jasmineHelpers'; -const nightmare = createNightmare(); -const moduleAccessViewHashURL = '#!/'; - -jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000; +import createNightmare from '../../helpers/helpers'; describe('Add address notes path', () => { - it('should log in', done => { - nightmare - .login() - .waitForURL(moduleAccessViewHashURL) - .url() - .then(url => { - expect(url).toEqual(config.url + moduleAccessViewHashURL); - done(); - }) - .catch(catchErrors(done)); - }); + const nightmare = createNightmare(); - it('should make sure the language is English', done => { - nightmare - .changeLanguageToEnglish() - .then(() => { - done(); - }) - .catch(catchErrors(done)); - }); - - it('should click on the Clients button of the top bar menu', done => { - nightmare + it('should click on the Clients button of the top bar menu', () => { + return nightmare .waitToClick(selectors.globalItems.applicationsMenuButton) .wait(selectors.globalItems.applicationsMenuVisible) .waitToClick(selectors.globalItems.clientsButton) .wait(selectors.clientsIndex.createClientButton) - .url() + .urlParsed() .then(url => { - expect(url).toEqual(config.url + '#!/clients'); - done(); - }) - .catch(catchErrors(done)); + expect(url.hash).toEqual('#!/clients'); + }); }); - it('should search for the user Bruce Banner', done => { - nightmare + it('should search for the user Bruce Banner', () => { + return nightmare .wait(selectors.clientsIndex.searchResult) .type(selectors.clientsIndex.searchClientInput, 'Bruce Banner') .click(selectors.clientsIndex.searchButton) @@ -52,13 +25,11 @@ describe('Add address notes path', () => { .countSearchResults(selectors.clientsIndex.searchResult) .then(result => { expect(result).toEqual(1); - done(); - }) - .catch(catchErrors(done)); + }); }); - it(`should click on the search result to access to the client addresses`, done => { - nightmare + it(`should click on the search result to access to the client addresses`, () => { + return nightmare .waitForTextInElement(selectors.clientsIndex.searchResult, 'Bruce Banner') .waitToClick(selectors.clientsIndex.searchResult) .waitToClick(selectors.clientAddresses.addressesButton) @@ -66,34 +37,27 @@ describe('Add address notes path', () => { .url() .then(url => { expect(url).toContain('addresses/list'); - done(); - }) - .catch(catchErrors(done)); + }); }); - it(`should click on the edit icon of the default address`, done => { - nightmare + it(`should click on the edit icon of the default address`, () => { + return nightmare .waitForTextInElement(selectors.clientAddresses.defaultAddress, 'Somewhere in Thailand') .waitToClick(selectors.clientAddresses.firstEditButton) .waitForURL('/edit') .url() .then(result => { expect(result).toContain('/edit'); - done(); - }) - .catch(catchErrors(done)); + }); }); - // it('should add as many notes as observation types', done => { - // nightmare - // .waitToClick(selectors.clientAddresses.defaultCheckboxInput) + // it('should add as many notes as observation types', () => { + // return nightmare + // .waitToClick(selectors.clientAddresses.defaultCheckboxInput) // .waitToClick(selectors.clientFiscalData.saveButton) - // .wait(selectors.globalItems.snackbarIsActive) - // .getInnerText(selectors.globalItems.snackbarIsActive) + // .waitForSnackbar() // .then(result => { // expect(result).toContain('Some fields are invalid'); - // done(); // }) - // .catch(catchErrors(done)); // }); }); diff --git a/e2e/paths/client-module/07_edit_web_access.spec.js b/e2e/paths/client-module/07_edit_web_access.spec.js index 10619ebcf3..2457513e00 100644 --- a/e2e/paths/client-module/07_edit_web_access.spec.js +++ b/e2e/paths/client-module/07_edit_web_access.spec.js @@ -1,50 +1,23 @@ -import config from '../../helpers/config.js'; -import createNightmare from '../../helpers/nightmare'; import selectors from '../../helpers/selectors.js'; -import {catchErrors} from '../../../services/utils/jasmineHelpers'; -const nightmare = createNightmare(); -const moduleAccessViewHashURL = '#!/'; - -jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000; +import createNightmare from '../../helpers/helpers'; describe('Edit web access path', () => { - it('should log in', done => { - nightmare - .login() - .waitForURL(moduleAccessViewHashURL) - .url() - .then(url => { - expect(url).toEqual(config.url + moduleAccessViewHashURL); - done(); - }) - .catch(catchErrors(done)); - }); + const nightmare = createNightmare(); - it('should make sure the language is English', done => { - nightmare - .changeLanguageToEnglish() - .then(() => { - done(); - }) - .catch(catchErrors(done)); - }); - - it('should click on the Clients button of the top bar menu', done => { - nightmare + it('should click on the Clients button of the top bar menu', () => { + return nightmare .waitToClick(selectors.globalItems.applicationsMenuButton) .wait(selectors.globalItems.applicationsMenuVisible) .waitToClick(selectors.globalItems.clientsButton) .wait(selectors.clientsIndex.createClientButton) - .url() + .urlParsed() .then(url => { - expect(url).toEqual(config.url + '#!/clients'); - done(); - }) - .catch(catchErrors(done)); + expect(url.hash).toEqual('#!/clients'); + }); }); - it('should search for the user Bruce Banner', done => { - nightmare + it('should search for the user Bruce Banner', () => { + return nightmare .wait(selectors.clientsIndex.searchResult) .type(selectors.clientsIndex.searchClientInput, 'Bruce Banner') .click(selectors.clientsIndex.searchButton) @@ -52,13 +25,11 @@ describe('Edit web access path', () => { .countSearchResults(selectors.clientsIndex.searchResult) .then(result => { expect(result).toEqual(1); - done(); - }) - .catch(catchErrors(done)); + }); }); - it(`should click on the search result to access to the client's web access`, done => { - nightmare + it(`should click on the search result to access to the client's web access`, () => { + return nightmare .waitForTextInElement(selectors.clientsIndex.searchResult, 'Bruce Banner') .waitToClick(selectors.clientsIndex.searchResult) .waitToClick(selectors.clientWebAccess.webAccessButton) @@ -66,27 +37,21 @@ describe('Edit web access path', () => { .url() .then(url => { expect(url).toContain('web-access'); - done(); - }) - .catch(catchErrors(done)); + }); }); - it(`should click on the Enable web access checkbox to uncheck it`, done => { - nightmare + it(`should click on the Enable web access checkbox to uncheck it`, () => { + return nightmare .waitToClick(selectors.clientWebAccess.enableWebAccessCheckbox) .waitToClick(selectors.clientFiscalData.saveButton) - .wait(selectors.globalItems.snackbarIsActive) - .getInnerText(selectors.globalItems.snackbarIsActive) + .waitForSnackbar() .then(result => { expect(result).toContain(`Data saved!`); - done(); - }) - .catch(catchErrors(done)); + }); }); - it('should confirm Enable web access checkbox is unchecked', done => { - nightmare - .waitForSnackbarReset() + it('should confirm Enable web access checkbox is unchecked', () => { + return nightmare .waitToClick(selectors.clientBasicData.basicDataButton) .wait(selectors.clientBasicData.nameInput) .waitToClick(selectors.clientWebAccess.webAccessButton) @@ -96,29 +61,23 @@ describe('Edit web access path', () => { }, selectors.clientWebAccess.enableWebAccessCheckbox) .then(value => { expect(value).toBeFalsy(); - done(); - }) - .catch(catchErrors(done)); + }); }); - it('should edit the User name', done => { - nightmare + it('should edit the User name', () => { + return nightmare .wait(selectors.clientWebAccess.userNameInput) .clearInput(selectors.clientWebAccess.userNameInput) .type(selectors.clientWebAccess.userNameInput, 'Hulk') .click(selectors.clientWebAccess.saveButton) - .wait(selectors.globalItems.snackbarIsActive) - .getInnerText(selectors.globalItems.snackbarIsActive) + .waitForSnackbar() .then(result => { expect(result).toEqual('Data saved!'); - done(); - }) - .catch(catchErrors(done)); + }); }); - it('should confirm the User name have been edited', done => { - nightmare - .waitForSnackbarReset() + it('should confirm the User name have been edited', () => { + return nightmare .click(selectors.clientBasicData.basicDataButton) .wait(selectors.clientBasicData.nameInput) .click(selectors.clientWebAccess.webAccessButton) @@ -127,8 +86,6 @@ describe('Edit web access path', () => { .getInputValue(selectors.clientWebAccess.userNameInput) .then(result => { expect(result).toEqual('Hulk'); - done(); - }) - .catch(catchErrors(done)); + }); }); }); diff --git a/e2e/paths/client-module/08_add_notes.spec.js b/e2e/paths/client-module/08_add_notes.spec.js index 1e78f3a1f9..ca07ec054a 100644 --- a/e2e/paths/client-module/08_add_notes.spec.js +++ b/e2e/paths/client-module/08_add_notes.spec.js @@ -1,50 +1,23 @@ -import config from '../../helpers/config.js'; -import createNightmare from '../../helpers/nightmare'; import selectors from '../../helpers/selectors.js'; -import {catchErrors} from '../../../services/utils/jasmineHelpers'; -const nightmare = createNightmare(); -const moduleAccessViewHashURL = '#!/'; - -jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000; +import createNightmare from '../../helpers/helpers'; describe('Add notes path', () => { - it('should log in', done => { - nightmare - .login() - .waitForURL(moduleAccessViewHashURL) - .url() - .then(url => { - expect(url).toEqual(config.url + moduleAccessViewHashURL); - done(); - }) - .catch(catchErrors(done)); - }); + const nightmare = createNightmare(); - it('should make sure the language is English', done => { - nightmare - .changeLanguageToEnglish() - .then(() => { - done(); - }) - .catch(catchErrors(done)); - }); - - it('should click on the Clients button of the top bar menu', done => { - nightmare + it('should click on the Clients button of the top bar menu', () => { + return nightmare .waitToClick(selectors.globalItems.applicationsMenuButton) .wait(selectors.globalItems.applicationsMenuVisible) .waitToClick(selectors.globalItems.clientsButton) .wait(selectors.clientsIndex.createClientButton) - .url() + .urlParsed() .then(url => { - expect(url).toEqual(config.url + '#!/clients'); - done(); - }) - .catch(catchErrors(done)); + expect(url.hash).toEqual('#!/clients'); + }); }); - it('should search for the user Bruce Banner', done => { - nightmare + it('should search for the user Bruce Banner', () => { + return nightmare .wait(selectors.clientsIndex.searchResult) .type(selectors.clientsIndex.searchClientInput, 'Bruce Banner') .click(selectors.clientsIndex.searchButton) @@ -52,13 +25,11 @@ describe('Add notes path', () => { .countSearchResults(selectors.clientsIndex.searchResult) .then(result => { expect(result).toEqual(1); - done(); - }) - .catch(catchErrors(done)); + }); }); - it(`should click on the search result to access to the client's notes`, done => { - nightmare + it(`should click on the search result to access to the client's notes`, () => { + return nightmare .waitForTextInElement(selectors.clientsIndex.searchResult, 'Bruce Banner') .waitToClick(selectors.clientsIndex.searchResult) .waitToClick(selectors.clientNotes.notesButton) @@ -66,45 +37,35 @@ describe('Add notes path', () => { .url() .then(url => { expect(url).toContain('notes/list'); - done(); - }) - .catch(catchErrors(done)); + }); }); - it(`should click on the add note button`, done => { - nightmare + it(`should click on the add note button`, () => { + return nightmare .waitToClick(selectors.clientNotes.addNoteFloatButton) .waitForURL('/notes/create') .url() .then(url => { expect(url).toContain('/notes/create'); - done(); - }) - .catch(catchErrors(done)); + }); }); - it(`should create a note`, done => { - nightmare + it(`should create a note`, () => { + return nightmare .type(selectors.clientNotes.noteInput, 'Meeting with Black Widow 21st 9am') .click(selectors.clientNotes.saveButton) - .wait(selectors.globalItems.snackbarIsActive) - .getInnerText(selectors.globalItems.snackbarIsActive) + .waitForSnackbar() .then(result => { expect(result).toEqual('Data saved!'); - done(); - }) - .catch(catchErrors(done)); + }); }); - it('should confirm the note was created', done => { - nightmare - .waitForSnackbarReset() + it('should confirm the note was created', () => { + return nightmare .wait(selectors.clientNotes.firstNoteText) .getInnerText(selectors.clientNotes.firstNoteText) .then(value => { expect(value).toEqual('Meeting with Black Widow 21st 9am'); - done(); - }) - .catch(catchErrors(done)); + }); }); }); diff --git a/e2e/paths/client-module/09_add_credit.spec.js b/e2e/paths/client-module/09_add_credit.spec.js index 4608755ce5..206adc0d46 100644 --- a/e2e/paths/client-module/09_add_credit.spec.js +++ b/e2e/paths/client-module/09_add_credit.spec.js @@ -1,50 +1,23 @@ -import config from '../../helpers/config.js'; -import createNightmare from '../../helpers/nightmare'; import selectors from '../../helpers/selectors.js'; -import {catchErrors} from '../../../services/utils/jasmineHelpers'; -const nightmare = createNightmare(); -const moduleAccessViewHashURL = '#!/'; - -jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000; +import createNightmare from '../../helpers/helpers'; describe('Add credit path', () => { - it('should log in', done => { - nightmare - .login() - .waitForURL(moduleAccessViewHashURL) - .url() - .then(url => { - expect(url).toEqual(config.url + moduleAccessViewHashURL); - done(); - }) - .catch(catchErrors(done)); - }); + const nightmare = createNightmare(); - it('should make sure the language is English', done => { - nightmare - .changeLanguageToEnglish() - .then(() => { - done(); - }) - .catch(catchErrors(done)); - }); - - it('should click on the Clients button of the top bar menu', done => { - nightmare + it('should click on the Clients button of the top bar menu', () => { + return nightmare .waitToClick(selectors.globalItems.applicationsMenuButton) .wait(selectors.globalItems.applicationsMenuVisible) .waitToClick(selectors.globalItems.clientsButton) .wait(selectors.clientsIndex.createClientButton) - .url() + .urlParsed() .then(url => { - expect(url).toEqual(config.url + '#!/clients'); - done(); - }) - .catch(catchErrors(done)); + expect(url.hash).toEqual('#!/clients'); + }); }); - it('should search for the user Petter Parker', done => { - nightmare + it('should search for the user Petter Parker', () => { + return nightmare .wait(selectors.clientsIndex.searchResult) .type(selectors.clientsIndex.searchClientInput, 'Petter Parker') .click(selectors.clientsIndex.searchButton) @@ -52,13 +25,11 @@ describe('Add credit path', () => { .countSearchResults(selectors.clientsIndex.searchResult) .then(result => { expect(result).toEqual(1); - done(); - }) - .catch(catchErrors(done)); + }); }); - it(`should click on the search result to access to the client's credit`, done => { - nightmare + it(`should click on the search result to access to the client's credit`, () => { + return nightmare .waitForTextInElement(selectors.clientsIndex.searchResult, 'Petter Parker') .waitToClick(selectors.clientsIndex.searchResult) .waitToClick(selectors.clientCredit.creditButton) @@ -66,46 +37,36 @@ describe('Add credit path', () => { .url() .then(url => { expect(url).toContain('credit/list'); - done(); - }) - .catch(catchErrors(done)); + }); }); - it(`should click on the add credit button`, done => { - nightmare + it(`should click on the add credit button`, () => { + return nightmare .waitToClick(selectors.clientCredit.addCreditFloatButton) .waitForURL('/credit/create') .url() .then(url => { expect(url).toContain('/credit/create'); - done(); - }) - .catch(catchErrors(done)); + }); }); - it(`should edit the credit`, done => { - nightmare + it(`should edit the credit`, () => { + return nightmare .clearInput(selectors.clientCredit.creditInput) .type(selectors.clientCredit.creditInput, 999) .click(selectors.clientCredit.saveButton) - .wait(selectors.globalItems.snackbarIsActive) - .getInnerText(selectors.globalItems.snackbarIsActive) + .waitForSnackbar() .then(result => { expect(result).toEqual('Data saved!'); - done(); - }) - .catch(catchErrors(done)); + }); }); - it('should confirm the credit was updated', done => { - nightmare - .waitForSnackbarReset() + it('should confirm the credit was updated', () => { + return nightmare .wait(selectors.clientCredit.firstCreditText) .getInnerText(selectors.clientCredit.firstCreditText) .then(value => { expect(value).toContain(999); - done(); - }) - .catch(catchErrors(done)); + }); }); }); diff --git a/e2e/paths/client-module/10_add_greuge.spec.js b/e2e/paths/client-module/10_add_greuge.spec.js index 5e35e5801e..adf081ea20 100644 --- a/e2e/paths/client-module/10_add_greuge.spec.js +++ b/e2e/paths/client-module/10_add_greuge.spec.js @@ -1,50 +1,23 @@ -import config from '../../helpers/config.js'; -import createNightmare from '../../helpers/nightmare'; import selectors from '../../helpers/selectors.js'; -import {catchErrors} from '../../../services/utils/jasmineHelpers'; -const nightmare = createNightmare(); -const moduleAccessViewHashURL = '#!/'; - -jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000; +import createNightmare from '../../helpers/helpers'; describe('Add greuge path', () => { - it('should log in', done => { - nightmare - .login() - .waitForURL(moduleAccessViewHashURL) - .url() - .then(url => { - expect(url).toEqual(config.url + moduleAccessViewHashURL); - done(); - }) - .catch(catchErrors(done)); - }); + const nightmare = createNightmare(); - it('should make sure the language is English', done => { - nightmare - .changeLanguageToEnglish() - .then(() => { - done(); - }) - .catch(catchErrors(done)); - }); - - it('should click on the Clients button of the top bar menu', done => { - nightmare + it('should click on the Clients button of the top bar menu', () => { + return nightmare .waitToClick(selectors.globalItems.applicationsMenuButton) .wait(selectors.globalItems.applicationsMenuVisible) .waitToClick(selectors.globalItems.clientsButton) .wait(selectors.clientsIndex.createClientButton) - .url() + .urlParsed() .then(url => { - expect(url).toEqual(config.url + '#!/clients'); - done(); - }) - .catch(catchErrors(done)); + expect(url.hash).toEqual('#!/clients'); + }); }); - it('should search for the user Petter Parker', done => { - nightmare + it('should search for the user Petter Parker', () => { + return nightmare .wait(selectors.clientsIndex.searchResult) .type(selectors.clientsIndex.searchClientInput, 'Petter Parker') .click(selectors.clientsIndex.searchButton) @@ -52,13 +25,11 @@ describe('Add greuge path', () => { .countSearchResults(selectors.clientsIndex.searchResult) .then(result => { expect(result).toEqual(1); - done(); - }) - .catch(catchErrors(done)); + }); }); - it(`should click on the search result to access to the client's greuge`, done => { - nightmare + it(`should click on the search result to access to the client's greuge`, () => { + return nightmare .waitForTextInElement(selectors.clientsIndex.searchResult, 'Petter Parker') .waitToClick(selectors.clientsIndex.searchResult) .waitToClick(selectors.clientGreuge.greugeButton) @@ -66,103 +37,81 @@ describe('Add greuge path', () => { .url() .then(url => { expect(url).toContain('greuge/list'); - done(); - }) - .catch(catchErrors(done)); + }); }); - it(`should click on the add greuge button`, done => { - nightmare + it(`should click on the add greuge button`, () => { + return nightmare .waitToClick(selectors.clientGreuge.addGreugeFloatButton) .waitForURL('greuge/create') .url() .then(url => { expect(url).toContain('greuge/create'); - done(); - }) - .catch(catchErrors(done)); + }); }); - it(`should receive an error if all fields are empty but date on submit`, done => { - nightmare + it(`should receive an error if all fields are empty but date on submit`, () => { + return nightmare .click(selectors.clientCredit.saveButton) - .wait(selectors.globalItems.snackbarIsActive) - .getInnerText(selectors.globalItems.snackbarIsActive) + .waitForSnackbar() .then(result => { expect(result).toContain('Some fields are invalid'); - done(); - }) - .catch(catchErrors(done)); + }); }); - it(`should receive an error if all fields are empty but date and amount on submit`, done => { - nightmare + it(`should receive an error if all fields are empty but date and amount on submit`, () => { + return nightmare .type(selectors.clientGreuge.amountInput, 999) .click(selectors.clientGreuge.saveButton) - .wait(selectors.globalItems.snackbarIsActive) - .getInnerText(selectors.globalItems.snackbarIsActive) + .waitForSnackbar() .then(result => { expect(result).toContain('Some fields are invalid'); - done(); - }) - .catch(catchErrors(done)); + }); }); - it(`should receive an error if all fields are empty but date and description on submit`, done => { - nightmare + it(`should receive an error if all fields are empty but date and description on submit`, () => { + return nightmare .clearInput(selectors.clientGreuge.amountInput) .type(selectors.clientGreuge.descriptionInput, 'new armor for Batman!') .click(selectors.clientGreuge.saveButton) - .wait(selectors.globalItems.snackbarIsActive) - .getInnerText(selectors.globalItems.snackbarIsActive) + .waitForSnackbar() .then(result => { expect(result).toContain('Some fields are invalid'); - done(); - }) - .catch(catchErrors(done)); + }); }); - it(`should receive an error if all fields are empty but date and type on submit`, done => { - nightmare + it(`should receive an error if all fields are empty but date and type on submit`, () => { + return nightmare .clearInput(selectors.clientGreuge.descriptionInput) .waitToClick(selectors.clientGreuge.typeInput) .waitToClick(selectors.clientGreuge.typeSecondOption) .click(selectors.clientGreuge.saveButton) - .wait(selectors.globalItems.snackbarIsActive) - .getInnerText(selectors.globalItems.snackbarIsActive) + .waitForSnackbar() .then(result => { expect(result).toContain('Some fields are invalid'); - done(); - }) - .catch(catchErrors(done)); + }); }); - it(`should create a new greuge with all its data`, done => { - nightmare + it(`should create a new greuge with all its data`, () => { + return nightmare .clearInput(selectors.clientGreuge.amountInput) .type(selectors.clientGreuge.amountInput, 999) .type(selectors.clientGreuge.descriptionInput, 'new armor for Batman!') .click(selectors.clientGreuge.saveButton) - .wait(selectors.globalItems.snackbarIsActive) - .getInnerText(selectors.globalItems.snackbarIsActive) + .waitForSnackbar() .then(result => { expect(result).toContain('Data saved!'); - done(); - }) - .catch(catchErrors(done)); + }); }); - it('should confirm the greuge was added to the list', done => { - nightmare - .waitForSnackbarReset() + it('should confirm the greuge was added to the list', () => { + return nightmare .wait(selectors.clientGreuge.firstGreugeText) .getInnerText(selectors.clientGreuge.firstGreugeText) .then(value => { expect(value).toContain(999); expect(value).toContain('new armor for Batman!'); expect(value).toContain('Diff'); - done(); - }) - .catch(catchErrors(done)); + }); }); }); diff --git a/e2e/paths/client-module/11_mandate.spec.js b/e2e/paths/client-module/11_mandate.spec.js index c0e5355352..570f696b1c 100644 --- a/e2e/paths/client-module/11_mandate.spec.js +++ b/e2e/paths/client-module/11_mandate.spec.js @@ -1,50 +1,23 @@ -import config from '../../helpers/config.js'; -import createNightmare from '../../helpers/nightmare'; import selectors from '../../helpers/selectors.js'; -import {catchErrors} from '../../../services/utils/jasmineHelpers'; -const nightmare = createNightmare(); -const moduleAccessViewHashURL = '#!/'; - -jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000; +import createNightmare from '../../helpers/helpers'; describe('mandate path', () => { - it('should log in', done => { - nightmare - .login() - .waitForURL(moduleAccessViewHashURL) - .url() - .then(url => { - expect(url).toEqual(config.url + moduleAccessViewHashURL); - done(); - }) - .catch(catchErrors(done)); - }); + const nightmare = createNightmare(); - it('should make sure the language is English', done => { - nightmare - .changeLanguageToEnglish() - .then(() => { - done(); - }) - .catch(catchErrors(done)); - }); - - it('should click on the Clients button of the top bar menu', done => { - nightmare + it('should click on the Clients button of the top bar menu', () => { + return nightmare .waitToClick(selectors.globalItems.applicationsMenuButton) .wait(selectors.globalItems.applicationsMenuVisible) .waitToClick(selectors.globalItems.clientsButton) .wait(selectors.clientsIndex.createClientButton) - .url() + .urlParsed() .then(url => { - expect(url).toEqual(config.url + '#!/clients'); - done(); - }) - .catch(catchErrors(done)); + expect(url.hash).toEqual('#!/clients'); + }); }); - it('should search for the user Petter Parker', done => { - nightmare + it('should search for the user Petter Parker', () => { + return nightmare .wait(selectors.clientsIndex.searchResult) .type(selectors.clientsIndex.searchClientInput, 'Petter Parker') .click(selectors.clientsIndex.searchButton) @@ -52,13 +25,11 @@ describe('mandate path', () => { .countSearchResults(selectors.clientsIndex.searchResult) .then(result => { expect(result).toEqual(1); - done(); - }) - .catch(catchErrors(done)); + }); }); - it(`should click on the search result to access to the client's mandate`, done => { - nightmare + it(`should click on the search result to access to the client's mandate`, () => { + return nightmare .waitForTextInElement(selectors.clientsIndex.searchResult, 'Petter') .waitToClick(selectors.clientsIndex.searchResult) .waitToClick(selectors.clientMandate.mandateButton) @@ -66,21 +37,17 @@ describe('mandate path', () => { .url() .then(url => { expect(url).toContain('mandate'); - done(); - }) - .catch(catchErrors(done)); + }); }); - it('should confirm the client has a mandate of the CORE type', done => { - nightmare + it('should confirm the client has a mandate of the CORE type', () => { + return nightmare .wait(selectors.clientMandate.firstMandateText) .getInnerText(selectors.clientMandate.firstMandateText) .then(value => { expect(value).toContain('1'); expect(value).toContain('WAY'); expect(value).toContain('CORE'); - done(); - }) - .catch(catchErrors(done)); + }); }); }); diff --git a/gulpfile.js b/gulpfile.js index af1ecc6368..303b15bc2a 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -40,8 +40,8 @@ gulp.task('default', () => { return gulp.start('services', 'client'); }); -gulp.task('client', ['build-clean'], () => { - return gulp.start('watch', 'routes', 'locales', 'webpack-dev-server'); +gulp.task('client', ['build-clean'], async () => { + await runSequenceP(['routes', 'locales'], 'watch', 'webpack-dev-server'); }); /** diff --git a/webpack.config.js b/webpack.config.js index 79078697b9..fd13179bbe 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -72,8 +72,7 @@ let prodConfig = { path: outputPath }), new webpack.HashedModuleIdsPlugin() - ], - devtool: 'source-map' + ] }; let devConfig = { @@ -83,8 +82,7 @@ let devConfig = { }, plugins: [ new webpack.NamedModulesPlugin() - ], - devtool: 'eval' + ] }; let mrgConfig = devMode ? devConfig : prodConfig;