salix/e2e/paths/ticket-module/01_create_ticket_observatio...

73 lines
3.0 KiB
JavaScript

import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare';
describe('Ticket', () => {
describe('Create notes path', () => {
const nightmare = createNightmare();
beforeAll(() => {
return nightmare
.waitForLogin('employee');
});
it('should access to the tickets index by clicking the tickets button', async () => {
let 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 () => {
let 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 notes`, async () => {
let url = await nightmare
.waitForTextInElement(selectors.ticketsIndex.searchResult, '1')
.waitToClick(selectors.ticketsIndex.searchResult)
.waitToClick(selectors.ticketNotes.notesButton)
.waitForURL('observation')
.parsedUrl();
expect(url.hash).toContain('observation');
});
it(`should click create a new note and delete a former one`, async () => {
let result = await nightmare
.waitToClick(selectors.ticketNotes.firstNoteRemoveButton)
.waitToClick(selectors.ticketNotes.addNoteButton)
.waitToClick(selectors.ticketNotes.firstNoteSelect)
.waitToClick(selectors.ticketNotes.firstNoteSelectSecondOption)
.type(selectors.ticketNotes.firstDescriptionInput, 'description')
.click(selectors.ticketNotes.submitNotesButton)
.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});
it(`should confirm the note is the expected one`, async () => {
let firstNoteSelect = await nightmare
.click(selectors.ticketPackages.packagesButton)
.wait(selectors.ticketPackages.firstPackageSelect)
.click(selectors.ticketNotes.notesButton)
.waitToGetProperty(selectors.ticketNotes.firstNoteSelect, 'value');
expect(firstNoteSelect).toEqual('observation one');
let firstDescription = await nightmare
.waitToGetProperty(selectors.ticketNotes.firstDescriptionInput, 'value');
expect(firstDescription).toEqual('description');
});
});
});