diff --git a/e2e/clients_path/clients.spec.js b/e2e/clients_path/clients.spec.js deleted file mode 100644 index a01aff850..000000000 --- a/e2e/clients_path/clients.spec.js +++ /dev/null @@ -1,12 +0,0 @@ -import createNightmare from '../nightmare'; -const nightmare = createNightmare(); - -describe('Clients path', () => { - it('should create a new client', done => { - // nightmare user to go any further. - nightmare.login('Nightmare', 'NightmarePassword') - .then(() => { - done(); - }); - }); -}); diff --git a/e2e/clients_path/clients_path.spec.js b/e2e/clients_path/clients_path.spec.js new file mode 100644 index 000000000..fc11e40c3 --- /dev/null +++ b/e2e/clients_path/clients_path.spec.js @@ -0,0 +1,49 @@ +import createNightmare from '../nightmare'; +const nightmare = createNightmare(); + +describe('Clients path', () => { + it('should log in', done => { + // nightmare user to go any further. + nightmare + .login('Nightmare', 'NightmarePassword') + .wait('body > vn-app > vn-vertical > vn-topbar') + .url() + .then(url => { + expect(url).toBe('http://localhost:5000/#!/'); + done(); + }); + }); + + it('should access to the clients index by clicking the clients button', done => { + nightmare + .click('body > vn-app > vn-vertical > vn-vertical > vn-home > vn-vertical > vn-module-container > a:nth-child(1)') + .wait('body > vn-app > vn-vertical > vn-vertical > vn-client-index > div > a > vn-float-button > button') + .url() + .then(url => { + expect(url).toBe('http://localhost:5000/#!/clients'); + done(); + }); + }); + + it('should access to the create client by clicking the create-client button', done => { + nightmare + .click('body > vn-app > vn-vertical > vn-vertical > vn-client-index > div > a > vn-float-button > button') + .wait('body > vn-app > vn-vertical > vn-vertical > vn-client-create > form > div > vn-card > div > vn-vertical > vn-title > h3') + .url() + .then(url => { + expect(url).toBe('http://localhost:5000/#!/create'); + done(); + }); + }); + + it('should receive an error when clicking the create button having all the form fields empty', done => { + nightmare + .click('body > vn-app > vn-vertical > vn-vertical > vn-client-create > form > div > vn-button-bar > vn-button > button') + .wait('body > vn-app > vn-vertical > vn-snackbar > div > div') + .getInnerText('body > vn-app > vn-vertical > vn-snackbar > div > div') + .then(result => { + expect(result).toBe('No hay cambios que guardar'); + done(); + }); + }); +}); diff --git a/e2e/helpers.js b/e2e/helpers.js index 49f46eaaa..b40bd67d0 100644 --- a/e2e/helpers.js +++ b/e2e/helpers.js @@ -8,3 +8,10 @@ Nightmare.action('login', function(name, password, done) { .click('input[type="submit"]') .then(done); }); + +Nightmare.action('getInnerText', function(selector, done) { + this.wait(selector) + .evaluate_now(function(elementToSelect) { + return document.querySelector(elementToSelect).innerText; + }, done, selector); +}); diff --git a/services/client/common/methods/client/specs/create.spec.js b/services/client/common/methods/client/specs/create.spec.js index bed7e9796..0674802b9 100644 --- a/services/client/common/methods/client/specs/create.spec.js +++ b/services/client/common/methods/client/specs/create.spec.js @@ -20,7 +20,6 @@ describe('Client Create()', () => { //connect to db and query for the new account OR use accounts model to check it like this app.models.Account.findOne({where: {name: 'John'}}) .then((account) => { - console.log(account); done(); }); });