salix/e2e/paths/06-claim/04_claim_action.spec.js

80 lines
2.9 KiB
JavaScript

import selectors from '../../helpers/selectors.js';
import getBrowser from '../../helpers/puppeteer';
describe('Claim action path', () => {
let browser;
let page;
beforeAll(async() => {
browser = await getBrowser();
page = browser.page;
await page.loginAndModule('administrative', 'claim');
await page.accessToSearchResult('2');
await page.accessToSection('claim.card.action');
});
afterAll(async() => {
await browser.close();
});
it('should import the claim', async() => {
await page.waitToClick(selectors.claimAction.importClaimButton);
const result = await page.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});
it('should import the second importable ticket', async() => {
await page.waitFor(3000); // the animation adding the header element for the claimed total obscures somehow other elements for about 2 seconds
await page.waitToClick(selectors.claimAction.importTicketButton);
await page.waitToClick(selectors.claimAction.secondImportableTicket);
const result = await page.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});
it('should edit the second line destination field', async() => {
await page.waitForContentLoaded();
await page.autocompleteSearch(selectors.claimAction.secondLineDestination, 'Bueno');
const result = await page.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});
it('should delete the first line', async() => {
await page.waitToClick(selectors.claimAction.firstDeleteLine);
const result = await page.waitForLastSnackbar();
expect(result).toContain('Data saved!');
});
it('should refresh the view to check the remaining line is the expected one', async() => {
await page.reloadSection('claim.card.action');
const result = await page.waitToGetProperty(selectors.claimAction.firstLineDestination, 'value');
expect(result).toEqual('Bueno');
});
it('should delete the current first line', async() => {
await page.waitToClick(selectors.claimAction.firstDeleteLine);
const result = await page.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});
it('should check the "is paid with mana" checkbox', async() => {
page.waitFor(3000); // can't use waitForNavigation here and needs more time than a single second to get the section ready...
await page.waitToClick(selectors.claimAction.isPaidWithManaCheckbox);
const result = await page.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});
it('should confirm the "is paid with mana" checkbox is checked', async() => {
await page.reloadSection('claim.card.action');
const result = await page.checkboxState(selectors.claimAction.isPaidWithManaCheckbox);
expect(result).toBe('checked');
});
});