2017-09-15 10:24:37 +00:00
|
|
|
import config from '../helpers/config.js';
|
|
|
|
import createNightmare from '../helpers/nightmare';
|
|
|
|
import selectors from '../helpers/selectors.js';
|
2017-09-17 16:09:59 +00:00
|
|
|
import {catchErrors} from '../../services/utils/jasmineHelpers';
|
2017-09-11 14:12:32 +00:00
|
|
|
const nightmare = createNightmare();
|
|
|
|
|
2017-09-18 07:38:50 +00:00
|
|
|
let longWait = 3000;
|
|
|
|
|
2017-09-17 17:09:20 +00:00
|
|
|
jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000;
|
|
|
|
|
2017-09-11 14:12:32 +00:00
|
|
|
describe('Clients path', () => {
|
2017-09-17 13:09:10 +00:00
|
|
|
it('should log in', done => {
|
2017-09-11 14:12:32 +00:00
|
|
|
nightmare
|
2017-09-15 13:36:03 +00:00
|
|
|
.login()
|
2017-09-18 07:38:50 +00:00
|
|
|
.wait(longWait)
|
2017-09-17 16:09:59 +00:00
|
|
|
.wait(selectors.globalItems.topBar)
|
2017-09-11 14:12:32 +00:00
|
|
|
.url()
|
|
|
|
.then(url => {
|
2017-09-15 10:24:37 +00:00
|
|
|
expect(url).toBe(config.url + '#!/');
|
2017-09-11 14:12:32 +00:00
|
|
|
done();
|
2017-09-17 16:09:59 +00:00
|
|
|
})
|
|
|
|
.catch(catchErrors(done));
|
2017-09-11 14:12:32 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should access to the clients index by clicking the clients button', done => {
|
|
|
|
nightmare
|
2017-09-17 16:09:59 +00:00
|
|
|
.click(selectors.moduleAccessView.clientsSectionButton)
|
2017-09-18 07:38:50 +00:00
|
|
|
.wait(longWait)
|
2017-09-17 16:09:59 +00:00
|
|
|
.wait(selectors.clientsView.createClientButton)
|
2017-09-11 14:12:32 +00:00
|
|
|
.url()
|
|
|
|
.then(url => {
|
2017-09-15 10:24:37 +00:00
|
|
|
expect(url).toBe(config.url + '#!/clients');
|
2017-09-11 14:12:32 +00:00
|
|
|
done();
|
2017-09-17 16:09:59 +00:00
|
|
|
})
|
|
|
|
.catch(catchErrors(done));
|
2017-09-11 14:12:32 +00:00
|
|
|
});
|
|
|
|
|
2017-09-17 16:09:59 +00:00
|
|
|
it('should access to the create client view by clicking the create-client floating button', done => {
|
2017-09-11 14:12:32 +00:00
|
|
|
nightmare
|
2017-09-17 16:09:59 +00:00
|
|
|
.click(selectors.clientsView.createClientButton)
|
2017-09-18 07:38:50 +00:00
|
|
|
.wait(longWait)
|
2017-09-17 16:36:44 +00:00
|
|
|
.wait(selectors.createClientView.createButton)
|
2017-09-11 14:12:32 +00:00
|
|
|
.url()
|
|
|
|
.then(url => {
|
2017-09-15 10:24:37 +00:00
|
|
|
expect(url).toBe(config.url + '#!/create');
|
2017-09-11 14:12:32 +00:00
|
|
|
done();
|
2017-09-17 18:43:55 +00:00
|
|
|
})
|
|
|
|
.catch(catchErrors(done));
|
2017-09-11 14:12:32 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should receive an error when clicking the create button having all the form fields empty', done => {
|
|
|
|
nightmare
|
2017-09-17 16:09:59 +00:00
|
|
|
.click(selectors.createClientView.createButton)
|
2017-09-18 07:38:50 +00:00
|
|
|
.wait(selectors.globalItems.snackbarIsActive)
|
|
|
|
.getInnerText(selectors.globalItems.snackbarIsActive)
|
2017-09-11 14:12:32 +00:00
|
|
|
.then(result => {
|
|
|
|
expect(result).toBe('No hay cambios que guardar');
|
|
|
|
done();
|
2017-09-17 18:43:55 +00:00
|
|
|
})
|
|
|
|
.catch(catchErrors(done));
|
2017-09-11 14:12:32 +00:00
|
|
|
});
|
2017-09-17 18:01:15 +00:00
|
|
|
|
|
|
|
it('should receive an error when clicking the create button having all the form fields empty but name', done => {
|
|
|
|
nightmare
|
2017-09-18 07:38:50 +00:00
|
|
|
.wait(longWait)
|
2017-09-17 18:01:15 +00:00
|
|
|
.type(selectors.createClientView.name, 'Bruce Wayne')
|
|
|
|
.click(selectors.createClientView.createButton)
|
2017-09-18 07:38:50 +00:00
|
|
|
.wait(selectors.globalItems.snackbarIsActive)
|
|
|
|
.getInnerText(selectors.globalItems.snackbarIsActive)
|
2017-09-17 18:01:15 +00:00
|
|
|
.then(result => {
|
|
|
|
expect(result).toContain(`Error:`);
|
|
|
|
done();
|
2017-09-17 18:43:55 +00:00
|
|
|
})
|
|
|
|
.catch(catchErrors(done));
|
2017-09-17 18:01:15 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should receive an error when clicking the create button having all the form fields empty but Tax Number', done => {
|
|
|
|
nightmare
|
2017-09-18 07:38:50 +00:00
|
|
|
.wait(longWait)
|
2017-09-17 18:01:15 +00:00
|
|
|
.clearInput(selectors.createClientView.name)
|
|
|
|
.type(selectors.createClientView.taxNumber, 'Wayne Industries Tax Number')
|
|
|
|
.click(selectors.createClientView.createButton)
|
2017-09-18 07:38:50 +00:00
|
|
|
.wait(selectors.globalItems.snackbarIsActive)
|
|
|
|
.getInnerText(selectors.globalItems.snackbarIsActive)
|
2017-09-17 18:01:15 +00:00
|
|
|
.then(result => {
|
|
|
|
expect(result).toContain(`Error:`);
|
|
|
|
done();
|
2017-09-17 18:43:55 +00:00
|
|
|
})
|
|
|
|
.catch(catchErrors(done));
|
2017-09-17 18:01:15 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should receive an error when clicking the create button having all the form fields empty but Business Name', done => {
|
|
|
|
nightmare
|
2017-09-18 07:38:50 +00:00
|
|
|
.wait(longWait)
|
2017-09-17 18:01:15 +00:00
|
|
|
.clearInput(selectors.createClientView.taxNumber)
|
|
|
|
.type(selectors.createClientView.businessName, 'Wayne Industries')
|
|
|
|
.click(selectors.createClientView.createButton)
|
2017-09-18 07:38:50 +00:00
|
|
|
.wait(selectors.globalItems.snackbarIsActive)
|
|
|
|
.getInnerText(selectors.globalItems.snackbarIsActive)
|
2017-09-17 18:01:15 +00:00
|
|
|
.then(result => {
|
|
|
|
expect(result).toContain(`Error:`);
|
|
|
|
done();
|
2017-09-17 18:43:55 +00:00
|
|
|
})
|
|
|
|
.catch(catchErrors(done));
|
2017-09-17 18:01:15 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should receive an error when clicking the create button having all the form fields empty but User Name', done => {
|
|
|
|
nightmare
|
2017-09-18 07:38:50 +00:00
|
|
|
.wait(longWait)
|
2017-09-17 18:01:15 +00:00
|
|
|
.clearInput(selectors.createClientView.businessName)
|
|
|
|
.type(selectors.createClientView.userName, 'Batman')
|
|
|
|
.click(selectors.createClientView.createButton)
|
2017-09-18 07:38:50 +00:00
|
|
|
.wait(selectors.globalItems.snackbarIsActive)
|
|
|
|
.getInnerText(selectors.globalItems.snackbarIsActive)
|
2017-09-17 18:01:15 +00:00
|
|
|
.then(result => {
|
|
|
|
expect(result).toContain(`Error:`);
|
|
|
|
done();
|
2017-09-17 18:43:55 +00:00
|
|
|
})
|
|
|
|
.catch(catchErrors(done));
|
2017-09-17 18:01:15 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
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
|
2017-09-18 07:38:50 +00:00
|
|
|
.wait(longWait)
|
2017-09-17 18:01:15 +00:00
|
|
|
.clearInput(selectors.createClientView.userName)
|
|
|
|
.type(selectors.createClientView.email, 'I will save Gotham!')
|
|
|
|
.click(selectors.createClientView.createButton)
|
2017-09-18 07:38:50 +00:00
|
|
|
.wait(selectors.globalItems.snackbarIsActive)
|
|
|
|
.getInnerText(selectors.globalItems.snackbarIsActive)
|
2017-09-17 18:01:15 +00:00
|
|
|
.then(result => {
|
|
|
|
expect(result).toBe(`Algunos campos no son válidos`);
|
|
|
|
done();
|
2017-09-17 18:43:55 +00:00
|
|
|
})
|
|
|
|
.catch(catchErrors(done));
|
2017-09-17 18:01:15 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should receive an error when clicking the create button having all the form fields empty but email', done => {
|
|
|
|
nightmare
|
2017-09-18 07:38:50 +00:00
|
|
|
.wait(longWait)
|
2017-09-17 18:01:15 +00:00
|
|
|
.clearInput(selectors.createClientView.email)
|
|
|
|
.type(selectors.createClientView.email, 'IAmBatman@WayneIndustries.gotham')
|
|
|
|
.click(selectors.createClientView.createButton)
|
2017-09-18 07:38:50 +00:00
|
|
|
.wait(selectors.globalItems.snackbarIsActive)
|
|
|
|
.getInnerText(selectors.globalItems.snackbarIsActive)
|
2017-09-17 18:01:15 +00:00
|
|
|
.then(result => {
|
|
|
|
expect(result).toContain(`Error:`);
|
|
|
|
done();
|
2017-09-17 18:43:55 +00:00
|
|
|
})
|
|
|
|
.catch(catchErrors(done));
|
2017-09-17 18:01:15 +00:00
|
|
|
});
|
2017-09-17 18:43:55 +00:00
|
|
|
|
|
|
|
// this test should remain commented until the fixtures are implemented to avoid chainned failures.
|
|
|
|
|
2017-09-18 08:35:49 +00:00
|
|
|
// it(`should create a new user with all it's data`, done => {
|
2017-09-17 18:43:55 +00:00
|
|
|
// nightmare
|
2017-09-18 07:38:50 +00:00
|
|
|
// .wait(longWait)
|
2017-09-17 18:43:55 +00:00
|
|
|
// .clearInput(selectors.createClientView.email)
|
|
|
|
// .type(selectors.createClientView.name, 'Bruce Wayne')
|
|
|
|
// .type(selectors.createClientView.taxNumber, 'Wayne Industries Tax Number')
|
|
|
|
// .type(selectors.createClientView.businessName, 'Wayne Industries')
|
|
|
|
// .type(selectors.createClientView.userName, 'Batman')
|
|
|
|
// .type(selectors.createClientView.email, 'IAmBatman@WayneIndustries.gotham')
|
|
|
|
// .click(selectors.createClientView.createButton)
|
|
|
|
// .wait(6000)
|
2017-09-18 07:38:50 +00:00
|
|
|
// .wait(selectors.globalItems.snackbarIsActive)
|
|
|
|
// .getInnerText(selectors.globalItems.snackbarIsActive)
|
2017-09-17 18:43:55 +00:00
|
|
|
// .then(result => {
|
|
|
|
// expect(result).toContain(`some validation message`);
|
|
|
|
// done();
|
|
|
|
// })
|
|
|
|
// .catch(catchErrors(done));
|
|
|
|
// });
|
2017-09-11 14:12:32 +00:00
|
|
|
});
|