import selectors from '../../helpers/selectors.js'; import getBrowser from '../../helpers/puppeteer'; describe('Claim edit basic data path', () => { let browser; let page; beforeAll(async() => { browser = await getBrowser(); page = browser.page; }); afterAll(async() => { await browser.close(); }); it(`should log in as claimManager then reach basic data of the target claim`, async() => { await page.loginAndModule('claimManager', 'claim'); await page.accessToSearchResult('1'); await page.accessToSection('claim.card.basicData'); }); it(`should edit claim state and observation fields`, async() => { await page.autocompleteSearch(selectors.claimBasicData.claimState, 'Gestionado'); await page.clearInput(selectors.claimBasicData.packages); await page.write(selectors.claimBasicData.packages, '2'); await page.waitToClick(selectors.claimBasicData.saveButton); const message = await page.waitForSnackbar(); expect(message.text).toContain('Data saved!'); }); it(`should have been redirected to the next section of claims as the role is claimManager`, async() => { await page.waitForState('claim.card.detail'); }); it('should check the "Pick up" checkbox', async() => { await page.reloadSection('claim.card.basicData'); await page.waitToClick(selectors.claimBasicData.hasToPickUpCheckbox); await page.waitToClick(selectors.claimBasicData.saveButton); const message = await page.waitForSnackbar(); expect(message.text).toContain('Data saved!'); }); it('should confirm the claim state was edited', async() => { await page.reloadSection('claim.card.basicData'); await page.waitForSelector(selectors.claimBasicData.claimState); const result = await page.waitToGetProperty(selectors.claimBasicData.claimState, 'value'); expect(result).toEqual('Gestionado'); }); it('should confirm the "is paid with mana" and "Pick up" checkbox are checked', async() => { const hasToPickUpCheckbox = await page.checkboxState(selectors.claimBasicData.hasToPickUpCheckbox); expect(hasToPickUpCheckbox).toBe('checked'); }); it('should confirm the claim packages was edited', async() => { const result = await page .waitToGetProperty(selectors.claimBasicData.packages, 'value'); expect(result).toEqual('2'); }); it(`should edit the claim to leave it untainted`, async() => { await page.autocompleteSearch(selectors.claimBasicData.claimState, 'Pendiente'); await page.clearInput(selectors.claimBasicData.packages); await page.write(selectors.claimBasicData.packages, '0'); await page.waitToClick(selectors.claimBasicData.saveButton); const message = await page.waitForSnackbar(); expect(message.text).toContain('Data saved!'); }); });