salix/e2e/paths/06-claim-module/06_descriptor.spec.js

71 lines
2.6 KiB
JavaScript

import selectors from '../../helpers/selectors.js';
import getBrowser from '../../helpers/puppeteer';
describe('claim Descriptor path', () => {
let browser;
let page;
const claimId = '1';
beforeAll(async() => {
browser = await getBrowser();
page = browser.page;
});
afterAll(async() => {
await browser.close();
});
it('should now navigate to the target claim summary section', async() => {
await page.loginAndModule('employee', 'claim');
await page.accessToSearchResult(claimId);
await page.waitForURL('/summary');
const url = await page.parsedUrl();
expect(url.hash).toContain('/summary');
});
it(`should not be able to see the delete claim button of the descriptor more menu`, async() => {
await page.waitForContentLoaded();
await page.waitToClick(selectors.claimDescriptor.moreMenu);
await page.waitForSelector(selectors.claimDescriptor.moreMenuDeleteClaim, {hidden: true});
});
it(`should log in as salesAssistant and navigate to the target claim`, async() => {
await page.loginAndModule('salesAssistant', 'claim');
await page.accessToSearchResult(claimId);
await page.waitForURL('/summary');
const url = await page.parsedUrl();
expect(url.hash).toContain('/summary');
});
it(`should be able to see the delete claim button of the descriptor more menu`, async() => {
await page.waitToClick(selectors.claimDescriptor.moreMenu);
await page.waitForSelector(selectors.claimDescriptor.moreMenuDeleteClaim, {visible: true});
});
it(`should delete the claim`, async() => {
await page.waitToClick(selectors.claimDescriptor.moreMenuDeleteClaim);
await page.waitToClick(selectors.claimDescriptor.acceptDeleteClaim);
const result = await page.waitForLastSnackbar();
expect(result).toEqual('Claim deleted!');
});
it(`should have been relocated to the claim index`, async() => {
await page.waitForURL('/claim/index');
const url = await page.parsedUrl();
expect(url.hash).toContain('/claim/index');
});
it(`should search for the deleted claim to find no results`, async() => {
await page.write(selectors.claimsIndex.searchClaimInput, claimId);
await page.waitToClick(selectors.claimsIndex.searchButton);
await page.waitForNumberOfElements(selectors.claimsIndex.searchResult, 0);
const result = await page.countElement(selectors.claimsIndex.searchResult);
expect(result).toEqual(0);
});
});