From 639c7e901e903e2f495f5af74230f15cc5000d15 Mon Sep 17 00:00:00 2001 From: Carlos Date: Sun, 17 Sep 2017 20:01:15 +0200 Subject: [PATCH] e2e client path tests, full user creation pending --- e2e/helpers/selectors.js | 6 +-- e2e/paths/clients_path.spec.js | 89 ++++++++++++++++++++++++++++++++++ 2 files changed, 92 insertions(+), 3 deletions(-) diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index a4900fca9d..f65d1f549a 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -18,9 +18,9 @@ export default { createClientView: { name: 'body > vn-app > vn-vertical > vn-vertical > vn-client-create > form > div > vn-card > div > vn-vertical > vn-horizontal:nth-child(2) > vn-textfield:nth-child(1) > div > input', taxNumber: 'body > vn-app > vn-vertical > vn-vertical > vn-client-create > form > div > vn-card > div > vn-vertical > vn-horizontal:nth-child(2) > vn-textfield:nth-child(2) > div > input', - BusinessName: 'body > vn-app > vn-vertical > vn-vertical > vn-client-create > form > div > vn-card > div > vn-vertical > vn-horizontal:nth-child(2) > vn-textfield:nth-child(3) > div > input', - UserName: 'body > vn-app > vn-vertical > vn-vertical > vn-client-create > form > div > vn-card > div > vn-vertical > vn-horizontal:nth-child(2) > vn-textfield:nth-child(4) > div > input', - email: 'body > vn-app > vn-vertical > vn-vertical > vn-client-create > form > div > vn-card > div > vn-vertical > vn-horizontal:nth-child(2) > vn-textfield:nth-child(5) > div > input', + businessName: 'body > vn-app > vn-vertical > vn-vertical > vn-client-create > form > div > vn-card > div > vn-vertical > vn-horizontal:nth-child(3) > vn-textfield:nth-child(1) > div > input', + userName: 'body > vn-app > vn-vertical > vn-vertical > vn-client-create > form > div > vn-card > div > vn-vertical > vn-horizontal:nth-child(3) > vn-textfield:nth-child(2) > div > input', + email: 'body > vn-app > vn-vertical > vn-vertical > vn-client-create > form > div > vn-card > div > vn-vertical > vn-horizontal:nth-child(4) > vn-textfield > div > input', createButton: 'body > vn-app > vn-vertical > vn-vertical > vn-client-create > form > div > vn-button-bar > vn-button > button' } }; diff --git a/e2e/paths/clients_path.spec.js b/e2e/paths/clients_path.spec.js index 27547fa05a..0e9903e933 100644 --- a/e2e/paths/clients_path.spec.js +++ b/e2e/paths/clients_path.spec.js @@ -55,4 +55,93 @@ describe('Clients path', () => { done(); }); }); + + it('should receive an error when clicking the create button having all the form fields empty but name', done => { + nightmare + .wait(3000) + .type(selectors.createClientView.name, 'Bruce Wayne') + .click(selectors.createClientView.createButton) + .wait(100) + .wait(selectors.globalItems.snackbar) + .getInnerText(selectors.globalItems.snackbar) + .then(result => { + expect(result).toContain(`Error:`); + done(); + }); + }); + + it('should receive an error when clicking the create button having all the form fields empty but Tax Number', done => { + nightmare + .wait(3000) + .clearInput(selectors.createClientView.name) + .type(selectors.createClientView.taxNumber, 'Wayne Industries Tax Number') + .click(selectors.createClientView.createButton) + .wait(100) + .wait(selectors.globalItems.snackbar) + .getInnerText(selectors.globalItems.snackbar) + .then(result => { + expect(result).toContain(`Error:`); + done(); + }); + }); + + it('should receive an error when clicking the create button having all the form fields empty but Business Name', done => { + nightmare + .wait(3000) + .clearInput(selectors.createClientView.taxNumber) + .type(selectors.createClientView.businessName, 'Wayne Industries') + .click(selectors.createClientView.createButton) + .wait(100) + .wait(selectors.globalItems.snackbar) + .getInnerText(selectors.globalItems.snackbar) + .then(result => { + expect(result).toContain(`Error:`); + done(); + }); + }); + + it('should receive an error when clicking the create button having all the form fields empty but User Name', done => { + nightmare + .wait(3000) + .clearInput(selectors.createClientView.businessName) + .type(selectors.createClientView.userName, 'Batman') + .click(selectors.createClientView.createButton) + .wait(100) + .wait(selectors.globalItems.snackbar) + .getInnerText(selectors.globalItems.snackbar) + .then(result => { + expect(result).toContain(`Error:`); + 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 + .wait(3000) + .clearInput(selectors.createClientView.userName) + .type(selectors.createClientView.email, 'I will save Gotham!') + .click(selectors.createClientView.createButton) + .wait(100) + .wait(selectors.globalItems.snackbar) + .getInnerText(selectors.globalItems.snackbar) + .then(result => { + expect(result).toBe(`Algunos campos no son vĂ¡lidos`); + done(); + }); + }); + + it('should receive an error when clicking the create button having all the form fields empty but email', done => { + nightmare + .wait(3000) + .clearInput(selectors.createClientView.email) + .type(selectors.createClientView.email, 'IAmBatman@WayneIndustries.gotham') + .click(selectors.createClientView.createButton) + .wait(100) + .wait(selectors.globalItems.snackbar) + .getInnerText(selectors.globalItems.snackbar) + .then(result => { + expect(result).toContain(`Error:`); + done(); + }); + }); });