salix/e2e/paths/client-module/09_add_credit.spec.js

87 lines
3.2 KiB
JavaScript
Raw Normal View History

import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/helpers';
describe('Client', () => {
describe('Add credit path', () => {
const nightmare = createNightmare();
beforeAll(() => {
return nightmare
2018-10-11 07:14:26 +00:00
.waitForLogin('salesAssistant');
});
2018-10-22 15:12:41 +00:00
it('should click on the Clients button of the top bar menu', done => {
return nightmare
.waitToClick(selectors.globalItems.applicationsMenuButton)
.wait(selectors.globalItems.applicationsMenuVisible)
.waitToClick(selectors.globalItems.clientsButton)
.wait(selectors.clientsIndex.createClientButton)
.parsedUrl()
.then(url => {
2018-05-23 12:26:51 +00:00
expect(url.hash).toEqual('#!/client/index');
2018-10-22 15:12:41 +00:00
done();
}).catch(done.fail);
});
2018-10-22 15:12:41 +00:00
it('should search for the user Ororo Munroe', done => {
return nightmare
.wait(selectors.clientsIndex.searchResult)
2018-05-11 09:22:04 +00:00
.type(selectors.clientsIndex.searchClientInput, 'Ororo Munroe')
.click(selectors.clientsIndex.searchButton)
.waitForNumberOfElements(selectors.clientsIndex.searchResult, 1)
.countElement(selectors.clientsIndex.searchResult)
.then(result => {
expect(result).toEqual(1);
2018-10-22 15:12:41 +00:00
done();
}).catch(done.fail);
});
2018-10-22 15:12:41 +00:00
it(`should click on the search result to access to the client's credit`, done => {
return nightmare
2018-05-11 09:22:04 +00:00
.waitForTextInElement(selectors.clientsIndex.searchResult, 'Ororo Munroe')
.waitToClick(selectors.clientsIndex.searchResult)
.waitToClick(selectors.clientCredit.creditButton)
2018-05-23 12:26:51 +00:00
.waitForURL('credit/index')
.url()
.then(url => {
2018-05-23 12:26:51 +00:00
expect(url).toContain('credit/index');
2018-10-22 15:12:41 +00:00
done();
}).catch(done.fail);
});
2018-10-22 15:12:41 +00:00
it(`should click on the add credit button`, done => {
return nightmare
.waitToClick(selectors.clientCredit.addCreditFloatButton)
.waitForURL('/credit/create')
.url()
.then(url => {
expect(url).toContain('/credit/create');
2018-10-22 15:12:41 +00:00
done();
}).catch(done.fail);
});
2018-10-22 15:12:41 +00:00
it(`should edit the credit`, done => {
return nightmare
.clearInput(selectors.clientCredit.creditInput)
.type(selectors.clientCredit.creditInput, 999)
.click(selectors.clientCredit.saveButton)
.waitForLastSnackbar()
.then(result => {
expect(result).toEqual('Data saved!');
2018-10-22 15:12:41 +00:00
done();
}).catch(done.fail);
});
2018-10-22 15:12:41 +00:00
it('should confirm the credit was updated', done => {
return nightmare
.wait(selectors.clientCredit.firstCreditText)
.getInnerText(selectors.clientCredit.firstCreditText)
.then(value => {
expect(value).toContain(999);
2018-10-11 07:14:26 +00:00
expect(value).toContain('salesAssistant');
2018-10-22 15:12:41 +00:00
done();
}).catch(done.fail);
});
});
});