salix/e2e/paths/06-claim-module/03_detail.spec.js

122 lines
4.3 KiB
JavaScript
Raw Normal View History

import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare';
2019-07-02 12:44:36 +00:00
// #1528 e2e claim/detail
xdescribe('Claim detail', () => {
const nightmare = createNightmare();
beforeAll(() => {
nightmare
.loginAndModule('salesPerson', 'claim')
2019-07-02 12:44:36 +00:00
.accessToSearchResult(1)
.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);
});
2019-07-02 12:44:36 +00:00
it('should edit de first item claimed quantity', async() => {
const result = await nightmare
2019-07-02 12:44:36 +00:00
.clearInput(selectors.claimDetail.firstItemQuantityInput)
.write(selectors.claimDetail.firstItemQuantityInput, 4)
2019-01-23 14:33:25 +00:00
.write('body', '\u000d') // simulates enter
.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});
2019-07-02 12:44:36 +00:00
it('should confirm the first item quantity, and the claimed total were correctly edited', async() => {
const claimedQuantity = await nightmare
2019-07-02 12:44:36 +00:00
.waitToGetProperty(selectors.claimDetail.firstItemQuantityInput, 'value');
const totalClaimed = await nightmare
2019-01-23 14:33:25 +00:00
.waitToGetProperty(selectors.claimDetail.totalClaimed, 'innerText');
2019-07-02 12:44:36 +00:00
expect(claimedQuantity).toEqual('4');
expect(totalClaimed).toContain('€47.62');
});
it('should login as salesAssistant and navigate to the claim.detail section', async() => {
const url = await nightmare
.loginAndModule('salesAssistant', 'claim')
.accessToSearchResult(1)
.accessToSection('claim.card.detail')
.waitForURL('/detail')
.parsedUrl();
expect(url.hash).toContain('/detail');
});
it('should edit de second item claimed discount', async() => {
const result = await nightmare
.waitToClick(selectors.claimDetail.secondItemDiscount)
.write(selectors.claimDetail.discountInput, 100)
.write('body', '\u000d') // simulates enter
.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});
it('should check the mana is the expected one', async() => {
const result = await nightmare
.waitToClick(selectors.claimDetail.secondItemDiscount)
.waitToGetProperty(selectors.claimDetail.discoutPopoverMana, 'innerText');
expect(result).toContain('MANÁ: €106');
});
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
2019-07-02 12:44:36 +00:00
it('should add the deleted ticket from to the claim', async() => {
2019-04-08 13:38:47 +00:00
const result = await nightmare
.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-07-02 12:44:36 +00:00
it('should navigate back to claim.detail to confirm the claim contains now two items', async() => {
const result = await nightmare
.accessToSection('claim.card.detail')
.wait(selectors.claimDetail.claimDetailLine)
.countElement(selectors.claimDetail.claimDetailLine);
expect(result).toEqual(2);
});
});