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

83 lines
3.4 KiB
JavaScript
Raw Normal View History

2018-03-19 15:29:55 +00:00
import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare';
2018-03-19 15:29:55 +00:00
describe('Ticket', () => {
describe('Create notes path', () => {
const nightmare = createNightmare();
2018-03-19 15:29:55 +00:00
beforeAll(() => {
return nightmare
2018-10-25 14:44:03 +00:00
.waitForLogin('employee');
});
2018-03-19 15:29:55 +00:00
it('should access to the tickets index by clicking the tickets button', done => {
return nightmare
2018-10-25 14:44:03 +00:00
.click(selectors.moduleAccessView.ticketsSectionButton)
.wait(selectors.ticketsIndex.searchTicketInput)
2018-10-25 14:44:03 +00:00
.parsedUrl()
.then(url => {
2018-10-25 14:44:03 +00:00
expect(url.hash).toEqual('#!/ticket/index');
done();
}).catch(done.fail);
2018-03-19 15:29:55 +00:00
});
it('should search for the ticket with id 1', done => {
return nightmare
2018-10-25 14:44:03 +00:00
.wait(selectors.ticketsIndex.searchTicketInput)
.type(selectors.ticketsIndex.searchTicketInput, 'id:1')
.click(selectors.ticketsIndex.searchButton)
.waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1)
.countElement(selectors.ticketsIndex.searchResult)
.then(result => {
2018-10-25 14:44:03 +00:00
expect(result).toEqual(1);
done();
}).catch(done.fail);
2018-03-19 15:29:55 +00:00
});
it(`should click on the search result to access to the ticket notes`, done => {
return nightmare
2018-10-25 14:44:03 +00:00
.waitForTextInElement(selectors.ticketsIndex.searchResult, '1')
.waitToClick(selectors.ticketsIndex.searchResult)
.waitToClick(selectors.ticketNotes.notesButton)
.waitForURL('observation')
.url()
.then(url => {
2018-10-25 14:44:03 +00:00
expect(url).toContain('observation');
done();
}).catch(done.fail);
2018-03-19 15:29:55 +00:00
});
it(`should click create a new note and delete a former one`, done => {
return nightmare
2018-10-25 14:44:03 +00:00
.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()
.then(result => {
2018-10-25 14:44:03 +00:00
expect(result).toEqual('Data saved!');
done();
}).catch(done.fail);
2018-03-19 15:29:55 +00:00
});
it(`should confirm the note is the expected one`, done => {
2018-03-19 15:29:55 +00:00
return nightmare
2018-10-25 14:44:03 +00:00
.click(selectors.ticketPackages.packagesButton)
.wait(selectors.ticketPackages.firstPackageSelect)
.click(selectors.ticketNotes.notesButton)
.waitProperty(selectors.ticketNotes.firstNoteSelect, 'value')
.then(result => {
2018-10-25 14:44:03 +00:00
expect(result).toEqual('observation one');
return nightmare
.getProperty(selectors.ticketNotes.firstDescriptionInput, 'value');
})
.then(result => {
2018-10-25 14:44:03 +00:00
expect(result).toEqual('description');
done();
}).catch(done.fail);
2018-03-19 15:29:55 +00:00
});
});
});