2019-01-22 12:18:20 +00:00
|
|
|
import selectors from '../../helpers/selectors.js';
|
|
|
|
import createNightmare from '../../helpers/nightmare';
|
|
|
|
|
|
|
|
describe('Claim detail', () => {
|
|
|
|
const nightmare = createNightmare();
|
|
|
|
|
|
|
|
beforeAll(() => {
|
|
|
|
nightmare
|
|
|
|
.loginAndModule('salesPerson', 'claim')
|
|
|
|
.accessToSearchResult('4')
|
|
|
|
.accessToSection('claim.card.detail');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should add the first claimable item from ticket to the claim', async() => {
|
|
|
|
const result = await nightmare
|
|
|
|
.waitToClick(selectors.claimDetail.addItemButton)
|
|
|
|
.waitToClick(selectors.claimDetail.firstClaimableSaleFromTicket)
|
|
|
|
.waitForLastSnackbar();
|
|
|
|
|
|
|
|
expect(result).toEqual('Data saved!');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should confirm the claim contains now two items', async() => {
|
|
|
|
const result = await nightmare
|
|
|
|
.countElement(selectors.claimDetail.claimDetailLine);
|
|
|
|
|
|
|
|
expect(result).toEqual(2);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should edit de second item claimed quantity', async() => {
|
|
|
|
const result = await nightmare
|
2019-03-26 06:29:45 +00:00
|
|
|
.clearInput(selectors.claimDetail.secondItemQuantityInput)
|
2019-01-22 12:18:20 +00:00
|
|
|
.write(selectors.claimDetail.secondItemQuantityInput, 10)
|
2019-01-23 14:33:25 +00:00
|
|
|
.write('body', '\u000d') // simulates enter
|
2019-01-22 12:18:20 +00:00
|
|
|
.waitForLastSnackbar();
|
|
|
|
|
|
|
|
expect(result).toEqual('Data saved!');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should confirm the second item, and the claimed total were correctly edited', async() => {
|
|
|
|
const claimedQuantity = await nightmare
|
2019-01-23 14:33:25 +00:00
|
|
|
.waitToGetProperty(selectors.claimDetail.secondItemQuantityInput, 'value');
|
2019-01-22 12:18:20 +00:00
|
|
|
|
|
|
|
const totalClaimed = await nightmare
|
2019-01-23 14:33:25 +00:00
|
|
|
.waitToGetProperty(selectors.claimDetail.totalClaimed, 'innerText');
|
2019-01-22 12:18:20 +00:00
|
|
|
|
|
|
|
expect(claimedQuantity).toEqual('10');
|
2019-01-31 10:44:03 +00:00
|
|
|
expect(totalClaimed).toContain('29.50');
|
2019-01-22 12:18:20 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should delete the second item from the claim', async() => {
|
|
|
|
const result = await nightmare
|
|
|
|
.waitToClick(selectors.claimDetail.secondItemDeleteButton)
|
|
|
|
.waitForLastSnackbar();
|
|
|
|
|
|
|
|
expect(result).toEqual('Data saved!');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should confirm the claim contains now one item', async() => {
|
|
|
|
const result = await nightmare
|
|
|
|
.countElement(selectors.claimDetail.claimDetailLine);
|
|
|
|
|
|
|
|
expect(result).toEqual(1);
|
|
|
|
});
|
2019-04-08 13:38:47 +00:00
|
|
|
|
|
|
|
it('should login as salesAssistant to be redirected to the next claim section', async() => {
|
|
|
|
const result = await nightmare
|
|
|
|
.loginAndModule('salesAssistant', 'claim')
|
|
|
|
.accessToSearchResult('2')
|
|
|
|
.accessToSection('claim.card.detail')
|
|
|
|
.waitToClick(selectors.claimDetail.addItemButton)
|
|
|
|
.waitToClick(selectors.claimDetail.firstClaimableSaleFromTicket)
|
|
|
|
.waitForLastSnackbar();
|
|
|
|
|
|
|
|
expect(result).toEqual('Data saved!');
|
|
|
|
});
|
|
|
|
|
|
|
|
it(`should have been redirected to the next section in claims`, async() => {
|
|
|
|
const url = await nightmare
|
|
|
|
.waitForURL('/development')
|
|
|
|
.parsedUrl();
|
|
|
|
|
|
|
|
expect(url.hash).toContain('development');
|
|
|
|
});
|
2019-01-22 12:18:20 +00:00
|
|
|
});
|