e2e tests on clients path

This commit is contained in:
Carlos 2017-09-11 16:12:32 +02:00
parent 0cc707bc2c
commit f5fd729634
4 changed files with 56 additions and 13 deletions

View File

@ -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();
});
});
});

View File

@ -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();
});
});
});

View File

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

View File

@ -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();
});
});