import selectors from '../../helpers/selectors.js'; import createNightmare from '../../helpers/nightmare'; describe('Ticket Summary path', () => { const nightmare = createNightmare(); const ticketId = 20; it('should navigate to the target ticket summary section', async() => { let url = await nightmare .loginAndModule('employee', 'ticket') .accessToSearchResult(ticketId) .waitForURL('/summary') .parsedUrl(); expect(url.hash).toContain('/summary'); }); it(`should display details from the ticket and it's client on the top of the header`, async() => { let result = await nightmare .waitForSpinnerLoad() .waitToGetProperty(selectors.ticketSummary.header, 'innerText'); expect(result).toContain(`Ticket #${ticketId}`); expect(result).toContain('Bruce Banner (109)'); expect(result).toContain('Somewhere in Thailand'); }); it('should display ticket details', async() => { let result = await nightmare .waitToGetProperty(selectors.ticketSummary.state, 'innerText'); expect(result).toContain('Arreglar'); }); it('should display delivery details', async() => { let result = await nightmare .waitToGetProperty(selectors.ticketSummary.route, 'innerText'); expect(result).toContain('3'); }); it('should display the ticket total', async() => { let result = await nightmare .waitToGetProperty(selectors.ticketSummary.total, 'innerText'); expect(result).toContain('€155.54'); }); it('should display the ticket line(s)', async() => { let result = await nightmare .waitToGetProperty(selectors.ticketSummary.firstSaleItemId, 'innerText'); expect(result).toContain('000002'); }); it(`should click on the first sale ID making the item descriptor visible`, async() => { const visible = await nightmare .waitToClick(selectors.ticketSummary.firstSaleItemId) .waitImgLoad(selectors.ticketSummary.firstSaleDescriptorImage) .isVisible(selectors.ticketSummary.itemDescriptorPopover); expect(visible).toBeTruthy(); }); it(`should check the url for the item diary link of the descriptor is for the right item id`, async() => { const exists = await nightmare .exists(selectors.ticketSummary.itemDescriptorPopoverItemDiaryButton); expect(exists).toBeTruthy(); }); it('should log in as production then navigate to the summary of the same ticket', async() => { let url = await nightmare .loginAndModule('production', 'ticket') .accessToSearchResult(ticketId) .waitForURL('/summary') .parsedUrl(); expect(url.hash).toContain('/summary'); }); it('should click on the SET OK button', async() => { let result = await nightmare .waitToClick(selectors.ticketSummary.setOk) .waitForLastSnackbar(); expect(result).toEqual('Data saved!'); }); it('should confirm the ticket state was updated', async() => { let result = await nightmare .waitForSpinnerLoad() .waitToGetProperty(selectors.ticketSummary.state, 'innerText'); expect(result).toContain('OK'); }); });