salix/e2e/paths/ticket-module/02_delete_ticket_expedition...

58 lines
2.4 KiB
JavaScript

import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare';
describe('Ticket', () => {
describe('Delete expeditions path', () => {
const nightmare = createNightmare();
beforeAll(() => {
return nightmare
.waitForLogin('production');
});
it('should access to the tickets index by clicking the tickets button', async () => {
const url = await nightmare
.click(selectors.moduleAccessView.ticketsSectionButton)
.wait(selectors.ticketsIndex.searchTicketInput)
.parsedUrl();
expect(url.hash).toEqual('#!/ticket/index');
});
it('should search for the ticket with id 1', async () => {
const result = await nightmare
.wait(selectors.ticketsIndex.searchTicketInput)
.type(selectors.ticketsIndex.searchTicketInput, 'id:1')
.click(selectors.ticketsIndex.searchButton)
.waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1)
.countElement(selectors.ticketsIndex.searchResult);
expect(result).toEqual(1);
});
it(`should click on the search result to access to the ticket expeditions`, async () => {
const url = await nightmare
.waitForTextInElement(selectors.ticketsIndex.searchResult, '1')
.waitToClick(selectors.ticketsIndex.searchResult)
.waitToClick(selectors.ticketExpedition.expeditionButton)
.waitForURL('expedition')
.url();
expect(url).toContain('expedition');
});
it(`should delete a former expedition and confirm the remaining expedition are the expected ones`, async () => {
const result = await nightmare
.waitToClick(selectors.ticketExpedition.secondExpeditionRemoveButton)
.waitToClick(selectors.ticketExpedition.acceptDeleteRowButton)
.click(selectors.ticketPackages.packagesButton)
.wait(selectors.ticketPackages.firstPackageSelect)
.click(selectors.ticketExpedition.expeditionButton)
.wait(selectors.ticketExpedition.expeditionRow)
.countElement(selectors.ticketExpedition.expeditionRow);
expect(result).toEqual(3);
});
});
});