2018-02-15 11:28:05 +00:00
|
|
|
import config from '../../helpers/config.js';
|
|
|
|
import createNightmare from '../../helpers/nightmare';
|
|
|
|
import selectors from '../../helpers/selectors.js';
|
|
|
|
import {catchErrors} from '../../../services/utils/jasmineHelpers';
|
2018-01-08 07:12:39 +00:00
|
|
|
const nightmare = createNightmare();
|
|
|
|
const moduleAccessViewHashURL = '#!/';
|
|
|
|
|
|
|
|
jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000;
|
|
|
|
|
2018-01-08 12:40:05 +00:00
|
|
|
describe('Add credit path', () => {
|
2018-01-08 07:12:39 +00:00
|
|
|
it('should log in', done => {
|
|
|
|
nightmare
|
|
|
|
.login()
|
|
|
|
.waitForURL(moduleAccessViewHashURL)
|
|
|
|
.url()
|
|
|
|
.then(url => {
|
|
|
|
expect(url).toEqual(config.url + moduleAccessViewHashURL);
|
|
|
|
done();
|
|
|
|
})
|
|
|
|
.catch(catchErrors(done));
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should make sure the language is English', done => {
|
|
|
|
nightmare
|
|
|
|
.changeLanguageToEnglish()
|
|
|
|
.then(() => {
|
|
|
|
done();
|
|
|
|
})
|
|
|
|
.catch(catchErrors(done));
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should click on the Clients button of the top bar menu', done => {
|
|
|
|
nightmare
|
|
|
|
.waitToClick(selectors.globalItems.applicationsMenuButton)
|
|
|
|
.wait(selectors.globalItems.applicationsMenuVisible)
|
|
|
|
.waitToClick(selectors.globalItems.clientsButton)
|
|
|
|
.wait(selectors.clientsIndex.createClientButton)
|
|
|
|
.url()
|
|
|
|
.then(url => {
|
|
|
|
expect(url).toEqual(config.url + '#!/clients');
|
|
|
|
done();
|
|
|
|
})
|
|
|
|
.catch(catchErrors(done));
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should search for the user Petter Parker', done => {
|
|
|
|
nightmare
|
|
|
|
.wait(selectors.clientsIndex.searchResult)
|
|
|
|
.type(selectors.clientsIndex.searchClientInput, 'Petter Parker')
|
|
|
|
.click(selectors.clientsIndex.searchButton)
|
|
|
|
.waitForNumberOfElements(selectors.clientsIndex.searchResult, 1)
|
|
|
|
.countSearchResults(selectors.clientsIndex.searchResult)
|
|
|
|
.then(result => {
|
|
|
|
expect(result).toEqual(1);
|
|
|
|
done();
|
|
|
|
})
|
|
|
|
.catch(catchErrors(done));
|
|
|
|
});
|
|
|
|
|
|
|
|
it(`should click on the search result to access to the client's credit`, done => {
|
|
|
|
nightmare
|
|
|
|
.waitForTextInElement(selectors.clientsIndex.searchResult, 'Petter Parker')
|
|
|
|
.waitToClick(selectors.clientsIndex.searchResult)
|
2018-02-15 11:28:05 +00:00
|
|
|
.waitToClick(selectors.clientCredit.creditButton)
|
2018-01-08 07:12:39 +00:00
|
|
|
.waitForURL('credit/list')
|
|
|
|
.url()
|
|
|
|
.then(url => {
|
|
|
|
expect(url).toContain('credit/list');
|
|
|
|
done();
|
|
|
|
})
|
|
|
|
.catch(catchErrors(done));
|
|
|
|
});
|
|
|
|
|
|
|
|
it(`should click on the add credit button`, done => {
|
|
|
|
nightmare
|
2018-02-15 11:28:05 +00:00
|
|
|
.waitToClick(selectors.clientCredit.addCreditFloatButton)
|
2018-01-08 07:12:39 +00:00
|
|
|
.waitForURL('/credit/create')
|
|
|
|
.url()
|
|
|
|
.then(url => {
|
|
|
|
expect(url).toContain('/credit/create');
|
|
|
|
done();
|
|
|
|
})
|
|
|
|
.catch(catchErrors(done));
|
|
|
|
});
|
|
|
|
|
|
|
|
it(`should edit the credit`, done => {
|
|
|
|
nightmare
|
2018-02-15 11:28:05 +00:00
|
|
|
.clearInput(selectors.clientCredit.creditInput)
|
|
|
|
.type(selectors.clientCredit.creditInput, 999)
|
|
|
|
.click(selectors.clientCredit.saveButton)
|
2018-01-08 07:12:39 +00:00
|
|
|
.wait(selectors.globalItems.snackbarIsActive)
|
|
|
|
.getInnerText(selectors.globalItems.snackbarIsActive)
|
|
|
|
.then(result => {
|
2018-01-08 12:40:05 +00:00
|
|
|
expect(result).toEqual('Data saved!');
|
2018-01-08 07:12:39 +00:00
|
|
|
done();
|
|
|
|
})
|
|
|
|
.catch(catchErrors(done));
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should confirm the credit was updated', done => {
|
|
|
|
nightmare
|
|
|
|
.waitForSnackbarReset()
|
2018-02-15 11:28:05 +00:00
|
|
|
.wait(selectors.clientCredit.firstCreditText)
|
|
|
|
.getInnerText(selectors.clientCredit.firstCreditText)
|
2018-01-08 07:12:39 +00:00
|
|
|
.then(value => {
|
|
|
|
expect(value).toContain(999);
|
|
|
|
done();
|
|
|
|
})
|
|
|
|
.catch(catchErrors(done));
|
|
|
|
});
|
|
|
|
});
|