This commit is contained in:
Vicente Falco 2018-02-23 07:18:26 +01:00
commit 443c888d73
124 changed files with 2855 additions and 1859 deletions

View File

@ -3,8 +3,19 @@
<div class="box">
<img src="./logo.svg"/>
<form name="form" ng-submit="$ctrl.submit()">
<vn-textfield vn-id="userField" label="User" model="$ctrl.user" vn-focus></vn-textfield>
<vn-textfield label="Password" model="$ctrl.password" type="password"></vn-textfield>
<vn-textfield
label="User"
model="$ctrl.user"
name="user"
vn-id="userField"
vn-focus>
</vn-textfield>
<vn-textfield
label="Password"
model="$ctrl.password"
name="password"
type="password">
</vn-textfield>
<div class="footer">
<vn-submit label="Enter"></vn-submit>
<div class="spinner-wrapper">

View File

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

View File

@ -58,7 +58,7 @@
show-field = "description"
label = "Observation type"
order = "description ASC"
filter-search="{where: {description: {regexp: 'search'}} }">
filter-search="{where: {description: {regexp: 'search'}}}">
<tpl-item>{{$parent.$parent.item.description}}</tpl-item>
</vn-autocomplete>
<vn-textfield vn-three label="Description" model="observation.description"></vn-textfield>
@ -75,8 +75,8 @@
orange
icon="add_circle"
ng-if = "observation.showAddIcon && observationsTypes.model.length > $ctrl.observations.length"
ng-click="$ctrl.addObservation()"
></vn-icon>
ng-click="$ctrl.addObservation()">
</vn-icon>
</vn-one>
</vn-horizontal>
</vn-one>

View File

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

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 VNL: Recibido core VNL
Received B2B VNL: Recibido B2B VNL
SAVE: GUARDAR
Save: Guardar

View File

@ -3,8 +3,7 @@
label="{{$ctrl.label}}"
model="$ctrl.displayValue"
readonly="$ctrl.readonly"
tab-index="-1"
>
tab-index="-1">
</vn-textfield>
<vn-drop-down vn-auto
items="$ctrl.items"
@ -17,6 +16,7 @@
filter-action="$ctrl.findItems(search)"
item-width="$ctrl.width"
multiple="$ctrl.multiple"
parent = "$ctrl.element"
><vn-item ng-transclude="tplItem">{{$parent.item[$ctrl.showField]}}</vn-item></vn-drop-down>
parent = "$ctrl.element">
<vn-item ng-transclude="tplItem">{{$parent.item[$ctrl.showField]}}</vn-item>
</vn-drop-down>
</vn-vertical>

View File

@ -1,23 +1,10 @@
<div ng-mousedown="$ctrl.onDialogMouseDown($event)">
<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>
<h6 class="dialog-title" translate>
{{::$ctrl.question}}
</h6>
<span translate>
{{::$ctrl.message}}
</span>
</tpl-body>
</div>
<div class="button-bar" ng-click="$ctrl.onButtonClick($event)">
<tpl-buttons>
<button response="CANCEL" translate>Cancel</button>
<button response="ACCEPT" translate>Accept</button>
</tpl-buttons>
</div>
</form>
</div>
<root>
<tpl-body>
<h6 translate>{{::$ctrl.question}}</h6>
<span translate>{{::$ctrl.message}}</span>
</tpl-body>
<tpl-buttons>
<button response="CANCEL" translate>Cancel</button>
<button response="ACCEPT" translate>Accept</button>
</tpl-buttons>
</root>

View File

@ -1,13 +1,21 @@
import ngModule from '../../module';
import Dialog from '../dialog/dialog';
import './style.scss';
import template from './confirm.html';
export default class Confirm extends Dialog {}
Dialog.$inject = ['$element'];
export default class Confirm extends Dialog {
constructor($element, $scope, $compile) {
super($element);
let cTemplate = $compile(template)($scope)[0];
this.body = cTemplate.querySelector('tpl-body');
this.buttons = cTemplate.querySelector('tpl-buttons');
}
}
Confirm.$inject = ['$element', '$scope', '$compile'];
ngModule.component('vnConfirm', {
template: require('./confirm.html'),
template: require('../dialog/dialog.html'),
bindings: {
onOpen: '&?',
onResponse: '&',
question: '@',
message: '@?'

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)">
<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>
<form>
<div ng-transclude="tplBody"></div>
<div
ng-transclude="tplButtons"
class="button-bar"
class="body">
</div>
<div
class="buttons"
ng-click="$ctrl.onButtonClick($event)">
</div>
</form>

View File

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

View File

@ -9,168 +9,45 @@ describe('Component vnDialog', () => {
beforeEach(angular.mock.inject(_$componentController_ => {
$componentController = _$componentController_;
$element = angular.element('<div></div>');
controller = $componentController('vnDialog', {$element});
$element = angular.element('<vn-dialog></vn-dialog>');
controller = $componentController('vnDialog', {$element: $element, $transclude: null});
}));
describe('show()', () => {
it(`should define keypressHandler function, call addEventListener function and define element.style.display to block then call onOpen function`, () => {
it(`should handle escape keypress event, define element.style.display to not none and call onOpen function`, () => {
window.innerHeight = 600;
window.innerWidth = 800;
controller.dialog = {style: {display: 'none'}};
controller.onOpen = () => {};
controller.dialog = {style: {}, offsetWidth: 780, offsetHeight: 581};
spyOn(controller.document, 'addEventListener');
spyOn(controller, 'onOpen');
controller.show();
expect(controller.keypressHandler).toBeDefined();
expect(controller.document.addEventListener).toHaveBeenCalledWith('keypress', controller.keypressHandler);
expect(controller.element.style.display).toEqual('block');
expect(controller.element.style.display).not.toEqual('none');
expect(controller.onOpen).toHaveBeenCalledWith();
});
it(`should define keypressHandler function, call addEventListener function and define element.style.display to block and never call onOpen function`, () => {
window.innerHeight = 600;
window.innerWidth = 800;
controller.dialog = {style: {}, offsetWidth: 781, offsetHeight: 581};
spyOn(controller.document, 'addEventListener');
controller.show();
expect(controller.keypressHandler).toBeDefined();
expect(controller.document.addEventListener).toHaveBeenCalledWith('keypress', controller.keypressHandler);
expect(controller.element.style.display).toEqual('block');
expect(controller.onOpen).not.toBeDefined();
});
});
describe('hide()', () => {
it(`should call fireResponse() and realHide()`, () => {
spyOn(controller, 'fireResponse');
spyOn(controller, 'realHide');
it(`should call onResponse()`, () => {
controller.onResponse = () => {};
spyOn(controller, 'onResponse');
controller.hide();
expect(controller.fireResponse).toHaveBeenCalledWith();
expect(controller.realHide).toHaveBeenCalledWith();
expect(controller.onResponse).toHaveBeenCalled();
});
});
describe('fireResponse()', () => {
it(`should return cancel as false`, () => {
let result = controller.fireResponse('I am the answer!');
expect(controller.onResponse).not.toBeDefined();
expect(result).toEqual(false);
});
it(`should return onResponse()`, () => {
let text = 'I am the answer!';
controller.onResponse = () => {
return {response: text};
it(`should call onResponse()`, () => {
let resposneRes;
controller.onResponse = response => {
resposneRes = response;
return false;
};
let result = controller.fireResponse(text);
let responseRet = controller.fireResponse('answer');
expect(result.response).toEqual(text);
});
});
describe('realHide()', () => {
it(`should set element.style.display and lastEvent properties and call removeEvenListener()`, () => {
spyOn(controller.document, 'removeEventListener');
expect(controller.element.style.display).not.toEqual('none');
expect(controller.lastEvent).not.toBeDefined();
controller.realHide();
expect(controller.element.style.display).toEqual('none');
expect(controller.document.removeEventListener).toHaveBeenCalledWith('keypress', controller.keypressHandler);
expect(controller.lastEvent).toEqual(null);
});
});
describe('onButtonClick()', () => {
it(`should call realHide if cancel isn't false`, () => {
controller.element = document.createElement('div');
controller.element.className = 'tpl-buttons';
let childElement = document.createElement('div');
childElement.className = 'button-bar';
controller.element.appendChild(childElement);
let event = {target: controller.element, attribute: true};
spyOn(controller, 'realHide');
spyOn(controller, 'fireResponse').and.returnValue(true);
controller.onButtonClick(event);
expect(controller.realHide).toHaveBeenCalledWith();
});
it(`should call fireResponse with the value of response`, () => {
controller.element = document.createElement('div');
controller.element.className = 'tpl-buttons';
let childElement = document.createElement('div');
childElement.className = 'button-bar';
controller.element.appendChild(childElement);
let attribute = document.createAttribute('response');
attribute.value = 'I am the response!';
controller.element.setAttributeNode(attribute);
spyOn(controller, 'fireResponse');
let event = {target: controller.element};
controller.onButtonClick(event);
expect(controller.fireResponse).toHaveBeenCalledWith('I am the response!');
});
});
describe('onDialogMouseDown()', () => {
it(`should set controller's lastEvent property`, () => {
controller.element = document.createElement('div');
let event = {target: controller.element};
controller.onDialogMouseDown(event);
expect(controller.lastEvent).toEqual(event);
});
});
describe('onBackgroundMouseDown()', () => {
it(`shouldn't call hide() function as event equals lastEvent`, () => {
controller.element = document.createElement('div');
let event = {target: controller.element};
controller.lastEvent = event;
spyOn(controller, 'hide');
controller.onBackgroundMouseDown(event);
expect(controller.hide).not.toHaveBeenCalledWith();
});
it(`should call hide() function as event doesn't equal lastEvent`, () => {
controller.element = document.createElement('div');
let event = {target: controller.element};
controller.lastEvent = event;
controller.lastEvent = 'the singularity event!';
spyOn(controller, 'hide');
controller.onBackgroundMouseDown(event);
expect(controller.hide).toHaveBeenCalledWith();
});
});
describe('onKeypress()', () => {
it(`should call hide() if the key pressed equal the code 27`, () => {
controller.element = document.createElement('div');
let event = {target: controller.element};
event.keyCode = 27;
spyOn(controller, 'hide');
controller.onKeypress(event);
expect(controller.hide).toHaveBeenCalledWith();
});
it(`should't call hide() as the key pressed equal the code 999`, () => {
controller.element = document.createElement('div');
let event = {target: controller.element};
event.keyCode = 999;
spyOn(controller, 'hide');
controller.onKeypress(event);
expect(controller.hide).not.toHaveBeenCalledWith();
expect(resposneRes).toEqual({response: 'answer'});
expect(responseRet).toEqual(false);
});
});
});

View File

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

View File

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

View File

@ -1,8 +1,33 @@
import ngModule from '../../module';
import './style.css';
class Icon {
constructor($attrs) {
this.$attrs = $attrs;
this._icon = null;
}
set icon(value) {
this._icon = value;
this.drawIcon();
}
get icon() {
return this._icon;
}
drawIcon() {
if (this.icon.startsWith('icon-')) {
this.iconClass = this.icon;
this.iconContent = '';
} else {
this.iconClass = 'material-icons';
this.iconContent = this.icon;
}
}
}
Icon.$inject = ['$attrs'];
ngModule.component('vnIcon', {
template: '<i class="material-icons">{{::$ctrl.icon}}</i>',
template: '<i class="{{::$ctrl.iconClass}}">{{::$ctrl.iconContent}}</i>',
controller: Icon,
bindings: {
icon: '@'
}

View File

@ -1,8 +1,8 @@
vn-icon {
display: inline;
display: inline-block;
font-size: 18pt;
}
vn-icon > i {
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 class="mdl-snackbar__text"></div>
<button class="mdl-snackbar__action" type="button"></button>
<div ng-click="$ctrl.onSnackbarClick($event)">
<button ng-click="$ctrl.onButtonClick()"></button>
<div class="text"></div>
</div>

View File

@ -1,12 +1,19 @@
import ngModule from '../../module';
import Component from '../../lib/component';
import './style.scss';
/**
* A simple component to show non-obstructive notifications to the user.
*/
export default class Controller {
constructor($element) {
export default class Controller extends Component {
constructor($element, $translate) {
super($element);
this.$translate = $translate;
this.shown = false;
this.snackbar = $element[0].firstChild;
componentHandler.upgradeElement(this.snackbar);
this.$snackbar = angular.element(this.snackbar);
this.button = $element[0].querySelector('button');
this.textNode = this.snackbar.querySelector('.text');
}
/**
* Shows a notification.
@ -14,10 +21,76 @@ export default class Controller {
* @param {Object} data The message data
*/
show(data) {
this.snackbar.MaterialSnackbar.showSnackbar(data);
this.clearTimeouts();
this.shown = true;
this.textNode.textContent = data.message;
this.actionHandler = data.actionHandler;
this.button.textContent =
data.actionText || this.$translate.instant('Hide');
this.documentClickHandler = e => this.onDocumentClick(e);
document.addEventListener('click', this.documentClickHandler);
this.timeoutId = setTimeout(() => this.hide(),
data.timeout || 6000);
this.transitionTimeout =
setTimeout(() => this.$snackbar.addClass('shown'), 30);
}
/**
* Shows an error.
*
* @param {Object} data The message data
*/
showError(data) {
this.$snackbar.addClass('error');
this.show(data);
}
/**
* Hides the snackbar.
*/
hide() {
if (!this.shown) return;
clearTimeout(this.timeoutId);
document.removeEventListener('click', this.documentClickHandler);
this.shown = false;
this.hideTimeout = setTimeout(() => this.onTransitionEnd(), 250);
this.transitionTimeout =
setTimeout(() => this.$snackbar.removeClass('shown'), 30);
}
onTransitionEnd() {
this.$snackbar.removeClass('error');
this.textNode.textContent = '';
this.button.textContent = '';
this.actionHandler = null;
}
onDocumentClick(event) {
if (event === this.event) return;
this.hide();
}
onSnackbarClick(event) {
this.event = event;
}
onButtonClick() {
if (this.actionHandler)
this.actionHandler();
else
this.hide();
}
clearTimeouts() {
clearTimeout(this.timeoutId);
clearTimeout(this.hideTimeout);
clearTimeout(this.transitionTimeout);
this.timeoutId = null;
this.hideTimeout = null;
this.transitionTimeout = null;
}
$onDestroy() {
this.clearTimeouts();
}
}
Controller.$inject = ['$element'];
Controller.$inject = ['$element', '$translate'];
ngModule.component('vnSnackbar', {
template: require('./snackbar.html'),

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;
background: white;
opacity: 1;
z-index: 9999;
z-index: 1;
color: #aaa;
}
.mdl-textfield {
width: 100%;
}
.mdl-textfield__error {
visibility: visible;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
width: 100%;
}
.mdl-textfield.invalid {
.mdl-textfield__input {
border-color: #d50000;
box-shadow: none;
}
.mdl-textfield__label::after {
background-color: #d50000;
}
}
.mdl-textfield--floating-label.invalid .mdl-textfield__label {
color: #d50000;
font-size: 12px;
top: 4px;
}
.material-icons {
font-size: 18px;
float: right;

View File

@ -34,11 +34,12 @@ function tooltip($document, $compile, $interpolate, $sce, $templateCache, $http,
return {
restrict: 'A',
priority: -1,
link: function(scope, element, attrs) {
var tipHtml = '<div class="mdl-shadow--2dp" ng-class="tipClass"><div class="tooltip-text" translate>{{text}}</div><div ng-if="isHtmlContent" ng-bind-html="htmlContent"></div><div class="tooltip-arrow"></div></div>';
var tip;
var tipClassName = 'tooltip';
var tipActiveClassName = 'tooltip-show';
link: function($scope, element, attrs) {
let tipHtml = '<div class="mdl-shadow--2dp" ng-class="tipClass"><div class="tooltip-text" translate>{{::text}}</div><div ng-if="isHtmlContent" ng-bind-html="htmlContent"></div><div class="tooltip-arrow"></div></div>';
let tip;
let tipClassName = 'tooltip';
let tipActiveClassName = 'tooltip-show';
let scope = $scope.$new();
scope.tipClass = [tipClassName];
scope.text = attrs.vnTooltip || '';
@ -116,6 +117,7 @@ function tooltip($document, $compile, $interpolate, $sce, $templateCache, $http,
element.on('$destroy', function() {
tip.remove();
scope.$destroy();
});
}
}

View File

@ -101,10 +101,21 @@ export default class Watcher extends Component {
(resolve, reject) => this.noChanges(reject)
);
}
let changedData = (this.$attrs.save && this.$attrs.save.toLowerCase() === 'post')
let isPost = (this.$attrs.save && this.$attrs.save.toLowerCase() === 'post');
let changedData = isPost
? this.copyInNewObject(this.data)
: getModifiedData(this.data, this.orgData);
if (this.requiredField && !changedData[this.requiredField]) {
let required = this.data[this.requiredField] || this.orgData[this.requiredField];
if (required === undefined) {
return new Promise(
(resolve, reject) => this.invalidForm(reject)
);
}
changedData[this.requiredField] = required;
}
if (this.save && this.save.accept) {
this.save.model = changedData; // this.copyInNewObject(changedData);
return new Promise((resolve, reject) => {
@ -213,6 +224,7 @@ ngModule.component('vnWatcher', {
bindings: {
url: '@?',
idField: '@?',
requiredField: '@?',
data: '<',
form: '<',
save: '<',

View File

@ -1,9 +1,7 @@
import './styles/mdl-override.css';
import './styles/mdi-override.css';
import './styles/zoom-image.css';
import './styles';
export * from './module';
export * from './directives/index';
export * from './filters/index';
export * from './lib/index';
export * from './components/index';
export * from './directives';
export * from './filters';
export * from './lib';
export * from './components';

View File

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

View File

@ -24,7 +24,7 @@ describe('Directive dialog', () => {
$componentController = _$componentController_;
_$httpBackend_.when('GET', /\/locale\/\w+\/[a-z]{2}\.json/).respond({});
$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', () => {

View File

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

View File

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

View File

@ -1,4 +1,3 @@
import ngModule from '../module';
import isEqual from './equals';
export default function getModifiedData(object, objectOld) {
@ -19,5 +18,5 @@ export default function getModifiedData(object, objectOld) {
}
}
return newObject;
return Object.keys(newObject).length ? newObject : undefined;
}

View File

@ -4,4 +4,7 @@ Close: Close
Clear: Clear
Save: Save
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
Search: Buscar
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

@ -0,0 +1,30 @@
@font-face {
font-family: 'fontello';
src: url('./fontello.woff2') format('woff2');
font-weight: normal;
font-style: normal;
}
[class^="icon-"]:before, [class*=" icon-"]:before {
font-family: "fontello";
font-style: normal;
font-weight: 400;
speak: none;
display: inline-block;
text-decoration: inherit;
text-align: center;
/* opacity: .8; */
/* For safety - reset parent styles, that can break glyph codes*/
font-variant: normal;
text-transform: none;
/* Font smoothing. That was taken from TWBS */
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}

View File

@ -0,0 +1,6 @@
.icon-tags:before { content: '\e800'; }
.icon-tree:before { content: '\e801'; }
.icon-clone2:before { content: '\e802'; }
.icon-preview:before { content: '\e803'; }
.icon-history:before { content: '\f1da'; }

Binary file not shown.

View File

@ -0,0 +1,5 @@
import './mdl-override.css';
import './mdi-override.css';
import './zoom-image.css';
import './fontello-head.css';
import './fontello-icons.css';

View File

@ -6,11 +6,6 @@ body {
line-height: initial;
font-size: 12pt;
}
.mdl-textfield {
width: 100%;
}
.mdl-button {
font-weight: bolder;
color: #ffa410;
@ -32,33 +27,3 @@ body {
background-color: #ff9400 !important;
}
.mdl-dialog__actions--full-width>*{
text-align: center;
}
.mdl-dialog{
width: 400px;
font-family: vn-font;
line-height: 60px;
text-align: center;
}
.mdl-textfield__error {
visibility: visible;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
width: 100%;
}
.mdl-textfield.invalid .mdl-textfield__input {
border-color: #d50000;
box-shadow: none;
}
.mdl-textfield.invalid .mdl-textfield__label::after {
background-color: #d50000;
}
.mdl-textfield--floating-label.invalid .mdl-textfield__label {
color: #d50000;
font-size: 12px;
top: 4px;
}

View File

@ -11,7 +11,7 @@ div#zoomImage, div#zoomImage .zoomImage-background {
}
div#zoomImage .zoomImage-background{
background-color: rgba(0, 0, 0, 0.7);
background-color: rgba(1, 1, 1, 0.6);
cursor: zoom-out;
background-repeat: no-repeat;
background-position: center center;

View File

@ -13,8 +13,7 @@
{
"url": "/list",
"state": "item.index",
"component": "vn-item-list",
"acl": ["developer"]
"component": "vn-item-list"
},
{
"url": "/create",
@ -37,7 +36,8 @@
"menu": {
"description": "Basic data",
"icon": "folder"
}
},
"acl": ["buyer"]
},
{
"url" : "/tags",
@ -49,7 +49,8 @@
"menu": {
"description": "Tags",
"icon": "folder"
}
},
"acl": ["buyer"]
},
{
"url" : "/history",
@ -73,7 +74,8 @@
"menu": {
"description": "Niche",
"icon": "folder"
}
},
"acl": ["buyer","replenisher"]
},
{
"url" : "/botanical",
@ -85,7 +87,8 @@
"menu": {
"description": "Botanical",
"icon": "folder"
}
},
"acl": ["buyer"]
},{
"url" : "/barcode",
"state": "item.card.itemBarcode",
@ -96,6 +99,14 @@
"menu": {
"description": "Barcode",
"icon": "folder"
},
"acl": ["buyer","replenisher"]
},{
"url" : "/summary",
"state": "item.card.summary",
"component": "vn-item-summary",
"params": {
"item": "$ctrl.item"
}
}
]

View File

@ -3,7 +3,6 @@
<vn-vertical pad-large>
<vn-one margin-medium-top>
<vn-title>Item Barcodes</vn-title>
<mg-ajax path="/item/api/ItemBarcodes" options="mgIndex as barcodes"></mg-ajax>
<vn-horizontal ng-repeat="barcode in $ctrl.barcodes track by $index">
<vn-textfield vn-three label="code" model="barcode.code" vn-acl="buyer, replenisher"></vn-textfield>
<vn-one pad-medium-top>

View File

@ -1,5 +1,43 @@
<vn-card>
<vn-vertical pad-large>
<vn-title>Botanical</vn-title>
</vn-vertical>
</vn-card>
<mg-ajax
path="/item/api/ItemBotanicals"
options="vnPatch">
</mg-ajax>
<vn-watcher
vn-id="watcher"
data="$ctrl.botanical"
id-field="itemFk"
required-field="itemFk"
form="form"
save="patch">
</vn-watcher>
<form name="form" ng-submit="watcher.submit()" ng-cloak>
<vn-card>
<vn-vertical pad-large>
<vn-title>Botanical</vn-title>
<vn-horizontal>
<vn-textfield vn-one label="Botanical" model="$ctrl.botanical.botanical"></vn-textfield>
</vn-horizontal>
<vn-horizontal>
<vn-autocomplete vn-one
initial-data="$ctrl.botanical.genus"
field="$ctrl.botanical.genusFk"
url="/item/api/genera"
show-field="latin_genus_name"
value-field="genus_id"
label="Genus">
</vn-autocomplete>
<vn-autocomplete vn-one
initial-data="$ctrl.botanical.specie"
field="$ctrl.botanical.specieFk"
url="/item/api/species"
show-field="latin_species_name"
value-field="specie_id"
label="Species">
</vn-autocomplete>
</vn-horizontal>
</vn-vertical>
</vn-card>
<vn-button-bar>
<vn-submit label="Save"></vn-submit>
</vn-button-bar>
</form>

View File

@ -1,5 +1,36 @@
import ngModule from '../module';
class ItemBotanical {
constructor($http, $state) {
this.$http = $http;
this.$state = $state;
}
_getBotanical() {
let filter = {
where: {itemFk: this.$state.params.id},
include: [{relation: 'genus'}, {relation: 'specie'}]
};
this.$http.get(`/item/api/ItemBotanicals?filter=${JSON.stringify(filter)}`)
.then(res => {
if (res.data.length) {
this.botanical = res.data[0];
} else {
this.botanical = {
itemFk: this.$state.params.id,
botanical: null,
genusFk: null,
specieFk: null
};
}
});
}
$onInit() {
this._getBotanical();
}
}
ItemBotanical.$inject = ['$http', '$state'];
ngModule.component('vnItemBotanical', {
template: require('./item-botanical.html')
template: require('./item-botanical.html'),
controller: ItemBotanical
});

View File

@ -0,0 +1,34 @@
import './item-botanical.js';
describe('ItemBotanical', () => {
describe('Component vnItemBotanical', () => {
let $componentController;
let $httpBackend;
let $state;
let controller;
beforeEach(() => {
angular.mock.module('item');
});
beforeEach(angular.mock.inject((_$componentController_, _$state_, _$httpBackend_) => {
$componentController = _$componentController_;
$httpBackend = _$httpBackend_;
$state = {
params: {
id: 123
}
};
controller = $componentController('vnItemBotanical', {$state: $state});
}));
describe('_getBotanical()', () => {
it('should request to patch the propagation of botanical status', () => {
$httpBackend.whenGET('/item/api/ItemBotanicals?filter={"where":{"itemFk":123},"include":[{"relation":"genus"},{"relation":"specie"}]}').respond({data: 'item'});
$httpBackend.expectGET('/item/api/ItemBotanicals?filter={"where":{"itemFk":123},"include":[{"relation":"genus"},{"relation":"specie"}]}');
controller.$onInit();
$httpBackend.flush();
});
});
});
});

View File

@ -1,10 +1,12 @@
import ngModule from '../module';
class ItemCard {
constructor($http, $state) {
constructor($http, $state, $timeout) {
this.$http = $http;
this.$state = $state;
this.item = {};
this.$timeout = $timeout;
this.item = null;
}
$onInit() {
@ -19,14 +21,19 @@ class ItemCard {
{relation: "itemTag", scope: {order: "priority ASC", include: {relation: "tag"}}}
]
};
this.$http.get(`/item/api/Items/${this.$state.params.id}?filter=${JSON.stringify(filter)}`).then(
res => {
this.item = res.data;
}
this.$http.get(`/item/api/Items/${this.$state.params.id}?filter=${JSON.stringify(filter)}`)
.then(
res => {
if (res.data && res.data.id) {
this.$timeout(() => {
this.item = res.data;
});
}
}
);
}
}
ItemCard.$inject = ['$http', '$state'];
ItemCard.$inject = ['$http', '$state', '$timeout'];
ngModule.component('vnItemCard', {
template: require('./item-card.html'),

View File

@ -14,19 +14,20 @@ describe('Item', () => {
beforeEach(angular.mock.inject((_$componentController_, _$state_, _$httpBackend_) => {
$componentController = _$componentController_;
$httpBackend = _$httpBackend_;
$state = _$state_;
$state = {
params: {
id: 123
}
};
controller = $componentController('vnItemCard', {$state: $state});
}));
describe('$onInit()', () => {
it('should request to patch the propagation of tax status', () => {
controller.client = {id: 123, isEqualizated: false};
$httpBackend.whenGET('/item/api/Items/undefined?filter={"include":[{"relation":"itemType"},{"relation":"origin"},{"relation":"ink"},{"relation":"producer"},{"relation":"intrastat"},{"relation":"expence"},{"relation":"itemTag","scope":{"order":"priority ASC","include":{"relation":"tag"}}}]}').respond({data: 'item'});
$httpBackend.expectGET('/item/api/Items/undefined?filter={"include":[{"relation":"itemType"},{"relation":"origin"},{"relation":"ink"},{"relation":"producer"},{"relation":"intrastat"},{"relation":"expence"},{"relation":"itemTag","scope":{"order":"priority ASC","include":{"relation":"tag"}}}]}');
$httpBackend.whenGET('/item/api/Items/123?filter={"include":[{"relation":"itemType"},{"relation":"origin"},{"relation":"ink"},{"relation":"producer"},{"relation":"intrastat"},{"relation":"expence"},{"relation":"itemTag","scope":{"order":"priority ASC","include":{"relation":"tag"}}}]}').respond({data: 'item'});
$httpBackend.expectGET('/item/api/Items/123?filter={"include":[{"relation":"itemType"},{"relation":"origin"},{"relation":"ink"},{"relation":"producer"},{"relation":"intrastat"},{"relation":"expence"},{"relation":"itemTag","scope":{"order":"priority ASC","include":{"relation":"tag"}}}]}');
controller.$onInit();
$httpBackend.flush();
expect(controller.item).toEqual({data: 'item'});
});
});
});

View File

@ -1,9 +1,7 @@
<mg-ajax
path="/item/api/Items/{{patch.params.id}}"
options="vnPatch"
override="{filter: {include: [{relation: 'itemType'}, {relation: 'origin'}, {relation: 'ink'}, {relation: 'producer'}, {relation: 'expence'}]}}"
>
override="{filter: {include: [{relation: 'itemType'}, {relation: 'origin'}, {relation: 'ink'}, {relation: 'producer'}, {relation: 'expence'}]}}">
</mg-ajax>
<vn-watcher
vn-id="watcher"
@ -23,8 +21,7 @@
show-field="name"
value-field="id"
field="$ctrl.item.typeFk"
initial-data="$ctrl.item.itemType"
>
initial-data="$ctrl.item.itemType">
</vn-autocomplete>
</vn-horizontal>
<vn-horizontal>
@ -36,14 +33,11 @@
field="$ctrl.item.intrastatFk"
order="description ASC"
filter-search="{where: {description: {regexp: 'search'}} }"
initial-data="$ctrl.item.intrastat"
>
initial-data="$ctrl.item.intrastat">
<tpl-item>{{$parent.$parent.item.description}}</tpl-item>
</vn-autocomplete>
<vn-textfield vn-one label="Relevancy" field="$ctrl.item.relevancy" type="number"></vn-textfield>
</vn-horizontal>
<vn-horizontal>
<vn-autocomplete vn-one
url="/item/api/Origins"
@ -51,14 +45,14 @@
show-field="name"
value-field="id"
field="$ctrl.item.originFk"
initial-data="$ctrl.item.origin"
></vn-autocomplete>
initial-data="$ctrl.item.origin">
</vn-autocomplete>
<vn-autocomplete vn-one
url="/item/api/Expences"
label="Expence"
field="$ctrl.item.expenceFk"
initial-data="$ctrl.item.expence"
></vn-autocomplete>
initial-data="$ctrl.item.expence">
</vn-autocomplete>
</vn-horizontal>
</vn-vertical>
</vn-card>
@ -66,4 +60,3 @@
<vn-submit label="Save"></vn-submit>
</vn-button-bar>
</form>

View File

@ -1,8 +1,23 @@
import ngModule from '../module';
class ItemData {
constructor($scope, $timeout) {
this.$scope = $scope;
this.$timeout = $timeout;
}
$onChanges(data) {
this.$timeout(() => {
this.$scope.watcher.data = data.item.currentValue;
});
}
}
ItemData.$inject = ['$scope', '$timeout'];
ngModule.component('vnItemData', {
template: require('./item-data.html'),
bindings: {
item: '<'
}
},
controller: ItemData
});

View File

@ -12,4 +12,5 @@ import './history/item-history';
import './niche/item-niche';
import './botanical/item-botanical';
import './barcode/item-barcode';
import './summary/item-summary';

View File

@ -1,14 +1,23 @@
<vn-horizontal pad-medium border-solid-bottom>
<vn-auto margin-medium-right>
<img ng-src="http://verdnatura.es/vn-image-data/catalog/200x200/{{$ctrl.item.image}}" on-error-src/>
<vn-auto margin-medium-right >
<img ng-src="http://verdnatura.es/vn-image-data/catalog/200x200/{{$ctrl.item.image}}"
zoom-image="http://verdnatura.es/vn-image-data/catalog/900x900/{{::$ctrl.item.image}}" on-error-src/>
</vn-auto>
<vn-one>
<div><span translate>Id</span>: <b>{{$ctrl.item.id}}</b></div>
<div><span translate>Name</span>: <b>{{$ctrl.item.name}}</b></div>
<div><span translate>Description</span>: <b>{{$ctrl.item.description}}</b></div>
<div><span translate>Size</span>: <b>{{$ctrl.item.size}}</b></div>
<div><span translate>Type</span>: <b>{{$ctrl.item.itemType.name}}</b></div>
<vn-one ui-sref="item.card.summary({ id: {{$ctrl.item.id}} })">
<div><span translate>Id</span>: <b>{{::$ctrl.item.id}}</b></div>
<div><span translate>Name</span>: <b>{{::$ctrl.item.name}}</b></div>
<div><span translate>Description</span>: <b>{{::$ctrl.item.description}}</b></div>
<div><span translate>Size</span>: <b>{{::$ctrl.item.size}}</b></div>
<div><span translate>Type</span>: <b>{{::$ctrl.item.itemType.name}}</b></div>
</vn-one>
<vn-horizontal vn-auto pad-large-top>
<vn-one>
<vn-icon ng-click="$ctrl.clone()" vn-tooltip="Clone" pad-medium-top margin-medium-right margin-small-top icon="icon-clone2"></vn-icon>
</vn-one>
<vn-one>
<vn-icon ng-click="$ctrl.preview()" vn-tooltip="Preview" pad-medium-top margin-small-top icon="icon-preview"></vn-icon>
</vn-one>
</vn-horizontal>
</vn-horizontal>

View File

@ -1,8 +1,27 @@
import ngModule from '../module';
class ItemProduct {
constructor($http) {
this.$http = $http;
}
clone() {
this.ItemList.cloneItem(this.item);
}
preview() {
this.ItemList.showItemPreview(this.item);
}
}
ItemProduct.$inject = ['$http', '$scope', 'vnPopover'];
ngModule.component('vnItemProduct', {
template: require('./item-product.html'),
bindings: {
item: '<'
},
controller: ItemProduct,
require: {
ItemList: '^vnItemList'
}
});

View File

@ -13,13 +13,30 @@
</vn-horizontal>
</vn-card>
<vn-card margin-medium-top>
<a class="item-product-link" ng-repeat="item in index.model.instances" ui-sref="item.card.data({ id: {{item.id}} })" >
<vn-item-product title="View item" item="item"></vn-item-product>
</a>
<vn-auto class="item-product-link" ng-repeat="item in index.model.instances">
<vn-item-product item="item"></vn-item-product>
</vn-auto>
</vn-card>
<vn-paging index="index" total="index.model.count"></vn-paging>
</div>
<a ui-sref="item.create" fixed-bottom-right>
<vn-float-button icon="add"></vn-float-button>
</a>
<vn-dialog vn-id="preview" class="dialog-item-summary">
<tpl-body style="width:auto; background-color: transparent">
<vn-item-summary item="$ctrl.itemSelected"></vn-item-summary>
</tpl-body>
</vn-dialog>
<vn-dialog
vn-id="clone"
on-response="$ctrl.onCloneAccept(response)">
<tpl-body>
<p translate>Do you want to clone this item?</p>
</tpl-body>
<tpl-buttons>
<button response="CANCEL" translate>Cancel</button>
<button response="ACCEPT" translate>Yes, clone</button>
</tpl-buttons>
</vn-dialog>
</div>

View File

@ -1,15 +1,38 @@
import ngModule from '../module';
import './item-product';
import './style.css';
import './style.scss';
class ItemList {
constructor() {
constructor($http, $state, $scope) {
this.$http = $http;
this.$state = $state;
this.$scope = $scope;
this.model = {};
this.itemSelected = null;
}
search(index) {
index.accept();
}
cloneItem(item) {
this.itemSelected = item;
this.$scope.clone.show();
}
onCloneAccept(response) {
if (response == 'ACCEPT' && this.itemSelected) {
this.$http.post(`/item/api/Items/${this.itemSelected.id}/clone`).then(res => {
if (res && res.data && res.data.id) {
this.$state.go('item.card.tags', {id: res.data.id});
}
});
}
this.itemSelected = null;
}
showItemPreview(item) {
this.itemSelected = item;
this.$scope.preview.show();
}
}
ItemList.$inject = ['$http', '$state', '$scope'];
ngModule.component('vnItemList', {
template: require('./list.html'),

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 21.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 30 24" style="enable-background:new 0 0 30 24;" xml:space="preserve" width="24px" heigth="24px">
<g>
<path d="M27,0H3C1.4,0,0,1.3,0,3v18c0,1.7,1.4,3,3,3h24c1.6,0,3-1.3,3-3V3C30,1.3,28.6,0,27,0z M27.9,19.8c0,1.4-1.2,2.6-2.6,2.6
H4.6c-1.4,0-2.6-1.2-2.6-2.6V4.2c0-1.4,1.2-2.6,2.6-2.6h20.7c1.4,0,2.6,1.2,2.6,2.6V19.8z"/>
<path d="M24.6,2.9H5.4c-1,0-1.9,0.8-1.9,1.9v14.4c0,1,0.8,1.9,1.9,1.9h19.1c1,0,1.9-0.8,1.9-1.9V4.8C26.4,3.8,25.6,2.9,24.6,2.9z"
/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 750 B

View File

@ -1,20 +0,0 @@
vn-item-product {
display: block;
}
a.item-product-link {
display: block;
text-decoration: none;
color: inherit;
}
a.item-product-link:hover {
color: white;
background-color: #424242;
}
vn-item-product img {
max-width: 150px;
}
.vn-item-product-name {
font-family: vn-font-bold;
}

View File

@ -0,0 +1,43 @@
@import "../../../salix/src/styles/colors";
vn-item-product {
display: block;
}
vn-auto.item-product-link {
display: block;
text-decoration: none;
color: inherit;
}
vn-auto.item-product-link:hover {
color: $color-white;
background-color: $color-dark;
}
vn-auto.item-product-link i{
opacity: .3;
}
vn-auto.item-product-link:hover i{
color: $color-orange;
opacity: 1;
cursor: pointer;
}
vn-item-product img {
max-width: 150px;
}
.vn-item-product-name {
font-family: vn-font-bold;
}
.vn-dialog.dialog-item-summary > div {
border: none;
background: transparent;
box-shadow: none;
}
.vn-dialog.dialog-item-summary > div > button.close > vn-icon {
color: $color-orange;
}
.vn-dialog.dialog-item-summary vn-item-summary > vn-card {
min-width: 680px;
margin-left: -20px;
}

View File

@ -17,4 +17,8 @@ Barcode: Código barras
Item barcode: Código de barras del artículo
Changed by: Cambiado por
Action: Acción
Date: Fecha
Date: Fecha
Preview: Vista previa
Clone: Clonar
Do you want to clone this item?: ¿Desea clonar este artículo?
Yes, clone: Si, clonar

View File

@ -1,5 +1,48 @@
<vn-card>
<vn-vertical pad-large>
<vn-title>Niche</vn-title>
</vn-vertical>
</vn-card>
<form name="form" ng-submit="$ctrl.submit()">
<vn-card>
<vn-vertical pad-large>
<vn-one margin-medium-top>
<vn-title>Item Niches</vn-title>
<vn-horizontal ng-repeat="niche in $ctrl.niches track by $index">
<vn-autocomplete
vn-three
initial-data = "niche.warehouse"
field = "niche.warehouseFk"
data = "$ctrl.warehouses"
show-field = "name"
value-field = "id"
label = "Warehouse"
order = "name ASC"
vn-acl="buyer,replenisher">
</vn-autocomplete>
<vn-textfield
vn-three label="code"
model="niche.code"
vn-acl="buyer,replenisher">
</vn-textfield>
<vn-one pad-medium-top>
<vn-icon
vn-acl="buyer,replenisher"
pointer
medium-grey
icon="remove_circle_outline"
ng-click="$ctrl.removeNiche($index)">
</vn-icon>
<vn-icon
vn-acl="buyer, replenisher"
pointer
margin-medium-left
orange
icon="add_circle"
ng-if = "niche.showAddIcon"
ng-click="$ctrl.addNiche()">
</vn-icon>
</vn-one>
</vn-horizontal>
</vn-one>
</vn-vertical>
</vn-card>
<vn-button-bar>
<vn-submit label="Save"></vn-submit>
</vn-button-bar>
</form>

View File

@ -1,5 +1,142 @@
import ngModule from '../module';
export default class Controller {
constructor($state, $scope, $http, $q, $translate, vnApp) {
this.$state = $state;
this.$scope = $scope;
this.$http = $http;
this.$q = $q;
this.$translate = $translate;
this.vnApp = vnApp;
this.warehouses = [];
this.niches = [];
this.removedNiches = [];
this.oldNiches = {};
}
_setIconAdd() {
if (this.niches.length) {
this.niches.map(element => {
element.showAddIcon = false;
return true;
});
this.niches[this.niches.length - 1].showAddIcon = true;
} else {
this.addNiche();
}
}
_setDirtyForm() {
if (this.$scope.form) {
this.$scope.form.$setDirty();
}
}
_unsetDirtyForm() {
if (this.$scope.form) {
this.$scope.form.$setPristine();
}
}
addNiche() {
this.niches.push({code: null, itemFk: this.$state.params.id, showAddIcon: true});
this._setIconAdd();
}
removeNiche(index) {
let item = this.niches[index];
if (item) {
this.niches.splice(index, 1);
this._setIconAdd();
if (item.id) {
this.removedNiches.push(item.id);
this._setDirtyForm();
}
}
}
_equalNiches(oldNiche, newNiche) {
return oldNiche.id === newNiche.id && oldNiche.code === newNiche.code && oldNiche.warehouseFk === newNiche.warehouseFk;
}
submit() {
let warehousesDefined = [];
let repeatedWarehouse = false;
let canSubmit;
let nichesObj = {
delete: this.removedNiches,
create: [],
update: []
};
this.niches.forEach(niche => {
let isNewNiche = !niche.id;
if (warehousesDefined.indexOf(niche.warehouseFk) !== -1) {
repeatedWarehouse = true;
return;
}
warehousesDefined.push(niche.warehouseFk);
if (isNewNiche) {
nichesObj.create.push(niche);
}
if (!isNewNiche && !this._equalNiches(this.oldNiches[niche.id], niche)) {
nichesObj.update.push(niche);
}
});
if (repeatedWarehouse) {
return this.vnApp.showMessage(this.$translate.instant('The niche must be unique'));
}
canSubmit = nichesObj.update.length > 0 || nichesObj.create.length > 0 || nichesObj.delete.length > 0;
if (canSubmit) {
return this.$http.post(`/item/api/ItemNiches/crudItemNiches`, nichesObj).then(() => {
this.getNiches();
this._unsetDirtyForm();
});
}
this.vnApp.showMessage(this.$translate.instant('No changes to save'));
}
setOldNiches(response) {
this._setIconAdd();
response.data.forEach(niche => {
this.oldNiches[niche.id] = Object.assign({}, niche);
});
}
getWarehouse(id, warehouses) {
return warehouses.find(warehouse => warehouse.id === id);
}
getNiches() {
let filter = {
where: {itemFk: this.$state.params.id},
include: {relation: 'warehouse'}
};
this.$http.get(`/item/api/ItemNiches?filter=${JSON.stringify(filter)}`).then(response => {
this.niches = response.data;
this.setOldNiches(response);
});
}
getWarehouses() {
this.$http.get(`/item/api/Warehouses`).then(response => {
this.warehouses = response.data;
});
}
$onInit() {
this.getNiches();
this.getWarehouses();
}
}
Controller.$inject = ['$state', '$scope', '$http', '$q', '$translate', 'vnApp'];
ngModule.component('vnItemNiche', {
template: require('./item-niche.html')
template: require('./item-niche.html'),
controller: Controller
});

View File

@ -0,0 +1,150 @@
import './item-niche.js';
describe('Item', () => {
describe('Component vnItemNiche', () => {
let $componentController;
let $state;
let controller;
let $httpBackend;
beforeEach(() => {
angular.mock.module('item');
});
beforeEach(angular.mock.inject((_$componentController_, _$state_, _$httpBackend_) => {
$componentController = _$componentController_;
$state = _$state_;
$httpBackend = _$httpBackend_;
controller = $componentController('vnItemNiche', {$state: $state});
}));
describe('add / remove niche()', () => {
it('should add one empty niche into controller niches collection and call _setIconAdd()', () => {
controller.niches = [];
spyOn(controller, '_setIconAdd').and.callThrough();
controller.addNiche();
expect(controller._setIconAdd).toHaveBeenCalledWith();
expect(controller.niches.length).toEqual(1);
expect(controller.niches[0].id).toBe(undefined);
expect(controller.niches[0].showAddIcon).toBeTruthy();
});
it('should remove a niche that occupies the position in the index given and call _setIconAdd()', () => {
let index = 2;
controller.niches = [
{id: 1, warehouseFk: 1, code: '1111', showAddIcon: false},
{id: 2, warehouseFk: 2, code: '2222', showAddIcon: false},
{id: 3, warehouseFk: 3, code: '3333', showAddIcon: true}
];
spyOn(controller, '_setIconAdd').and.callThrough();
controller.removeNiche(index);
expect(controller._setIconAdd).toHaveBeenCalledWith();
expect(controller.niches.length).toEqual(2);
expect(controller.niches[0].showAddIcon).toBeFalsy();
expect(controller.niches[1].showAddIcon).toBeTruthy();
expect(controller.niches[index]).toBe(undefined);
});
});
describe('_equalNiches()', () => {
it('should return true if two niches are equals independent of control attributes', () => {
let niche1 = {id: 1, warehouseFk: 1, code: '1111', showAddIcon: true};
let niche2 = {id: 1, warehouseFk: 1, code: '1111', showAddIcon: false};
let equals = controller._equalNiches(niche2, niche1);
expect(equals).toBeTruthy();
});
it('should return false if two niches aint equals independent of control attributes', () => {
let niche1 = {id: 1, warehouseFk: 1, code: '1111', showAddIcon: true};
let niche2 = {id: 1, warehouseFk: 1, code: '2222', showAddIcon: true};
let equals = controller._equalNiches(niche2, niche1);
expect(equals).toBeFalsy();
});
});
describe('get Niches / Warehouses', () => {
it('should perform a GET query to receive the item niches', () => {
let res = [{id: 1, warehouseFk: 1, code: '1111'}];
$httpBackend.when('GET', `/item/api/ItemNiches?filter={"where":{},"include":{"relation":"warehouse"}}`).respond(res);
$httpBackend.expectGET(`/item/api/ItemNiches?filter={"where":{},"include":{"relation":"warehouse"}}`);
controller.getNiches();
$httpBackend.flush();
});
it('should perform a GET query to receive the all warehouses', () => {
let res = [
{id: 1, warehouseFk: 1, name: 'warehouse one'},
{id: 2, warehouseFk: 2, name: 'warehouse two'}
];
$httpBackend.when('GET', `/item/api/Warehouses`).respond(res);
$httpBackend.expectGET(`/item/api/Warehouses`);
controller.getWarehouses();
$httpBackend.flush();
});
});
describe('submit()', () => {
it("should return an error message 'The niche must be unique' when the niche code isnt unique", () => {
spyOn(controller.vnApp, 'showMessage').and.callThrough();
controller.niches = [
{warehouseFk: 1, code: 123454, itemFk: 1, id: 1},
{warehouseFk: 1, code: 123454, itemFk: 1}
];
controller.oldNiches = {1: {warehouseFk: 1, id: 1, code: 123454, itemFk: 1}};
controller.submit();
expect(controller.vnApp.showMessage).toHaveBeenCalledWith('The niche must be unique');
});
it("should perfom a query to delete niches", () => {
controller.oldNiches = {1: {id: 1, warehouseFk: 1, code: '1111'}};
controller.niches = [];
controller.removedNiches = [1];
$httpBackend.when('GET', `/item/api/ItemNiches?filter={"where":{},"include":{"relation":"warehouse"}}`).respond([]);
$httpBackend.expectPOST(`/item/api/ItemNiches/crudItemNiches`).respond('ok!');
controller.submit();
$httpBackend.flush();
});
it("should perfom a query to update niches", () => {
controller.niches = [{id: 1, warehouseFk: 1, code: '2222'}];
controller.oldNiches = {1: {id: 1, warehouseFk: 1, code: '1111'}};
$httpBackend.whenGET(`/item/api/ItemNiches?filter={"where":{},"include":{"relation":"warehouse"}}`).respond([]);
$httpBackend.expectPOST(`/item/api/ItemNiches/crudItemNiches`).respond('ok!');
controller.submit();
$httpBackend.flush();
});
it("should perfom a query to create new niche", () => {
controller.niches = [{warehouseFk: 1, code: 1111, itemFk: 1}];
$httpBackend.whenGET(`/item/api/ItemNiches?filter={"where":{},"include":{"relation":"warehouse"}}`).respond([]);
$httpBackend.expectPOST(`/item/api/ItemNiches/crudItemNiches`).respond('ok!');
controller.submit();
$httpBackend.flush();
});
it("should return a message 'No changes to save' when there are no changes to apply", () => {
spyOn(controller.vnApp, 'showMessage').and.callThrough();
controller.oldNiches = [
{warehouseFk: 1, code: 1, itemFk: 1, id: 1},
{warehouseFk: 2, code: 2, itemFk: 1, id: 2}
];
controller.niches = [];
controller.submit();
expect(controller.vnApp.showMessage).toHaveBeenCalledWith('No changes to save');
});
});
});
});

View File

@ -0,0 +1,69 @@
<vn-card>
<vn-vertical pad-medium>
<vn-horizontal>
<vn-one margin-medium>
<vn-horizontal>
<vn-one></vn-one>
<vn-auto>
<vn-vertical>
<vn-one>
<img
ng-src="http://verdnatura.es/vn-image-data/catalog/200x200/{{$ctrl.item.image}}"
zoom-image="http://verdnatura.es/vn-image-data/catalog/900x900/{{$ctrl.item.image}}" on-error-src/>
</vn-one>
<vn-one>
<h5 text-center pad-small-v class="summaryId">{{$ctrl.item.id}}</h5>
</vn-one>
</vn-vertical>
</vn-auto>
<vn-one></vn-one>
</vn-horizontal>
</vn-one>
<vn-one margin-medium>
<vn-vertical>
<h5 translate>Basic data</h5>
<p><span translate>Name</span>: <b>{{$ctrl.item.name}}</b></p>
<p><span translate>Type</span>: <b>{{$ctrl.item.itemType.name}}</b></p>
<p><span translate>Intrastat</span>: <b>{{$ctrl.item.intrastat.description}}</b></p>
<p><span translate>Relevancy</span>: <b>{{$ctrl.item.relevancy}}</b></p>
<p><span translate>Origin</span>: <b>{{$ctrl.item.origin.name}}</b></p>
<p><span translate>Expence</span>: <b>{{$ctrl.item.expence.name}}</b></p>
</vn-vertical>
</vn-one>
<vn-one margin-medium>
<vn-vertical>
<h5 translate>Tags</h5>
<p ng-repeat="tag in $ctrl.tags track by tag.id">
<span translate>{{tag.tag.name}}</span>: <b>{{tag.value}}</b>
</p>
</vn-vertical>
</vn-one>
</vn-horizontal>
<vn-horizontal>
<vn-one margin-medium>
<vn-vertical>
<h5 translate>Nicho</h5>
<p ng-repeat="niche in $ctrl.niches track by $index">
<span>{{niche.warehouse.name}}</span>: <b>{{niche.code}}</b>
</p>
</vn-vertical>
</vn-one>
<vn-one margin-medium>
<vn-vertical>
<h5 translate>Botanical</h5>
<p><span translate>Botanical</span>: <b>{{$ctrl.item.botanical.botanical}}</b></p>
<p><span translate>Genus</span>: <b>{{$ctrl.item.botanical.genus.latin_genus_name}}</b></p>
<p><span translate>Specie</span>: <b>{{$ctrl.item.botanical.specie.latin_species_name}}</b></p>
</vn-vertical>
</vn-one>
<vn-one margin-medium>
<vn-vertical>
<h5 translate>Barcode</h5>
<p ng-repeat="barcode in $ctrl.barcodes track by $index">
<b>{{barcode.code}}</b>
</p>
</vn-vertical>
</vn-one>
</vn-horizontal>
</vn-vertical>
</vn-card>

View File

@ -0,0 +1,75 @@
import ngModule from '../module';
import './style.scss';
class ItemSummary {
constructor($http) {
this.$http = $http;
}
_getTags() {
let filter = {
where: {
itemFk: this.item.id
}
};
this.tags = [];
this.$http.get(`/item/api/ItemTags?filter=${JSON.stringify(Object.assign({}, filter, {include: {relation: 'tag'}}))}`).then(res => {
this.tags = res.data;
});
}
_getBotanical() {
let filter = {
where: {itemFk: this.item.id},
include: [{relation: 'genus'}, {relation: 'specie'}]
};
this.item.botanical = {};
this.$http.get(`/item/api/ItemBotanicals?filter=${JSON.stringify(filter)}`)
.then(res => {
if (res.data.length) {
this.item.botanical = res.data[0];
}
});
}
_getNiches() {
let filter = {
where: {itemFk: this.item.id},
include: {relation: 'warehouse'}
};
this.$http.get(`/item/api/ItemNiches?filter=${JSON.stringify(filter)}`).then(response => {
this.niches = response.data;
});
}
_getBarcodes() {
let filter = {
where: {
itemFk: this.item.id
}
};
this.barcodes = [];
this.$http.get(`/item/api/ItemBarcodes?filter=${JSON.stringify(filter)}`).then(response => {
this.barcodes = response.data;
});
}
$onChanges() {
if (this.item && this.item.id) {
this._getTags();
this._getBarcodes();
this._getNiches();
if (!this.item.botanical)
this._getBotanical();
}
}
}
ItemSummary.$inject = ['$http'];
ngModule.component('vnItemSummary', {
template: require('./item-summary.html'),
controller: ItemSummary,
bindings: {
item: '<'
}
});

View File

@ -0,0 +1,15 @@
@import "../../../salix/src/styles/colors";
vn-item-summary{
h5 {
border-bottom: 2px solid $color-orange;
}
h5.summaryId {
border: none;
background: $color-orange;
color: $color-white;
}
p {
margin: 0 0 5px 0;
}
}

View File

@ -4,28 +4,27 @@
<vn-vertical pad-medium>
<vn-horizontal vn-one margin-large-bottom class="locator-header">
<vn-title vn-one><span translate>Finder</span></vn-title>
<vn-searchbar vn-two
<vn-searchbar
vn-two
index="index"
on-search="$ctrl.searchTickets(index.filter)"
advanced="true"
popover="vn-production-filter-panel"
ignore-keys = "['page', 'size', 'search', 'warehouseFk']"
data ="$ctrl.sharedData"
>
data ="$ctrl.sharedData">
</vn-searchbar>
<vn-one vn-horizontal>
<vn-one></vn-one>
<vn-autocomplete vn-two
<vn-autocomplete
vn-two
initial-value="$ctrl.filter.warehouseFk"
show-field="name"
value-field="id"
field="$ctrl.filter.warehouseFk"
url="/production/api/Warehouses/production"
on-change = "$ctrl.onChangeWareHouse(item)"
label="Store"
></vn-autocomplete>
label="Store">
</vn-autocomplete>
<vn-icon-button vn-none pad-ten-top margin-medium-left icon="refresh" ng-click="$ctrl.refreshTickets()"></vn-icon-button>
</vn-one>
</vn-horizontal>

View File

@ -12,15 +12,14 @@
<vn-title>Create Route</vn-title>
<vn-horizontal>
<vn-date-picker vn-one label="Date" model="$ctrl.delivery.date"></vn-date-picker>
<vn-autocomplete vn-one
<vn-autocomplete
vn-one
label="Agency"
url="/route/api/Agencies"
field="$ctrl.delivery.agency"
>
field="$ctrl.delivery.agency">
</vn-autocomplete>
</vn-horizontal>
<vn-horizontal>
<vn-autocomplete vn-one
field="$ctrl.delivery.driver"
url="/route/api/Vehicles/activeDrivers"
@ -31,10 +30,9 @@
url="/route/api/Vehicles/comboVehicles"
label="Vehicle"
order="tradeMark ASC"
filter="{where: {isActive:1, warehouseFk:1}}"
></vn-autocomplete>
filter="{where: {isActive:1, warehouseFk:1}}">
</vn-autocomplete>
</vn-horizontal>
</vn-vertical>
</vn-card>
<vn-button-bar>

View File

@ -7,8 +7,8 @@
label="Zone"
field="$ctrl.filter.zone"
url="/route/api/Zones"
order="printingOrder ASC"
></vn-autocomplete>
order="printingOrder ASC">
</vn-autocomplete>
</vn-horizontal>
<vn-horizontal>
<vn-textfield vn-one label="Postcode" model="$ctrl.filter.postcode"></vn-textfield>

View File

@ -1,14 +1,22 @@
<div style="position: fixed; top: 0; right: 0; padding: .8em 1.5em; z-index: 10;">
<vn-icon icon="apps" id="apps" translate-attr="{title: 'Applications'}"></vn-icon>
<ul for="apps" class="mdl-menu mdl-js-menu mdl-menu--bottom-right" pad-small>
<vn-icon
id="apps"
icon="apps"
translate-attr="{title: 'Applications'}">
</vn-icon>
<ul id="apps-menu" for="apps" class="mdl-menu mdl-js-menu mdl-menu--bottom-right" pad-small>
<li ng-repeat="mod in ::$ctrl.modules" class="mdl-menu__item" ui-sref="{{::mod.route.state}}">
<vn-icon ng-if="::mod.icon && !mod.icon.startsWith('/')" icon="{{::mod.icon}}"></vn-icon>
<img ng-if="::mod.icon && mod.icon.startsWith('/')" ng-src="{{::mod.icon}}" />
<span translate="{{::mod.name}}"></span>
</li>
</ul>
<vn-icon id="lang-button" icon="language" translate-attr="{title: 'Change language'}"></vn-icon>
<ul id="langs" for="lang-button" class="mdl-menu mdl-js-menu mdl-menu--bottom-right" pad-small>
<vn-icon
id="lang"
icon="language"
translate-attr="{title: 'Change language'}">
</vn-icon>
<ul id="langs-menu" for="lang" class="mdl-menu mdl-js-menu mdl-menu--bottom-right" pad-small>
<li
ng-repeat="lang in ::$ctrl.langs"
name="{{::lang}}"
@ -17,7 +25,12 @@
<span>{{::lang}}</span>
</li>
</ul>
<vn-icon icon="exit_to_app" translate-attr="{title: 'Logout'}" ng-click="$ctrl.onLogoutClick()"></vn-icon>
<vn-icon
id="logout"
icon="exit_to_app"
translate-attr="{title: 'Logout'}"
ng-click="$ctrl.onLogoutClick()">
</vn-icon>
<!--
TODO: Keep it commented until they are functional

View File

@ -17,5 +17,6 @@ export default {
vnMenuItem: 'vn-menu-item > li > a',
vnAutocomplete: 'vn-autocomplete',
vnCheck: 'vn-check',
vnIconButton: 'vn-icon-button'
vnIconButton: 'vn-icon-button',
vnItemSummary: 'vn-item-summary > vn-card > div > vn-vertical'
};

View File

@ -1,22 +1,49 @@
import config from './config.js';
import Nightmare from 'nightmare';
import selectors from './selectors.js';
function child(selector, childNumber) {
let aux = selector.split(' ');
return selector.replace(aux[0], `${aux[0]}:nth-child(${childNumber})`);
}
import {URL} from 'url';
Nightmare.action('login', function(done) {
this.goto(`${config.url}auth/?apiKey=salix`)
.wait(selectors.login.textFieldInput)
.write(`${child(selectors.login.textFieldInput, 1)}`, 'JessicaJones')
.write(`${child(selectors.login.textFieldInput, 2)}`, 'nightmare')
.click(selectors.login.submitButton)
.wait(1000) // should create an extension like: https://github.com/segmentio/nightmare/issues/481 to wait for dom to be ready.
.wait(`vn-login input[name=user]`)
.write(`vn-login input[name=user]`, 'developer')
.write(`vn-login input[name=password]`, 'nightmare')
.click(`vn-login input[type=submit]`)
// FIXME: Wait for dom to be ready: https://github.com/segmentio/nightmare/issues/481
.wait(1000)
.then(done);
});
Nightmare.action('changeLanguageToEnglish', function(done) {
this.wait('#lang')
.evaluate(selector => {
return document.querySelector(selector).title;
}, '#lang')
.then(title => {
if (title === 'Change language') {
this.then(done);
} else {
this.click('#lang')
.click('#langs-menu > li[name="en"]')
.then(done);
}
});
});
Nightmare.action('waitForLogin', function(done) {
this.login()
.waitForURL('#!/')
.url()
.changeLanguageToEnglish()
.then(done);
});
Nightmare.action('parsedUrl', function(done) {
this.url()
.then(url => {
done(null, new URL(url));
});
});
Nightmare.action('getInnerText', function(selector, done) {
this.wait(selector)
.evaluate_now(function(elementToSelect) {
@ -134,29 +161,39 @@ Nightmare.action('waitForTextInInput', function(selector, name, done) {
.then(done);
});
Nightmare.action('changeLanguageToEnglish', function(done) {
this.wait('#lang-button')
.evaluate(selector => {
return document.querySelector(selector).title;
}, '#lang-button')
.then(title => {
if (title === 'Change language') {
this.then(done);
} else {
this.click('#lang-button')
.click('#langs > li[name="en"]')
.then(done);
}
});
Nightmare.action('waitForInnerText', function(selector, done) {
this.wait(selector)
.wait(selector => {
let innerText = document.querySelector(selector).innerText;
return innerText != null && innerText != '';
}, selector)
.evaluate_now(selector => {
return document.querySelector(selector).innerText;
}, done, selector);
});
Nightmare.action('waitForEmptyInnerText', function(selector, done) {
this.wait(selector => {
return document.querySelector(selector).innerText == '';
}, selector)
.then(done);
});
Nightmare.action('waitForSnackbarReset', function(done) {
this.wait(() => {
return document.querySelector('vn-snackbar').innerText === '';
})
this.click('vn-snackbar button')
.waitForEmptyInnerText('vn-snackbar .text')
.then(done);
});
Nightmare.action('waitForSnackbar', function(done) {
this.wait(500)
.waitForInnerText('vn-snackbar .text')
.then(value => {
this.waitForSnackbarReset()
.then(() => done(null, value));
});
});
Nightmare.action('waitForURL', function(hashURL, done) {
this.wait(hash => {
return document.location.hash.includes(hash);

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

@ -3,15 +3,9 @@
import components from './components_selectors.js';
export default {
login: {
textFieldInput: `${components.vnTextfield}`,
submitButton: `${components.vnSubmit}`
},
globalItems: {
topBar: `${components.vnTopbar}`,
logOutButton: `${components.vnIcon}[icon="exit_to_app"]`,
snackbarIsActive: '.mdl-snackbar--active > .mdl-snackbar__text',
applicationsMenuButton: `${components.vnIcon}[icon="apps"]`,
logOutButton: `#logout`,
applicationsMenuButton: `#apps`,
applicationsMenuVisible: `${components.vnMainMenu} .is-visible > div`,
clientsButton: `${components.vnMainMenu} > div > ul > li:nth-child(1)`
},
@ -44,7 +38,7 @@ export default {
faxInput: `${components.vnTextfield}[name="fax"]`,
emailInput: `${components.vnTextfield}[name="email"]`,
salesPersonInput: `${components.vnAutocomplete}[field="$ctrl.client.salesPersonFk"] > vn-vertical > ${components.vnTextfield}`,
salesBruceBannerOption: `${components.vnAutocomplete}[field="$ctrl.client.salesPersonFk"] > vn-vertical > vn-drop-down > vn-vertical:not(.ng-hide) > vn-auto:nth-child(2) > ul > li:nth-child(1)`,
salesPersonOptionOne: `${components.vnAutocomplete}[field="$ctrl.client.salesPersonFk"] > vn-vertical > vn-drop-down > vn-vertical:not(.ng-hide) > vn-auto:nth-child(2) > ul > li:nth-child(1)`,
channelInput: `${components.vnAutocomplete}[field="$ctrl.client.contactChannelFk"] > vn-vertical > ${components.vnTextfield}`,
channelMetropolisOption: `${components.vnAutocomplete}[field="$ctrl.client.contactChannelFk"] > vn-vertical > vn-drop-down > vn-vertical:not(.ng-hide) > vn-auto:nth-child(2) > ul > li:nth-child(3)`,
saveButton: `${components.vnSubmit}`
@ -54,7 +48,7 @@ export default {
socialNameInput: `${components.vnTextfield}[name="socialName"]`,
fiscalIdInput: `${components.vnTextfield}[name="fi"]`,
equalizationTaxCheckboxLabel: `${components.vnCheck}[label='Is equalizated'] > label > input`,
acceptPropagationButton: `body > vn-app > vn-vertical > vn-vertical > vn-client-card > vn-main-block > vn-horizontal > vn-one > vn-vertical > vn-client-fiscal-data > vn-confirm > div > form > div.button-bar > tpl-buttons > button:nth-child(2)`,
acceptPropagationButton: `vn-client-fiscal-data > vn-confirm button[response=ACCEPT]`,
addressInput: `${components.vnTextfield}[name="street"]`,
cityInput: `${components.vnTextfield}[name="city"]`,
postcodeInput: `${components.vnTextfield}[name="postcode"]`,
@ -77,7 +71,7 @@ export default {
payMethodOptionOne: `${components.vnAutocomplete}[field="$ctrl.client.payMethodFk"] > vn-vertical > vn-drop-down > vn-vertical:not(.ng-hide) > vn-auto:nth-child(2) > ul > li:nth-child(2)`,
IBANInput: `${components.vnTextfield}[name="iban"]`,
dueDayInput: `${components.vnTextfield}[name="dueDay"]`,
cancelNotificationButton: 'vn-client-billing-data > vn-dialog tpl-buttons > button:nth-child(1)',
cancelNotificationButton: 'vn-client-billing-data > vn-confirm button[response=CANCEL]',
receivedCoreVNHCheckbox: `${components.vnCheck}[label='Received core VNH'] > label > input`,
receivedCoreVNLCheckbox: `${components.vnCheck}[label='Received core VNL'] > label > input`,
receivedB2BVNLCheckbox: `${components.vnCheck}[label='Received B2B VNL'] > label > input`,
@ -97,8 +91,8 @@ export default {
agenctySecondOption: `${components.vnAutocomplete}[field="$ctrl.address.agencyFk"] > vn-vertical > vn-drop-down > vn-vertical:not(.ng-hide) > vn-auto:nth-child(2) > ul > li:nth-child(2)`,
phoneInput: `${components.vnTextfield}[name="phone"]`,
mobileInput: `${components.vnTextfield}[name="mobile"]`,
defaultAddress: 'body > vn-app > vn-vertical > vn-vertical > vn-client-card > vn-main-block > vn-horizontal > vn-one > vn-vertical > ui-view > vn-client-addresses > vn-vertical > vn-card > div > vn-vertical > vn-horizontal:nth-child(2) > vn-one > vn-horizontal > vn-one > div:nth-child(2)',
secondMakeDefaultStar: 'body > vn-app > vn-vertical > vn-vertical > vn-client-card > vn-main-block > vn-horizontal > vn-one > vn-vertical > ui-view > vn-client-addresses > vn-vertical > vn-card > div > vn-vertical > vn-horizontal:nth-child(3) > vn-one > vn-horizontal > vn-none > i',
defaultAddress: 'vn-client-addresses > vn-vertical > vn-card > div > vn-vertical > vn-horizontal:nth-child(2) > vn-one > vn-horizontal > vn-one > div:nth-child(2)',
secondMakeDefaultStar: 'vn-client-addresses > vn-vertical > vn-card > div > vn-vertical > vn-horizontal:nth-child(3) > vn-one > vn-horizontal > vn-none > i',
firstEditButton: `${components.vnIconButton}[icon='edit']`,
secondEditButton: `vn-horizontal:nth-child(3) > vn-one > vn-horizontal > a > ${components.vnIconButton}[icon='edit']`,
activeCheckbox: `${components.vnCheck}[label='Enabled'] > label > input`,
@ -116,14 +110,14 @@ export default {
addNoteFloatButton: `${components.vnFloatButton}`,
noteInput: `${components.vnTextarea}[label="Note"]`,
saveButton: `${components.vnSubmit}`,
firstNoteText: 'body > vn-app > vn-vertical > vn-vertical > vn-client-card > vn-main-block > vn-horizontal > vn-one > vn-vertical > ui-view > vn-client-notes > vn-card > div > vn-vertical > vn-one:nth-child(2) > vn-horizontal.ng-binding'
firstNoteText: 'vn-client-notes > vn-card > div > vn-vertical > vn-one:nth-child(2) > vn-horizontal.ng-binding'
},
clientCredit: {
creditButton: `${components.vnMenuItem}[ui-sref="clientCard.credit.list"]`,
addCreditFloatButton: `${components.vnFloatButton}`,
creditInput: `${components.vnTextfield}[name="credit"]`,
saveButton: `${components.vnSubmit}`,
firstCreditText: 'body > vn-app > vn-vertical > vn-vertical > vn-client-card > vn-main-block > vn-horizontal > vn-one > vn-vertical > ui-view > vn-client-credit-list > vn-card > div > vn-vertical > vn-one > vn-horizontal:nth-child(1) > vn-one'
firstCreditText: 'vn-client-credit-list > vn-card > div > vn-vertical > vn-one > vn-horizontal:nth-child(1) > vn-one'
},
clientGreuge: {
greugeButton: `${components.vnMenuItem}[ui-sref="clientCard.greuge.list"]`,
@ -133,28 +127,72 @@ export default {
typeInput: `${components.vnAutocomplete}[field="$ctrl.greuge.greugeTypeFk"] > vn-vertical > ${components.vnTextfield}`,
typeSecondOption: `${components.vnAutocomplete}[field="$ctrl.greuge.greugeTypeFk"] > vn-vertical > vn-drop-down > vn-vertical > vn-auto:nth-child(2) > ul > li`,
saveButton: `${components.vnSubmit}`,
firstGreugeText: 'body > vn-app > vn-vertical > vn-vertical > vn-client-card > vn-main-block > vn-horizontal > vn-one > vn-vertical > ui-view > vn-client-greuge-list > vn-card > div > vn-vertical > vn-one > vn-horizontal'
firstGreugeText: 'vn-client-greuge-list > vn-card > div > vn-vertical > vn-one > vn-horizontal'
},
clientMandate: {
mandateButton: `${components.vnMenuItem}[ui-sref="clientCard.mandate"]`,
firstMandateText: 'body > vn-app > vn-vertical > vn-vertical > vn-client-card > vn-main-block > vn-horizontal > vn-one > vn-vertical > vn-client-mandate > vn-card > div > vn-vertical > vn-one > vn-horizontal'
firstMandateText: 'vn-client-mandate > vn-card > div > vn-vertical > vn-one > vn-horizontal'
},
itemsIndex: {
createItemButton: `${components.vnFloatButton}`,
searchResult: `${components.vnItemProduct} > vn-horizontal`,
searchResult: `${components.vnItemProduct} > vn-horizontal > vn-one`,
searchResultPreviewButton: `${components.vnItemProduct}:nth-child(1) > vn-horizontal > vn-horizontal > vn-one:nth-child(2) > vn-icon > i`,
searchItemInput: `${components.vnTextfield}`,
searchButton: `${components.vnSearchBar} > vn-icon-button > button`
searchButton: `${components.vnSearchBar} > vn-icon-button > button`,
closeItemSummaryPreview: 'body > vn-app > vn-vertical > vn-vertical > ui-view > vn-item-list:nth-child(1) > div > vn-dialog > div > button > vn-icon'
},
itemBasicData: {
basicDataButton: `${components.vnMenuItem}[ui-sref="item.card.data"]`
basicDataButton: `${components.vnMenuItem}[ui-sref="item.card.data"]`,
typeSelect: `${components.vnAutocomplete}[field="$ctrl.item.typeFk"] > vn-vertical > ${components.vnTextfield}`,
typeSelectOptionTwo: `${components.vnAutocomplete}[field="$ctrl.item.typeFk"] > vn-vertical > vn-drop-down > vn-vertical:not(.ng-hide) > vn-auto:nth-child(2) > ul > li:nth-child(2)`,
intrastatSelect: `${components.vnAutocomplete}[field="$ctrl.item.intrastatFk"] > vn-vertical > ${components.vnTextfield}`,
intrastatSelectOptionOne: `${components.vnAutocomplete}[field="$ctrl.item.intrastatFk"] > vn-vertical > vn-drop-down > vn-vertical:not(.ng-hide) > vn-auto:nth-child(2) > ul > li:nth-child(1)`,
nameInput: `vn-horizontal:nth-child(2) > ${components.vnTextfield}`,
relevancyInput: `vn-horizontal:nth-child(3) > ${components.vnTextfield}`,
originSelect: `${components.vnAutocomplete}[field="$ctrl.item.originFk"] > vn-vertical > ${components.vnTextfield}`,
originSelectOptionTwo: `${components.vnAutocomplete}[field="$ctrl.item.originFk"] > vn-vertical > vn-drop-down > vn-vertical:not(.ng-hide) > vn-auto:nth-child(2) > ul > li:nth-child(2)`,
expenceSelect: `${components.vnAutocomplete}[field="$ctrl.item.expenceFk"] > vn-vertical > ${components.vnTextfield}`,
expenceSelectOptionTwo: `${components.vnAutocomplete}[field="$ctrl.item.expenceFk"] > vn-vertical > vn-drop-down > vn-vertical:not(.ng-hide) > vn-auto:nth-child(2) > ul > li:nth-child(2)`,
submitBasicDataButton: `${components.vnSubmit}`
},
itemBarcodes: {
barcodeButton: `${components.vnMenuItem}[ui-sref="item.card.itemBarcode"]`,
addBarcodeButton: `${components.vnIcon}[icon="add_circle"]`,
thirdCodeInput: `vn-horizontal:nth-child(5) > ${components.vnTextfield}`,
fourthCodeInput: `vn-horizontal:nth-child(6) > ${components.vnTextfield}`,
thirdCodeInput: `vn-horizontal:nth-child(4) > ${components.vnTextfield}`,
submitBarcodesButton: `${components.vnSubmit}`,
firstCodeRemoveButton: `vn-horizontal:nth-child(3) > vn-one > ${components.vnIcon}[icon="remove_circle_outline"]`
firstCodeRemoveButton: `vn-horizontal:nth-child(2) > vn-one > ${components.vnIcon}[icon="remove_circle_outline"]`
},
itemNiches: {
nicheButton: `${components.vnMenuItem}[ui-sref="item.card.niche"]`,
addNicheButton: `${components.vnIcon}[icon="add_circle"]`,
firstWarehouseSelect: `${components.vnAutocomplete}[field="niche.warehouseFk"] > vn-vertical > ${components.vnTextfield}`,
firstWarehouseSelectSecondOption: `${components.vnAutocomplete}[field="niche.warehouseFk"] > vn-vertical > vn-drop-down > vn-vertical:not(.ng-hide) > vn-auto:nth-child(2) > ul > li:nth-child(2)`,
thirdWarehouseSelect: `vn-horizontal:nth-child(4) > ${components.vnAutocomplete}[field="niche.warehouseFk"] > vn-vertical > ${components.vnTextfield}`,
thirdWarehouseSelectFourthOption: `vn-horizontal:nth-child(4) > ${components.vnAutocomplete}[field="niche.warehouseFk"] > vn-vertical > vn-drop-down > vn-vertical:not(.ng-hide) > vn-auto:nth-child(2) > ul > li:nth-child(4)`,
secondNicheRemoveButton: `vn-horizontal:nth-child(3) > vn-one > ${components.vnIcon}[icon="remove_circle_outline"]`,
firstCodeInput: `vn-horizontal:nth-child(2) > ${components.vnTextfield}`,
thirdCodeInput: `vn-horizontal:nth-child(4) > ${components.vnTextfield}`,
submitNichesButton: `${components.vnSubmit}`
},
itemBotanical: {
botanicalButton: `${components.vnMenuItem}[ui-sref="item.card.botanical"]`,
botanicalInput: `vn-horizontal:nth-child(2) > ${components.vnTextfield}`,
genusSelect: `${components.vnAutocomplete}[field="$ctrl.botanical.genusFk"] > vn-vertical > ${components.vnTextfield}`,
genusSelectOptionOne: `${components.vnAutocomplete}[field="$ctrl.botanical.genusFk"] > vn-vertical > vn-drop-down > vn-vertical:not(.ng-hide) > vn-auto:nth-child(2) > ul > li:nth-child(1)`,
genusSelectOptionTwo: `${components.vnAutocomplete}[field="$ctrl.botanical.genusFk"] > vn-vertical > vn-drop-down > vn-vertical:not(.ng-hide) > vn-auto:nth-child(2) > ul > li:nth-child(2)`,
speciesSelect: `${components.vnAutocomplete}[field="$ctrl.botanical.specieFk"] > vn-vertical > ${components.vnTextfield}`,
speciesSelectOptionOne: `${components.vnAutocomplete}[field="$ctrl.botanical.specieFk"] > vn-vertical > vn-drop-down > vn-vertical:not(.ng-hide) > vn-auto:nth-child(2) > ul > li:nth-child(1)`,
speciesSelectOptionTwo: `${components.vnAutocomplete}[field="$ctrl.botanical.specieFk"] > vn-vertical > vn-drop-down > vn-vertical:not(.ng-hide) > vn-auto:nth-child(2) > ul > li:nth-child(2)`,
submitBotanicalButton: `${components.vnSubmit}`
},
itemTags: {
tagsButton: `${components.vnMenuItem}[ui-sref="item.card.tags"]`
},
itemSummary: {
basicData: `${components.vnItemSummary} > vn-horizontal:nth-child(1) > vn-one:nth-child(2) > vn-vertical > p:nth-child(2)`,
tags: `${components.vnItemSummary} > vn-horizontal:nth-child(1) > vn-one:nth-child(3) > vn-vertical > p`,
niche: `${components.vnItemSummary} > vn-horizontal:nth-child(2) > vn-one:nth-child(1) > vn-vertical > p:nth-child(2)`,
botanical: `${components.vnItemSummary} > vn-horizontal:nth-child(2) > vn-one:nth-child(2) > vn-vertical > p`,
barcode: `${components.vnItemSummary} > vn-horizontal:nth-child(2) > vn-one:nth-child(3) > vn-vertical > p`
}
};

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -0,0 +1,130 @@
import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/helpers';
describe('Item summary path', () => {
const nightmare = createNightmare();
it('should access to the items index by clicking the items button', () => {
return nightmare
.click(selectors.moduleAccessView.itemsSectionButton)
.wait(selectors.itemsIndex.createItemButton)
.parsedUrl()
.then(url => {
expect(url.hash).toEqual('#!/item/list');
});
});
it('should search for the item Gem of Mind', () => {
return nightmare
.wait(selectors.itemsIndex.searchResult)
.type(selectors.itemsIndex.searchItemInput, 'Gem of Time')
.click(selectors.itemsIndex.searchButton)
.waitForNumberOfElements(selectors.itemsIndex.searchResult, 1)
.countSearchResults(selectors.itemsIndex.searchResult)
.then(result => {
expect(result).toEqual(1);
});
});
it(`should click on the search result summary button to open the item summary popup`, () => {
return nightmare
.waitForTextInElement(selectors.itemsIndex.searchResult, 'Gem of Time')
.isVisible(selectors.itemSummary.basicData)
.then(result => {
expect(result).toBeFalsy();
return nightmare
.waitToClick(selectors.itemsIndex.searchResultPreviewButton)
.isVisible(selectors.itemSummary.basicData);
})
.then(result => {
expect(result).toBeTruthy();
});
});
it(`should check the item summary preview shows fields from basic data`, () => {
return nightmare
.getInnerText(selectors.itemSummary.basicData)
.then(result => {
expect(result).toContain('Name: Gem of Time');
});
});
it(`should check the item summary preview shows fields from tags`, () => {
return nightmare
.getInnerText(selectors.itemSummary.tags)
.then(result => {
expect(result).toContain('Color: Yellow');
});
});
it(`should check the item summary preview shows fields from niche`, () => {
return nightmare
.getInnerText(selectors.itemSummary.niche)
.then(result => {
expect(result).toContain('Warehouse One: A1');
});
});
it(`should check the item summary preview shows fields from botanical`, () => {
return nightmare
.getInnerText(selectors.itemSummary.botanical)
.then(result => {
expect(result).toContain('Botanical: Hedera helix');
});
});
it(`should check the item summary preview shows fields from barcode`, () => {
return nightmare
.getInnerText(selectors.itemSummary.barcode)
.then(result => {
expect(result).toContain('1');
});
});
it(`should close the summary popup`, () => {
return nightmare
.waitToClick(selectors.itemsIndex.closeItemSummaryPreview)
.isVisible(selectors.itemSummary.basicData)
.then(result => {
expect(result).toBeFalsy();
});
});
it(`should navigate to the one of the items detailed section`, () => {
return nightmare
.waitToClick(selectors.itemsIndex.searchResult)
.waitForURL('summary')
.parsedUrl()
.then(url => {
expect(url.hash).toContain('summary');
});
});
it(`should check the item summary shows fields from all its sections`, () => {
return nightmare
.getInnerText(selectors.itemSummary.basicData)
.then(result => {
expect(result).toContain('Name: Gem of Time');
return nightmare
.getInnerText(selectors.itemSummary.tags);
})
.then(result => {
expect(result).toContain('Color: Yellow');
return nightmare
.getInnerText(selectors.itemSummary.niche);
})
.then(result => {
expect(result).toContain('Warehouse One: A1');
return nightmare
.getInnerText(selectors.itemSummary.botanical);
})
.then(result => {
expect(result).toContain('Botanical: Hedera helix');
return nightmare
.getInnerText(selectors.itemSummary.barcode);
})
.then(result => {
expect(result).toContain('1');
});
});
});

View File

@ -0,0 +1,113 @@
import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/helpers';
describe('edit item basic data path', () => {
const nightmare = createNightmare();
it('should access to the items index by clicking the items button', () => {
return nightmare
.click(selectors.moduleAccessView.itemsSectionButton)
.wait(selectors.itemsIndex.createItemButton)
.parsedUrl()
.then(url => {
expect(url.hash).toEqual('#!/item/list');
});
});
it('should search for the item Gem of Mind', () => {
return nightmare
.wait(selectors.itemsIndex.searchResult)
.type(selectors.itemsIndex.searchItemInput, 'Gem of Mind')
.click(selectors.itemsIndex.searchButton)
.waitForNumberOfElements(selectors.itemsIndex.searchResult, 1)
.countSearchResults(selectors.itemsIndex.searchResult)
.then(result => {
expect(result).toEqual(1);
});
});
it(`should click on the search result to access to the item basic data`, () => {
return nightmare
.waitForTextInElement(selectors.itemsIndex.searchResult, 'Gem of Mind')
.waitToClick(selectors.itemsIndex.searchResult)
.waitToClick(selectors.itemBasicData.basicDataButton)
.waitForURL('data')
.url()
.then(url => {
expect(url).toContain('data');
});
});
it(`should edit the item basic data`, () => {
return nightmare
.clearInput(selectors.itemBasicData.nameInput)
.type(selectors.itemBasicData.nameInput, 'Rose of Purity')
.waitToClick(selectors.itemBasicData.typeSelect)
.waitToClick(selectors.itemBasicData.typeSelectOptionTwo)
.waitToClick(selectors.itemBasicData.intrastatSelect)
.waitToClick(selectors.itemBasicData.intrastatSelectOptionOne)
.clearInput(selectors.itemBasicData.relevancyInput)
.type(selectors.itemBasicData.relevancyInput, '1')
.waitToClick(selectors.itemBasicData.originSelect)
.waitToClick(selectors.itemBasicData.originSelectOptionTwo)
.waitToClick(selectors.itemBasicData.expenceSelect)
.waitToClick(selectors.itemBasicData.expenceSelectOptionTwo)
.click(selectors.itemBasicData.submitBasicDataButton)
.waitForSnackbar()
.then(result => {
expect(result).toContain('Data saved!');
});
});
it(`should confirm the item name was edited`, () => {
return nightmare
.click(selectors.itemTags.tagsButton)
.wait(selectors.itemTags.tagsButton)
.waitToClick(selectors.itemBasicData.basicDataButton)
.wait(200)
.getInputValue(selectors.itemBasicData.nameInput)
.then(result => {
expect(result).toEqual('Rose of Purity');
});
});
it(`should confirm the item type was edited`, () => {
return nightmare
.getInputValue(selectors.itemBasicData.typeSelect)
.then(result => {
expect(result).toEqual('Crisantemo');
});
});
it(`should confirm the item intrastad was edited`, () => {
return nightmare
.getInputValue(selectors.itemBasicData.intrastatSelect)
.then(result => {
expect(result).toEqual('Coral y materiales similares');
});
});
it(`should confirm the item relevancy was edited`, () => {
return nightmare
.getInputValue(selectors.itemBasicData.relevancyInput)
.then(result => {
expect(result).toEqual('1');
});
});
it(`should confirm the item origin was edited`, () => {
return nightmare
.getInputValue(selectors.itemBasicData.originSelect)
.then(result => {
expect(result).toEqual('Spain');
});
});
it(`should confirm the item expence was edited`, () => {
return nightmare
.getInputValue(selectors.itemBasicData.expenceSelect)
.then(result => {
expect(result).toEqual('loan');
});
});
});

View File

@ -0,0 +1,70 @@
import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/helpers';
describe('create item niche path', () => {
const nightmare = createNightmare();
it('should access to the items index by clicking the items button', () => {
return nightmare
.click(selectors.moduleAccessView.itemsSectionButton)
.wait(selectors.itemsIndex.createItemButton)
.parsedUrl()
.then(url => {
expect(url.hash).toEqual('#!/item/list');
});
});
it('should search for the item Gem of Time', () => {
return nightmare
.wait(selectors.itemsIndex.searchResult)
.type(selectors.itemsIndex.searchItemInput, 'Gem of Time')
.click(selectors.itemsIndex.searchButton)
.waitForNumberOfElements(selectors.itemsIndex.searchResult, 1)
.countSearchResults(selectors.itemsIndex.searchResult)
.then(result => {
expect(result).toEqual(1);
});
});
it(`should click on the search result to access to the item niches`, () => {
return nightmare
.waitForTextInElement(selectors.itemsIndex.searchResult, 'Gem of Time')
.waitToClick(selectors.itemsIndex.searchResult)
.waitToClick(selectors.itemNiches.nicheButton)
.waitForURL('niche')
.url()
.then(url => {
expect(url).toContain('niche');
});
});
it(`should click create a new niche, edit another and delete a former one`, () => {
return nightmare
.waitToClick(selectors.itemNiches.addNicheButton)
.waitToClick(selectors.itemNiches.firstWarehouseSelect)
.waitToClick(selectors.itemNiches.firstWarehouseSelectSecondOption)
.clearInput(selectors.itemNiches.firstCodeInput)
.type(selectors.itemNiches.firstCodeInput, 'New Location')
.waitToClick(selectors.itemNiches.secondNicheRemoveButton)
.waitToClick(selectors.itemNiches.thirdWarehouseSelect)
.waitToClick(selectors.itemNiches.thirdWarehouseSelectFourthOption)
.type(selectors.itemNiches.thirdCodeInput, 'a code')
.click(selectors.itemNiches.submitNichesButton)
.waitForSnackbar()
.then(result => {
expect(result).toContain('Data saved!');
});
});
it(`should confirm the remaining niches are for the second third and fourth warehouses`, () => {
return nightmare
.click(selectors.itemBasicData.basicDataButton)
.wait(selectors.itemBasicData.nameInput)
.click(selectors.itemNiches.nicheButton)
.wait(200)
.getInputValue(selectors.itemNiches.thirdCodeInput)
.then(result => {
expect(result).toEqual('a code');
});
});
});

View File

@ -1,101 +0,0 @@
import config from '../../helpers/config.js';
import createNightmare from '../../helpers/nightmare';
import selectors from '../../helpers/selectors.js';
import {catchErrors} from '../../../services/utils/jasmineHelpers';
const nightmare = createNightmare();
const moduleAccessViewHashURL = '#!/';
jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000;
describe('create item barcodes path', () => {
it('should log in', done => {
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 => {
nightmare
.changeLanguageToEnglish()
.then(() => {
done();
})
.catch(catchErrors(done));
});
it('should access to the items index by clicking the items button', done => {
nightmare
.click(selectors.moduleAccessView.itemsSectionButton)
.wait(selectors.itemsIndex.createItemButton)
.url()
.then(url => {
expect(url).toEqual(config.url + '#!/item/list');
done();
})
.catch(catchErrors(done));
});
it('should search for the item Gem of Time', done => {
nightmare
.wait(selectors.itemsIndex.searchResult)
.type(selectors.itemsIndex.searchItemInput, 'Gem of Time')
.click(selectors.itemsIndex.searchButton)
.waitForNumberOfElements(selectors.itemsIndex.searchResult, 1)
.countSearchResults(selectors.itemsIndex.searchResult)
.then(result => {
expect(result).toEqual(1);
done();
})
.catch(catchErrors(done));
});
it(`should click on the search result to access to the item barcodes`, done => {
nightmare
.waitForTextInElement(selectors.itemsIndex.searchResult, 'Gem of Time')
.waitToClick(selectors.itemsIndex.searchResult)
.waitToClick(selectors.itemBarcodes.barcodeButton)
.waitForURL('barcode')
.url()
.then(url => {
expect(url).toContain('barcode');
done();
})
.catch(catchErrors(done));
});
it(`should click create a new code and delete a former one`, done => {
nightmare
.waitToClick(selectors.itemBarcodes.addBarcodeButton)
.type(selectors.itemBarcodes.fourthCodeInput, '5')
.click(selectors.itemBarcodes.firstCodeRemoveButton)
.click(selectors.itemBarcodes.submitBarcodesButton)
.wait(selectors.globalItems.snackbarIsActive)
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => {
expect(result).toContain('Data saved!');
done();
})
.catch(catchErrors(done));
});
it(`should confirm the barcode 5 is created and it is now the third barcode as the first was deleted`, done => {
nightmare
.waitForSnackbarReset()
.click(selectors.itemBasicData.basicDataButton)
.wait(selectors.itemBasicData.nameInput)
.click(selectors.itemBarcodes.barcodeButton)
.wait(200)
.getInputValue(selectors.itemBarcodes.thirdCodeInput)
.then(result => {
expect(result).toEqual('5');
done();
})
.catch(catchErrors(done));
});
});

View File

@ -0,0 +1,129 @@
import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/helpers';
describe('create item botanical path', () => {
const nightmare = createNightmare();
it('should access to the items index by clicking the items button', () => {
return nightmare
.click(selectors.moduleAccessView.itemsSectionButton)
.wait(selectors.itemsIndex.createItemButton)
.parsedUrl()
.then(url => {
expect(url.hash).toEqual('#!/item/list');
});
});
it('should search for the item Gem of Time', () => {
return nightmare
.wait(selectors.itemsIndex.searchResult)
.type(selectors.itemsIndex.searchItemInput, 'Mjolnir')
.click(selectors.itemsIndex.searchButton)
.waitForNumberOfElements(selectors.itemsIndex.searchResult, 1)
.countSearchResults(selectors.itemsIndex.searchResult)
.then(result => {
expect(result).toEqual(1);
});
});
it(`should click on the search result to access to the item botanical`, () => {
return nightmare
.waitForTextInElement(selectors.itemsIndex.searchResult, 'Mjolnir')
.waitToClick(selectors.itemsIndex.searchResult)
.waitToClick(selectors.itemBotanical.botanicalButton)
.waitForURL('botanical')
.url()
.then(url => {
expect(url).toContain('botanical');
});
});
it(`should create a new botanical for the item with id Mjolnir`, () => {
return nightmare
.type(selectors.itemBotanical.botanicalInput, 'Cicuta maculata')
.waitToClick(selectors.itemBotanical.genusSelect)
.waitToClick(selectors.itemBotanical.genusSelectOptionOne)
.waitToClick(selectors.itemBotanical.speciesSelect)
.waitToClick(selectors.itemBotanical.speciesSelectOptionOne)
.waitToClick(selectors.itemBotanical.submitBotanicalButton)
.waitForSnackbar()
.then(result => {
expect(result).toContain('Data saved!');
});
});
it(`should confirm the botanical for item 5 was created`, () => {
return nightmare
.click(selectors.itemBasicData.basicDataButton)
.wait(selectors.itemBasicData.nameInput)
.click(selectors.itemBotanical.botanicalButton)
.wait(200)
.getInputValue(selectors.itemBotanical.botanicalInput)
.then(result => {
expect(result).toEqual('Cicuta maculata');
});
});
it(`should confirm the Genus for item 5 was created`, () => {
return nightmare
.wait(200)
.getInputValue(selectors.itemBotanical.genusSelect)
.then(result => {
expect(result).toEqual('Abelia');
});
});
it(`should confirm the Species for item 5 was created`, () => {
return nightmare
.wait(200)
.getInputValue(selectors.itemBotanical.speciesSelect)
.then(result => {
expect(result).toEqual('dealbata');
});
});
it(`should edit botanical for the item with id Mjolnir`, () => {
return nightmare
.clearInput(selectors.itemBotanical.botanicalInput)
.type(selectors.itemBotanical.botanicalInput, 'Herp Derp')
.waitToClick(selectors.itemBotanical.genusSelect)
.waitToClick(selectors.itemBotanical.genusSelectOptionTwo)
.waitToClick(selectors.itemBotanical.speciesSelect)
.waitToClick(selectors.itemBotanical.speciesSelectOptionTwo)
.waitToClick(selectors.itemBotanical.submitBotanicalButton)
.waitForSnackbar()
.then(result => {
expect(result).toContain('Data saved!');
});
});
it(`should confirm the botanical for item 5 was edited`, () => {
return nightmare
.click(selectors.itemBasicData.basicDataButton)
.wait(selectors.itemBasicData.nameInput)
.click(selectors.itemBotanical.botanicalButton)
.wait(200)
.getInputValue(selectors.itemBotanical.botanicalInput)
.then(result => {
expect(result).toEqual('Herp Derp');
});
});
it(`should confirm the Genus for item 5 was edited`, () => {
return nightmare
.wait(200)
.getInputValue(selectors.itemBotanical.genusSelect)
.then(result => {
expect(result).toEqual('Abies');
});
});
it(`should confirm the Species for item 5 was edited`, () => {
return nightmare
.wait(200)
.getInputValue(selectors.itemBotanical.speciesSelect)
.then(result => {
expect(result).toEqual('decurrens');
});
});
});

View File

@ -0,0 +1,65 @@
import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/helpers';
describe('create item barcodes path', () => {
const nightmare = createNightmare();
it('should access to the items index by clicking the items button', () => {
return nightmare
.click(selectors.moduleAccessView.itemsSectionButton)
.wait(selectors.itemsIndex.createItemButton)
.parsedUrl()
.then(url => {
expect(url.hash).toEqual('#!/item/list');
});
});
it('should search for the item Gem of Time', () => {
return nightmare
.wait(selectors.itemsIndex.searchResult)
.type(selectors.itemsIndex.searchItemInput, 'Gem of Time')
.click(selectors.itemsIndex.searchButton)
.waitForNumberOfElements(selectors.itemsIndex.searchResult, 1)
.countSearchResults(selectors.itemsIndex.searchResult)
.then(result => {
expect(result).toEqual(1);
});
});
it(`should click on the search result to access to the item barcodes`, () => {
return nightmare
.waitForTextInElement(selectors.itemsIndex.searchResult, 'Gem of Time')
.waitToClick(selectors.itemsIndex.searchResult)
.waitToClick(selectors.itemBarcodes.barcodeButton)
.waitForURL('barcode')
.url()
.then(url => {
expect(url).toContain('barcode');
});
});
it(`should click create a new code and delete a former one`, () => {
return nightmare
.waitToClick(selectors.itemBarcodes.firstCodeRemoveButton)
.waitToClick(selectors.itemBarcodes.addBarcodeButton)
.wait(selectors.itemBarcodes.thirdCodeInput)
.type(selectors.itemBarcodes.thirdCodeInput, '5')
.waitToClick(selectors.itemBarcodes.submitBarcodesButton)
.waitForSnackbar()
.then(result => {
expect(result).toContain('Data saved!');
});
});
it(`should confirm the barcode 5 is created and it is now the third barcode as the first was deleted`, () => {
return nightmare
.click(selectors.itemBasicData.basicDataButton)
.wait(selectors.itemBasicData.nameInput)
.click(selectors.itemBarcodes.barcodeButton)
.wait(200)
.getInputValue(selectors.itemBarcodes.thirdCodeInput)
.then(result => {
expect(result).toEqual('5');
});
});
});

View File

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

View File

@ -22,7 +22,7 @@ USE `account`;
LOCK TABLES `role` WRITE;
/*!40000 ALTER TABLE `role` DISABLE KEYS */;
INSERT INTO `role` VALUES (0,'root','Rol con todos los privilegios',0,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(1,'employee','Empleado básico',1,'2017-05-19 07:04:58','2017-11-29 10:06:31'),(2,'customer','Privilegios básicos de un cliente',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(3,'agency','Consultar tablas de predicciones de bultos',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(5,'administrative','Tareas relacionadas con la contabilidad',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(6,'guest','Privilegios para usuarios sin cuenta',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(9,'developer','Desarrolladores del sistema',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(11,'account','Privilegios relacionados con el login',0,'2017-05-19 07:04:58','2017-09-20 17:06:35'),(13,'teamBoss','Jefe de departamento',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(14,'manageEmployee','Privilegios para gestión de empleados',0,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(15,'logistic','Departamento de compras, responsables de la logistica',1,'2017-05-19 07:04:58','2018-02-12 10:50:10'),(16,'logisticBoss','Jefe del departamento de logística',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(17,'adminBoss','Jefe del departamento de administración',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(18,'salesPerson','Departamento de ventas',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(19,'salesBoss','Jefe del departamento de ventas',1,'2017-05-19 07:04:58','2017-08-16 12:38:27'),(20,'manager','Departamento de gerencia',1,'2017-06-01 14:57:02','2017-06-01 14:57:51'),(21,'salesAssistant','Jefe auxiliar de ventas',1,'2017-08-16 12:40:52','2017-08-16 12:40:52'),(22,'teamManager','Jefe de departamento con privilegios de auxiliar de venta.',1,'2017-09-07 09:08:12','2017-09-07 09:08:12'),(30,'financialBoss','Director finaciero',1,'2017-09-21 11:05:36','2017-09-21 11:05:36'),(31,'freelancer','Trabajadores por cuenta ajena',1,'2017-10-10 12:57:26','2017-10-10 12:59:27'),(32,'ett','Trabajadores de empresa temporal',1,'2017-10-10 12:58:58','2017-10-10 12:59:20'),(33,'invoicing','Personal con acceso a facturación',0,'2018-01-29 16:43:34','2018-01-29 16:43:34'),(34,'agencyAdmin','Gestión administrativa de agencias',1,'2018-01-29 16:44:39','2018-01-29 16:44:39'),(35,'buyer','Departamento de compras',1,'2018-02-12 10:35:42','2018-02-12 10:35:42');
INSERT INTO `role` VALUES (0,'root','Rol con todos los privilegios',0,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(1,'employee','Empleado básico',1,'2017-05-19 07:04:58','2017-11-29 10:06:31'),(2,'customer','Privilegios básicos de un cliente',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(3,'agency','Consultar tablas de predicciones de bultos',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(5,'administrative','Tareas relacionadas con la contabilidad',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(6,'guest','Privilegios para usuarios sin cuenta',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(9,'developer','Desarrolladores del sistema',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(11,'account','Privilegios relacionados con el login',0,'2017-05-19 07:04:58','2017-09-20 17:06:35'),(13,'teamBoss','Jefe de departamento',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(14,'manageEmployee','Privilegios para gestión de empleados',0,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(15,'logistic','Departamento de compras, responsables de la logistica',1,'2017-05-19 07:04:58','2018-02-12 10:50:10'),(16,'logisticBoss','Jefe del departamento de logística',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(17,'adminBoss','Jefe del departamento de administración',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(18,'salesPerson','Departamento de ventas',1,'2017-05-19 07:04:58','2017-05-19 07:04:58'),(19,'salesBoss','Jefe del departamento de ventas',1,'2017-05-19 07:04:58','2017-08-16 12:38:27'),(20,'manager','Departamento de gerencia',1,'2017-06-01 14:57:02','2017-06-01 14:57:51'),(21,'salesAssistant','Jefe auxiliar de ventas',1,'2017-08-16 12:40:52','2017-08-16 12:40:52'),(22,'teamManager','Jefe de departamento con privilegios de auxiliar de venta.',1,'2017-09-07 09:08:12','2017-09-07 09:08:12'),(30,'financialBoss','Director finaciero',1,'2017-09-21 11:05:36','2017-09-21 11:05:36'),(31,'freelancer','Trabajadores por cuenta ajena',1,'2017-10-10 12:57:26','2017-10-10 12:59:27'),(32,'ett','Trabajadores de empresa temporal',1,'2017-10-10 12:58:58','2017-10-10 12:59:20'),(33,'invoicing','Personal con acceso a facturación',0,'2018-01-29 16:43:34','2018-01-29 16:43:34'),(34,'agencyAdmin','Gestión administrativa de agencias',1,'2018-01-29 16:44:39','2018-01-29 16:44:39'),(35,'buyer','Departamento de compras',1,'2018-02-12 10:35:42','2018-02-12 10:35:42'),(36,'replenisher','Trabajador en la camara',1,'2018-02-16 14:07:10','2018-02-16 14:08:11');
/*!40000 ALTER TABLE `role` ENABLE KEYS */;
UNLOCK TABLES;
@ -32,7 +32,7 @@ UNLOCK TABLES;
LOCK TABLES `roleRole` WRITE;
/*!40000 ALTER TABLE `roleRole` DISABLE KEYS */;
INSERT INTO `roleRole` VALUES (0,0),(0,1),(0,2),(0,3),(0,5),(0,6),(0,9),(0,11),(0,13),(0,14),(0,15),(0,16),(0,17),(0,18),(0,19),(0,20),(0,21),(0,22),(0,30),(0,31),(0,32),(0,33),(0,34),(0,35),(1,1),(1,2),(1,3),(1,6),(1,11),(2,2),(2,6),(2,11),(3,3),(3,6),(3,11),(5,1),(5,2),(5,3),(5,5),(5,6),(5,11),(5,13),(5,14),(5,18),(5,19),(5,21),(5,33),(6,6),(9,0),(9,1),(9,2),(9,3),(9,5),(9,6),(9,9),(9,11),(9,13),(9,14),(9,15),(9,16),(9,17),(9,18),(9,19),(9,20),(9,21),(9,22),(9,30),(9,31),(9,32),(9,33),(9,34),(9,35),(11,6),(11,11),(13,1),(13,2),(13,3),(13,6),(13,11),(13,13),(13,14),(14,14),(15,1),(15,2),(15,3),(15,6),(15,11),(15,15),(15,35),(16,1),(16,2),(16,3),(16,6),(16,11),(16,13),(16,14),(16,15),(16,16),(16,35),(17,1),(17,2),(17,3),(17,5),(17,6),(17,11),(17,13),(17,14),(17,17),(17,18),(17,19),(17,20),(17,21),(17,33),(18,1),(18,2),(18,3),(18,6),(18,11),(18,18),(19,1),(19,2),(19,3),(19,6),(19,11),(19,13),(19,14),(19,18),(19,19),(19,21),(20,1),(20,2),(20,3),(20,6),(20,11),(20,13),(20,14),(20,20),(21,1),(21,2),(21,3),(21,6),(21,11),(21,13),(21,14),(21,18),(21,21),(22,1),(22,2),(22,3),(22,6),(22,11),(22,13),(22,14),(22,18),(22,21),(22,22),(30,1),(30,2),(30,3),(30,5),(30,6),(30,11),(30,13),(30,14),(30,18),(30,19),(30,20),(30,21),(30,22),(30,30),(30,33),(31,1),(31,2),(31,3),(31,6),(31,11),(31,31),(32,1),(32,2),(32,3),(32,6),(32,11),(32,32),(33,33),(34,1),(34,2),(34,3),(34,6),(34,11),(34,33),(34,34),(35,1),(35,2),(35,3),(35,6),(35,11),(35,35);
INSERT INTO `roleRole` VALUES (0,0),(0,1),(0,2),(0,3),(0,5),(0,6),(0,9),(0,11),(0,13),(0,14),(0,15),(0,16),(0,17),(0,18),(0,19),(0,20),(0,21),(0,22),(0,30),(0,31),(0,32),(0,33),(0,34),(0,35),(0,36),(1,1),(1,2),(1,3),(1,6),(1,11),(2,2),(2,6),(2,11),(3,3),(3,6),(3,11),(5,1),(5,2),(5,3),(5,5),(5,6),(5,11),(5,13),(5,14),(5,18),(5,19),(5,21),(5,33),(6,6),(9,0),(9,1),(9,2),(9,3),(9,5),(9,6),(9,9),(9,11),(9,13),(9,14),(9,15),(9,16),(9,17),(9,18),(9,19),(9,20),(9,21),(9,22),(9,30),(9,31),(9,32),(9,33),(9,34),(9,35),(9,36),(11,6),(11,11),(13,1),(13,2),(13,3),(13,6),(13,11),(13,13),(13,14),(14,14),(15,1),(15,2),(15,3),(15,6),(15,11),(15,15),(15,35),(16,1),(16,2),(16,3),(16,6),(16,11),(16,13),(16,14),(16,15),(16,16),(16,35),(17,1),(17,2),(17,3),(17,5),(17,6),(17,11),(17,13),(17,14),(17,17),(17,18),(17,19),(17,20),(17,21),(17,33),(18,1),(18,2),(18,3),(18,6),(18,11),(18,18),(19,1),(19,2),(19,3),(19,6),(19,11),(19,13),(19,14),(19,18),(19,19),(19,21),(20,1),(20,2),(20,3),(20,6),(20,11),(20,13),(20,14),(20,20),(21,1),(21,2),(21,3),(21,6),(21,11),(21,13),(21,14),(21,18),(21,21),(22,1),(22,2),(22,3),(22,6),(22,11),(22,13),(22,14),(22,18),(22,21),(22,22),(30,1),(30,2),(30,3),(30,5),(30,6),(30,11),(30,13),(30,14),(30,18),(30,19),(30,20),(30,21),(30,22),(30,30),(30,33),(31,1),(31,2),(31,3),(31,6),(31,11),(31,31),(32,1),(32,2),(32,3),(32,6),(32,11),(32,32),(33,33),(34,1),(34,2),(34,3),(34,6),(34,11),(34,33),(34,34),(35,1),(35,2),(35,3),(35,6),(35,11),(35,35),(36,1),(36,2),(36,3),(36,6),(36,11),(36,36);
/*!40000 ALTER TABLE `roleRole` ENABLE KEYS */;
UNLOCK TABLES;
@ -42,7 +42,7 @@ UNLOCK TABLES;
LOCK TABLES `roleInherit` WRITE;
/*!40000 ALTER TABLE `roleInherit` DISABLE KEYS */;
INSERT INTO `roleInherit` VALUES (9,0),(5,1),(13,1),(18,1),(31,1),(32,1),(34,1),(35,1),(1,2),(5,2),(1,3),(17,5),(30,5),(11,6),(1,11),(2,11),(3,11),(16,13),(17,13),(19,13),(20,13),(21,13),(22,13),(5,14),(13,14),(16,15),(21,18),(5,19),(17,20),(30,20),(19,21),(22,21),(30,22),(5,33),(34,33),(15,35);
INSERT INTO `roleInherit` VALUES (9,0),(5,1),(13,1),(18,1),(31,1),(32,1),(34,1),(35,1),(36,1),(1,2),(5,2),(1,3),(17,5),(30,5),(11,6),(1,11),(2,11),(3,11),(16,13),(17,13),(19,13),(20,13),(21,13),(22,13),(5,14),(13,14),(16,15),(21,18),(5,19),(17,20),(30,20),(19,21),(22,21),(30,22),(5,33),(34,33),(15,35);
/*!40000 ALTER TABLE `roleInherit` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
@ -55,7 +55,7 @@ UNLOCK TABLES;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2018-02-12 13:49:52
-- Dump completed on 2018-02-20 14:01:13
USE `salix`;
-- MySQL dump 10.13 Distrib 5.7.17, for Win64 (x86_64)
--
@ -80,7 +80,7 @@ USE `salix`;
LOCK TABLES `ACL` WRITE;
/*!40000 ALTER TABLE `ACL` DISABLE KEYS */;
INSERT INTO `ACL` VALUES (1,'Account','*','*','ALLOW','ROLE','employee'),(3,'Address','*','*','ALLOW','ROLE','employee'),(5,'AgencyService','*','READ','ALLOW','ROLE','employee'),(7,'Client','*','*','ALLOW','ROLE','employee'),(9,'ClientObservation','*','*','ALLOW','ROLE','employee'),(11,'ContactChannel','*','READ','ALLOW','ROLE','employee'),(13,'Employee','*','READ','ALLOW','ROLE','employee'),(14,'PayMethod','*','READ','ALLOW','ROLE','employee'),(16,'FakeProduction','*','READ','ALLOW','ROLE','employee'),(17,'Warehouse','* ','READ','ALLOW','ROLE','employee'),(18,'State','*','READ','ALLOW','ROLE','employee'),(20,'TicketState','*','*','ALLOW','ROLE','employee'),(24,'Delivery','*','READ','ALLOW','ROLE','employee'),(25,'Zone','*','READ','ALLOW','ROLE','employee'),(26,'ClientCredit','*','*','ALLOW','ROLE','employee'),(27,'ClientCreditLimit','*','READ','ALLOW','ROLE','employee'),(28,'ClientObservation','*','READ','ALLOW','ROLE','employee'),(30,'GreugeType','*','READ','ALLOW','ROLE','employee'),(31,'Mandate','*','READ','ALLOW','ROLE','employee'),(32,'MandateType','*','READ','ALLOW','ROLE','employee'),(33,'Company','*','READ','ALLOW','ROLE','employee'),(34,'Greuge','*','READ','ALLOW','ROLE','employee'),(35,'AddressObservation','*','*','ALLOW','ROLE','employee');
INSERT INTO `ACL` VALUES (1,'Account','*','*','ALLOW','ROLE','employee'),(3,'Address','*','*','ALLOW','ROLE','employee'),(5,'AgencyService','*','READ','ALLOW','ROLE','employee'),(7,'Client','*','*','ALLOW','ROLE','employee'),(9,'ClientObservation','*','*','ALLOW','ROLE','employee'),(11,'ContactChannel','*','READ','ALLOW','ROLE','employee'),(13,'Employee','*','READ','ALLOW','ROLE','employee'),(14,'PayMethod','*','READ','ALLOW','ROLE','employee'),(16,'FakeProduction','*','READ','ALLOW','ROLE','employee'),(17,'Warehouse','* ','READ','ALLOW','ROLE','employee'),(18,'State','*','READ','ALLOW','ROLE','employee'),(20,'TicketState','*','*','ALLOW','ROLE','employee'),(24,'Delivery','*','READ','ALLOW','ROLE','employee'),(25,'Zone','*','READ','ALLOW','ROLE','employee'),(26,'ClientCredit','*','*','ALLOW','ROLE','employee'),(27,'ClientCreditLimit','*','READ','ALLOW','ROLE','employee'),(28,'ClientObservation','*','READ','ALLOW','ROLE','employee'),(30,'GreugeType','*','READ','ALLOW','ROLE','employee'),(31,'Mandate','*','READ','ALLOW','ROLE','employee'),(32,'MandateType','*','READ','ALLOW','ROLE','employee'),(33,'Company','*','READ','ALLOW','ROLE','employee'),(34,'Greuge','*','READ','ALLOW','ROLE','employee'),(35,'AddressObservation','*','*','ALLOW','ROLE','employee'),(36,'ObservationType','*','*','ALLOW','ROLE','employee'),(37,'Greuge','*','WRITE','ALLOW','ROLE','employee'),(38,'AgencyMode','*','READ','ALLOW','ROLE','employee'),(39,'ItemTag','*','WRITE','ALLOW','ROLE','buyer'),(40,'ItemBotanical','*','WRITE','ALLOW','ROLE','buyer'),(41,'ItemBotanical','*','READ','ALLOW','ROLE','employee'),(42,'ItemPlacement','*','WRITE','ALLOW','ROLE','buyer'),(43,'ItemPlacement','*','WRITE','ALLOW','ROLE','replenisher'),(44,'ItemPlacement','*','READ','ALLOW','ROLE','employee'),(45,'ItemBarcode','*','READ','ALLOW','ROLE','employee'),(46,'ItemBarcode','*','WRITE','ALLOW','ROLE','buyer'),(47,'ItemBarcode','*','WRITE','ALLOW','ROLE','replenisher'),(48,'ItemNiche','*','READ','ALLOW','ROLE','employee'),(49,'ItemNiche','*','WRITE','ALLOW','ROLE','buyer'),(50,'ItemNiche','*','WRITE','ALLOW','ROLE','replenisher'),(51,'ItemTag','*','READ','ALLOW','ROLE','employee'),(52,'ItemTag','*','WRITE','ALLOW','ROLE','buyer'),(53,'Item','*','READ','ALLOW','ROLE','employee'),(54,'Item','*','WRITE','ALLOW ','ROLE','buyer');
/*!40000 ALTER TABLE `ACL` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
@ -93,4 +93,4 @@ UNLOCK TABLES;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2018-02-12 13:49:52
-- Dump completed on 2018-02-20 14:01:13

View File

@ -1,6 +1,14 @@
INSERT INTO `util`.`config` ( `dbVersion`, `hasTriggersDisabled`, `environment`)
VALUES ('1.0.0', '0', 'development');
INSERT INTO `account`.`user`(`name`,`password`,`role`,`active`,`email`)
SELECT name,'ac754a330530832ba1bf7687f577da91',id,1,CONCAT(name,'@verdnatura.es')
FROM `account`.`role`;
INSERT INTO `vn`.`worker`(`workerCode`, `firstName`, `name`, `userFk`)
SELECT UPPER(LPAD(role, 3, '0')),name,name,id
FROM `vn`.`user`;
INSERT INTO `account`.`user`(`id`,`name`,`password`,`role`,`active`,`email`)
VALUES
(1, 'BruceWayne', 'ac754a330530832ba1bf7687f577da91', 2, 1, 'BruceWayne@verdnatura.es'),
@ -15,10 +23,6 @@ INSERT INTO `account`.`user`(`id`,`name`,`password`,`role`,`active`,`email`)
(10, 'JessicaJones', 'ac754a330530832ba1bf7687f577da91', 9, 1, 'JessicaJones@verdnatura.es'),
(11, 'Cyborg', 'ac754a330530832ba1bf7687f577da91', 1, 1, 'cyborg@verdnatura.es');
INSERT INTO `account`.`user`(`name`,`password`,`role`,`active`,`email`)
SELECT name,'ac754a330530832ba1bf7687f577da91',id,1,CONCAT(name,'@verdnatura.es')
FROM `account`.`role`;
INSERT INTO `vn`.`country`(`id`, `country`, `isUeeMember`, `code`, `currencyFk`)
VALUES
(1, 'España', 0, 'ES', 1),
@ -186,9 +190,9 @@ INSERT INTO `vn`.`clientCredit`(`id`, `clientFk`, `workerFk`, `amount`, `created
INSERT INTO `vn`.`clientCreditLimit`(`id`, `maxAmount`, `roleFk`)
VALUES
(1, 1000, 5),
(2, 600, 5),
(3, 0, 5);
(1, 9999999, 5),
(2, 10000, 5),
(3, 600, 5);
INSERT INTO `vn`.`clientObservation`(`id`, `clientFk`, `workerFk`, `text`, `created`)
VALUES
@ -418,10 +422,10 @@ INSERT INTO `salix`.`user`(`id`,`username`,`password`,`email`)
VALUES
(10, 'JessicaJones', 'ac754a330530832ba1bf7687f577da91', 'JessicaJones@verdnatura.es');
INSERT INTO `vn`.`tag`(`id`,`name`,`free`,`isQuantitatif`,`sourceTable`,`unit`)
INSERT INTO `vn`.`tag`(`id`,`name`,`isFree`,`isQuantitatif`,`sourceTable`,`unit`)
VALUES
(1, 'Color', 1, 0, null, null),
(2, 'Power', 1, 0, null, null),
(1, 'Color', 0, 0, null, null),
(2, 'Power', 0, 0, null, null),
(3, 'Shape', 1, 0, null, null),
(4, 'Location', 1, 0, null, null),
(5, 'Owner', 1, 1, null, null);
@ -436,4 +440,4 @@ INSERT INTO `vn`.`itemTag`(`id`,`itemFk`,`tagFk`,`value`,`priority`)
INSERT INTO `vn`.`itemLog` (`id`, `originFk`, `userFk`, `action`, `description`)
VALUES
('1', '1', '1', 'insert', 'We made an change!');
('1', '1', '1', 'insert', 'We made an change!');

View File

@ -0,0 +1,2 @@
ALTER TABLE `vn2008`.`Articles_nicho`
ADD UNIQUE INDEX `Id_Article_UNIQUE` (`Id_Article` ASC, `warehouse_id` ASC);

View File

@ -0,0 +1,2 @@
ALTER TABLE `vn`.`tag`
CHANGE COLUMN `free` `isFree` TINYINT(1) NOT NULL DEFAULT '1' ;

View File

@ -0,0 +1,5 @@
echo USE `account`; > 02-dumpedFixtures.sql
mysqldump --defaults-file=connect.ini --no-create-info account role roleRole roleInherit >> 02-dumpedFixtures.sql
echo USE `salix`; >> 02-dumpedFixtures.sql
mysqldump --defaults-file=connect.ini --no-create-info salix ACL >> 02-dumpedFixtures.sql

View File

@ -1,7 +1,2 @@
mysqldump --defaults-file=connect.ini --default-character-set=utf8 --no-data --triggers --routines --events --databases account util vn2008 vn edi bs bi pbx cache salix vncontrol hedera > 01-structure.sql
echo USE `account`; > 02-dumpedFixtures.sql
mysqldump --defaults-file=connect.ini --no-create-info account role roleRole roleInherit >> 02-dumpedFixtures.sql
echo USE `salix`; >> 02-dumpedFixtures.sql
mysqldump --defaults-file=connect.ini --no-create-info salix ACL >> 02-dumpedFixtures.sql

View File

@ -0,0 +1,59 @@
var UserError = require('../../../../loopback/common/helpers').UserError;
module.exports = Self => {
Self.remoteMethod('clone', {
description: 'clone item',
accessType: 'WRITE',
accepts: [{
arg: 'id',
type: 'number',
required: true,
description: 'origin itemId',
http: {source: 'path'}
}],
returns: {
arg: 'id',
description: 'new cloned itemId'
},
http: {
path: `/:id/clone`,
verb: 'post'
}
});
Self.clone = async (itemId, callback) => {
let filter = {
where: {
id: itemId
},
include: [
{relation: "itemTag", scope: {order: "priority ASC", include: {relation: "tag"}}}
]
};
try {
let origin = await Self.findOne(filter);
let copy = JSON.parse(JSON.stringify(origin));
delete copy.id;
delete copy.itemTag;
let newItem = await Self.create(copy);
let promises = [];
let createBotanical = `INSERT INTO vn.itemBotanical (itemFk, botanical, genusFk, specieFk)
SELECT ?, botanical, genusFk, specieFk
FROM vn.itemBotanical ib WHERE itemFk = ?`;
promises.push(Self.rawSql(createBotanical, [newItem.id, origin.id]));
let createTags = `INSERT INTO vn.itemTag (itemFk, tagFk, value, priority)
SELECT ?, tagFk, value, priority
FROM vn.itemTag WHERE itemFk = ?`;
promises.push(Self.rawSql(createTags, [newItem.id, origin.id]));
await Promise.all(promises);
return newItem.id;
} catch (err) {
throw new UserError(err);
}
};
};

View File

@ -0,0 +1,36 @@
module.exports = Self => {
Self.remoteMethod('crudItemNiches', {
description: 'create, update or delete niches',
accessType: 'WRITE',
accepts: [
{
arg: 'niches',
type: 'Object',
require: true,
description: 'object with niches to create, update or delete, Example: {create: [], update: [], delete: []}',
http: {source: 'body'}
}
],
http: {
path: `/crudItemNiches`,
verb: 'post'
}
});
Self.crudItemNiches = niches => {
let promises = [];
if (niches.delete && niches.delete.length) {
promises.push(Self.destroyAll({id: {inq: niches.delete}}));
}
if (niches.create.length) {
promises.push(Self.create(niches.create));
}
if (niches.update.length) {
niches.update.forEach(niche => {
promises.push(Self.upsert(niche));
});
}
return Promise.all(promises);
};
};

View File

@ -0,0 +1,51 @@
const crudItemNiches = require('../crudItemNiches');
const catchErrors = require('../../../../../../services/utils/jasmineHelpers').catchErrors;
describe('Item crudItemNiches()', () => {
it('should call the destroyAll method if there are ids in delete Array', done => {
let self = jasmine.createSpyObj('self', ['remoteMethod', 'crudItemNiches', 'destroyAll', 'create', 'upsert']);
crudItemNiches(self);
self.crudItemNiches({
delete: [1],
create: [],
update: []
}).then(result => {
expect(self.destroyAll).toHaveBeenCalledWith({id: {inq: [1]}});
done();
})
.catch(catchErrors(done));
});
it('should call the create method if there are ids in create Array', done => {
let self = jasmine.createSpyObj('self', ['remoteMethod', 'crudItemNiches', 'destroyAll', 'create', 'upsert']);
crudItemNiches(self);
self.crudItemNiches({
delete: [],
create: [1],
update: []
}).then(result => {
expect(self.create).toHaveBeenCalledWith([1]);
done();
})
.catch(catchErrors(done));
});
it('should call the upsert method as many times as ids in update Array', done => {
let self = jasmine.createSpyObj('self', ['remoteMethod', 'crudItemNiches', 'destroyAll', 'create', 'upsert']);
crudItemNiches(self);
self.crudItemNiches({
delete: [],
create: [],
update: [1, 2]
}).then(result => {
expect(self.upsert).toHaveBeenCalledWith(1);
expect(self.upsert).toHaveBeenCalledWith(2);
expect(self.upsert.calls.count()).toEqual(2);
done();
})
.catch(catchErrors(done));
});
});

View File

@ -25,5 +25,13 @@
"model": "TaxType",
"foreignKey": "taxTypeFk"
}
}
},
"acls": [
{
"accessType": "READ",
"principalType": "ROLE",
"principalId": "$everyone",
"permission": "ALLOW"
}
]
}

View File

@ -24,5 +24,13 @@
"change_date_time": {
"type": "date"
}
}
},
"acls": [
{
"accessType": "READ",
"principalType": "ROLE",
"principalId": "$everyone",
"permission": "ALLOW"
}
]
}

Some files were not shown because too many files have changed in this diff Show More