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

81 lines
2.9 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
.waitForLogin('developer');
});
it('should click on the Clients button of the top bar menu', () => {
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-05-11 09:22:04 +00:00
it('should search for the user Ororo Munroe', () => {
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);
});
});
it(`should click on the search result to access to the client's credit`, () => {
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');
});
});
it(`should click on the add credit button`, () => {
return nightmare
.waitToClick(selectors.clientCredit.addCreditFloatButton)
.waitForURL('/credit/create')
.url()
.then(url => {
expect(url).toContain('/credit/create');
});
});
it(`should edit the credit`, () => {
return nightmare
.clearInput(selectors.clientCredit.creditInput)
.type(selectors.clientCredit.creditInput, 999)
.click(selectors.clientCredit.saveButton)
.waitForLastSnackbar()
.then(result => {
expect(result).toEqual('Data saved!');
});
});
it('should confirm the credit was updated', () => {
return nightmare
.wait(selectors.clientCredit.firstCreditText)
.getInnerText(selectors.clientCredit.firstCreditText)
.then(value => {
expect(value).toContain(999);
expect(value).toContain('developer');
});
});
});
});