salix/e2e/paths/ticket-module/09_ticket_weekly.spec.js

172 lines
6.6 KiB
JavaScript
Raw Normal View History

2018-11-11 16:40:02 +00:00
import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare';
2018-11-13 12:03:44 +00:00
describe('Ticket descriptor path', () => {
2018-11-11 16:40:02 +00:00
const nightmare = createNightmare();
beforeAll(() => {
nightmare
.waitForLogin('employee');
});
it('should click on the Tickets button of the top bar menu', async () => {
const url = await nightmare
.waitToClick(selectors.globalItems.applicationsMenuButton)
.wait(selectors.globalItems.applicationsMenuVisible)
.waitToClick(selectors.globalItems.ticketsButton)
.wait(selectors.ticketsIndex.searchResult)
.parsedUrl();
expect(url.hash).toEqual('#!/ticket/index');
});
it('should count the mount of tickets in the turns section', async () => {
const result = await nightmare
.waitToClick(selectors.ticketsIndex.moreMenu)
.waitToClick(selectors.ticketsIndex.moreMenuTurns)
.wait(selectors.ticketsIndex.weeklyTicket)
.countElement(selectors.ticketsIndex.weeklyTicket);
expect(result).toEqual(5);
});
it('should now click on the Tickets button of the top bar menu', async () => {
const url = await nightmare
.waitToClick(selectors.globalItems.applicationsMenuButton)
.wait(selectors.globalItems.applicationsMenuVisible)
.waitToClick(selectors.globalItems.ticketsButton)
.wait(selectors.ticketsIndex.searchResult)
.parsedUrl();
expect(url.hash).toEqual('#!/ticket/index');
});
it('should search for the ticket 11', async () => {
const result = await nightmare
.wait(selectors.ticketsIndex.searchResult)
.type(selectors.ticketsIndex.searchTicketInput, 'id:11')
.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`, async () => {
const url = await nightmare
.waitToClick(selectors.ticketsIndex.searchResult)
.waitForURL('/summary')
.url();
expect(url).toContain('/summary');
});
2018-11-19 08:27:15 +00:00
it('should add the ticket to thirsday turn using the descriptor more menu', async () => {
2018-11-11 16:40:02 +00:00
const result = await nightmare
.waitToClick(selectors.ticketDescriptor.moreMenu)
.waitToClick(selectors.ticketDescriptor.moreMenuAddToTurn)
.waitToClick(selectors.ticketDescriptor.thursdayButton)
.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});
it('should again click on the Tickets button of the top bar menu', async () => {
const url = await nightmare
.waitToClick(selectors.globalItems.applicationsMenuButton)
.wait(selectors.globalItems.applicationsMenuVisible)
.waitToClick(selectors.globalItems.ticketsButton)
.wait(selectors.ticketsIndex.searchResult)
.parsedUrl();
expect(url.hash).toEqual('#!/ticket/index');
});
2018-11-19 08:27:15 +00:00
it('should confirm the ticket 11 was added on thursday', async () => {
2018-11-11 16:40:02 +00:00
const result = await nightmare
.waitToClick(selectors.ticketsIndex.moreMenu)
.waitToClick(selectors.ticketsIndex.moreMenuTurns)
2018-11-19 08:27:15 +00:00
.waitProperty(selectors.ticketsIndex.sixthWeeklyTicketTurn, 'value')
.getProperty(selectors.ticketsIndex.sixthWeeklyTicketTurn, 'value');
expect(result).toEqual('Thursday');
});
it('should click on the Tickets button of the top bar menu once more', async () => {
const url = await nightmare
.waitToClick(selectors.globalItems.applicationsMenuButton)
.wait(selectors.globalItems.applicationsMenuVisible)
.waitToClick(selectors.globalItems.ticketsButton)
.wait(selectors.ticketsIndex.searchResult)
.parsedUrl();
expect(url.hash).toEqual('#!/ticket/index');
});
it('should now search for the ticket 11', async () => {
const result = await nightmare
.wait(selectors.ticketsIndex.searchResult)
.type(selectors.ticketsIndex.searchTicketInput, 'id:11')
.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`, async () => {
const url = await nightmare
.waitToClick(selectors.ticketsIndex.searchResult)
.waitForURL('/summary')
.url();
expect(url).toContain('/summary');
});
it('should add the ticket to saturday turn using the descriptor more menu', async () => {
const result = await nightmare
.waitToClick(selectors.ticketDescriptor.moreMenu)
.waitToClick(selectors.ticketDescriptor.moreMenuAddToTurn)
.waitToClick(selectors.ticketDescriptor.saturdayButton)
.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});
it('should click on the Tickets button of the top bar menu once again', async () => {
const url = await nightmare
.waitToClick(selectors.globalItems.applicationsMenuButton)
.wait(selectors.globalItems.applicationsMenuVisible)
.waitToClick(selectors.globalItems.ticketsButton)
.wait(selectors.ticketsIndex.searchResult)
.parsedUrl();
expect(url.hash).toEqual('#!/ticket/index');
});
it('should confirm the ticket 11 was added on saturday', async () => {
const result = await nightmare
.waitToClick(selectors.ticketsIndex.moreMenu)
.waitToClick(selectors.ticketsIndex.moreMenuTurns)
.waitProperty(selectors.ticketsIndex.sixthWeeklyTicketTurn, 'value')
.getProperty(selectors.ticketsIndex.sixthWeeklyTicketTurn, 'value');
2018-11-11 16:40:02 +00:00
2018-11-19 08:27:15 +00:00
expect(result).toEqual('Saturday');
2018-11-11 16:40:02 +00:00
});
it('should delete the weekly ticket 11', async () => {
const result = await nightmare
.waitToClick(selectors.ticketsIndex.sixthWeeklyTicketDeleteIcon)
.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});
it('should confirm the sixth weekly ticket was deleted', async () => {
const result = await nightmare
.countElement(selectors.ticketsIndex.weeklyTicket);
expect(result).toEqual(5);
});
});