diff --git a/client/core/src/lib/validator.js b/client/core/src/lib/validator.js index c8e2b5e27..9f8d6d53f 100644 --- a/client/core/src/lib/validator.js +++ b/client/core/src/lib/validator.js @@ -2,7 +2,7 @@ import {validator} from 'vendor'; export const validators = { presence: value => { - if (validator.isEmpty(value.toString())) + if (validator.isEmpty(value ? String(value) : '')) throw new Error(`Value can't be empty`); }, absence: value => { diff --git a/e2e/helpers/nightmare.js b/e2e/helpers/nightmare.js index 777d17862..8bc84526d 100644 --- a/e2e/helpers/nightmare.js +++ b/e2e/helpers/nightmare.js @@ -4,11 +4,11 @@ import Nightmare from 'nightmare'; export default function createNightmare(width = 1280, height = 720) { const nightmare = new Nightmare({show: true, typeInterval: 10, x: 0, y: 0}).viewport(width, height); - nightmare.on('page', function(type, message, error) { + nightmare.on('page', (type, message, error) => { fail(error); }); - nightmare.on('console', function(type, message) { + nightmare.on('console', (type, message) => { if (type === 'error') { fail(message); } diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 514abb232..90003ed42 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -128,7 +128,7 @@ export default { greuge: { greugeButton: `${components.vnMenuItem}[ui-sref="clientCard.greuge.list"]`, addGreugeFloatButton: `${components.vnFloatButton}`, - amountInput: `${components.vnTextfield}[name="Amount"]`, + amountInput: `${components.vnTextfield}[name="amount"]`, descriptionInput: `${components.vnTextfield}[name="Description"]`, 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`, diff --git a/e2e/paths/09_add_greuge.spec.js b/e2e/paths/09_add_greuge.spec.js index 06c781ef4..a2cab1a5d 100644 --- a/e2e/paths/09_add_greuge.spec.js +++ b/e2e/paths/09_add_greuge.spec.js @@ -108,18 +108,18 @@ describe('Add greuge path', () => { .catch(catchErrors(done)); }); - // it(`should receive an error if all fields are empty but date and amount on submit`, done => { - // nightmare - // .type(selectors.greuge.amountInput, 999) - // .click(selectors.credit.saveButton) - // .wait(selectors.globalItems.snackbarIsActive) - // .getInnerText(selectors.globalItems.snackbarIsActive) - // .then(result => { - // expect(result).toContain('Error'); - // done(); - // }) - // .catch(catchErrors(done)); - // }); + it(`should receive an error if all fields are empty but date and amount on submit`, done => { + nightmare + .type(selectors.greuge.amountInput, 999) + .click(selectors.greuge.saveButton) + .wait(selectors.globalItems.snackbarIsActive) + .getInnerText(selectors.globalItems.snackbarIsActive) + .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