diff --git a/client/client/src/fiscal-data/fiscal-data.html b/client/client/src/fiscal-data/fiscal-data.html index ce221c67f..73d9a96cc 100644 --- a/client/client/src/fiscal-data/fiscal-data.html +++ b/client/client/src/fiscal-data/fiscal-data.html @@ -11,10 +11,10 @@ Fiscal data - + - + @@ -37,7 +37,7 @@ url="/client/api/Countries" show-field="name" value-field="id" - label="País"> + label="CountryFk"> diff --git a/client/client/src/locale/es.json b/client/client/src/locale/es.json index 3a36dab65..c3bc8aac5 100644 --- a/client/client/src/locale/es.json +++ b/client/client/src/locale/es.json @@ -1,5 +1,8 @@ { "Client": "Cliente", "Clients": "Clientes", - "Fiscal data": "Datos Fiscales" + "Fiscal data": "Datos Fiscales", + "Has to invoice": "Factura", + "Invoice by mail": "Factura impresa", + "CountryFk": "País" } \ No newline at end of file diff --git a/e2e/helpers/selector_variables.js b/e2e/helpers/components_selectors.js similarity index 89% rename from e2e/helpers/selector_variables.js rename to e2e/helpers/components_selectors.js index 7b4d4eae2..87dc22c69 100644 --- a/e2e/helpers/selector_variables.js +++ b/e2e/helpers/components_selectors.js @@ -13,5 +13,6 @@ export default { vnItemClient: 'vn-item-client', vnFloatButton: 'vn-float-button > button', vnMenuItem: 'vn-menu-item > li > a', - vnAutocomplete: 'vn-autocomplete' + vnAutocomplete: 'vn-autocomplete', + vnCheck: 'vn-check' }; diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index c832dd8a6..97c496bbf 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -1,16 +1,6 @@ // eslint max-len: ["error", 500] // eslint key-spacing: ["error", 500] -import components from './selector_variables.js'; - -function checkElement(selector, attributeValue) { - let aux = selector.split(' '); - if (aux[0] === 'vn-autocomplete') { - return selector.replace(aux[0], `${aux[0]}[field="${attributeValue}"]`); - } - if (aux[0] === 'vn-textfield') { - return selector.replace(aux[4], `${aux[4]}[name="${attributeValue}"]`); - } -} +import components from './components_selectors.js'; export default { login: { @@ -35,34 +25,34 @@ export default { createClientButton: `${components.vnFloatButton}` }, createClientView: { - name: `${checkElement(components.vnTextfield, 'name')}`, - taxNumber: `${checkElement(components.vnTextfield, 'fi')}`, - socialName: `${checkElement(components.vnTextfield, 'socialName')}`, - userName: `${checkElement(components.vnTextfield, 'userName')}`, - email: `${checkElement(components.vnTextfield, 'email')}`, + name: `${components.vnTextfield}[name="name"]`, + taxNumber: `${components.vnTextfield}[name="fi"]`, + socialName: `${components.vnTextfield}[name="socialName"]`, + userName: `${components.vnTextfield}[name="userName"]`, + email: `${components.vnTextfield}[name="email"]`, createButton: `${components.vnSubmit}` }, basicData: { - basicDataButton: `${components.vnMenuItem}`, - nameInput: `${checkElement(components.vnTextfield, 'name')}`, - taxNumberInput: `${checkElement(components.vnTextfield, 'fi')}`, - socialNameInput: `${checkElement(components.vnTextfield, 'socialName')}`, - phoneInput: `${checkElement(components.vnTextfield, 'phone')}`, - mobileInput: `${checkElement(components.vnTextfield, 'mobile')}`, - faxInput: `${checkElement(components.vnTextfield, 'fax')}`, - emailInput: `${checkElement(components.vnTextfield, 'email')}`, - salesPersonInput: `${checkElement(components.vnAutocomplete, '$ctrl.client.salesPersonFk')}`, - channelInput: 'body > vn-app > vn-vertical > vn-vertical > vn-client-card > vn-horizontal > vn-auto > vn-vertical > vn-client-basic-data > form > vn-card > div > vn-vertical > vn-horizontal:nth-child(4) > vn-autocomplete:nth-child(3) > vn-vertical > vn-textfield > div > input', - channelMetropolisOption: 'body > vn-app > vn-vertical > vn-vertical > vn-client-card > vn-horizontal > vn-auto > vn-vertical > vn-client-basic-data > form > vn-card > div > vn-vertical > vn-horizontal:nth-child(4) > vn-autocomplete:nth-child(3) > vn-vertical > vn-drop-down > vn-vertical > vn-one:nth-child(2) > ul > li:nth-child(3)', - saveButton: 'body > vn-app > vn-vertical > vn-vertical > vn-client-card > vn-horizontal > vn-auto > vn-vertical > vn-client-basic-data > form > vn-button-bar > vn-submit > input' + basicDataButton: `${components.vnMenuItem}[ui-sref="clientCard.basicData"]`, + nameInput: `${components.vnTextfield}[name="name"]`, + taxNumberInput: `${components.vnTextfield}[name="fi"]`, + socialNameInput: `${components.vnTextfield}[name="socialName"]`, + phoneInput: `${components.vnTextfield}[name="phone"]`, + mobileInput: `${components.vnTextfield}[name="mobile"]`, + faxInput: `${components.vnTextfield}[name="fax"]`, + emailInput: `${components.vnTextfield}[name="email"]`, + salesPersonInput: `${components.vnAutocomplete}[field="$ctrl.client.salesPersonFk"]`, + 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 > vn-one:nth-child(2) > ul > li:nth-child(3)`, + saveButton: `${components.vnSubmit}` }, fiscalData: { - fiscalDataButton: 'body > vn-app > vn-vertical > vn-vertical > vn-client-card > vn-horizontal > vn-empty > vn-left-menu > vn-card > div > vn-vertical > vn-actions > vn-horizontal > ul > vn-menu-item:nth-child(2) > li > a', - addressInput: 'body > vn-app > vn-vertical > vn-vertical > vn-client-card > vn-horizontal > vn-auto > vn-vertical > vn-client-fiscal-data > form > vn-card > div > vn-vertical > vn-horizontal:nth-child(3) > vn-textfield:nth-child(1) > div > input', - hasToInvoiceCheckboxLabel: 'body > vn-app > vn-vertical > vn-vertical > vn-client-card > vn-horizontal > vn-auto > vn-vertical > vn-client-fiscal-data > form > vn-card > div > vn-vertical > vn-horizontal:nth-child(2) > vn-one:nth-child(1) > vn-check > label', - hasToInvoiceCheckboxInput: 'body > vn-app > vn-vertical > vn-vertical > vn-client-card > vn-horizontal > vn-auto > vn-vertical > vn-client-fiscal-data > form > vn-card > div > vn-vertical > vn-horizontal:nth-child(2) > vn-one:nth-child(1) > vn-check > label > input', - // printToInvoiceCheckboxLabel: '', - // printInvoiceCheckboxInput: '', + fiscalDataButton: `${components.vnMenuItem}[ui-sref="clientCard.fiscalData"]`, + hasToInvoiceCheckboxLabel: `${components.vnCheck}[label='Has to invoice'] > label`, + hasToInvoiceCheckboxInput: `${components.vnCheck}[label='Has to invoice'] > label > label > input`, + invoiceByMailCheckboxLabel: `${components.vnCheck}[label='Invoice by mail'] > label`, + invoiceByMailCheckboxInput: `${components.vnCheck}[label='Invoice by mail'] > label > label > input`, + addressInput: `${components.vnTextfield}[name="street"]`, saveButton: 'body > vn-app > vn-vertical > vn-vertical > vn-client-card > vn-horizontal > vn-auto > vn-vertical > vn-client-fiscal-data > form > vn-button-bar > vn-submit > input' } }; diff --git a/e2e/paths/create_client_path.spec.js b/e2e/paths/create_client_path.spec.js index 42b416ab1..b9107bf2c 100644 --- a/e2e/paths/create_client_path.spec.js +++ b/e2e/paths/create_client_path.spec.js @@ -25,7 +25,7 @@ describe('create client path', () => { .waitForURL(moduleAccessViewHashURL) .url() .then(url => { - expect(url).toBe(config.url + moduleAccessViewHashURL); + expect(url).toEqual(config.url + moduleAccessViewHashURL); done(); }) .catch(catchErrors(done)); @@ -37,7 +37,7 @@ describe('create client path', () => { .wait(selectors.clientsIndex.createClientButton) .url() .then(url => { - expect(url).toBe(config.url + '#!/clients'); + expect(url).toEqual(config.url + '#!/clients'); done(); }) .catch(catchErrors(done)); @@ -51,7 +51,7 @@ describe('create client path', () => { .waitForNumberOfElements(selectors.clientsIndex.searchResult, 0) .countSearchResults(selectors.clientsIndex.searchResult) .then(result => { - expect(result).toBe(0); + expect(result).toEqual(0); done(); }) .catch(catchErrors(done)); @@ -63,7 +63,7 @@ describe('create client path', () => { .wait(selectors.createClientView.createButton) .url() .then(url => { - expect(url).toBe(config.url + '#!/create'); + expect(url).toEqual(config.url + '#!/create'); done(); }) .catch(catchErrors(done)); @@ -75,7 +75,7 @@ describe('create client path', () => { .wait(selectors.globalItems.snackbarIsActive) .getInnerText(selectors.globalItems.snackbarIsActive) .then(result => { - expect(result).toBe('No hay cambios que guardar'); + expect(result).toEqual('No hay cambios que guardar'); done(); }) .catch(catchErrors(done)); @@ -149,7 +149,7 @@ describe('create client path', () => { .wait(selectors.globalItems.snackbarIsActive) .getInnerText(selectors.globalItems.snackbarIsActive) .then(result => { - expect(result).toBe(`Algunos campos no son válidos`); + expect(result).toEqual(`Algunos campos no son válidos`); done(); }) .catch(catchErrors(done)); @@ -198,7 +198,7 @@ describe('create client path', () => { .wait(selectors.clientsIndex.createClientButton) .url() .then(url => { - expect(url).toBe(config.url + '#!/clients'); + expect(url).toEqual(config.url + '#!/clients'); done(); }) .catch(catchErrors(done)); @@ -212,7 +212,7 @@ describe('create client path', () => { .waitForNumberOfElements(selectors.clientsIndex.searchResult, 1) .countSearchResults(selectors.clientsIndex.searchResult) .then(result => { - expect(result).toBe(1); + expect(result).toEqual(1); done(); }) .catch(catchErrors(done)); diff --git a/e2e/paths/edit_basic_data.spec.js b/e2e/paths/edit_basic_data.spec.js index d8d79a9e9..0c8436a0c 100644 --- a/e2e/paths/edit_basic_data.spec.js +++ b/e2e/paths/edit_basic_data.spec.js @@ -25,7 +25,7 @@ describe('Edit basicData path', () => { .waitForURL(moduleAccessViewHashURL) .url() .then(url => { - expect(url).toBe(config.url + moduleAccessViewHashURL); + expect(url).toEqual(config.url + moduleAccessViewHashURL); done(); }) .catch(catchErrors(done)); @@ -39,7 +39,7 @@ describe('Edit basicData path', () => { .wait(selectors.clientsIndex.createClientButton) .url() .then(url => { - expect(url).toBe(config.url + '#!/clients'); + expect(url).toEqual(config.url + '#!/clients'); done(); }) .catch(catchErrors(done)); @@ -53,7 +53,7 @@ describe('Edit basicData path', () => { .waitForNumberOfElements(selectors.clientsIndex.searchResult, 1) .countSearchResults(selectors.clientsIndex.searchResult) .then(result => { - expect(result).toBe(1); + expect(result).toEqual(1); done(); }) .catch(catchErrors(done)); @@ -81,7 +81,7 @@ describe('Edit basicData path', () => { .wait(selectors.globalItems.snackbarIsActive) .getInnerText(selectors.globalItems.snackbarIsActive) .then(result => { - expect(result).toBe(`¡Datos guardados!`); + expect(result).toEqual(`¡Datos guardados!`); done(); }) .catch(catchErrors(done)); @@ -96,7 +96,7 @@ describe('Edit basicData path', () => { .wait(selectors.basicData.nameInput) .getInputValue(selectors.basicData.nameInput) .then(result => { - expect(result).toBe(`Carol Danvers Edited`); + expect(result).toEqual(`Carol Danvers Edited`); done(); }) .catch(catchErrors(done)); @@ -111,7 +111,7 @@ describe('Edit basicData path', () => { .wait(selectors.globalItems.snackbarIsActive) .getInnerText(selectors.globalItems.snackbarIsActive) .then(result => { - expect(result).toBe(`¡Datos guardados!`); + expect(result).toEqual(`¡Datos guardados!`); done(); }) .catch(catchErrors(done)); @@ -126,7 +126,7 @@ describe('Edit basicData path', () => { .wait(selectors.basicData.taxNumberInput) .getInputValue(selectors.basicData.taxNumberInput) .then(result => { - expect(result).toBe(`AVG tax Edited`); + expect(result).toEqual(`AVG tax Edited`); done(); }) .catch(catchErrors(done)); @@ -141,7 +141,7 @@ describe('Edit basicData path', () => { .wait(selectors.globalItems.snackbarIsActive) .getInnerText(selectors.globalItems.snackbarIsActive) .then(result => { - expect(result).toBe(`¡Datos guardados!`); + expect(result).toEqual(`¡Datos guardados!`); done(); }) .catch(catchErrors(done)); @@ -156,7 +156,7 @@ describe('Edit basicData path', () => { .wait(selectors.basicData.socialNameInput) .getInputValue(selectors.basicData.socialNameInput) .then(result => { - expect(result).toBe(`Avengers Team Edited`); + expect(result).toEqual(`Avengers Team Edited`); done(); }) .catch(catchErrors(done)); @@ -171,7 +171,7 @@ describe('Edit basicData path', () => { .wait(selectors.globalItems.snackbarIsActive) .getInnerText(selectors.globalItems.snackbarIsActive) .then(result => { - expect(result).toBe(`¡Datos guardados!`); + expect(result).toEqual(`¡Datos guardados!`); done(); }) .catch(catchErrors(done)); @@ -186,7 +186,7 @@ describe('Edit basicData path', () => { .wait(selectors.basicData.phoneInput) .getInputValue(selectors.basicData.phoneInput) .then(result => { - expect(result).toBe('123456789'); + expect(result).toEqual('123456789'); done(); }) .catch(catchErrors(done)); @@ -201,7 +201,7 @@ describe('Edit basicData path', () => { .wait(selectors.globalItems.snackbarIsActive) .getInnerText(selectors.globalItems.snackbarIsActive) .then(result => { - expect(result).toBe(`¡Datos guardados!`); + expect(result).toEqual(`¡Datos guardados!`); done(); }) .catch(catchErrors(done)); @@ -216,7 +216,7 @@ describe('Edit basicData path', () => { .wait(selectors.basicData.mobileInput) .getInputValue(selectors.basicData.mobileInput) .then(result => { - expect(result).toBe('987654321'); + expect(result).toEqual('987654321'); done(); }) .catch(catchErrors(done)); @@ -231,7 +231,7 @@ describe('Edit basicData path', () => { .wait(selectors.globalItems.snackbarIsActive) .getInnerText(selectors.globalItems.snackbarIsActive) .then(result => { - expect(result).toBe(`¡Datos guardados!`); + expect(result).toEqual(`¡Datos guardados!`); done(); }) .catch(catchErrors(done)); @@ -246,7 +246,7 @@ describe('Edit basicData path', () => { .wait(selectors.basicData.faxInput) .getInputValue(selectors.basicData.faxInput) .then(result => { - expect(result).toBe('432198765'); + expect(result).toEqual('432198765'); done(); }) .catch(catchErrors(done)); @@ -261,7 +261,7 @@ describe('Edit basicData path', () => { .wait(selectors.globalItems.snackbarIsActive) .getInnerText(selectors.globalItems.snackbarIsActive) .then(result => { - expect(result).toBe(`¡Datos guardados!`); + expect(result).toEqual(`¡Datos guardados!`); done(); }) .catch(catchErrors(done)); @@ -276,7 +276,7 @@ describe('Edit basicData path', () => { .wait(selectors.basicData.emailInput) .getInputValue(selectors.basicData.emailInput) .then(result => { - expect(result).toBe('CarolDanversEdited@verdnatura.es'); + expect(result).toEqual('CarolDanversEdited@verdnatura.es'); done(); }) .catch(catchErrors(done)); @@ -290,7 +290,7 @@ describe('Edit basicData path', () => { // .wait(selectors.globalItems.snackbarIsActive) // .getInnerText(selectors.globalItems.snackbarIsActive) // .then(result => { - // expect(result).toBe(`¡Datos guardados!`); + // expect(result).toEqual(`¡Datos guardados!`); // done(); // }) // .catch(catchErrors(done)); @@ -305,7 +305,7 @@ describe('Edit basicData path', () => { .wait(selectors.globalItems.snackbarIsActive) .getInnerText(selectors.globalItems.snackbarIsActive) .then(result => { - expect(result).toBe(`¡Datos guardados!`); + expect(result).toEqual(`¡Datos guardados!`); done(); }) .catch(catchErrors(done)); @@ -320,7 +320,7 @@ describe('Edit basicData path', () => { .wait(100) .getInputValue(selectors.basicData.channelInput) .then(result => { - expect(result).toBe('Metropolis newspaper'); + expect(result).toEqual('Metropolis newspaper'); done(); }) .catch(catchErrors(done)); diff --git a/e2e/paths/edit_fiscal_data.spec.js b/e2e/paths/edit_fiscal_data.spec.js index 3dcea55a0..add095d7c 100644 --- a/e2e/paths/edit_fiscal_data.spec.js +++ b/e2e/paths/edit_fiscal_data.spec.js @@ -25,7 +25,7 @@ describe('Edit fiscalData path', () => { .waitForURL(moduleAccessViewHashURL) .url() .then(url => { - expect(url).toBe(config.url + moduleAccessViewHashURL); + expect(url).toEqual(config.url + moduleAccessViewHashURL); done(); }) .catch(catchErrors(done)); @@ -39,7 +39,7 @@ describe('Edit fiscalData path', () => { .wait(selectors.clientsIndex.createClientButton) .url() .then(url => { - expect(url).toBe(config.url + '#!/clients'); + expect(url).toEqual(config.url + '#!/clients'); done(); }) .catch(catchErrors(done)); @@ -53,7 +53,7 @@ describe('Edit fiscalData path', () => { .waitForNumberOfElements(selectors.clientsIndex.searchResult, 1) .countSearchResults(selectors.clientsIndex.searchResult) .then(result => { - expect(result).toBe(1); + expect(result).toEqual(1); done(); }) .catch(catchErrors(done)); @@ -80,7 +80,7 @@ describe('Edit fiscalData path', () => { .wait(selectors.globalItems.snackbarIsActive) .getInnerText(selectors.globalItems.snackbarIsActive) .then(result => { - expect(result).toBe('¡Datos guardados!'); + expect(result).toEqual('¡Datos guardados!'); done(); }) .catch(catchErrors(done)); @@ -95,7 +95,37 @@ describe('Edit fiscalData path', () => { .wait(selectors.fiscalData.hasToInvoiceCheckboxLabel) .evaluate(selector => { return document.querySelector(selector).checked; - }, selectors.fiscalData.hasToInvoiceCheckboxInput) + }, selectors.fiscalData.hasToInvoiceCheckboxLabel) + .then(value => { + expect(value).toBeFalsy(); + done(); + }) + .catch(catchErrors(done)); + }); + + it(`should uncheck the invoiceByMail checkbox`, done => { + nightmare + .waitToClick(selectors.fiscalData.invoiceByMailCheckboxLabel) + .waitToClick(selectors.fiscalData.saveButton) + .wait(selectors.globalItems.snackbarIsActive) + .getInnerText(selectors.globalItems.snackbarIsActive) + .then(result => { + expect(result).toEqual('¡Datos guardados!'); + done(); + }) + .catch(catchErrors(done)); + }); + + it(`should confirm invoiceByMail checkbox is unchecked`, done => { + nightmare + .waitForSnackbarReset() + .waitToClick(selectors.basicData.basicDataButton) + .wait(selectors.basicData.nameInput) + .waitToClick(selectors.fiscalData.fiscalDataButton) + .wait(selectors.fiscalData.invoiceByMailCheckboxLabel) + .evaluate(selector => { + return document.querySelector(selector).checked; + }, selectors.fiscalData.invoiceByMailCheckboxLabel) .then(value => { expect(value).toBeFalsy(); done();