E2E refactor, Snackbar with hide button, Dialog, bugs solved

This commit is contained in:
Juan Ferrer Toribio 2018-02-20 10:00:19 +01:00
parent f2d5d58513
commit eb0276183f
42 changed files with 944 additions and 1553 deletions

View File

@ -1,6 +1,9 @@
import ngModule from '../module'; import ngModule from '../module';
import './style.scss'; import './style.scss';
/**
* A simple login form.
*/
export default class Controller { export default class Controller {
constructor($element, $scope, $window, $http) { constructor($element, $scope, $window, $http) {
this.$element = $element; this.$element = $element;
@ -9,9 +12,9 @@ export default class Controller {
this.$http = $http; this.$http = $http;
} }
submit() { submit() {
if (!(this.user && this.password)) { if (!this.user) {
this.focusUser(); this.focusUser();
this.showMessage('Please insert your user and password'); this.showError('Please insert your user and password');
return; return;
} }
@ -62,15 +65,15 @@ export default class Controller {
message = 'Something went wrong'; message = 'Something went wrong';
} }
this.showMessage(message); this.showError(message);
this.focusUser(); this.focusUser();
} }
focusUser() { focusUser() {
this.$.userField.select(); this.$.userField.select();
this.$.userField.focus(); this.$.userField.focus();
} }
showMessage(message) { showError(message) {
this.$.snackbar.show({message: message}); this.$.snackbar.showError({message: message});
} }
} }
Controller.$inject = ['$element', '$scope', '$window', '$http']; Controller.$inject = ['$element', '$scope', '$window', '$http'];

View File

@ -39,17 +39,9 @@
<vn-submit label="Save" vn-acl="administrative"></vn-submit> <vn-submit label="Save" vn-acl="administrative"></vn-submit>
</vn-button-bar> </vn-button-bar>
</form> </form>
<vn-dialog <vn-confirm
vn-id="send-mail" vn-id="send-mail"
on-response="$ctrl.returnDialog(response)"> on-response="$ctrl.returnDialog(response)"
<tpl-body> question="Changed terms"
<vn-vertical> message="Notify customer?">
<vn-one text-center translate>Changed terms</vn-one> </vn-confirm>
<vn-one text-center translate>Notify customer?</vn-one>
</vn-vertical>
</tpl-body>
<tpl-buttons>
<button response="CANCEL" translate>No</button>
<button response="ACCEPT" translate>Yes, notify</button>
</tpl-buttons>
</vn-dialog>

View File

@ -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

View File

@ -12,4 +12,4 @@ Due day: Vencimiento
Received core VNH: Recibido core VNH Received core VNH: Recibido core VNH
Received core VNL: Recibido core VNL Received core VNL: Recibido core VNL
Received B2B VNL: Recibido B2B VNL Received B2B VNL: Recibido B2B VNL
SAVE: GUARDAR Save: Guardar

View File

@ -1,23 +1,10 @@
<div ng-mousedown="$ctrl.onDialogMouseDown($event)"> <root>
<button ng-click="$ctrl.hide()" class="close" translate-attr="{title: 'Close'}">
<vn-icon vn-one icon="clear" style="color:black"></vn-icon>
</button>
<form>
<div>
<tpl-body> <tpl-body>
<h6 class="dialog-title" translate> <h6 translate>{{::$ctrl.question}}</h6>
{{::$ctrl.question}} <span translate>{{::$ctrl.message}}</span>
</h6>
<span translate>
{{::$ctrl.message}}
</span>
</tpl-body> </tpl-body>
</div>
<div class="button-bar" ng-click="$ctrl.onButtonClick($event)">
<tpl-buttons> <tpl-buttons>
<button response="CANCEL" translate>Cancel</button> <button response="CANCEL" translate>Cancel</button>
<button response="ACCEPT" translate>Accept</button> <button response="ACCEPT" translate>Accept</button>
</tpl-buttons> </tpl-buttons>
</div> </root>
</form>
</div>

View File

@ -1,13 +1,21 @@
import ngModule from '../../module'; import ngModule from '../../module';
import Dialog from '../dialog/dialog'; import Dialog from '../dialog/dialog';
import './style.scss'; import template from './confirm.html';
export default class Confirm extends Dialog {} export default class Confirm extends Dialog {
Dialog.$inject = ['$element']; 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', { ngModule.component('vnConfirm', {
template: require('./confirm.html'), template: require('../dialog/dialog.html'),
bindings: { bindings: {
onOpen: '&?',
onResponse: '&', onResponse: '&',
question: '@', question: '@',
message: '@?' message: '@?'

View File

@ -1,5 +0,0 @@
vn-confirm .dialog-title {
color:#424242;
font-family: vn-font-bold;
}

View File

@ -1,12 +1,13 @@
<div ng-mousedown="$ctrl.onDialogMouseDown($event)"> <div ng-mousedown="$ctrl.onDialogMouseDown($event)">
<button ng-click="$ctrl.hide()" class="close" translate-attr="{title: 'Close'}"> <button ng-click="$ctrl.hide()" class="close" translate-attr="{title: 'Close'}">
<vn-icon vn-one icon="clear" style="color:black"></vn-icon> <vn-icon icon="clear"></vn-icon>
</button> </button>
<form> <form>
<div ng-transclude="tplBody"></div>
<div <div
ng-transclude="tplButtons" class="body">
class="button-bar" </div>
<div
class="buttons"
ng-click="$ctrl.onButtonClick($event)"> ng-click="$ctrl.onButtonClick($event)">
</div> </div>
</form> </form>

View File

@ -4,44 +4,44 @@ import './style.scss';
/** /**
* Dialog component. * Dialog component.
*
* @property {HTMLElement} body The dialog HTML body
* @property {HTMLElement} buttons The dialog HTML buttons
*/ */
export default class Dialog extends Component { export default class Dialog extends Component {
/** constructor($element, $transclude) {
* Contructor.
*
* @param {HTMLElement} $element The HTML element object
*/
constructor($element) {
super($element); super($element);
$element.addClass('vn-dialog'); this.shown = false;
this.dialog = $element[0].firstChild; this.$element.addClass('vn-dialog');
this.element.addEventListener('mousedown', event => this.onBackgroundMouseDown(event)); 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. * Displays the dialog to the user.
*/ */
show() { show() {
let style = this.dialog.style; if (this.shown) return;
let window = this.window; this.shown = true;
let innerWidth = window.innerWidth; this.keypressHandler = e => this.onKeypress(e);
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);
this.document.addEventListener('keypress', this.keypressHandler); 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) if (this.onOpen)
this.onOpen(); this.onOpen();
@ -65,19 +65,21 @@ export default class Dialog extends Component {
cancel = this.onResponse({response: response}); cancel = this.onResponse({response: response});
return cancel; return cancel;
} }
realHide() { realHide() {
if (!this.shown) return;
this.element.style.display = 'none'; this.element.style.display = 'none';
this.document.removeEventListener('keypress', this.keypressHandler); this.document.removeEventListener('keypress', this.keypressHandler);
this.lastEvent = null; this.lastEvent = null;
this.shown = false;
this.transitionTimeout =
setTimeout(() => this.$element.removeClass('shown'), 30);
} }
onButtonClick(event) { onButtonClick(event) {
let buttonBar = this.element.querySelector('.button-bar'); let buttons = this.element.querySelector('.buttons');
let buttons = buttonBar.querySelector('tpl-buttons'); let tplButtons = buttons.querySelector('tpl-buttons');
let node = event.target; let node = event.target;
while (node.parentNode != buttons) { while (node.parentNode != tplButtons) {
if (node == buttonBar) return; if (node == buttons) return;
node = node.parentNode; node = node.parentNode;
} }
@ -85,28 +87,28 @@ export default class Dialog extends Component {
let cancel = this.fireResponse(response); let cancel = this.fireResponse(response);
if (cancel !== false) this.realHide(); if (cancel !== false) this.realHide();
} }
onDialogMouseDown(event) { onDialogMouseDown(event) {
this.lastEvent = event; this.lastEvent = event;
} }
onBackgroundMouseDown(event) { onBackgroundMouseDown(event) {
if (event != this.lastEvent) if (event != this.lastEvent)
this.hide(); this.hide();
} }
onKeypress(event) { onKeypress(event) {
if (event.keyCode == 27) // Esc if (event.keyCode == 27) // Esc
this.hide(); this.hide();
} }
$onDestroy() {
clearTimeout(this.transitionTimeout);
}
} }
Dialog.$inject = ['$element']; Dialog.$inject = ['$element', '$transclude'];
ngModule.component('vnDialog', { ngModule.component('vnDialog', {
template: require('./dialog.html'), template: require('./dialog.html'),
transclude: { transclude: {
tplBody: 'tplBody', body: 'tplBody',
tplButtons: 'tplButtons' buttons: 'tplButtons'
}, },
bindings: { bindings: {
onOpen: '&?', onOpen: '&?',

View File

@ -9,168 +9,45 @@ describe('Component vnDialog', () => {
beforeEach(angular.mock.inject(_$componentController_ => { beforeEach(angular.mock.inject(_$componentController_ => {
$componentController = _$componentController_; $componentController = _$componentController_;
$element = angular.element('<div></div>'); $element = angular.element('<vn-dialog></vn-dialog>');
controller = $componentController('vnDialog', {$element}); controller = $componentController('vnDialog', {$element: $element, $transclude: null});
})); }));
describe('show()', () => { 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.innerHeight = 600;
window.innerWidth = 800; window.innerWidth = 800;
controller.dialog = {style: {display: 'none'}};
controller.onOpen = () => {}; controller.onOpen = () => {};
controller.dialog = {style: {}, offsetWidth: 780, offsetHeight: 581};
spyOn(controller.document, 'addEventListener');
spyOn(controller, 'onOpen'); spyOn(controller, 'onOpen');
controller.show(); controller.show();
expect(controller.keypressHandler).toBeDefined(); expect(controller.element.style.display).not.toEqual('none');
expect(controller.document.addEventListener).toHaveBeenCalledWith('keypress', controller.keypressHandler);
expect(controller.element.style.display).toEqual('block');
expect(controller.onOpen).toHaveBeenCalledWith(); 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()', () => { describe('hide()', () => {
it(`should call fireResponse() and realHide()`, () => { it(`should call onResponse()`, () => {
spyOn(controller, 'fireResponse'); controller.onResponse = () => {};
spyOn(controller, 'realHide'); spyOn(controller, 'onResponse');
controller.hide(); controller.hide();
expect(controller.fireResponse).toHaveBeenCalledWith(); expect(controller.onResponse).toHaveBeenCalled();
expect(controller.realHide).toHaveBeenCalledWith();
}); });
}); });
describe('fireResponse()', () => { describe('fireResponse()', () => {
it(`should return cancel as false`, () => { it(`should call onResponse()`, () => {
let result = controller.fireResponse('I am the answer!'); let resposneRes;
controller.onResponse = response => {
expect(controller.onResponse).not.toBeDefined(); resposneRes = response;
expect(result).toEqual(false); return false;
});
it(`should return onResponse()`, () => {
let text = 'I am the answer!';
controller.onResponse = () => {
return {response: text};
}; };
let result = controller.fireResponse(text); let responseRet = controller.fireResponse('answer');
expect(result.response).toEqual(text); expect(resposneRes).toEqual({response: 'answer'});
}); expect(responseRet).toEqual(false);
});
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();
}); });
}); });
}); });

View File

@ -1,33 +1,19 @@
.vn-dialog { .vn-dialog {
display: none; display: none;
z-index: 100; justify-content: center;
align-items: center;
z-index: 50;
position: fixed; position: fixed;
left: 0; left: 0;
top: 0; top: 0;
height: 100%; height: 100%;
width: 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 { &.shown {
position: absolute; opacity: 1;
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);
}
} }
& > div { & > div {
position: relative; position: relative;
@ -35,34 +21,47 @@
background-color: white; background-color: white;
border-radius: .2em; border-radius: .2em;
overflow: auto; overflow: auto;
top: 50%;
left: 50%;
padding: 2em; padding: 2em;
box-sizing: border-box; box-sizing: border-box;
width: 28em; tpl-body {
margin-top: -10em; display: block;
margin-left: -14em; width: 20em;
} }
.button-bar {
margin-top: 1.5em;
text-align: right;
button { button {
background: none;
border: none;
text-transform: uppercase; text-transform: uppercase;
font-size: 1.1em; background-color: transparent;
color: #ffa410; border: none;
font-family: vn-font-bold;
cursor: pointer; cursor: pointer;
padding: .5em; transition: background-color 250ms;
margin: -0.5em; border-radius: .1em;
margin-left: .5em;
&:hover { &:hover {
background-color: rgba(1,1,1,.1); 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;
}
}
} }
} }

View File

@ -1,6 +1,6 @@
vn-drop-down { vn-drop-down {
position: absolute; position: absolute;
z-index: 9999; z-index: 10;
padding: 0 15px; padding: 0 15px;
margin-left: -15px; margin-left: -15px;
background: transparent; background: transparent;

View File

@ -1,8 +1,8 @@
vn-icon { vn-icon {
display: inline; display: inline-block;
font-size: 18pt; font-size: 18pt;
} }
vn-icon > i { vn-icon > i.material-icons {
display: block; display: block;
font-size: inherit !important; font-size: inherit;
} }

View File

@ -1,4 +1,4 @@
<div class="mdl-js-snackbar mdl-snackbar" style="z-index: 200;"> <div ng-click="$ctrl.onSnackbarClick($event)">
<div class="mdl-snackbar__text"></div> <button ng-click="$ctrl.onButtonClick()"></button>
<button class="mdl-snackbar__action" type="button"></button> <div class="text"></div>
</div> </div>

View File

@ -1,12 +1,19 @@
import ngModule from '../../module'; import ngModule from '../../module';
import Component from '../../lib/component';
import './style.scss';
/** /**
* A simple component to show non-obstructive notifications to the user. * A simple component to show non-obstructive notifications to the user.
*/ */
export default class Controller { export default class Controller extends Component {
constructor($element) { constructor($element, $translate) {
super($element);
this.$translate = $translate;
this.shown = false;
this.snackbar = $element[0].firstChild; 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. * Shows a notification.
@ -14,10 +21,76 @@ export default class Controller {
* @param {Object} data The message data * @param {Object} data The message data
*/ */
show(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', { ngModule.component('vnSnackbar', {
template: require('./snackbar.html'), template: require('./snackbar.html'),

View File

@ -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;
}
}

View File

@ -10,9 +10,33 @@ vn-textfield {
margin: 21px 0px; margin: 21px 0px;
background: white; background: white;
opacity: 1; opacity: 1;
z-index: 9999; z-index: 1;
color: #aaa; 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 { .material-icons {
font-size: 18px; font-size: 18px;
float: right; float: right;

View File

@ -2,8 +2,8 @@ import ngModule from '../module';
import {kebabToCamel} from '../lib/string'; import {kebabToCamel} from '../lib/string';
/** /**
* Registers the element controller into its scope as a * Registers the element controller into the scope as a property whose name is
* property whose name is the directive value. * the directive value transformed to lowerCamelCase.
* *
* @return {Object} The directive * @return {Object} The directive
*/ */
@ -12,7 +12,8 @@ export function directive() {
restrict: 'A', restrict: 'A',
link: function($scope, $element, $attrs) { link: function($scope, $element, $attrs) {
let id = kebabToCamel($attrs.vnId); 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) if (!id)
throw new Error(`vnId: Attribute can't be null`); throw new Error(`vnId: Attribute can't be null`);

View File

@ -24,7 +24,7 @@ describe('Directive dialog', () => {
$componentController = _$componentController_; $componentController = _$componentController_;
_$httpBackend_.when('GET', /\/locale\/\w+\/[a-z]{2}\.json/).respond({}); _$httpBackend_.when('GET', /\/locale\/\w+\/[a-z]{2}\.json/).respond({});
$element = angular.element('<div></div>'); $element = angular.element('<div></div>');
controller = $componentController('vnDialog', {$element}); controller = $componentController('vnDialog', {$element: $element, $transclude: null});
})); }));
it('should call show() function if dialog is a instance of vnDialog', () => { it('should call show() function if dialog is a instance of vnDialog', () => {

View File

@ -11,15 +11,13 @@ export default class App {
this.loaderStatus = 0; this.loaderStatus = 0;
this.$rootScope = $rootScope; this.$rootScope = $rootScope;
} }
show(message) {
this.timeout = window.snackbarTimeout || 2000;
if (this.snackbar) this.snackbar.show({message: message, timeout: this.timeout});
}
showMessage(message) { showMessage(message) {
this.show(message); if (this.snackbar)
this.snackbar.show({message: message});
} }
showError(message) { showError(message) {
this.show(`Error: ${message}`); if (this.snackbar)
this.snackbar.showError({message: `Error: ${message}`});
} }
pushLoader() { pushLoader() {
this.loaderStatus++; this.loaderStatus++;

View File

@ -21,9 +21,10 @@ export default class Component {
* @param {$rootScope.Scope} $scope The element scope * @param {$rootScope.Scope} $scope The element scope
*/ */
constructor($element, $scope) { constructor($element, $scope) {
this.$ = $scope;
this.$element = $element;
this.element = $element[0]; this.element = $element[0];
this.element.$ctrl = this;
this.$element = $element;
this.$ = $scope;
} }
} }
Component.$inject = ['$element', '$scope']; Component.$inject = ['$element', '$scope'];

View File

@ -5,3 +5,6 @@ Clear: Clear
Save: Save Save: Save
Add: Add Add: Add
Search: Search Search: Search
Show More: Show More
No more results: No more results
Hide: Hide

View File

@ -6,4 +6,5 @@ Save: Guardar
Add: Añadir Add: Añadir
Search: Buscar Search: Buscar
Show More: Ver más Show More: Ver más
No more results : No hay más resultados No more results: No hay más resultados
Hide: Ocultar

View File

@ -6,11 +6,6 @@ body {
line-height: initial; line-height: initial;
font-size: 12pt; font-size: 12pt;
} }
.mdl-textfield {
width: 100%;
}
.mdl-button { .mdl-button {
font-weight: bolder; font-weight: bolder;
color: #ffa410; color: #ffa410;
@ -32,33 +27,3 @@ body {
background-color: #ff9400 !important; 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;
}

View File

@ -1,6 +1,7 @@
import config from './config.js'; import config from './config.js';
import Nightmare from 'nightmare'; import Nightmare from 'nightmare';
import selectors from './selectors.js'; import selectors from './selectors.js';
import {URL} from 'url';
function child(selector, childNumber) { function child(selector, childNumber) {
let aux = selector.split(' '); let aux = selector.split(' ');
@ -17,6 +18,37 @@ Nightmare.action('login', function(done) {
.then(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) { Nightmare.action('getInnerText', function(selector, done) {
this.wait(selector) this.wait(selector)
.evaluate_now(function(elementToSelect) { .evaluate_now(function(elementToSelect) {
@ -134,29 +166,39 @@ Nightmare.action('waitForTextInInput', function(selector, name, done) {
.then(done); .then(done);
}); });
Nightmare.action('changeLanguageToEnglish', function(done) { Nightmare.action('waitForInnerText', function(selector, done) {
this.wait('#lang-button') this.wait(selector)
.evaluate(selector => { .wait(selector => {
return document.querySelector(selector).title; let innerText = document.querySelector(selector).innerText;
}, '#lang-button') return innerText != null && innerText != '';
.then(title => { }, selector)
if (title === 'Change language') { .evaluate_now(selector => {
this.then(done); return document.querySelector(selector).innerText;
} else { }, done, selector);
this.click('#lang-button') });
.click('#langs > li[name="en"]')
Nightmare.action('waitForEmptyInnerText', function(selector, done) {
this.wait(selector => {
return document.querySelector(selector).innerText == '';
}, selector)
.then(done); .then(done);
}
});
}); });
Nightmare.action('waitForSnackbarReset', function(done) { Nightmare.action('waitForSnackbarReset', function(done) {
this.wait(() => { this.click('vn-snackbar button')
return document.querySelector('vn-snackbar').innerText === ''; .waitForEmptyInnerText('vn-snackbar .text')
})
.then(done); .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) { Nightmare.action('waitForURL', function(hashURL, done) {
this.wait(hash => { this.wait(hash => {
return document.location.hash.includes(hash); return document.location.hash.includes(hash);

19
e2e/helpers/helpers.js Normal file
View File

@ -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;
}

View File

@ -22,3 +22,5 @@ export default function createNightmare(width = 1280, height = 720) {
}); });
return nightmare; return nightmare;
} }
jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000;

View File

@ -1,2 +0,0 @@
// snackbar default 2500 and jasmine timeout should be 10000
window.snackbarTimeout = 400;

View File

@ -10,7 +10,7 @@ export default {
globalItems: { globalItems: {
topBar: `${components.vnTopbar}`, topBar: `${components.vnTopbar}`,
logOutButton: `${components.vnIcon}[icon="exit_to_app"]`, logOutButton: `${components.vnIcon}[icon="exit_to_app"]`,
snackbarIsActive: '.mdl-snackbar--active > .mdl-snackbar__text', snackbarIsActive: 'vn-snackbar .text',
applicationsMenuButton: `${components.vnIcon}[icon="apps"]`, applicationsMenuButton: `${components.vnIcon}[icon="apps"]`,
applicationsMenuVisible: `${components.vnMainMenu} .is-visible > div`, applicationsMenuVisible: `${components.vnMainMenu} .is-visible > div`,
clientsButton: `${components.vnMainMenu} > div > ul > li:nth-child(1)` clientsButton: `${components.vnMainMenu} > div > ul > li:nth-child(1)`
@ -54,7 +54,7 @@ export default {
socialNameInput: `${components.vnTextfield}[name="socialName"]`, socialNameInput: `${components.vnTextfield}[name="socialName"]`,
fiscalIdInput: `${components.vnTextfield}[name="fi"]`, fiscalIdInput: `${components.vnTextfield}[name="fi"]`,
equalizationTaxCheckboxLabel: `${components.vnCheck}[label='Is equalizated'] > label > input`, 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"]`, addressInput: `${components.vnTextfield}[name="street"]`,
cityInput: `${components.vnTextfield}[name="city"]`, cityInput: `${components.vnTextfield}[name="city"]`,
postcodeInput: `${components.vnTextfield}[name="postcode"]`, 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)`, 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"]`, IBANInput: `${components.vnTextfield}[name="iban"]`,
dueDayInput: `${components.vnTextfield}[name="dueDay"]`, 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`, receivedCoreVNHCheckbox: `${components.vnCheck}[label='Received core VNH'] > label > input`,
receivedCoreVNLCheckbox: `${components.vnCheck}[label='Received core VNL'] > label > input`, receivedCoreVNLCheckbox: `${components.vnCheck}[label='Received core VNL'] > label > input`,
receivedB2BVNLCheckbox: `${components.vnCheck}[label='Received B2B VNL'] > label > input`, receivedB2BVNLCheckbox: `${components.vnCheck}[label='Received B2B VNL'] > label > input`,

View File

@ -1,48 +1,21 @@
import config from '../../helpers/config.js'; import selectors from '../../helpers/selectors';
import createNightmare from '../../helpers/nightmare'; import createNightmare from '../../helpers/helpers';
import selectors from '../../helpers/selectors.js';
import {catchErrors} from '../../../services/utils/jasmineHelpers';
const nightmare = createNightmare();
const moduleAccessViewHashURL = '#!/';
jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000;
describe('create client path', () => { describe('create client path', () => {
it('should log in', done => { let nightmare = createNightmare();
nightmare
.login()
.waitForURL(moduleAccessViewHashURL)
.url()
.then(url => {
expect(url).toEqual(config.url + moduleAccessViewHashURL);
done();
})
.catch(catchErrors(done));
});
it('should make sure the language is English', done => { it('should access to the clients index by clicking the clients button', () => {
nightmare return nightmare
.changeLanguageToEnglish()
.then(() => {
done();
})
.catch(catchErrors(done));
});
it('should access to the clients index by clicking the clients button', done => {
nightmare
.click(selectors.moduleAccessView.clientsSectionButton) .click(selectors.moduleAccessView.clientsSectionButton)
.wait(selectors.clientsIndex.createClientButton) .wait(selectors.clientsIndex.createClientButton)
.url() .urlParsed()
.then(url => { .then(url => {
expect(url).toEqual(config.url + '#!/clients'); expect(url.hash).toEqual('#!/clients');
done(); });
})
.catch(catchErrors(done));
}); });
it(`should search for the user Carol Danvers to confirm it isn't created yet`, done => { it(`should search for the user Carol Danvers to confirm it isn't created yet`, () => {
nightmare return nightmare
.wait(selectors.clientsIndex.searchResult) .wait(selectors.clientsIndex.searchResult)
.type(selectors.clientsIndex.searchClientInput, 'Carol Danvers') .type(selectors.clientsIndex.searchClientInput, 'Carol Danvers')
.click(selectors.clientsIndex.searchButton) .click(selectors.clientsIndex.searchButton)
@ -50,142 +23,107 @@ describe('create client path', () => {
.countSearchResults(selectors.clientsIndex.searchResult) .countSearchResults(selectors.clientsIndex.searchResult)
.then(result => { .then(result => {
expect(result).toEqual(0); expect(result).toEqual(0);
done(); });
})
.catch(catchErrors(done));
}); });
it('should access to the create client view by clicking the create-client floating button', done => { it('should access to the create client view by clicking the create-client floating button', () => {
nightmare return nightmare
.click(selectors.clientsIndex.createClientButton) .click(selectors.clientsIndex.createClientButton)
.wait(selectors.createClientView.createButton) .wait(selectors.createClientView.createButton)
.url() .urlParsed()
.then(url => { .then(url => {
expect(url).toEqual(config.url + '#!/create'); expect(url.hash).toEqual('#!/create');
done(); });
})
.catch(catchErrors(done));
}); });
it('should receive an error when clicking the create button having all the form fields empty', done => { it('should receive an error when clicking the create button having all the form fields empty', () => {
nightmare return nightmare
.click(selectors.createClientView.createButton) .click(selectors.createClientView.createButton)
.wait(selectors.globalItems.snackbarIsActive) .waitForSnackbar()
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => { .then(result => {
expect(result).toEqual('Some fields are invalid'); 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 => { it('should receive an error when clicking the create button having all the form fields empty but name', () => {
nightmare return nightmare
.waitForSnackbarReset()
.type(selectors.createClientView.name, 'Carol Danvers') .type(selectors.createClientView.name, 'Carol Danvers')
.click(selectors.createClientView.createButton) .click(selectors.createClientView.createButton)
.wait(selectors.globalItems.snackbarIsActive) .waitForSnackbar()
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => { .then(result => {
expect(result).toContain('Some fields are invalid'); 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 => { it('should receive an error when clicking the create button having all the form fields empty but Tax Number', () => {
nightmare return nightmare
.waitForSnackbarReset()
.clearInput(selectors.createClientView.name) .clearInput(selectors.createClientView.name)
.type(selectors.createClientView.taxNumber, 'AVG tax') .type(selectors.createClientView.taxNumber, 'AVG tax')
.click(selectors.createClientView.createButton) .click(selectors.createClientView.createButton)
.wait(selectors.globalItems.snackbarIsActive) .waitForSnackbar()
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => { .then(result => {
expect(result).toContain('Some fields are invalid'); 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 => { it('should receive an error when clicking the create button having all the form fields empty but Business Name', () => {
nightmare return nightmare
.waitForSnackbarReset()
.clearInput(selectors.createClientView.taxNumber) .clearInput(selectors.createClientView.taxNumber)
.type(selectors.createClientView.socialName, 'Avengers team') .type(selectors.createClientView.socialName, 'Avengers team')
.click(selectors.createClientView.createButton) .click(selectors.createClientView.createButton)
.wait(selectors.globalItems.snackbarIsActive) .waitForSnackbar()
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => { .then(result => {
expect(result).toContain('Some fields are invalid'); 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 => { it('should receive an error when clicking the create button having all the form fields empty but User Name', () => {
nightmare return nightmare
.waitForSnackbarReset()
.clearInput(selectors.createClientView.socialName) .clearInput(selectors.createClientView.socialName)
.type(selectors.createClientView.userName, 'CaptainMarvel') .type(selectors.createClientView.userName, 'CaptainMarvel')
.click(selectors.createClientView.createButton) .click(selectors.createClientView.createButton)
.wait(selectors.globalItems.snackbarIsActive) .waitForSnackbar()
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => { .then(result => {
expect(result).toContain('Some fields are invalid'); 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 => { it('should receive an error when clicking the create button having all the form fields empty but email while email have incorrect format', () => {
nightmare return nightmare
.waitForSnackbarReset()
.clearInput(selectors.createClientView.userName) .clearInput(selectors.createClientView.userName)
.type(selectors.createClientView.email, 'I will save the Avengers!') .type(selectors.createClientView.email, 'I will save the Avengers!')
.click(selectors.createClientView.createButton) .click(selectors.createClientView.createButton)
.wait(selectors.globalItems.snackbarIsActive) .waitForSnackbar()
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => { .then(result => {
expect(result).toEqual('Some fields are invalid'); 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 => { it('should receive an error when clicking the create button having all the form fields empty but email', () => {
nightmare return nightmare
.waitForSnackbarReset()
.clearInput(selectors.createClientView.email) .clearInput(selectors.createClientView.email)
.type(selectors.createClientView.email, 'CarolDanvers@verdnatura.es') .type(selectors.createClientView.email, 'CarolDanvers@verdnatura.es')
.click(selectors.createClientView.createButton) .click(selectors.createClientView.createButton)
.wait(selectors.globalItems.snackbarIsActive) .waitForSnackbar()
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => { .then(result => {
expect(result).toContain('Some fields are invalid'); 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 => { it('should receive an error when clicking the create button having all the form fields empty but sales person', () => {
nightmare return nightmare
.waitToClick(selectors.createClientView.salesPersonInput) .waitToClick(selectors.createClientView.salesPersonInput)
.waitToClick(selectors.createClientView.salesBruceBannerOption) .waitToClick(selectors.createClientView.salesBruceBannerOption)
.wait(200) .wait(200)
.click(selectors.createClientView.createButton) .click(selectors.createClientView.createButton)
.wait(selectors.globalItems.snackbarIsActive) .waitForSnackbar()
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => { .then(result => {
expect(result).toContain('Some fields are invalid'); expect(result).toContain('Some fields are invalid');
done(); });
})
.catch(catchErrors(done));
}); });
it(`should create a new user with all it's data`, done => { it(`should create a new user with all it's data`, () => {
nightmare return nightmare
.waitForSnackbarReset()
.wait(selectors.createClientView.email) .wait(selectors.createClientView.email)
.clearInput(selectors.createClientView.email) .clearInput(selectors.createClientView.email)
.type(selectors.createClientView.name, 'Carol Danvers') .type(selectors.createClientView.name, 'Carol Danvers')
@ -194,31 +132,26 @@ describe('create client path', () => {
.type(selectors.createClientView.userName, 'CaptainMarvel') .type(selectors.createClientView.userName, 'CaptainMarvel')
.type(selectors.createClientView.email, 'CarolDanvers@verdnatura.es') .type(selectors.createClientView.email, 'CarolDanvers@verdnatura.es')
.click(selectors.createClientView.createButton) .click(selectors.createClientView.createButton)
.wait(selectors.globalItems.snackbarIsActive) .waitForSnackbar()
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => { .then(result => {
expect(result).toContain('Data saved!'); expect(result).toContain('Data saved!');
done(); });
})
.catch(catchErrors(done));
}); });
it('should click on the Clients button of the top bar menu', done => { it('should click on the Clients button of the top bar menu', () => {
nightmare return nightmare
.waitToClick(selectors.globalItems.applicationsMenuButton) .waitToClick(selectors.globalItems.applicationsMenuButton)
.wait(selectors.globalItems.applicationsMenuVisible) .wait(selectors.globalItems.applicationsMenuVisible)
.waitToClick(selectors.globalItems.clientsButton) .waitToClick(selectors.globalItems.clientsButton)
.wait(selectors.clientsIndex.createClientButton) .wait(selectors.clientsIndex.createClientButton)
.url() .urlParsed()
.then(url => { .then(url => {
expect(url).toEqual(config.url + '#!/clients'); expect(url.hash).toEqual('#!/clients');
done(); });
})
.catch(catchErrors(done));
}); });
it(`should search for the user Carol Danvers to confirm it exists`, done => { it(`should search for the user Carol Danvers to confirm it exists`, () => {
nightmare return nightmare
.wait(selectors.clientsIndex.searchResult) .wait(selectors.clientsIndex.searchResult)
.type(selectors.clientsIndex.searchClientInput, 'Carol Danvers') .type(selectors.clientsIndex.searchClientInput, 'Carol Danvers')
.click(selectors.clientsIndex.searchButton) .click(selectors.clientsIndex.searchButton)
@ -226,8 +159,6 @@ describe('create client path', () => {
.countSearchResults(selectors.clientsIndex.searchResult) .countSearchResults(selectors.clientsIndex.searchResult)
.then(result => { .then(result => {
expect(result).toEqual(1); expect(result).toEqual(1);
done(); });
})
.catch(catchErrors(done));
}); });
}); });

View File

@ -1,50 +1,23 @@
import config from '../../helpers/config.js';
import createNightmare from '../../helpers/nightmare';
import selectors from '../../helpers/selectors.js'; import selectors from '../../helpers/selectors.js';
import {catchErrors} from '../../../services/utils/jasmineHelpers'; import createNightmare from '../../helpers/helpers';
const nightmare = createNightmare();
const moduleAccessViewHashURL = '#!/';
jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000;
describe('Edit basicData path', () => { describe('Edit basicData path', () => {
it('should log in', done => { const nightmare = createNightmare();
nightmare
.login()
.waitForURL(moduleAccessViewHashURL)
.url()
.then(url => {
expect(url).toEqual(config.url + moduleAccessViewHashURL);
done();
})
.catch(catchErrors(done));
});
it('should make sure the language is English', done => { it('should click on the Clients button of the top bar menu', () => {
nightmare return nightmare
.changeLanguageToEnglish()
.then(() => {
done();
})
.catch(catchErrors(done));
});
it('should click on the Clients button of the top bar menu', done => {
nightmare
.waitToClick(selectors.globalItems.applicationsMenuButton) .waitToClick(selectors.globalItems.applicationsMenuButton)
.wait(selectors.globalItems.applicationsMenuVisible) .wait(selectors.globalItems.applicationsMenuVisible)
.waitToClick(selectors.globalItems.clientsButton) .waitToClick(selectors.globalItems.clientsButton)
.wait(selectors.clientsIndex.createClientButton) .wait(selectors.clientsIndex.createClientButton)
.url() .urlParsed()
.then(url => { .then(url => {
expect(url).toEqual(config.url + '#!/clients'); expect(url.hash).toEqual('#!/clients');
done(); });
})
.catch(catchErrors(done));
}); });
it('should search for the user Bruce Wayne', done => { it('should search for the user Bruce Wayne', () => {
nightmare return nightmare
.wait(selectors.clientsIndex.searchResult) .wait(selectors.clientsIndex.searchResult)
.type(selectors.clientsIndex.searchClientInput, 'Bruce Wayne') .type(selectors.clientsIndex.searchClientInput, 'Bruce Wayne')
.click(selectors.clientsIndex.searchButton) .click(selectors.clientsIndex.searchButton)
@ -52,42 +25,34 @@ describe('Edit basicData path', () => {
.countSearchResults(selectors.clientsIndex.searchResult) .countSearchResults(selectors.clientsIndex.searchResult)
.then(result => { .then(result => {
expect(result).toEqual(1); expect(result).toEqual(1);
done(); });
})
.catch(catchErrors(done));
}); });
it('should click on the search result to access to the clients basic data', done => { it('should click on the search result to access to the clients basic data', () => {
nightmare return nightmare
.waitForTextInElement(selectors.clientsIndex.searchResult, 'Bruce Wayne') .waitForTextInElement(selectors.clientsIndex.searchResult, 'Bruce Wayne')
.waitToClick(selectors.clientsIndex.searchResult) .waitToClick(selectors.clientsIndex.searchResult)
.waitForURL('basic-data') .waitForURL('basic-data')
.url() .url()
.then(url => { .then(url => {
expect(url).toContain('basic-data'); expect(url).toContain('basic-data');
done(); });
})
.catch(catchErrors(done));
}); });
it('should edit the name', done => { it('should edit the name', () => {
nightmare return nightmare
.wait(selectors.clientBasicData.nameInput) .wait(selectors.clientBasicData.nameInput)
.clearInput(selectors.clientBasicData.nameInput) .clearInput(selectors.clientBasicData.nameInput)
.type(selectors.clientBasicData.nameInput, 'Ororo Munroe') .type(selectors.clientBasicData.nameInput, 'Ororo Munroe')
.click(selectors.clientBasicData.saveButton) .click(selectors.clientBasicData.saveButton)
.wait(selectors.globalItems.snackbarIsActive) .waitForSnackbar()
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => { .then(result => {
expect(result).toEqual('Data saved!'); expect(result).toEqual('Data saved!');
done(); });
})
.catch(catchErrors(done));
}); });
it('should confirm the name have been edited', done => { it('should confirm the name have been edited', () => {
nightmare return nightmare
.waitForSnackbarReset()
.click(selectors.clientFiscalData.fiscalDataButton) .click(selectors.clientFiscalData.fiscalDataButton)
.wait(selectors.clientFiscalData.addressInput) .wait(selectors.clientFiscalData.addressInput)
.click(selectors.clientBasicData.basicDataButton) .click(selectors.clientBasicData.basicDataButton)
@ -95,29 +60,23 @@ describe('Edit basicData path', () => {
.getInputValue(selectors.clientBasicData.nameInput) .getInputValue(selectors.clientBasicData.nameInput)
.then(result => { .then(result => {
expect(result).toEqual('Ororo Munroe'); expect(result).toEqual('Ororo Munroe');
done(); });
})
.catch(catchErrors(done));
}); });
it('should edit the contact name', done => { it('should edit the contact name', () => {
nightmare return nightmare
.wait(selectors.clientBasicData.contactInput) .wait(selectors.clientBasicData.contactInput)
.clearInput(selectors.clientBasicData.contactInput) .clearInput(selectors.clientBasicData.contactInput)
.type(selectors.clientBasicData.contactInput, 'Black Panther') .type(selectors.clientBasicData.contactInput, 'Black Panther')
.click(selectors.clientBasicData.saveButton) .click(selectors.clientBasicData.saveButton)
.wait(selectors.globalItems.snackbarIsActive) .waitForSnackbar()
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => { .then(result => {
expect(result).toEqual('Data saved!'); expect(result).toEqual('Data saved!');
done(); });
})
.catch(catchErrors(done));
}); });
it('should confirm the contact name have been edited', done => { it('should confirm the contact name have been edited', () => {
nightmare return nightmare
.waitForSnackbarReset()
.click(selectors.clientFiscalData.fiscalDataButton) .click(selectors.clientFiscalData.fiscalDataButton)
.wait(selectors.clientFiscalData.addressInput) .wait(selectors.clientFiscalData.addressInput)
.click(selectors.clientBasicData.basicDataButton) .click(selectors.clientBasicData.basicDataButton)
@ -125,29 +84,23 @@ describe('Edit basicData path', () => {
.getInputValue(selectors.clientBasicData.contactInput) .getInputValue(selectors.clientBasicData.contactInput)
.then(result => { .then(result => {
expect(result).toEqual('Black Panther'); expect(result).toEqual('Black Panther');
done(); });
})
.catch(catchErrors(done));
}); });
it('should add the landline phone number', done => { it('should add the landline phone number', () => {
nightmare return nightmare
.wait(selectors.clientBasicData.phoneInput) .wait(selectors.clientBasicData.phoneInput)
.clearInput(selectors.clientBasicData.phoneInput) .clearInput(selectors.clientBasicData.phoneInput)
.type(selectors.clientBasicData.phoneInput, '123456789') .type(selectors.clientBasicData.phoneInput, '123456789')
.click(selectors.clientBasicData.saveButton) .click(selectors.clientBasicData.saveButton)
.wait(selectors.globalItems.snackbarIsActive) .waitForSnackbar()
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => { .then(result => {
expect(result).toEqual('Data saved!'); expect(result).toEqual('Data saved!');
done(); });
})
.catch(catchErrors(done));
}); });
it('should confirm the landline phone number have been added', done => { it('should confirm the landline phone number have been added', () => {
nightmare return nightmare
.waitForSnackbarReset()
.click(selectors.clientFiscalData.fiscalDataButton) .click(selectors.clientFiscalData.fiscalDataButton)
.wait(selectors.clientFiscalData.addressInput) .wait(selectors.clientFiscalData.addressInput)
.click(selectors.clientBasicData.basicDataButton) .click(selectors.clientBasicData.basicDataButton)
@ -155,29 +108,23 @@ describe('Edit basicData path', () => {
.getInputValue(selectors.clientBasicData.phoneInput) .getInputValue(selectors.clientBasicData.phoneInput)
.then(result => { .then(result => {
expect(result).toEqual('123456789'); expect(result).toEqual('123456789');
done(); });
})
.catch(catchErrors(done));
}); });
it('should add the mobile phone number', done => { it('should add the mobile phone number', () => {
nightmare return nightmare
.wait(selectors.clientBasicData.mobileInput) .wait(selectors.clientBasicData.mobileInput)
.clearInput(selectors.clientBasicData.mobileInput) .clearInput(selectors.clientBasicData.mobileInput)
.type(selectors.clientBasicData.mobileInput, '987654321') .type(selectors.clientBasicData.mobileInput, '987654321')
.click(selectors.clientBasicData.saveButton) .click(selectors.clientBasicData.saveButton)
.wait(selectors.globalItems.snackbarIsActive) .waitForSnackbar()
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => { .then(result => {
expect(result).toEqual('Data saved!'); expect(result).toEqual('Data saved!');
done(); });
})
.catch(catchErrors(done));
}); });
it('should confirm the mobile phone number have been added', done => { it('should confirm the mobile phone number have been added', () => {
nightmare return nightmare
.waitForSnackbarReset()
.click(selectors.clientFiscalData.fiscalDataButton) .click(selectors.clientFiscalData.fiscalDataButton)
.wait(selectors.clientFiscalData.addressInput) .wait(selectors.clientFiscalData.addressInput)
.click(selectors.clientBasicData.basicDataButton) .click(selectors.clientBasicData.basicDataButton)
@ -185,29 +132,23 @@ describe('Edit basicData path', () => {
.getInputValue(selectors.clientBasicData.mobileInput) .getInputValue(selectors.clientBasicData.mobileInput)
.then(result => { .then(result => {
expect(result).toEqual('987654321'); expect(result).toEqual('987654321');
done(); });
})
.catch(catchErrors(done));
}); });
it('should edit the email', done => { it('should edit the email', () => {
nightmare return nightmare
.wait(selectors.clientBasicData.emailInput) .wait(selectors.clientBasicData.emailInput)
.clearInput(selectors.clientBasicData.emailInput) .clearInput(selectors.clientBasicData.emailInput)
.type(selectors.clientBasicData.emailInput, 'Storm@verdnatura.es') .type(selectors.clientBasicData.emailInput, 'Storm@verdnatura.es')
.click(selectors.clientBasicData.saveButton) .click(selectors.clientBasicData.saveButton)
.wait(selectors.globalItems.snackbarIsActive) .waitForSnackbar()
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => { .then(result => {
expect(result).toEqual('Data saved!'); expect(result).toEqual('Data saved!');
done(); });
})
.catch(catchErrors(done));
}); });
it('should confirm the email have been edited', done => { it('should confirm the email have been edited', () => {
nightmare return nightmare
.waitForSnackbarReset()
.click(selectors.clientFiscalData.fiscalDataButton) .click(selectors.clientFiscalData.fiscalDataButton)
.wait(selectors.clientFiscalData.addressInput) .wait(selectors.clientFiscalData.addressInput)
.click(selectors.clientBasicData.basicDataButton) .click(selectors.clientBasicData.basicDataButton)
@ -215,29 +156,23 @@ describe('Edit basicData path', () => {
.getInputValue(selectors.clientBasicData.emailInput) .getInputValue(selectors.clientBasicData.emailInput)
.then(result => { .then(result => {
expect(result).toEqual('Storm@verdnatura.es'); expect(result).toEqual('Storm@verdnatura.es');
done(); });
})
.catch(catchErrors(done));
}); });
it('should select the sales person', done => { it('should select the sales person', () => {
nightmare return nightmare
.waitToClick(selectors.clientBasicData.salesPersonInput) .waitToClick(selectors.clientBasicData.salesPersonInput)
.waitToClick(selectors.clientBasicData.salesBruceBannerOption) .waitToClick(selectors.clientBasicData.salesBruceBannerOption)
.wait(200) .wait(200)
.waitToClick(selectors.clientBasicData.saveButton) .waitToClick(selectors.clientBasicData.saveButton)
.wait(selectors.globalItems.snackbarIsActive) .waitForSnackbar()
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => { .then(result => {
expect(result).toEqual('Data saved!'); expect(result).toEqual('Data saved!');
done(); });
})
.catch(catchErrors(done));
}); });
it('should confirm the sales person have been selected', done => { it('should confirm the sales person have been selected', () => {
nightmare return nightmare
.waitForSnackbarReset()
.waitToClick(selectors.clientFiscalData.fiscalDataButton) .waitToClick(selectors.clientFiscalData.fiscalDataButton)
.wait(selectors.clientFiscalData.addressInput) .wait(selectors.clientFiscalData.addressInput)
.waitToClick(selectors.clientBasicData.basicDataButton) .waitToClick(selectors.clientBasicData.basicDataButton)
@ -245,29 +180,23 @@ describe('Edit basicData path', () => {
.getInputValue(selectors.clientBasicData.salesPersonInput) .getInputValue(selectors.clientBasicData.salesPersonInput)
.then(result => { .then(result => {
expect(result).toEqual('Bruce Banner'); expect(result).toEqual('Bruce Banner');
done(); });
})
.catch(catchErrors(done));
}); });
it('should select the channel', done => { it('should select the channel', () => {
nightmare return nightmare
.waitToClick(selectors.clientBasicData.channelInput) .waitToClick(selectors.clientBasicData.channelInput)
.waitToClick(selectors.clientBasicData.channelMetropolisOption) .waitToClick(selectors.clientBasicData.channelMetropolisOption)
.wait(400) .wait(400)
.waitToClick(selectors.clientBasicData.saveButton) .waitToClick(selectors.clientBasicData.saveButton)
.wait(selectors.globalItems.snackbarIsActive) .waitForSnackbar()
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => { .then(result => {
expect(result).toEqual('Data saved!'); expect(result).toEqual('Data saved!');
done(); });
})
.catch(catchErrors(done));
}); });
it('should confirm the channel have been selected', done => { it('should confirm the channel have been selected', () => {
nightmare return nightmare
.waitForSnackbarReset()
.waitToClick(selectors.clientFiscalData.fiscalDataButton) .waitToClick(selectors.clientFiscalData.fiscalDataButton)
.wait(selectors.clientFiscalData.addressInput) .wait(selectors.clientFiscalData.addressInput)
.waitToClick(selectors.clientBasicData.basicDataButton) .waitToClick(selectors.clientBasicData.basicDataButton)
@ -275,8 +204,6 @@ describe('Edit basicData path', () => {
.getInputValue(selectors.clientBasicData.channelInput) .getInputValue(selectors.clientBasicData.channelInput)
.then(result => { .then(result => {
expect(result).toEqual('Metropolis newspaper'); expect(result).toEqual('Metropolis newspaper');
done(); });
})
.catch(catchErrors(done));
}); });
}); });

View File

@ -1,50 +1,23 @@
import config from '../../helpers/config.js';
import createNightmare from '../../helpers/nightmare';
import selectors from '../../helpers/selectors.js'; import selectors from '../../helpers/selectors.js';
import {catchErrors} from '../../../services/utils/jasmineHelpers'; import createNightmare from '../../helpers/helpers';
const nightmare = createNightmare();
const moduleAccessViewHashURL = '#!/';
jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000;
describe('Edit fiscalData path', () => { describe('Edit fiscalData path', () => {
it('should log in', done => { const nightmare = createNightmare();
nightmare
.login()
.waitForURL(moduleAccessViewHashURL)
.url()
.then(url => {
expect(url).toEqual(config.url + moduleAccessViewHashURL);
done();
})
.catch(catchErrors(done));
});
it('should make sure the language is English', done => { it('should click on the Clients button of the top bar menu', () => {
nightmare return nightmare
.changeLanguageToEnglish()
.then(() => {
done();
})
.catch(catchErrors(done));
});
it('should click on the Clients button of the top bar menu', done => {
nightmare
.waitToClick(selectors.globalItems.applicationsMenuButton) .waitToClick(selectors.globalItems.applicationsMenuButton)
.wait(selectors.globalItems.applicationsMenuVisible) .wait(selectors.globalItems.applicationsMenuVisible)
.waitToClick(selectors.globalItems.clientsButton) .waitToClick(selectors.globalItems.clientsButton)
.wait(selectors.clientsIndex.createClientButton) .wait(selectors.clientsIndex.createClientButton)
.url() .urlParsed()
.then(url => { .then(url => {
expect(url).toEqual(config.url + '#!/clients'); expect(url.hash).toEqual('#!/clients');
done(); });
})
.catch(catchErrors(done));
}); });
it('should search for the user Bruce Banner', done => { it('should search for the user Bruce Banner', () => {
nightmare return nightmare
.wait(selectors.clientsIndex.searchResult) .wait(selectors.clientsIndex.searchResult)
.type(selectors.clientsIndex.searchClientInput, 'Bruce Banner') .type(selectors.clientsIndex.searchClientInput, 'Bruce Banner')
.click(selectors.clientsIndex.searchButton) .click(selectors.clientsIndex.searchButton)
@ -52,14 +25,12 @@ describe('Edit fiscalData path', () => {
.countSearchResults(selectors.clientsIndex.searchResult) .countSearchResults(selectors.clientsIndex.searchResult)
.then(result => { .then(result => {
expect(result).toEqual(1); expect(result).toEqual(1);
done(); });
})
.catch(catchErrors(done));
}); });
describe('Confirm all addresses have EQtax false for future propagation test', () => { 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 => { it(`should click on the search result to access to the client's addresses`, () => {
nightmare return nightmare
.waitForTextInElement(selectors.clientsIndex.searchResult, 'Bruce Banner') .waitForTextInElement(selectors.clientsIndex.searchResult, 'Bruce Banner')
.waitToClick(selectors.clientsIndex.searchResult) .waitToClick(selectors.clientsIndex.searchResult)
.waitToClick(selectors.clientAddresses.addressesButton) .waitToClick(selectors.clientAddresses.addressesButton)
@ -67,13 +38,11 @@ describe('Edit fiscalData path', () => {
.url() .url()
.then(url => { .then(url => {
expect(url).toContain('/addresses/list'); expect(url).toContain('/addresses/list');
done(); });
})
.catch(catchErrors(done));
}); });
it(`should click on the 1st edit icon to check EQtax is checked`, done => { it(`should click on the 1st edit icon to check EQtax is checked`, () => {
nightmare return nightmare
.waitToClick(selectors.clientAddresses.firstEditButton) .waitToClick(selectors.clientAddresses.firstEditButton)
.wait(selectors.clientAddresses.equalizationTaxCheckboxLabel) .wait(selectors.clientAddresses.equalizationTaxCheckboxLabel)
.wait(200) .wait(200)
@ -82,13 +51,11 @@ describe('Edit fiscalData path', () => {
}, selectors.clientAddresses.equalizationTaxCheckboxLabel) }, selectors.clientAddresses.equalizationTaxCheckboxLabel)
.then(value => { .then(value => {
expect(value).toBeFalsy(); 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 => { it(`should go back to addresses then select the second one and confirm the EQtax is checked`, () => {
nightmare return nightmare
.waitToClick(selectors.clientAddresses.addressesButton) .waitToClick(selectors.clientAddresses.addressesButton)
.waitToClick(selectors.clientAddresses.secondEditButton) .waitToClick(selectors.clientAddresses.secondEditButton)
.wait(selectors.clientAddresses.equalizationTaxCheckboxLabel) .wait(selectors.clientAddresses.equalizationTaxCheckboxLabel)
@ -98,42 +65,34 @@ describe('Edit fiscalData path', () => {
}, selectors.clientAddresses.equalizationTaxCheckboxLabel) }, selectors.clientAddresses.equalizationTaxCheckboxLabel)
.then(value => { .then(value => {
expect(value).toBeFalsy(); expect(value).toBeFalsy();
done(); });
})
.catch(catchErrors(done));
}); });
}); });
it(`should click on the fiscal data button to start editing`, done => { it(`should click on the fiscal data button to start editing`, () => {
nightmare return nightmare
.waitToClick(selectors.clientFiscalData.fiscalDataButton) .waitToClick(selectors.clientFiscalData.fiscalDataButton)
.waitForURL('fiscal-data') .waitForURL('fiscal-data')
.url() .url()
.then(url => { .then(url => {
expect(url).toContain('fiscal-data'); expect(url).toContain('fiscal-data');
done(); });
})
.catch(catchErrors(done));
}); });
it('should edit the social name', done => { it('should edit the social name', () => {
nightmare return nightmare
.wait(selectors.clientFiscalData.socialNameInput) .wait(selectors.clientFiscalData.socialNameInput)
.clearInput(selectors.clientFiscalData.socialNameInput) .clearInput(selectors.clientFiscalData.socialNameInput)
.type(selectors.clientFiscalData.socialNameInput, 'Hulk edited') .type(selectors.clientFiscalData.socialNameInput, 'Hulk edited')
.click(selectors.clientFiscalData.saveButton) .click(selectors.clientFiscalData.saveButton)
.wait(selectors.globalItems.snackbarIsActive) .waitForSnackbar()
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => { .then(result => {
expect(result).toEqual('Data saved!'); expect(result).toEqual('Data saved!');
done(); });
})
.catch(catchErrors(done));
}); });
it('should confirm the social name have been edited', done => { it('should confirm the social name have been edited', () => {
nightmare return nightmare
.waitForSnackbarReset()
.waitToClick(selectors.clientBasicData.basicDataButton) .waitToClick(selectors.clientBasicData.basicDataButton)
.wait(selectors.clientBasicData.nameInput) .wait(selectors.clientBasicData.nameInput)
.waitToClick(selectors.clientFiscalData.fiscalDataButton) .waitToClick(selectors.clientFiscalData.fiscalDataButton)
@ -141,29 +100,23 @@ describe('Edit fiscalData path', () => {
.getInputValue(selectors.clientFiscalData.socialNameInput) .getInputValue(selectors.clientFiscalData.socialNameInput)
.then(result => { .then(result => {
expect(result).toEqual('Hulk edited'); expect(result).toEqual('Hulk edited');
done(); });
})
.catch(catchErrors(done));
}); });
it('should edit the fiscal id', done => { it('should edit the fiscal id', () => {
nightmare return nightmare
.wait(selectors.clientFiscalData.fiscalIdInput) .wait(selectors.clientFiscalData.fiscalIdInput)
.clearInput(selectors.clientFiscalData.fiscalIdInput) .clearInput(selectors.clientFiscalData.fiscalIdInput)
.type(selectors.clientFiscalData.fiscalIdInput, '94980061C') .type(selectors.clientFiscalData.fiscalIdInput, '94980061C')
.click(selectors.clientFiscalData.saveButton) .click(selectors.clientFiscalData.saveButton)
.wait(selectors.globalItems.snackbarIsActive) .waitForSnackbar()
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => { .then(result => {
expect(result).toEqual('Data saved!'); expect(result).toEqual('Data saved!');
done(); });
})
.catch(catchErrors(done));
}); });
it('should confirm the fiscal id have been edited', done => { it('should confirm the fiscal id have been edited', () => {
nightmare return nightmare
.waitForSnackbarReset()
.waitToClick(selectors.clientBasicData.basicDataButton) .waitToClick(selectors.clientBasicData.basicDataButton)
.wait(selectors.clientBasicData.nameInput) .wait(selectors.clientBasicData.nameInput)
.waitToClick(selectors.clientFiscalData.fiscalDataButton) .waitToClick(selectors.clientFiscalData.fiscalDataButton)
@ -171,39 +124,30 @@ describe('Edit fiscalData path', () => {
.getInputValue(selectors.clientFiscalData.fiscalIdInput) .getInputValue(selectors.clientFiscalData.fiscalIdInput)
.then(result => { .then(result => {
expect(result).toEqual('94980061C'); expect(result).toEqual('94980061C');
done(); });
})
.catch(catchErrors(done));
}); });
it('should check the Equalization tax checkbox', done => { it('should check the Equalization tax checkbox', () => {
nightmare return nightmare
.waitToClick(selectors.clientFiscalData.equalizationTaxCheckboxLabel) .waitToClick(selectors.clientFiscalData.equalizationTaxCheckboxLabel)
.waitToClick(selectors.clientFiscalData.saveButton) .waitToClick(selectors.clientFiscalData.saveButton)
.wait(selectors.globalItems.snackbarIsActive) .waitForSnackbar()
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => { .then(result => {
expect(result).toEqual('Data saved!'); expect(result).toEqual('Data saved!');
done(); });
})
.catch(catchErrors(done));
}); });
it('should propagate the Equalization tax', done => { it('should propagate the Equalization tax', () => {
nightmare return nightmare
.waitToClick(selectors.clientFiscalData.acceptPropagationButton) .waitToClick(selectors.clientFiscalData.acceptPropagationButton)
.wait(selectors.globalItems.snackbarIsActive) .waitForSnackbar()
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => { .then(result => {
expect(result).toEqual('Data saved!'); expect(result).toEqual('Equivalent tax spreaded');
done(); });
})
.catch(catchErrors(done));
}); });
it('should confirm Equalization tax checkbox is checked', done => { it('should confirm Equalization tax checkbox is checked', () => {
nightmare return nightmare
.waitForSnackbarReset()
.waitToClick(selectors.clientBasicData.basicDataButton) .waitToClick(selectors.clientBasicData.basicDataButton)
.wait(selectors.clientBasicData.nameInput) .wait(selectors.clientBasicData.nameInput)
.waitToClick(selectors.clientFiscalData.fiscalDataButton) .waitToClick(selectors.clientFiscalData.fiscalDataButton)
@ -213,26 +157,22 @@ describe('Edit fiscalData path', () => {
}, selectors.clientFiscalData.equalizationTaxCheckboxLabel) }, selectors.clientFiscalData.equalizationTaxCheckboxLabel)
.then(value => { .then(value => {
expect(value).toBeTruthy(); expect(value).toBeTruthy();
done(); });
})
.catch(catchErrors(done));
}); });
describe('Confirm all addresses have now EQtax checked', () => { describe('Confirm all addresses have now EQtax checked', () => {
it(`should click on the addresses button to access to the client's addresses`, done => { it(`should click on the addresses button to access to the client's addresses`, () => {
nightmare return nightmare
.waitToClick(selectors.clientAddresses.addressesButton) .waitToClick(selectors.clientAddresses.addressesButton)
.waitForURL('/addresses/list') .waitForURL('/addresses/list')
.url() .url()
.then(url => { .then(url => {
expect(url).toContain('/addresses/list'); expect(url).toContain('/addresses/list');
done(); });
})
.catch(catchErrors(done));
}); });
it(`should click on the 1st edit icon to confirm EQtax is checked`, done => { it(`should click on the 1st edit icon to confirm EQtax is checked`, () => {
nightmare return nightmare
.waitToClick(selectors.clientAddresses.firstEditButton) .waitToClick(selectors.clientAddresses.firstEditButton)
.wait(selectors.clientAddresses.equalizationTaxCheckboxLabel) .wait(selectors.clientAddresses.equalizationTaxCheckboxLabel)
.wait(200) .wait(200)
@ -241,13 +181,11 @@ describe('Edit fiscalData path', () => {
}, selectors.clientAddresses.equalizationTaxCheckboxLabel) }, selectors.clientAddresses.equalizationTaxCheckboxLabel)
.then(value => { .then(value => {
expect(value).toBeTruthy(); 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 => { it(`should go back to addresses then select the second one and confirm the EQtax is checked`, () => {
nightmare return nightmare
.waitToClick(selectors.clientAddresses.addressesButton) .waitToClick(selectors.clientAddresses.addressesButton)
.waitToClick(selectors.clientAddresses.secondEditButton) .waitToClick(selectors.clientAddresses.secondEditButton)
.wait(selectors.clientAddresses.equalizationTaxCheckboxLabel) .wait(selectors.clientAddresses.equalizationTaxCheckboxLabel)
@ -257,31 +195,25 @@ describe('Edit fiscalData path', () => {
}, selectors.clientAddresses.equalizationTaxCheckboxLabel) }, selectors.clientAddresses.equalizationTaxCheckboxLabel)
.then(value => { .then(value => {
expect(value).toBeTruthy(); expect(value).toBeTruthy();
done(); });
})
.catch(catchErrors(done));
}); });
}); });
it('should go to fiscal data then edit the address', done => { it('should go to fiscal data then edit the address', () => {
nightmare return nightmare
.waitToClick(selectors.clientFiscalData.fiscalDataButton) .waitToClick(selectors.clientFiscalData.fiscalDataButton)
.wait(selectors.clientFiscalData.addressInput) .wait(selectors.clientFiscalData.addressInput)
.clearInput(selectors.clientFiscalData.addressInput) .clearInput(selectors.clientFiscalData.addressInput)
.type(selectors.clientFiscalData.addressInput, 'Somewhere edited') .type(selectors.clientFiscalData.addressInput, 'Somewhere edited')
.click(selectors.clientFiscalData.saveButton) .click(selectors.clientFiscalData.saveButton)
.wait(selectors.globalItems.snackbarIsActive) .waitForSnackbar()
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => { .then(result => {
expect(result).toEqual('Data saved!'); expect(result).toEqual('Data saved!');
done(); });
})
.catch(catchErrors(done));
}); });
it('should confirm the address have been edited', done => { it('should confirm the address have been edited', () => {
nightmare return nightmare
.waitForSnackbarReset()
.click(selectors.clientBasicData.basicDataButton) .click(selectors.clientBasicData.basicDataButton)
.wait(selectors.clientBasicData.nameInput) .wait(selectors.clientBasicData.nameInput)
.click(selectors.clientFiscalData.fiscalDataButton) .click(selectors.clientFiscalData.fiscalDataButton)
@ -289,29 +221,23 @@ describe('Edit fiscalData path', () => {
.getInputValue(selectors.clientFiscalData.addressInput) .getInputValue(selectors.clientFiscalData.addressInput)
.then(result => { .then(result => {
expect(result).toEqual('Somewhere edited'); expect(result).toEqual('Somewhere edited');
done(); });
})
.catch(catchErrors(done));
}); });
it('should edit the city', done => { it('should edit the city', () => {
nightmare return nightmare
.wait(selectors.clientFiscalData.cityInput) .wait(selectors.clientFiscalData.cityInput)
.clearInput(selectors.clientFiscalData.cityInput) .clearInput(selectors.clientFiscalData.cityInput)
.type(selectors.clientFiscalData.cityInput, 'N/A') .type(selectors.clientFiscalData.cityInput, 'N/A')
.click(selectors.clientFiscalData.saveButton) .click(selectors.clientFiscalData.saveButton)
.wait(selectors.globalItems.snackbarIsActive) .waitForSnackbar()
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => { .then(result => {
expect(result).toEqual('Data saved!'); expect(result).toEqual('Data saved!');
done(); });
})
.catch(catchErrors(done));
}); });
it('should confirm the city have been edited', done => { it('should confirm the city have been edited', () => {
nightmare return nightmare
.waitForSnackbarReset()
.click(selectors.clientBasicData.basicDataButton) .click(selectors.clientBasicData.basicDataButton)
.wait(selectors.clientBasicData.nameInput) .wait(selectors.clientBasicData.nameInput)
.click(selectors.clientFiscalData.fiscalDataButton) .click(selectors.clientFiscalData.fiscalDataButton)
@ -319,29 +245,23 @@ describe('Edit fiscalData path', () => {
.getInputValue(selectors.clientFiscalData.cityInput) .getInputValue(selectors.clientFiscalData.cityInput)
.then(result => { .then(result => {
expect(result).toEqual('N/A'); expect(result).toEqual('N/A');
done(); });
})
.catch(catchErrors(done));
}); });
it('should edit the postcode', done => { it('should edit the postcode', () => {
nightmare return nightmare
.wait(selectors.clientFiscalData.postcodeInput) .wait(selectors.clientFiscalData.postcodeInput)
.clearInput(selectors.clientFiscalData.postcodeInput) .clearInput(selectors.clientFiscalData.postcodeInput)
.type(selectors.clientFiscalData.postcodeInput, '12345') .type(selectors.clientFiscalData.postcodeInput, '12345')
.click(selectors.clientFiscalData.saveButton) .click(selectors.clientFiscalData.saveButton)
.wait(selectors.globalItems.snackbarIsActive) .waitForSnackbar()
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => { .then(result => {
expect(result).toEqual('Data saved!'); expect(result).toEqual('Data saved!');
done(); });
})
.catch(catchErrors(done));
}); });
it('should confirm the postcode have been edited', done => { it('should confirm the postcode have been edited', () => {
nightmare return nightmare
.waitForSnackbarReset()
.click(selectors.clientBasicData.basicDataButton) .click(selectors.clientBasicData.basicDataButton)
.wait(selectors.clientBasicData.nameInput) .wait(selectors.clientBasicData.nameInput)
.click(selectors.clientFiscalData.fiscalDataButton) .click(selectors.clientFiscalData.fiscalDataButton)
@ -349,29 +269,23 @@ describe('Edit fiscalData path', () => {
.getInputValue(selectors.clientFiscalData.postcodeInput) .getInputValue(selectors.clientFiscalData.postcodeInput)
.then(result => { .then(result => {
expect(result).toEqual('12345'); expect(result).toEqual('12345');
done(); });
})
.catch(catchErrors(done));
}); });
it(`should edit the province`, done => { it(`should edit the province`, () => {
nightmare return nightmare
.waitToClick(selectors.clientFiscalData.provinceInput) .waitToClick(selectors.clientFiscalData.provinceInput)
.waitToClick(selectors.clientFiscalData.provinceFifthOption) .waitToClick(selectors.clientFiscalData.provinceFifthOption)
.wait(200) .wait(200)
.waitToClick(selectors.clientFiscalData.saveButton) .waitToClick(selectors.clientFiscalData.saveButton)
.wait(selectors.globalItems.snackbarIsActive) .waitForSnackbar()
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => { .then(result => {
expect(result).toEqual('Data saved!'); expect(result).toEqual('Data saved!');
done(); });
})
.catch(catchErrors(done));
}); });
it(`should confirm the province have been selected`, done => { it(`should confirm the province have been selected`, () => {
nightmare return nightmare
.waitForSnackbarReset()
.click(selectors.clientBasicData.basicDataButton) .click(selectors.clientBasicData.basicDataButton)
.wait(selectors.clientBasicData.nameInput) .wait(selectors.clientBasicData.nameInput)
.click(selectors.clientFiscalData.fiscalDataButton) .click(selectors.clientFiscalData.fiscalDataButton)
@ -379,27 +293,21 @@ describe('Edit fiscalData path', () => {
.getInputValue(selectors.clientFiscalData.provinceInput) .getInputValue(selectors.clientFiscalData.provinceInput)
.then(result => { .then(result => {
expect(result).toEqual('Province two'); expect(result).toEqual('Province two');
done(); });
})
.catch(catchErrors(done));
}); });
it('should uncheck the active checkbox', done => { it('should uncheck the active checkbox', () => {
nightmare return nightmare
.waitToClick(selectors.clientFiscalData.activeCheckboxLabel) .waitToClick(selectors.clientFiscalData.activeCheckboxLabel)
.waitToClick(selectors.clientFiscalData.saveButton) .waitToClick(selectors.clientFiscalData.saveButton)
.wait(selectors.globalItems.snackbarIsActive) .waitForSnackbar()
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => { .then(result => {
expect(result).toEqual('Data saved!'); expect(result).toEqual('Data saved!');
done(); });
})
.catch(catchErrors(done));
}); });
it('should confirm active checkbox is unchecked', done => { it('should confirm active checkbox is unchecked', () => {
nightmare return nightmare
.waitForSnackbarReset()
.waitToClick(selectors.clientBasicData.basicDataButton) .waitToClick(selectors.clientBasicData.basicDataButton)
.wait(selectors.clientBasicData.nameInput) .wait(selectors.clientBasicData.nameInput)
.waitToClick(selectors.clientFiscalData.fiscalDataButton) .waitToClick(selectors.clientFiscalData.fiscalDataButton)
@ -409,27 +317,21 @@ describe('Edit fiscalData path', () => {
}, selectors.clientFiscalData.activeCheckboxLabel) }, selectors.clientFiscalData.activeCheckboxLabel)
.then(value => { .then(value => {
expect(value).toBeFalsy(); expect(value).toBeFalsy();
done(); });
})
.catch(catchErrors(done));
}); });
it('should uncheck the invoice by address checkbox', done => { it('should uncheck the invoice by address checkbox', () => {
nightmare return nightmare
.waitToClick(selectors.clientFiscalData.invoiceByAddressCheckboxInput) .waitToClick(selectors.clientFiscalData.invoiceByAddressCheckboxInput)
.waitToClick(selectors.clientFiscalData.saveButton) .waitToClick(selectors.clientFiscalData.saveButton)
.wait(selectors.globalItems.snackbarIsActive) .waitForSnackbar()
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => { .then(result => {
expect(result).toEqual('Data saved!'); expect(result).toEqual('Data saved!');
done(); });
})
.catch(catchErrors(done));
}); });
it('should confirm invoice by address checkbox is unchecked', done => { it('should confirm invoice by address checkbox is unchecked', () => {
nightmare return nightmare
.waitForSnackbarReset()
.waitToClick(selectors.clientBasicData.basicDataButton) .waitToClick(selectors.clientBasicData.basicDataButton)
.wait(selectors.clientBasicData.nameInput) .wait(selectors.clientBasicData.nameInput)
.waitToClick(selectors.clientFiscalData.fiscalDataButton) .waitToClick(selectors.clientFiscalData.fiscalDataButton)
@ -439,27 +341,21 @@ describe('Edit fiscalData path', () => {
}, selectors.clientFiscalData.invoiceByAddressCheckboxInput) }, selectors.clientFiscalData.invoiceByAddressCheckboxInput)
.then(value => { .then(value => {
expect(value).toBeFalsy(); expect(value).toBeFalsy();
done(); });
})
.catch(catchErrors(done));
}); });
it('should check the Verified data checkbox', done => { it('should check the Verified data checkbox', () => {
nightmare return nightmare
.waitToClick(selectors.clientFiscalData.verifiedDataCheckboxInput) .waitToClick(selectors.clientFiscalData.verifiedDataCheckboxInput)
.waitToClick(selectors.clientFiscalData.saveButton) .waitToClick(selectors.clientFiscalData.saveButton)
.wait(selectors.globalItems.snackbarIsActive) .waitForSnackbar()
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => { .then(result => {
expect(result).toEqual('Data saved!'); expect(result).toEqual('Data saved!');
done(); });
})
.catch(catchErrors(done));
}); });
it('should confirm Verified data checkbox is unchecked', done => { it('should confirm Verified data checkbox is unchecked', () => {
nightmare return nightmare
.waitForSnackbarReset()
.waitToClick(selectors.clientBasicData.basicDataButton) .waitToClick(selectors.clientBasicData.basicDataButton)
.wait(selectors.clientBasicData.nameInput) .wait(selectors.clientBasicData.nameInput)
.waitToClick(selectors.clientFiscalData.fiscalDataButton) .waitToClick(selectors.clientFiscalData.fiscalDataButton)
@ -469,27 +365,21 @@ describe('Edit fiscalData path', () => {
}, selectors.clientFiscalData.verifiedDataCheckboxInput) }, selectors.clientFiscalData.verifiedDataCheckboxInput)
.then(value => { .then(value => {
expect(value).toBeFalsy(); expect(value).toBeFalsy();
done(); });
})
.catch(catchErrors(done));
}); });
it('should uncheck the Has to invoice checkbox', done => { it('should uncheck the Has to invoice checkbox', () => {
nightmare return nightmare
.waitToClick(selectors.clientFiscalData.hasToInvoiceCheckboxLabel) .waitToClick(selectors.clientFiscalData.hasToInvoiceCheckboxLabel)
.waitToClick(selectors.clientFiscalData.saveButton) .waitToClick(selectors.clientFiscalData.saveButton)
.wait(selectors.globalItems.snackbarIsActive) .waitForSnackbar()
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => { .then(result => {
expect(result).toEqual('Data saved!'); expect(result).toEqual('Data saved!');
done(); });
})
.catch(catchErrors(done));
}); });
it('should confirm Has to invoice checkbox is unchecked', done => { it('should confirm Has to invoice checkbox is unchecked', () => {
nightmare return nightmare
.waitForSnackbarReset()
.waitToClick(selectors.clientBasicData.basicDataButton) .waitToClick(selectors.clientBasicData.basicDataButton)
.wait(selectors.clientBasicData.nameInput) .wait(selectors.clientBasicData.nameInput)
.waitToClick(selectors.clientFiscalData.fiscalDataButton) .waitToClick(selectors.clientFiscalData.fiscalDataButton)
@ -499,27 +389,21 @@ describe('Edit fiscalData path', () => {
}, selectors.clientFiscalData.hasToInvoiceCheckboxLabel) }, selectors.clientFiscalData.hasToInvoiceCheckboxLabel)
.then(value => { .then(value => {
expect(value).toBeFalsy(); expect(value).toBeFalsy();
done(); });
})
.catch(catchErrors(done));
}); });
it('should uncheck the Invoice by mail checkbox', done => { it('should uncheck the Invoice by mail checkbox', () => {
nightmare return nightmare
.waitToClick(selectors.clientFiscalData.invoiceByMailCheckboxLabel) .waitToClick(selectors.clientFiscalData.invoiceByMailCheckboxLabel)
.waitToClick(selectors.clientFiscalData.saveButton) .waitToClick(selectors.clientFiscalData.saveButton)
.wait(selectors.globalItems.snackbarIsActive) .waitForSnackbar()
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => { .then(result => {
expect(result).toEqual('Data saved!'); expect(result).toEqual('Data saved!');
done(); });
})
.catch(catchErrors(done));
}); });
it('should confirm Invoice by mail checkbox is unchecked', done => { it('should confirm Invoice by mail checkbox is unchecked', () => {
nightmare return nightmare
.waitForSnackbarReset()
.waitToClick(selectors.clientBasicData.basicDataButton) .waitToClick(selectors.clientBasicData.basicDataButton)
.wait(selectors.clientBasicData.nameInput) .wait(selectors.clientBasicData.nameInput)
.waitToClick(selectors.clientFiscalData.fiscalDataButton) .waitToClick(selectors.clientFiscalData.fiscalDataButton)
@ -529,27 +413,21 @@ describe('Edit fiscalData path', () => {
}, selectors.clientFiscalData.invoiceByMailCheckboxLabel) }, selectors.clientFiscalData.invoiceByMailCheckboxLabel)
.then(value => { .then(value => {
expect(value).toBeFalsy(); expect(value).toBeFalsy();
done(); });
})
.catch(catchErrors(done));
}); });
it('should check the Vies checkbox', done => { it('should check the Vies checkbox', () => {
nightmare return nightmare
.waitToClick(selectors.clientFiscalData.viesCheckboxInput) .waitToClick(selectors.clientFiscalData.viesCheckboxInput)
.waitToClick(selectors.clientFiscalData.saveButton) .waitToClick(selectors.clientFiscalData.saveButton)
.wait(selectors.globalItems.snackbarIsActive) .waitForSnackbar()
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => { .then(result => {
expect(result).toEqual('Data saved!'); expect(result).toEqual('Data saved!');
done(); });
})
.catch(catchErrors(done));
}); });
it('should confirm Vies checkbox is checked', done => { it('should confirm Vies checkbox is checked', () => {
nightmare return nightmare
.waitForSnackbarReset()
.waitToClick(selectors.clientBasicData.basicDataButton) .waitToClick(selectors.clientBasicData.basicDataButton)
.wait(selectors.clientBasicData.nameInput) .wait(selectors.clientBasicData.nameInput)
.waitToClick(selectors.clientFiscalData.fiscalDataButton) .waitToClick(selectors.clientFiscalData.fiscalDataButton)
@ -559,8 +437,6 @@ describe('Edit fiscalData path', () => {
}, selectors.clientFiscalData.viesCheckboxInput) }, selectors.clientFiscalData.viesCheckboxInput)
.then(value => { .then(value => {
expect(value).toBeTruthy(); expect(value).toBeTruthy();
done(); });
})
.catch(catchErrors(done));
}); });
}); });

View File

@ -1,50 +1,23 @@
import config from '../../helpers/config.js';
import createNightmare from '../../helpers/nightmare';
import selectors from '../../helpers/selectors.js'; import selectors from '../../helpers/selectors.js';
import {catchErrors} from '../../../services/utils/jasmineHelpers'; import createNightmare from '../../helpers/helpers';
const nightmare = createNightmare();
const moduleAccessViewHashURL = '#!/';
jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000;
describe('Edit pay method path', () => { describe('Edit pay method path', () => {
it('should log in', done => { const nightmare = createNightmare();
nightmare
.login()
.waitForURL(moduleAccessViewHashURL)
.url()
.then(url => {
expect(url).toEqual(config.url + moduleAccessViewHashURL);
done();
})
.catch(catchErrors(done));
});
it('should make sure the language is English', done => { it('should click on the Clients button of the top bar menu', () => {
nightmare return nightmare
.changeLanguageToEnglish()
.then(() => {
done();
})
.catch(catchErrors(done));
});
it('should click on the Clients button of the top bar menu', done => {
nightmare
.waitToClick(selectors.globalItems.applicationsMenuButton) .waitToClick(selectors.globalItems.applicationsMenuButton)
.wait(selectors.globalItems.applicationsMenuVisible) .wait(selectors.globalItems.applicationsMenuVisible)
.waitToClick(selectors.globalItems.clientsButton) .waitToClick(selectors.globalItems.clientsButton)
.wait(selectors.clientsIndex.createClientButton) .wait(selectors.clientsIndex.createClientButton)
.url() .urlParsed()
.then(url => { .then(url => {
expect(url).toEqual(config.url + '#!/clients'); expect(url.hash).toEqual('#!/clients');
done(); });
})
.catch(catchErrors(done));
}); });
it('should search for the user Bruce Banner', done => { it('should search for the user Bruce Banner', () => {
nightmare return nightmare
.wait(selectors.clientsIndex.searchResult) .wait(selectors.clientsIndex.searchResult)
.type(selectors.clientsIndex.searchClientInput, 'Bruce Banner') .type(selectors.clientsIndex.searchClientInput, 'Bruce Banner')
.click(selectors.clientsIndex.searchButton) .click(selectors.clientsIndex.searchButton)
@ -52,13 +25,11 @@ describe('Edit pay method path', () => {
.countSearchResults(selectors.clientsIndex.searchResult) .countSearchResults(selectors.clientsIndex.searchResult)
.then(result => { .then(result => {
expect(result).toEqual(1); expect(result).toEqual(1);
done(); });
})
.catch(catchErrors(done));
}); });
it(`should click on the search result to access to the client's pay method`, done => { it(`should click on the search result to access to the client's pay method`, () => {
nightmare return nightmare
.waitForTextInElement(selectors.clientsIndex.searchResult, 'Bruce Banner') .waitForTextInElement(selectors.clientsIndex.searchResult, 'Bruce Banner')
.waitToClick(selectors.clientsIndex.searchResult) .waitToClick(selectors.clientsIndex.searchResult)
.waitToClick(selectors.clientPayMethod.payMethodButton) .waitToClick(selectors.clientPayMethod.payMethodButton)
@ -66,30 +37,24 @@ describe('Edit pay method path', () => {
.url() .url()
.then(url => { .then(url => {
expect(url).toContain('billing-data'); expect(url).toContain('billing-data');
done(); });
})
.catch(catchErrors(done));
}); });
it(`should edit the Pay method to any without IBAN`, done => { it(`should edit the Pay method to any without IBAN`, () => {
nightmare return nightmare
.waitToClick(selectors.clientPayMethod.payMethodInput) .waitToClick(selectors.clientPayMethod.payMethodInput)
.waitToClick(selectors.clientPayMethod.payMethodOptionOne) .waitToClick(selectors.clientPayMethod.payMethodOptionOne)
.wait(200) .wait(200)
.waitToClick(selectors.clientPayMethod.saveButton) .waitToClick(selectors.clientPayMethod.saveButton)
.waitToClick(selectors.clientPayMethod.cancelNotificationButton) .waitToClick(selectors.clientPayMethod.cancelNotificationButton)
.wait(selectors.globalItems.snackbarIsActive) .waitForSnackbar()
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => { .then(result => {
expect(result).toEqual('Data saved!'); expect(result).toEqual('Data saved!');
done(); });
})
.catch(catchErrors(done));
}); });
it(`should confirm the Pay method have been selected`, done => { it(`should confirm the Pay method have been selected`, () => {
nightmare return nightmare
.waitForSnackbarReset()
.click(selectors.clientBasicData.basicDataButton) .click(selectors.clientBasicData.basicDataButton)
.wait(selectors.clientBasicData.nameInput) .wait(selectors.clientBasicData.nameInput)
.click(selectors.clientPayMethod.payMethodButton) .click(selectors.clientPayMethod.payMethodButton)
@ -97,45 +62,36 @@ describe('Edit pay method path', () => {
.getInputValue(selectors.clientPayMethod.payMethodInput) .getInputValue(selectors.clientPayMethod.payMethodInput)
.then(result => { .then(result => {
expect(result).toEqual('PayMethod one'); expect(result).toEqual('PayMethod one');
done(); });
})
.catch(catchErrors(done));
}); });
it(`should receive an error when changing payMethod to IBAN without an IBAN entered`, done => { it(`should receive an error when changing payMethod to IBAN without an IBAN entered`, () => {
nightmare return nightmare
.waitToClick(selectors.clientPayMethod.payMethodInput) .waitToClick(selectors.clientPayMethod.payMethodInput)
.waitToClick(selectors.clientPayMethod.payMethodIBANOption) .waitToClick(selectors.clientPayMethod.payMethodIBANOption)
.wait(200) .wait(200)
.waitToClick(selectors.clientPayMethod.saveButton) .waitToClick(selectors.clientPayMethod.saveButton)
.waitToClick(selectors.clientPayMethod.cancelNotificationButton) .waitToClick(selectors.clientPayMethod.cancelNotificationButton)
.wait(selectors.globalItems.snackbarIsActive) .waitForSnackbar()
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => { .then(result => {
expect(result).toContain('Error'); expect(result).toContain('Error');
done(); });
})
.catch(catchErrors(done));
}); });
it(`should add the IBAN`, done => { it(`should add the IBAN`, () => {
nightmare return nightmare
.clearInput(selectors.clientPayMethod.IBANInput) .clearInput(selectors.clientPayMethod.IBANInput)
.type(selectors.clientPayMethod.IBANInput, 'ES91 2100 0418 4502 0005 1332') .type(selectors.clientPayMethod.IBANInput, 'ES91 2100 0418 4502 0005 1332')
.waitToClick(selectors.clientPayMethod.saveButton) .waitToClick(selectors.clientPayMethod.saveButton)
.waitToClick(selectors.clientPayMethod.cancelNotificationButton) .waitToClick(selectors.clientPayMethod.cancelNotificationButton)
.wait(selectors.globalItems.snackbarIsActive) .waitForSnackbar()
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => { .then(result => {
expect(result).toEqual('Data saved!'); expect(result).toEqual('Data saved!');
done(); });
})
.catch(catchErrors(done));
}); });
it(`should confirm the IBAN pay method is sucessfully saved`, done => { it(`should confirm the IBAN pay method is sucessfully saved`, () => {
nightmare return nightmare
.waitForSnackbarReset()
.click(selectors.clientBasicData.basicDataButton) .click(selectors.clientBasicData.basicDataButton)
.wait(selectors.clientBasicData.nameInput) .wait(selectors.clientBasicData.nameInput)
.click(selectors.clientPayMethod.payMethodButton) .click(selectors.clientPayMethod.payMethodButton)
@ -143,29 +99,23 @@ describe('Edit pay method path', () => {
.getInputValue(selectors.clientPayMethod.payMethodInput) .getInputValue(selectors.clientPayMethod.payMethodInput)
.then(result => { .then(result => {
expect(result).toEqual('PayMethod with IBAN'); expect(result).toEqual('PayMethod with IBAN');
done(); });
})
.catch(catchErrors(done));
}); });
it(`should edit the due day`, done => { it(`should edit the due day`, () => {
nightmare return nightmare
.clearInput(selectors.clientPayMethod.dueDayInput) .clearInput(selectors.clientPayMethod.dueDayInput)
.type(selectors.clientPayMethod.dueDayInput, '60') .type(selectors.clientPayMethod.dueDayInput, '60')
.waitToClick(selectors.clientPayMethod.saveButton) .waitToClick(selectors.clientPayMethod.saveButton)
.waitToClick(selectors.clientPayMethod.cancelNotificationButton) .waitToClick(selectors.clientPayMethod.cancelNotificationButton)
.wait(selectors.globalItems.snackbarIsActive) .waitForSnackbar()
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => { .then(result => {
expect(result).toEqual('Data saved!'); expect(result).toEqual('Data saved!');
done(); });
})
.catch(catchErrors(done));
}); });
it('should confirm the due day have been edited', done => { it('should confirm the due day have been edited', () => {
nightmare return nightmare
.waitForSnackbarReset()
.waitToClick(selectors.clientBasicData.basicDataButton) .waitToClick(selectors.clientBasicData.basicDataButton)
.wait(selectors.clientBasicData.nameInput) .wait(selectors.clientBasicData.nameInput)
.waitToClick(selectors.clientPayMethod.payMethodButton) .waitToClick(selectors.clientPayMethod.payMethodButton)
@ -173,27 +123,21 @@ describe('Edit pay method path', () => {
.getInputValue(selectors.clientPayMethod.dueDayInput) .getInputValue(selectors.clientPayMethod.dueDayInput)
.then(result => { .then(result => {
expect(result).toEqual('60'); expect(result).toEqual('60');
done(); });
})
.catch(catchErrors(done));
}); });
it('should uncheck the Received core VNH checkbox', done => { it('should uncheck the Received core VNH checkbox', () => {
nightmare return nightmare
.waitToClick(selectors.clientPayMethod.receivedCoreVNHCheckbox) .waitToClick(selectors.clientPayMethod.receivedCoreVNHCheckbox)
.waitToClick(selectors.clientPayMethod.saveButton) .waitToClick(selectors.clientPayMethod.saveButton)
.wait(selectors.globalItems.snackbarIsActive) .waitForSnackbar()
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => { .then(result => {
expect(result).toEqual('Data saved!'); expect(result).toEqual('Data saved!');
done(); });
})
.catch(catchErrors(done));
}); });
it('should confirm Received core VNH checkbox is unchecked', done => { it('should confirm Received core VNH checkbox is unchecked', () => {
nightmare return nightmare
.waitForSnackbarReset()
.waitToClick(selectors.clientBasicData.basicDataButton) .waitToClick(selectors.clientBasicData.basicDataButton)
.wait(selectors.clientBasicData.nameInput) .wait(selectors.clientBasicData.nameInput)
.waitToClick(selectors.clientPayMethod.payMethodButton) .waitToClick(selectors.clientPayMethod.payMethodButton)
@ -203,27 +147,21 @@ describe('Edit pay method path', () => {
}, selectors.clientPayMethod.receivedCoreVNHCheckbox) }, selectors.clientPayMethod.receivedCoreVNHCheckbox)
.then(value => { .then(value => {
expect(value).toBeFalsy(); expect(value).toBeFalsy();
done(); });
})
.catch(catchErrors(done));
}); });
it('should uncheck the Received core VNL checkbox', done => { it('should uncheck the Received core VNL checkbox', () => {
nightmare return nightmare
.waitToClick(selectors.clientPayMethod.receivedCoreVNLCheckbox) .waitToClick(selectors.clientPayMethod.receivedCoreVNLCheckbox)
.waitToClick(selectors.clientPayMethod.saveButton) .waitToClick(selectors.clientPayMethod.saveButton)
.wait(selectors.globalItems.snackbarIsActive) .waitForSnackbar()
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => { .then(result => {
expect(result).toEqual('Data saved!'); expect(result).toEqual('Data saved!');
done(); });
})
.catch(catchErrors(done));
}); });
it('should confirm Received core VNL checkbox is unchecked', done => { it('should confirm Received core VNL checkbox is unchecked', () => {
nightmare return nightmare
.waitForSnackbarReset()
.waitToClick(selectors.clientBasicData.basicDataButton) .waitToClick(selectors.clientBasicData.basicDataButton)
.wait(selectors.clientBasicData.nameInput) .wait(selectors.clientBasicData.nameInput)
.waitToClick(selectors.clientPayMethod.payMethodButton) .waitToClick(selectors.clientPayMethod.payMethodButton)
@ -233,27 +171,21 @@ describe('Edit pay method path', () => {
}, selectors.clientPayMethod.receivedCoreVNLCheckbox) }, selectors.clientPayMethod.receivedCoreVNLCheckbox)
.then(value => { .then(value => {
expect(value).toBeFalsy(); expect(value).toBeFalsy();
done(); });
})
.catch(catchErrors(done));
}); });
it('should uncheck the Received B2B VNL checkbox', done => { it('should uncheck the Received B2B VNL checkbox', () => {
nightmare return nightmare
.waitToClick(selectors.clientPayMethod.receivedB2BVNLCheckbox) .waitToClick(selectors.clientPayMethod.receivedB2BVNLCheckbox)
.waitToClick(selectors.clientPayMethod.saveButton) .waitToClick(selectors.clientPayMethod.saveButton)
.wait(selectors.globalItems.snackbarIsActive) .waitForSnackbar()
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => { .then(result => {
expect(result).toEqual('Data saved!'); expect(result).toEqual('Data saved!');
done(); });
})
.catch(catchErrors(done));
}); });
it('should confirm Received B2B VNL checkbox is unchecked', done => { it('should confirm Received B2B VNL checkbox is unchecked', () => {
nightmare return nightmare
.waitForSnackbarReset()
.waitToClick(selectors.clientBasicData.basicDataButton) .waitToClick(selectors.clientBasicData.basicDataButton)
.wait(selectors.clientBasicData.nameInput) .wait(selectors.clientBasicData.nameInput)
.waitToClick(selectors.clientPayMethod.payMethodButton) .waitToClick(selectors.clientPayMethod.payMethodButton)
@ -263,8 +195,6 @@ describe('Edit pay method path', () => {
}, selectors.clientPayMethod.receivedB2BVNLCheckbox) }, selectors.clientPayMethod.receivedB2BVNLCheckbox)
.then(value => { .then(value => {
expect(value).toBeFalsy(); expect(value).toBeFalsy();
done(); });
})
.catch(catchErrors(done));
}); });
}); });

View File

@ -1,50 +1,23 @@
import config from '../../helpers/config.js';
import createNightmare from '../../helpers/nightmare';
import selectors from '../../helpers/selectors.js'; import selectors from '../../helpers/selectors.js';
import {catchErrors} from '../../../services/utils/jasmineHelpers'; import createNightmare from '../../helpers/helpers';
const nightmare = createNightmare();
const moduleAccessViewHashURL = '#!/';
jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000;
describe('Add address path', () => { describe('Add address path', () => {
it('should log in', done => { const nightmare = createNightmare();
nightmare
.login()
.waitForURL(moduleAccessViewHashURL)
.url()
.then(url => {
expect(url).toEqual(config.url + moduleAccessViewHashURL);
done();
})
.catch(catchErrors(done));
});
it('should make sure the language is English', done => { it('should click on the Clients button of the top bar menu', () => {
nightmare return nightmare
.changeLanguageToEnglish()
.then(() => {
done();
})
.catch(catchErrors(done));
});
it('should click on the Clients button of the top bar menu', done => {
nightmare
.waitToClick(selectors.globalItems.applicationsMenuButton) .waitToClick(selectors.globalItems.applicationsMenuButton)
.wait(selectors.globalItems.applicationsMenuVisible) .wait(selectors.globalItems.applicationsMenuVisible)
.waitToClick(selectors.globalItems.clientsButton) .waitToClick(selectors.globalItems.clientsButton)
.wait(selectors.clientsIndex.createClientButton) .wait(selectors.clientsIndex.createClientButton)
.url() .urlParsed()
.then(url => { .then(url => {
expect(url).toEqual(config.url + '#!/clients'); expect(url.hash).toEqual('#!/clients');
done(); });
})
.catch(catchErrors(done));
}); });
it('should search for the user Bruce Banner', done => { it('should search for the user Bruce Banner', () => {
nightmare return nightmare
.wait(selectors.clientsIndex.searchResult) .wait(selectors.clientsIndex.searchResult)
.type(selectors.clientsIndex.searchClientInput, 'Bruce Banner') .type(selectors.clientsIndex.searchClientInput, 'Bruce Banner')
.click(selectors.clientsIndex.searchButton) .click(selectors.clientsIndex.searchButton)
@ -52,13 +25,11 @@ describe('Add address path', () => {
.countSearchResults(selectors.clientsIndex.searchResult) .countSearchResults(selectors.clientsIndex.searchResult)
.then(result => { .then(result => {
expect(result).toEqual(1); expect(result).toEqual(1);
done(); });
})
.catch(catchErrors(done));
}); });
it(`should click on the search result to access to the client addresses`, done => { it(`should click on the search result to access to the client addresses`, () => {
nightmare return nightmare
.waitForTextInElement(selectors.clientsIndex.searchResult, 'Bruce Banner') .waitForTextInElement(selectors.clientsIndex.searchResult, 'Bruce Banner')
.waitToClick(selectors.clientsIndex.searchResult) .waitToClick(selectors.clientsIndex.searchResult)
.waitToClick(selectors.clientAddresses.addressesButton) .waitToClick(selectors.clientAddresses.addressesButton)
@ -66,223 +37,168 @@ describe('Add address path', () => {
.url() .url()
.then(url => { .then(url => {
expect(url).toContain('addresses/list'); 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 => { it(`should click on the add new address button to access to the new address form`, () => {
nightmare return nightmare
.waitToClick(selectors.clientAddresses.createAddress) .waitToClick(selectors.clientAddresses.createAddress)
.waitForURL('addresses/create') .waitForURL('addresses/create')
.url() .url()
.then(url => { .then(url => {
expect(url).toContain('addresses/create'); 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 => { it('should check the default checkbox then receive an error after clicking save button as the form is empty', () => {
nightmare return nightmare
.waitToClick(selectors.clientAddresses.defaultCheckboxInput) .waitToClick(selectors.clientAddresses.defaultCheckboxInput)
.waitToClick(selectors.clientFiscalData.saveButton) .waitToClick(selectors.clientFiscalData.saveButton)
.wait(selectors.globalItems.snackbarIsActive) .waitForSnackbar()
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => { .then(result => {
expect(result).toContain('Some fields are invalid'); 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 => { it('should receive an error when clicking the save button having all the form fields empty but consignee', () => {
nightmare return nightmare
.waitForSnackbarReset()
.type(selectors.clientAddresses.consigneeInput, 'Bruce Bunner') .type(selectors.clientAddresses.consigneeInput, 'Bruce Bunner')
.click(selectors.createClientView.createButton) .click(selectors.createClientView.createButton)
.wait(selectors.globalItems.snackbarIsActive) .waitForSnackbar()
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => { .then(result => {
expect(result).toContain('Some fields are invalid'); 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 => { it('should receive an error when clicking the save button having all the form fields empty but Street', () => {
nightmare return nightmare
.waitForSnackbarReset()
.clearInput(selectors.clientAddresses.consigneeInput) .clearInput(selectors.clientAddresses.consigneeInput)
.type(selectors.clientAddresses.streetAddressInput, '320 Park Avenue New York') .type(selectors.clientAddresses.streetAddressInput, '320 Park Avenue New York')
.click(selectors.createClientView.createButton) .click(selectors.createClientView.createButton)
.wait(selectors.globalItems.snackbarIsActive) .waitForSnackbar()
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => { .then(result => {
expect(result).toContain('Some fields are invalid'); 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 => { it('should receive an error when clicking the save button having all the form fields empty but postcode', () => {
nightmare return nightmare
.waitForSnackbarReset()
.clearInput(selectors.clientAddresses.streetAddressInput) .clearInput(selectors.clientAddresses.streetAddressInput)
.type(selectors.clientAddresses.postcodeInput, '10022') .type(selectors.clientAddresses.postcodeInput, '10022')
.click(selectors.createClientView.createButton) .click(selectors.createClientView.createButton)
.wait(selectors.globalItems.snackbarIsActive) .waitForSnackbar()
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => { .then(result => {
expect(result).toContain('Some fields are invalid'); 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 => { it('should receive an error when clicking the save button having all the form fields empty but city', () => {
nightmare return nightmare
.waitForSnackbarReset()
.clearInput(selectors.clientAddresses.postcodeInput) .clearInput(selectors.clientAddresses.postcodeInput)
.type(selectors.clientAddresses.cityInput, 'New York') .type(selectors.clientAddresses.cityInput, 'New York')
.click(selectors.createClientView.createButton) .click(selectors.createClientView.createButton)
.wait(selectors.globalItems.snackbarIsActive) .waitForSnackbar()
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => { .then(result => {
expect(result).toContain('Some fields are invalid'); 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 => { it('should receive an error when clicking the save button having all the form fields empty but province', () => {
nightmare return nightmare
.waitForSnackbarReset()
.clearInput(selectors.clientAddresses.cityInput) .clearInput(selectors.clientAddresses.cityInput)
.waitToClick(selectors.clientAddresses.provinceInput) .waitToClick(selectors.clientAddresses.provinceInput)
.waitToClick(selectors.clientAddresses.provinceSecondOption) .waitToClick(selectors.clientAddresses.provinceSecondOption)
.click(selectors.createClientView.createButton) .click(selectors.createClientView.createButton)
.wait(selectors.globalItems.snackbarIsActive) .waitForSnackbar()
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => { .then(result => {
expect(result).toContain('Some fields are invalid'); 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 => { it('should receive an error when clicking the save button having all the form fields empty but province and agency', () => {
nightmare return nightmare
.waitForSnackbarReset()
.waitToClick(selectors.clientAddresses.agencyInput) .waitToClick(selectors.clientAddresses.agencyInput)
.waitToClick(selectors.clientAddresses.agenctySecondOption) .waitToClick(selectors.clientAddresses.agenctySecondOption)
.click(selectors.createClientView.createButton) .click(selectors.createClientView.createButton)
.wait(selectors.globalItems.snackbarIsActive) .waitForSnackbar()
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => { .then(result => {
expect(result).toContain('Some fields are invalid'); 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 => { it('should receive an error when clicking the save button having all the form fields empty but province, agency and phone', () => {
nightmare return nightmare
.waitForSnackbarReset()
.type(selectors.clientAddresses.phoneInput, '999887744') .type(selectors.clientAddresses.phoneInput, '999887744')
.click(selectors.createClientView.createButton) .click(selectors.createClientView.createButton)
.wait(selectors.globalItems.snackbarIsActive) .waitForSnackbar()
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => { .then(result => {
expect(result).toContain('Some fields are invalid'); 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 => { it('should receive an error when clicking the save button having all the form fields empty but province, agency and mobile', () => {
nightmare return nightmare
.waitForSnackbarReset()
.clearInput(selectors.clientAddresses.phoneInput) .clearInput(selectors.clientAddresses.phoneInput)
.type(selectors.clientAddresses.mobileInput, '999887744') .type(selectors.clientAddresses.mobileInput, '999887744')
.click(selectors.createClientView.createButton) .click(selectors.createClientView.createButton)
.wait(selectors.globalItems.snackbarIsActive) .waitForSnackbar()
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => { .then(result => {
expect(result).toContain('Some fields are invalid'); expect(result).toContain('Some fields are invalid');
done(); });
})
.catch(catchErrors(done));
}); });
it(`should create a new address with all it's data`, done => { it(`should create a new address with all it's data`, () => {
nightmare return nightmare
.waitForSnackbarReset()
.type(selectors.clientAddresses.consigneeInput, 'Bruce Bunner') .type(selectors.clientAddresses.consigneeInput, 'Bruce Bunner')
.type(selectors.clientAddresses.streetAddressInput, '320 Park Avenue New York') .type(selectors.clientAddresses.streetAddressInput, '320 Park Avenue New York')
.type(selectors.clientAddresses.postcodeInput, '10022') .type(selectors.clientAddresses.postcodeInput, '10022')
.type(selectors.clientAddresses.cityInput, 'New York') .type(selectors.clientAddresses.cityInput, 'New York')
.type(selectors.clientAddresses.phoneInput, '999887744') .type(selectors.clientAddresses.phoneInput, '999887744')
.click(selectors.clientAddresses.saveButton) .click(selectors.clientAddresses.saveButton)
.wait(selectors.globalItems.snackbarIsActive) .waitForSnackbar()
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => { .then(result => {
expect(result).toContain('Data saved!'); 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 => { it(`should click on the addresses button confirm the new address exists and it's the default one`, () => {
nightmare return nightmare
.waitForSnackbarReset()
.waitToClick(selectors.clientAddresses.addressesButton) .waitToClick(selectors.clientAddresses.addressesButton)
.wait(selectors.clientAddresses.defaultAddress) .wait(selectors.clientAddresses.defaultAddress)
.getInnerText(selectors.clientAddresses.defaultAddress) .getInnerText(selectors.clientAddresses.defaultAddress)
.then(result => { .then(result => {
expect(result).toContain('320 Park Avenue New York'); 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 => { it(`should click on the make default icon of the second address then confirm it is the default one now`, () => {
nightmare return nightmare
.waitForSnackbarReset()
.waitToClick(selectors.clientAddresses.secondMakeDefaultStar) .waitToClick(selectors.clientAddresses.secondMakeDefaultStar)
.waitForTextInElement(selectors.clientAddresses.defaultAddress, 'Somewhere in Thailand') .waitForTextInElement(selectors.clientAddresses.defaultAddress, 'Somewhere in Thailand')
.getInnerText(selectors.clientAddresses.defaultAddress) .getInnerText(selectors.clientAddresses.defaultAddress)
.then(result => { .then(result => {
expect(result).toContain('Somewhere in Thailand'); expect(result).toContain('Somewhere in Thailand');
done(); });
})
.catch(catchErrors(done));
}); });
it(`should click on the edit icon of the default address`, done => { it(`should click on the edit icon of the default address`, () => {
nightmare return nightmare
.waitForTextInElement(selectors.clientAddresses.defaultAddress, 'Somewhere in Thailand') .waitForTextInElement(selectors.clientAddresses.defaultAddress, 'Somewhere in Thailand')
.waitToClick(selectors.clientAddresses.firstEditButton) .waitToClick(selectors.clientAddresses.firstEditButton)
.waitForURL('/edit') .waitForURL('/edit')
.url() .url()
.then(result => { .then(result => {
expect(result).toContain('/edit'); 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 => { it(`should click on the active checkbox and receive an error to save it becouse it is the default address`, () => {
nightmare return nightmare
.waitForSnackbarReset()
.waitToClick(selectors.clientAddresses.activeCheckbox) .waitToClick(selectors.clientAddresses.activeCheckbox)
.waitToClick(selectors.clientAddresses.saveButton) .waitToClick(selectors.clientAddresses.saveButton)
.wait(selectors.globalItems.snackbarIsActive) .waitForSnackbar()
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => { .then(result => {
expect(result).toContain('Error'); expect(result).toContain('Error');
done(); });
})
.catch(catchErrors(done));
}); });
}); });

View File

@ -1,50 +1,23 @@
import config from '../../helpers/config.js';
import createNightmare from '../../helpers/nightmare';
import selectors from '../../helpers/selectors.js'; import selectors from '../../helpers/selectors.js';
import {catchErrors} from '../../../services/utils/jasmineHelpers'; import createNightmare from '../../helpers/helpers';
const nightmare = createNightmare();
const moduleAccessViewHashURL = '#!/';
jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000;
describe('Add address notes path', () => { describe('Add address notes path', () => {
it('should log in', done => { const nightmare = createNightmare();
nightmare
.login()
.waitForURL(moduleAccessViewHashURL)
.url()
.then(url => {
expect(url).toEqual(config.url + moduleAccessViewHashURL);
done();
})
.catch(catchErrors(done));
});
it('should make sure the language is English', done => { it('should click on the Clients button of the top bar menu', () => {
nightmare return nightmare
.changeLanguageToEnglish()
.then(() => {
done();
})
.catch(catchErrors(done));
});
it('should click on the Clients button of the top bar menu', done => {
nightmare
.waitToClick(selectors.globalItems.applicationsMenuButton) .waitToClick(selectors.globalItems.applicationsMenuButton)
.wait(selectors.globalItems.applicationsMenuVisible) .wait(selectors.globalItems.applicationsMenuVisible)
.waitToClick(selectors.globalItems.clientsButton) .waitToClick(selectors.globalItems.clientsButton)
.wait(selectors.clientsIndex.createClientButton) .wait(selectors.clientsIndex.createClientButton)
.url() .urlParsed()
.then(url => { .then(url => {
expect(url).toEqual(config.url + '#!/clients'); expect(url.hash).toEqual('#!/clients');
done(); });
})
.catch(catchErrors(done));
}); });
it('should search for the user Bruce Banner', done => { it('should search for the user Bruce Banner', () => {
nightmare return nightmare
.wait(selectors.clientsIndex.searchResult) .wait(selectors.clientsIndex.searchResult)
.type(selectors.clientsIndex.searchClientInput, 'Bruce Banner') .type(selectors.clientsIndex.searchClientInput, 'Bruce Banner')
.click(selectors.clientsIndex.searchButton) .click(selectors.clientsIndex.searchButton)
@ -52,13 +25,11 @@ describe('Add address notes path', () => {
.countSearchResults(selectors.clientsIndex.searchResult) .countSearchResults(selectors.clientsIndex.searchResult)
.then(result => { .then(result => {
expect(result).toEqual(1); expect(result).toEqual(1);
done(); });
})
.catch(catchErrors(done));
}); });
it(`should click on the search result to access to the client addresses`, done => { it(`should click on the search result to access to the client addresses`, () => {
nightmare return nightmare
.waitForTextInElement(selectors.clientsIndex.searchResult, 'Bruce Banner') .waitForTextInElement(selectors.clientsIndex.searchResult, 'Bruce Banner')
.waitToClick(selectors.clientsIndex.searchResult) .waitToClick(selectors.clientsIndex.searchResult)
.waitToClick(selectors.clientAddresses.addressesButton) .waitToClick(selectors.clientAddresses.addressesButton)
@ -66,34 +37,27 @@ describe('Add address notes path', () => {
.url() .url()
.then(url => { .then(url => {
expect(url).toContain('addresses/list'); expect(url).toContain('addresses/list');
done(); });
})
.catch(catchErrors(done));
}); });
it(`should click on the edit icon of the default address`, done => { it(`should click on the edit icon of the default address`, () => {
nightmare return nightmare
.waitForTextInElement(selectors.clientAddresses.defaultAddress, 'Somewhere in Thailand') .waitForTextInElement(selectors.clientAddresses.defaultAddress, 'Somewhere in Thailand')
.waitToClick(selectors.clientAddresses.firstEditButton) .waitToClick(selectors.clientAddresses.firstEditButton)
.waitForURL('/edit') .waitForURL('/edit')
.url() .url()
.then(result => { .then(result => {
expect(result).toContain('/edit'); expect(result).toContain('/edit');
done(); });
})
.catch(catchErrors(done));
}); });
// it('should add as many notes as observation types', done => { // it('should add as many notes as observation types', () => {
// nightmare // return nightmare
// .waitToClick(selectors.clientAddresses.defaultCheckboxInput) // .waitToClick(selectors.clientAddresses.defaultCheckboxInput)
// .waitToClick(selectors.clientFiscalData.saveButton) // .waitToClick(selectors.clientFiscalData.saveButton)
// .wait(selectors.globalItems.snackbarIsActive) // .waitForSnackbar()
// .getInnerText(selectors.globalItems.snackbarIsActive)
// .then(result => { // .then(result => {
// expect(result).toContain('Some fields are invalid'); // expect(result).toContain('Some fields are invalid');
// done();
// }) // })
// .catch(catchErrors(done));
// }); // });
}); });

View File

@ -1,50 +1,23 @@
import config from '../../helpers/config.js';
import createNightmare from '../../helpers/nightmare';
import selectors from '../../helpers/selectors.js'; import selectors from '../../helpers/selectors.js';
import {catchErrors} from '../../../services/utils/jasmineHelpers'; import createNightmare from '../../helpers/helpers';
const nightmare = createNightmare();
const moduleAccessViewHashURL = '#!/';
jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000;
describe('Edit web access path', () => { describe('Edit web access path', () => {
it('should log in', done => { const nightmare = createNightmare();
nightmare
.login()
.waitForURL(moduleAccessViewHashURL)
.url()
.then(url => {
expect(url).toEqual(config.url + moduleAccessViewHashURL);
done();
})
.catch(catchErrors(done));
});
it('should make sure the language is English', done => { it('should click on the Clients button of the top bar menu', () => {
nightmare return nightmare
.changeLanguageToEnglish()
.then(() => {
done();
})
.catch(catchErrors(done));
});
it('should click on the Clients button of the top bar menu', done => {
nightmare
.waitToClick(selectors.globalItems.applicationsMenuButton) .waitToClick(selectors.globalItems.applicationsMenuButton)
.wait(selectors.globalItems.applicationsMenuVisible) .wait(selectors.globalItems.applicationsMenuVisible)
.waitToClick(selectors.globalItems.clientsButton) .waitToClick(selectors.globalItems.clientsButton)
.wait(selectors.clientsIndex.createClientButton) .wait(selectors.clientsIndex.createClientButton)
.url() .urlParsed()
.then(url => { .then(url => {
expect(url).toEqual(config.url + '#!/clients'); expect(url.hash).toEqual('#!/clients');
done(); });
})
.catch(catchErrors(done));
}); });
it('should search for the user Bruce Banner', done => { it('should search for the user Bruce Banner', () => {
nightmare return nightmare
.wait(selectors.clientsIndex.searchResult) .wait(selectors.clientsIndex.searchResult)
.type(selectors.clientsIndex.searchClientInput, 'Bruce Banner') .type(selectors.clientsIndex.searchClientInput, 'Bruce Banner')
.click(selectors.clientsIndex.searchButton) .click(selectors.clientsIndex.searchButton)
@ -52,13 +25,11 @@ describe('Edit web access path', () => {
.countSearchResults(selectors.clientsIndex.searchResult) .countSearchResults(selectors.clientsIndex.searchResult)
.then(result => { .then(result => {
expect(result).toEqual(1); expect(result).toEqual(1);
done(); });
})
.catch(catchErrors(done));
}); });
it(`should click on the search result to access to the client's web access`, done => { it(`should click on the search result to access to the client's web access`, () => {
nightmare return nightmare
.waitForTextInElement(selectors.clientsIndex.searchResult, 'Bruce Banner') .waitForTextInElement(selectors.clientsIndex.searchResult, 'Bruce Banner')
.waitToClick(selectors.clientsIndex.searchResult) .waitToClick(selectors.clientsIndex.searchResult)
.waitToClick(selectors.clientWebAccess.webAccessButton) .waitToClick(selectors.clientWebAccess.webAccessButton)
@ -66,27 +37,21 @@ describe('Edit web access path', () => {
.url() .url()
.then(url => { .then(url => {
expect(url).toContain('web-access'); expect(url).toContain('web-access');
done(); });
})
.catch(catchErrors(done));
}); });
it(`should click on the Enable web access checkbox to uncheck it`, done => { it(`should click on the Enable web access checkbox to uncheck it`, () => {
nightmare return nightmare
.waitToClick(selectors.clientWebAccess.enableWebAccessCheckbox) .waitToClick(selectors.clientWebAccess.enableWebAccessCheckbox)
.waitToClick(selectors.clientFiscalData.saveButton) .waitToClick(selectors.clientFiscalData.saveButton)
.wait(selectors.globalItems.snackbarIsActive) .waitForSnackbar()
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => { .then(result => {
expect(result).toContain(`Data saved!`); expect(result).toContain(`Data saved!`);
done(); });
})
.catch(catchErrors(done));
}); });
it('should confirm Enable web access checkbox is unchecked', done => { it('should confirm Enable web access checkbox is unchecked', () => {
nightmare return nightmare
.waitForSnackbarReset()
.waitToClick(selectors.clientBasicData.basicDataButton) .waitToClick(selectors.clientBasicData.basicDataButton)
.wait(selectors.clientBasicData.nameInput) .wait(selectors.clientBasicData.nameInput)
.waitToClick(selectors.clientWebAccess.webAccessButton) .waitToClick(selectors.clientWebAccess.webAccessButton)
@ -96,29 +61,23 @@ describe('Edit web access path', () => {
}, selectors.clientWebAccess.enableWebAccessCheckbox) }, selectors.clientWebAccess.enableWebAccessCheckbox)
.then(value => { .then(value => {
expect(value).toBeFalsy(); expect(value).toBeFalsy();
done(); });
})
.catch(catchErrors(done));
}); });
it('should edit the User name', done => { it('should edit the User name', () => {
nightmare return nightmare
.wait(selectors.clientWebAccess.userNameInput) .wait(selectors.clientWebAccess.userNameInput)
.clearInput(selectors.clientWebAccess.userNameInput) .clearInput(selectors.clientWebAccess.userNameInput)
.type(selectors.clientWebAccess.userNameInput, 'Hulk') .type(selectors.clientWebAccess.userNameInput, 'Hulk')
.click(selectors.clientWebAccess.saveButton) .click(selectors.clientWebAccess.saveButton)
.wait(selectors.globalItems.snackbarIsActive) .waitForSnackbar()
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => { .then(result => {
expect(result).toEqual('Data saved!'); expect(result).toEqual('Data saved!');
done(); });
})
.catch(catchErrors(done));
}); });
it('should confirm the User name have been edited', done => { it('should confirm the User name have been edited', () => {
nightmare return nightmare
.waitForSnackbarReset()
.click(selectors.clientBasicData.basicDataButton) .click(selectors.clientBasicData.basicDataButton)
.wait(selectors.clientBasicData.nameInput) .wait(selectors.clientBasicData.nameInput)
.click(selectors.clientWebAccess.webAccessButton) .click(selectors.clientWebAccess.webAccessButton)
@ -127,8 +86,6 @@ describe('Edit web access path', () => {
.getInputValue(selectors.clientWebAccess.userNameInput) .getInputValue(selectors.clientWebAccess.userNameInput)
.then(result => { .then(result => {
expect(result).toEqual('Hulk'); expect(result).toEqual('Hulk');
done(); });
})
.catch(catchErrors(done));
}); });
}); });

View File

@ -1,50 +1,23 @@
import config from '../../helpers/config.js';
import createNightmare from '../../helpers/nightmare';
import selectors from '../../helpers/selectors.js'; import selectors from '../../helpers/selectors.js';
import {catchErrors} from '../../../services/utils/jasmineHelpers'; import createNightmare from '../../helpers/helpers';
const nightmare = createNightmare();
const moduleAccessViewHashURL = '#!/';
jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000;
describe('Add notes path', () => { describe('Add notes path', () => {
it('should log in', done => { const nightmare = createNightmare();
nightmare
.login()
.waitForURL(moduleAccessViewHashURL)
.url()
.then(url => {
expect(url).toEqual(config.url + moduleAccessViewHashURL);
done();
})
.catch(catchErrors(done));
});
it('should make sure the language is English', done => { it('should click on the Clients button of the top bar menu', () => {
nightmare return nightmare
.changeLanguageToEnglish()
.then(() => {
done();
})
.catch(catchErrors(done));
});
it('should click on the Clients button of the top bar menu', done => {
nightmare
.waitToClick(selectors.globalItems.applicationsMenuButton) .waitToClick(selectors.globalItems.applicationsMenuButton)
.wait(selectors.globalItems.applicationsMenuVisible) .wait(selectors.globalItems.applicationsMenuVisible)
.waitToClick(selectors.globalItems.clientsButton) .waitToClick(selectors.globalItems.clientsButton)
.wait(selectors.clientsIndex.createClientButton) .wait(selectors.clientsIndex.createClientButton)
.url() .urlParsed()
.then(url => { .then(url => {
expect(url).toEqual(config.url + '#!/clients'); expect(url.hash).toEqual('#!/clients');
done(); });
})
.catch(catchErrors(done));
}); });
it('should search for the user Bruce Banner', done => { it('should search for the user Bruce Banner', () => {
nightmare return nightmare
.wait(selectors.clientsIndex.searchResult) .wait(selectors.clientsIndex.searchResult)
.type(selectors.clientsIndex.searchClientInput, 'Bruce Banner') .type(selectors.clientsIndex.searchClientInput, 'Bruce Banner')
.click(selectors.clientsIndex.searchButton) .click(selectors.clientsIndex.searchButton)
@ -52,13 +25,11 @@ describe('Add notes path', () => {
.countSearchResults(selectors.clientsIndex.searchResult) .countSearchResults(selectors.clientsIndex.searchResult)
.then(result => { .then(result => {
expect(result).toEqual(1); expect(result).toEqual(1);
done(); });
})
.catch(catchErrors(done));
}); });
it(`should click on the search result to access to the client's notes`, done => { it(`should click on the search result to access to the client's notes`, () => {
nightmare return nightmare
.waitForTextInElement(selectors.clientsIndex.searchResult, 'Bruce Banner') .waitForTextInElement(selectors.clientsIndex.searchResult, 'Bruce Banner')
.waitToClick(selectors.clientsIndex.searchResult) .waitToClick(selectors.clientsIndex.searchResult)
.waitToClick(selectors.clientNotes.notesButton) .waitToClick(selectors.clientNotes.notesButton)
@ -66,45 +37,35 @@ describe('Add notes path', () => {
.url() .url()
.then(url => { .then(url => {
expect(url).toContain('notes/list'); expect(url).toContain('notes/list');
done(); });
})
.catch(catchErrors(done));
}); });
it(`should click on the add note button`, done => { it(`should click on the add note button`, () => {
nightmare return nightmare
.waitToClick(selectors.clientNotes.addNoteFloatButton) .waitToClick(selectors.clientNotes.addNoteFloatButton)
.waitForURL('/notes/create') .waitForURL('/notes/create')
.url() .url()
.then(url => { .then(url => {
expect(url).toContain('/notes/create'); expect(url).toContain('/notes/create');
done(); });
})
.catch(catchErrors(done));
}); });
it(`should create a note`, done => { it(`should create a note`, () => {
nightmare return nightmare
.type(selectors.clientNotes.noteInput, 'Meeting with Black Widow 21st 9am') .type(selectors.clientNotes.noteInput, 'Meeting with Black Widow 21st 9am')
.click(selectors.clientNotes.saveButton) .click(selectors.clientNotes.saveButton)
.wait(selectors.globalItems.snackbarIsActive) .waitForSnackbar()
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => { .then(result => {
expect(result).toEqual('Data saved!'); expect(result).toEqual('Data saved!');
done(); });
})
.catch(catchErrors(done));
}); });
it('should confirm the note was created', done => { it('should confirm the note was created', () => {
nightmare return nightmare
.waitForSnackbarReset()
.wait(selectors.clientNotes.firstNoteText) .wait(selectors.clientNotes.firstNoteText)
.getInnerText(selectors.clientNotes.firstNoteText) .getInnerText(selectors.clientNotes.firstNoteText)
.then(value => { .then(value => {
expect(value).toEqual('Meeting with Black Widow 21st 9am'); expect(value).toEqual('Meeting with Black Widow 21st 9am');
done(); });
})
.catch(catchErrors(done));
}); });
}); });

View File

@ -1,50 +1,23 @@
import config from '../../helpers/config.js';
import createNightmare from '../../helpers/nightmare';
import selectors from '../../helpers/selectors.js'; import selectors from '../../helpers/selectors.js';
import {catchErrors} from '../../../services/utils/jasmineHelpers'; import createNightmare from '../../helpers/helpers';
const nightmare = createNightmare();
const moduleAccessViewHashURL = '#!/';
jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000;
describe('Add credit path', () => { describe('Add credit path', () => {
it('should log in', done => { const nightmare = createNightmare();
nightmare
.login()
.waitForURL(moduleAccessViewHashURL)
.url()
.then(url => {
expect(url).toEqual(config.url + moduleAccessViewHashURL);
done();
})
.catch(catchErrors(done));
});
it('should make sure the language is English', done => { it('should click on the Clients button of the top bar menu', () => {
nightmare return nightmare
.changeLanguageToEnglish()
.then(() => {
done();
})
.catch(catchErrors(done));
});
it('should click on the Clients button of the top bar menu', done => {
nightmare
.waitToClick(selectors.globalItems.applicationsMenuButton) .waitToClick(selectors.globalItems.applicationsMenuButton)
.wait(selectors.globalItems.applicationsMenuVisible) .wait(selectors.globalItems.applicationsMenuVisible)
.waitToClick(selectors.globalItems.clientsButton) .waitToClick(selectors.globalItems.clientsButton)
.wait(selectors.clientsIndex.createClientButton) .wait(selectors.clientsIndex.createClientButton)
.url() .urlParsed()
.then(url => { .then(url => {
expect(url).toEqual(config.url + '#!/clients'); expect(url.hash).toEqual('#!/clients');
done(); });
})
.catch(catchErrors(done));
}); });
it('should search for the user Petter Parker', done => { it('should search for the user Petter Parker', () => {
nightmare return nightmare
.wait(selectors.clientsIndex.searchResult) .wait(selectors.clientsIndex.searchResult)
.type(selectors.clientsIndex.searchClientInput, 'Petter Parker') .type(selectors.clientsIndex.searchClientInput, 'Petter Parker')
.click(selectors.clientsIndex.searchButton) .click(selectors.clientsIndex.searchButton)
@ -52,13 +25,11 @@ describe('Add credit path', () => {
.countSearchResults(selectors.clientsIndex.searchResult) .countSearchResults(selectors.clientsIndex.searchResult)
.then(result => { .then(result => {
expect(result).toEqual(1); expect(result).toEqual(1);
done(); });
})
.catch(catchErrors(done));
}); });
it(`should click on the search result to access to the client's credit`, done => { it(`should click on the search result to access to the client's credit`, () => {
nightmare return nightmare
.waitForTextInElement(selectors.clientsIndex.searchResult, 'Petter Parker') .waitForTextInElement(selectors.clientsIndex.searchResult, 'Petter Parker')
.waitToClick(selectors.clientsIndex.searchResult) .waitToClick(selectors.clientsIndex.searchResult)
.waitToClick(selectors.clientCredit.creditButton) .waitToClick(selectors.clientCredit.creditButton)
@ -66,46 +37,36 @@ describe('Add credit path', () => {
.url() .url()
.then(url => { .then(url => {
expect(url).toContain('credit/list'); expect(url).toContain('credit/list');
done(); });
})
.catch(catchErrors(done));
}); });
it(`should click on the add credit button`, done => { it(`should click on the add credit button`, () => {
nightmare return nightmare
.waitToClick(selectors.clientCredit.addCreditFloatButton) .waitToClick(selectors.clientCredit.addCreditFloatButton)
.waitForURL('/credit/create') .waitForURL('/credit/create')
.url() .url()
.then(url => { .then(url => {
expect(url).toContain('/credit/create'); expect(url).toContain('/credit/create');
done(); });
})
.catch(catchErrors(done));
}); });
it(`should edit the credit`, done => { it(`should edit the credit`, () => {
nightmare return nightmare
.clearInput(selectors.clientCredit.creditInput) .clearInput(selectors.clientCredit.creditInput)
.type(selectors.clientCredit.creditInput, 999) .type(selectors.clientCredit.creditInput, 999)
.click(selectors.clientCredit.saveButton) .click(selectors.clientCredit.saveButton)
.wait(selectors.globalItems.snackbarIsActive) .waitForSnackbar()
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => { .then(result => {
expect(result).toEqual('Data saved!'); expect(result).toEqual('Data saved!');
done(); });
})
.catch(catchErrors(done));
}); });
it('should confirm the credit was updated', done => { it('should confirm the credit was updated', () => {
nightmare return nightmare
.waitForSnackbarReset()
.wait(selectors.clientCredit.firstCreditText) .wait(selectors.clientCredit.firstCreditText)
.getInnerText(selectors.clientCredit.firstCreditText) .getInnerText(selectors.clientCredit.firstCreditText)
.then(value => { .then(value => {
expect(value).toContain(999); expect(value).toContain(999);
done(); });
})
.catch(catchErrors(done));
}); });
}); });

View File

@ -1,50 +1,23 @@
import config from '../../helpers/config.js';
import createNightmare from '../../helpers/nightmare';
import selectors from '../../helpers/selectors.js'; import selectors from '../../helpers/selectors.js';
import {catchErrors} from '../../../services/utils/jasmineHelpers'; import createNightmare from '../../helpers/helpers';
const nightmare = createNightmare();
const moduleAccessViewHashURL = '#!/';
jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000;
describe('Add greuge path', () => { describe('Add greuge path', () => {
it('should log in', done => { const nightmare = createNightmare();
nightmare
.login()
.waitForURL(moduleAccessViewHashURL)
.url()
.then(url => {
expect(url).toEqual(config.url + moduleAccessViewHashURL);
done();
})
.catch(catchErrors(done));
});
it('should make sure the language is English', done => { it('should click on the Clients button of the top bar menu', () => {
nightmare return nightmare
.changeLanguageToEnglish()
.then(() => {
done();
})
.catch(catchErrors(done));
});
it('should click on the Clients button of the top bar menu', done => {
nightmare
.waitToClick(selectors.globalItems.applicationsMenuButton) .waitToClick(selectors.globalItems.applicationsMenuButton)
.wait(selectors.globalItems.applicationsMenuVisible) .wait(selectors.globalItems.applicationsMenuVisible)
.waitToClick(selectors.globalItems.clientsButton) .waitToClick(selectors.globalItems.clientsButton)
.wait(selectors.clientsIndex.createClientButton) .wait(selectors.clientsIndex.createClientButton)
.url() .urlParsed()
.then(url => { .then(url => {
expect(url).toEqual(config.url + '#!/clients'); expect(url.hash).toEqual('#!/clients');
done(); });
})
.catch(catchErrors(done));
}); });
it('should search for the user Petter Parker', done => { it('should search for the user Petter Parker', () => {
nightmare return nightmare
.wait(selectors.clientsIndex.searchResult) .wait(selectors.clientsIndex.searchResult)
.type(selectors.clientsIndex.searchClientInput, 'Petter Parker') .type(selectors.clientsIndex.searchClientInput, 'Petter Parker')
.click(selectors.clientsIndex.searchButton) .click(selectors.clientsIndex.searchButton)
@ -52,13 +25,11 @@ describe('Add greuge path', () => {
.countSearchResults(selectors.clientsIndex.searchResult) .countSearchResults(selectors.clientsIndex.searchResult)
.then(result => { .then(result => {
expect(result).toEqual(1); expect(result).toEqual(1);
done(); });
})
.catch(catchErrors(done));
}); });
it(`should click on the search result to access to the client's greuge`, done => { it(`should click on the search result to access to the client's greuge`, () => {
nightmare return nightmare
.waitForTextInElement(selectors.clientsIndex.searchResult, 'Petter Parker') .waitForTextInElement(selectors.clientsIndex.searchResult, 'Petter Parker')
.waitToClick(selectors.clientsIndex.searchResult) .waitToClick(selectors.clientsIndex.searchResult)
.waitToClick(selectors.clientGreuge.greugeButton) .waitToClick(selectors.clientGreuge.greugeButton)
@ -66,103 +37,81 @@ describe('Add greuge path', () => {
.url() .url()
.then(url => { .then(url => {
expect(url).toContain('greuge/list'); expect(url).toContain('greuge/list');
done(); });
})
.catch(catchErrors(done));
}); });
it(`should click on the add greuge button`, done => { it(`should click on the add greuge button`, () => {
nightmare return nightmare
.waitToClick(selectors.clientGreuge.addGreugeFloatButton) .waitToClick(selectors.clientGreuge.addGreugeFloatButton)
.waitForURL('greuge/create') .waitForURL('greuge/create')
.url() .url()
.then(url => { .then(url => {
expect(url).toContain('greuge/create'); expect(url).toContain('greuge/create');
done(); });
})
.catch(catchErrors(done));
}); });
it(`should receive an error if all fields are empty but date on submit`, done => { it(`should receive an error if all fields are empty but date on submit`, () => {
nightmare return nightmare
.click(selectors.clientCredit.saveButton) .click(selectors.clientCredit.saveButton)
.wait(selectors.globalItems.snackbarIsActive) .waitForSnackbar()
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => { .then(result => {
expect(result).toContain('Some fields are invalid'); 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 => { it(`should receive an error if all fields are empty but date and amount on submit`, () => {
nightmare return nightmare
.type(selectors.clientGreuge.amountInput, 999) .type(selectors.clientGreuge.amountInput, 999)
.click(selectors.clientGreuge.saveButton) .click(selectors.clientGreuge.saveButton)
.wait(selectors.globalItems.snackbarIsActive) .waitForSnackbar()
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => { .then(result => {
expect(result).toContain('Some fields are invalid'); 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 => { it(`should receive an error if all fields are empty but date and description on submit`, () => {
nightmare return nightmare
.clearInput(selectors.clientGreuge.amountInput) .clearInput(selectors.clientGreuge.amountInput)
.type(selectors.clientGreuge.descriptionInput, 'new armor for Batman!') .type(selectors.clientGreuge.descriptionInput, 'new armor for Batman!')
.click(selectors.clientGreuge.saveButton) .click(selectors.clientGreuge.saveButton)
.wait(selectors.globalItems.snackbarIsActive) .waitForSnackbar()
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => { .then(result => {
expect(result).toContain('Some fields are invalid'); 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 => { it(`should receive an error if all fields are empty but date and type on submit`, () => {
nightmare return nightmare
.clearInput(selectors.clientGreuge.descriptionInput) .clearInput(selectors.clientGreuge.descriptionInput)
.waitToClick(selectors.clientGreuge.typeInput) .waitToClick(selectors.clientGreuge.typeInput)
.waitToClick(selectors.clientGreuge.typeSecondOption) .waitToClick(selectors.clientGreuge.typeSecondOption)
.click(selectors.clientGreuge.saveButton) .click(selectors.clientGreuge.saveButton)
.wait(selectors.globalItems.snackbarIsActive) .waitForSnackbar()
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => { .then(result => {
expect(result).toContain('Some fields are invalid'); expect(result).toContain('Some fields are invalid');
done(); });
})
.catch(catchErrors(done));
}); });
it(`should create a new greuge with all its data`, done => { it(`should create a new greuge with all its data`, () => {
nightmare return nightmare
.clearInput(selectors.clientGreuge.amountInput) .clearInput(selectors.clientGreuge.amountInput)
.type(selectors.clientGreuge.amountInput, 999) .type(selectors.clientGreuge.amountInput, 999)
.type(selectors.clientGreuge.descriptionInput, 'new armor for Batman!') .type(selectors.clientGreuge.descriptionInput, 'new armor for Batman!')
.click(selectors.clientGreuge.saveButton) .click(selectors.clientGreuge.saveButton)
.wait(selectors.globalItems.snackbarIsActive) .waitForSnackbar()
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => { .then(result => {
expect(result).toContain('Data saved!'); expect(result).toContain('Data saved!');
done(); });
})
.catch(catchErrors(done));
}); });
it('should confirm the greuge was added to the list', done => { it('should confirm the greuge was added to the list', () => {
nightmare return nightmare
.waitForSnackbarReset()
.wait(selectors.clientGreuge.firstGreugeText) .wait(selectors.clientGreuge.firstGreugeText)
.getInnerText(selectors.clientGreuge.firstGreugeText) .getInnerText(selectors.clientGreuge.firstGreugeText)
.then(value => { .then(value => {
expect(value).toContain(999); expect(value).toContain(999);
expect(value).toContain('new armor for Batman!'); expect(value).toContain('new armor for Batman!');
expect(value).toContain('Diff'); expect(value).toContain('Diff');
done(); });
})
.catch(catchErrors(done));
}); });
}); });

View File

@ -1,50 +1,23 @@
import config from '../../helpers/config.js';
import createNightmare from '../../helpers/nightmare';
import selectors from '../../helpers/selectors.js'; import selectors from '../../helpers/selectors.js';
import {catchErrors} from '../../../services/utils/jasmineHelpers'; import createNightmare from '../../helpers/helpers';
const nightmare = createNightmare();
const moduleAccessViewHashURL = '#!/';
jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000;
describe('mandate path', () => { describe('mandate path', () => {
it('should log in', done => { const nightmare = createNightmare();
nightmare
.login()
.waitForURL(moduleAccessViewHashURL)
.url()
.then(url => {
expect(url).toEqual(config.url + moduleAccessViewHashURL);
done();
})
.catch(catchErrors(done));
});
it('should make sure the language is English', done => { it('should click on the Clients button of the top bar menu', () => {
nightmare return nightmare
.changeLanguageToEnglish()
.then(() => {
done();
})
.catch(catchErrors(done));
});
it('should click on the Clients button of the top bar menu', done => {
nightmare
.waitToClick(selectors.globalItems.applicationsMenuButton) .waitToClick(selectors.globalItems.applicationsMenuButton)
.wait(selectors.globalItems.applicationsMenuVisible) .wait(selectors.globalItems.applicationsMenuVisible)
.waitToClick(selectors.globalItems.clientsButton) .waitToClick(selectors.globalItems.clientsButton)
.wait(selectors.clientsIndex.createClientButton) .wait(selectors.clientsIndex.createClientButton)
.url() .urlParsed()
.then(url => { .then(url => {
expect(url).toEqual(config.url + '#!/clients'); expect(url.hash).toEqual('#!/clients');
done(); });
})
.catch(catchErrors(done));
}); });
it('should search for the user Petter Parker', done => { it('should search for the user Petter Parker', () => {
nightmare return nightmare
.wait(selectors.clientsIndex.searchResult) .wait(selectors.clientsIndex.searchResult)
.type(selectors.clientsIndex.searchClientInput, 'Petter Parker') .type(selectors.clientsIndex.searchClientInput, 'Petter Parker')
.click(selectors.clientsIndex.searchButton) .click(selectors.clientsIndex.searchButton)
@ -52,13 +25,11 @@ describe('mandate path', () => {
.countSearchResults(selectors.clientsIndex.searchResult) .countSearchResults(selectors.clientsIndex.searchResult)
.then(result => { .then(result => {
expect(result).toEqual(1); expect(result).toEqual(1);
done(); });
})
.catch(catchErrors(done));
}); });
it(`should click on the search result to access to the client's mandate`, done => { it(`should click on the search result to access to the client's mandate`, () => {
nightmare return nightmare
.waitForTextInElement(selectors.clientsIndex.searchResult, 'Petter') .waitForTextInElement(selectors.clientsIndex.searchResult, 'Petter')
.waitToClick(selectors.clientsIndex.searchResult) .waitToClick(selectors.clientsIndex.searchResult)
.waitToClick(selectors.clientMandate.mandateButton) .waitToClick(selectors.clientMandate.mandateButton)
@ -66,21 +37,17 @@ describe('mandate path', () => {
.url() .url()
.then(url => { .then(url => {
expect(url).toContain('mandate'); expect(url).toContain('mandate');
done(); });
})
.catch(catchErrors(done));
}); });
it('should confirm the client has a mandate of the CORE type', done => { it('should confirm the client has a mandate of the CORE type', () => {
nightmare return nightmare
.wait(selectors.clientMandate.firstMandateText) .wait(selectors.clientMandate.firstMandateText)
.getInnerText(selectors.clientMandate.firstMandateText) .getInnerText(selectors.clientMandate.firstMandateText)
.then(value => { .then(value => {
expect(value).toContain('1'); expect(value).toContain('1');
expect(value).toContain('WAY'); expect(value).toContain('WAY');
expect(value).toContain('CORE'); expect(value).toContain('CORE');
done(); });
})
.catch(catchErrors(done));
}); });
}); });

View File

@ -40,8 +40,8 @@ gulp.task('default', () => {
return gulp.start('services', 'client'); return gulp.start('services', 'client');
}); });
gulp.task('client', ['build-clean'], () => { gulp.task('client', ['build-clean'], async () => {
return gulp.start('watch', 'routes', 'locales', 'webpack-dev-server'); await runSequenceP(['routes', 'locales'], 'watch', 'webpack-dev-server');
}); });
/** /**

View File

@ -72,8 +72,7 @@ let prodConfig = {
path: outputPath path: outputPath
}), }),
new webpack.HashedModuleIdsPlugin() new webpack.HashedModuleIdsPlugin()
], ]
devtool: 'source-map'
}; };
let devConfig = { let devConfig = {
@ -83,8 +82,7 @@ let devConfig = {
}, },
plugins: [ plugins: [
new webpack.NamedModulesPlugin() new webpack.NamedModulesPlugin()
], ]
devtool: 'eval'
}; };
let mrgConfig = devMode ? devConfig : prodConfig; let mrgConfig = devMode ? devConfig : prodConfig;