#570 e2e Ticket Weekly + refactors

This commit is contained in:
Carlos Jimenez 2018-11-11 17:40:02 +01:00
parent c8f8dd1830
commit 25db73a88b
5 changed files with 148 additions and 30 deletions

View File

@ -292,7 +292,16 @@ export default {
searchResultDate: `vn-ticket-index vn-table vn-tbody > a:nth-child(1) > vn-td:nth-child(4)`,
searchResultAddress: `vn-ticket-index vn-table vn-tbody > a:nth-child(1) > vn-td:nth-child(6)`,
searchTicketInput: `vn-ticket-index ${components.vnTextfield}`,
searchButton: `vn-ticket-index vn-searchbar vn-icon[icon="search"]`
searchButton: `vn-ticket-index vn-searchbar vn-icon[icon="search"]`,
moreMenu: `vn-ticket-index vn-icon-menu[vn-id="more-button"] > div > vn-icon`,
moreMenuTurns: `vn-ticket-index vn-icon-menu vn-drop-down > vn-popover li`,
weeklyTicket: `vn-ticket-weekly vn-table > div > vn-tbody > vn-tr`,
sixthWeeklyTicketDeleteIcon: `vn-ticket-weekly > form vn-tbody > vn-tr:nth-child(6) > vn-td:nth-child(6) > vn-icon-button[icon="delete"]`
},
ticketDescriptor: {
moreMenu: `vn-ticket-descriptor > vn-card > div vn-icon-menu > div > vn-icon`,
moreMenuAddToTurn: `vn-ticket-descriptor vn-icon-menu > div > vn-drop-down > vn-popover ul > li:nth-child(1)`,
thursdayButton: `vn-ticket-descriptor > vn-dialog > div > form > div.body > tpl-body > div > vn-tool-bar > vn-button:nth-child(4)`
},
ticketNotes: {
notesButton: `vn-left-menu a[ui-sref="ticket.card.observation"]`,

View File

@ -45,7 +45,7 @@ describe('Client Edit basicData path', () => {
const result = await nightmare
.click(selectors.clientBasicData.basicDataButton)
.wait(selectors.clientBasicData.nameInput)
.evaluate((selector) => {
.evaluate(selector => {
return document.querySelector(selector).disabled;
}, selectors.clientBasicData.salesPersonInput);
@ -162,7 +162,7 @@ describe('Client Edit basicData path', () => {
const result = await nightmare
.click(selectors.clientBasicData.basicDataButton)
.wait(selectors.clientBasicData.nameInput)
.evaluate((selector) => {
.evaluate(selector => {
return document.querySelector(selector).disabled;
}, selectors.clientBasicData.salesPersonInput);
@ -234,7 +234,7 @@ describe('Client Edit basicData path', () => {
const result = await nightmare
.getInputValue(selectors.clientBasicData.salesPersonInput);
expect(result).toEqual('accessory accessory');
expect(result).toEqual('adminAssistant adminAssistant');
});
it('should now confirm the channel have been selected', async () => {

View File

@ -10,46 +10,46 @@ describe('Ticket', () => {
.waitForLogin('employee');
});
it('should click on the Tickets button of the top bar menu', (done) => {
it('should click on the Tickets button of the top bar menu', done => {
return nightmare
.waitToClick(selectors.globalItems.applicationsMenuButton)
.wait(selectors.globalItems.applicationsMenuVisible)
.waitToClick(selectors.globalItems.ticketsButton)
.wait(selectors.ticketsIndex.searchResult)
.parsedUrl()
.then((url) => {
.then(url => {
expect(url.hash).toEqual('#!/ticket/index');
done();
}).catch(done.fail);
});
it('should search for the ticket 11', (done) => {
it('should search for the ticket 11', done => {
return nightmare
.wait(selectors.ticketsIndex.searchResult)
.type(selectors.ticketsIndex.searchTicketInput, 'id:11')
.click(selectors.ticketsIndex.searchButton)
.waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1)
.countElement(selectors.ticketsIndex.searchResult)
.then((result) => {
.then(result => {
expect(result).toEqual(1);
done();
}).catch(done.fail);
});
it(`should click on the search result to access to the ticket Basic Data`, (done) => {
it(`should click on the search result to access to the ticket Basic Data`, done => {
return nightmare
.waitForTextInElement(selectors.ticketsIndex.searchResult, 'address 21') // should be Bruce Wayne
.waitToClick(selectors.ticketsIndex.searchResult)
.waitToClick(selectors.ticketBasicData.basicDataButton)
.waitForURL('data/step-one')
.url()
.then((url) => {
.then(url => {
expect(url).toContain('data/step-one');
done();
}).catch(done.fail);
});
it(`should edit the client and address of the ticket then click next`, (done) => {
it(`should edit the client and address of the ticket then click next`, done => {
return nightmare
.waitToClick(selectors.ticketBasicData.clientSelect)
.waitToClick(selectors.ticketBasicData.clientSelectThirdOption)
@ -60,33 +60,33 @@ describe('Ticket', () => {
.click(selectors.ticketBasicData.nextStepButton)
.waitForURL('data/step-two')
.url()
.then((url) => {
.then(url => {
expect(url).toContain('data/step-two');
done();
}).catch(done.fail);
});
it(`should have no price diference`, (done) => {
it(`should have no price diference`, done => {
return nightmare
.getInnerText(selectors.ticketBasicData.stepTwoTotalPriceDif)
.then((result) => {
.then(result => {
expect(result).toContain('0');
done();
}).catch(done.fail);
});
it(`should click next to move on to step three`, (done) => {
it(`should click next to move on to step three`, done => {
return nightmare
.click(selectors.ticketBasicData.nextStepButton)
.waitForURL('data/step-three')
.url()
.then((url) => {
.then(url => {
expect(url).toContain('data/step-three');
done();
}).catch(done.fail);
});
it(`should select a reason for the changes made then click on finalize`, (done) => {
it(`should select a reason for the changes made then click on finalize`, done => {
return nightmare
.waitToClick(selectors.ticketBasicData.chargesReason)
.waitToClick(selectors.ticketBasicData.chargesReasonFourthOption)
@ -94,24 +94,24 @@ describe('Ticket', () => {
.click(selectors.ticketBasicData.finalizeButton)
.waitForURL('summary')
.url()
.then((url) => {
.then(url => {
expect(url).toContain('summary');
done();
}).catch(done.fail);
});
it(`should go back to ticket.basicData section`, (done) => {
it(`should go back to ticket.basicData section`, done => {
return nightmare
.waitToClick(selectors.ticketBasicData.basicDataButton)
.waitForURL('data/step-one')
.url()
.then((url) => {
.then(url => {
expect(url).toContain('data/step-one');
done();
}).catch(done.fail);
});
it(`should edit the ticket agency then click next`, (done) => {
it(`should edit the ticket agency then click next`, done => {
return nightmare
.waitToClick(selectors.ticketBasicData.agencySelect)
.waitToClick(selectors.ticketBasicData.agencySelectOptionSix)
@ -119,33 +119,33 @@ describe('Ticket', () => {
.click(selectors.ticketBasicData.nextStepButton)
.waitForURL('data/step-two')
.url()
.then((url) => {
.then(url => {
expect(url).toContain('data/step-two');
done();
}).catch(done.fail);
});
it(`should have a price diference`, (done) => {
it(`should have a price diference`, done => {
return nightmare
.getInnerText(selectors.ticketBasicData.stepTwoTotalPriceDif)
.then((result) => {
expect(result).toContain('-20.65');
.then(result => {
expect(result).toContain('-20.65');
done();
}).catch(done.fail);
});
it(`should then click next to move on to step three`, (done) => {
it(`should then click next to move on to step three`, done => {
return nightmare
.click(selectors.ticketBasicData.nextStepButton)
.waitForURL('data/step-three')
.url()
.then((url) => {
.then(url => {
expect(url).toContain('data/step-three');
done();
}).catch(done.fail);
});
it(`should select a new reason for the changes made then click on finalize`, (done) => {
it(`should select a new reason for the changes made then click on finalize`, done => {
return nightmare
.waitToClick(selectors.ticketBasicData.chargesReason)
.waitToClick(selectors.ticketBasicData.chargesReasonFirstOption)
@ -153,7 +153,7 @@ describe('Ticket', () => {
.click(selectors.ticketBasicData.finalizeButton)
.waitForURL('summary')
.url()
.then((url) => {
.then(url => {
expect(url).toContain('summary');
done();
}).catch(done.fail);

View File

@ -605,7 +605,7 @@ describe('Ticket Edit sale path', () => {
expect(url.hash).toEqual('#!/ticket/index');
});
it('should again search for a specific ticket', async () => {
it('should once again search for a specific ticket', async () => {
const result = await nightmare
.wait(selectors.ticketsIndex.searchResult)
.type(selectors.ticketsIndex.searchTicketInput, 'id:16')

View File

@ -0,0 +1,109 @@
import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare';
describe('Ticket weekly path', () => {
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');
});
it('should add the ticket to sunday turn using the descriptor more menu', async () => {
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');
});
it('should confirm there is one more ticket 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(6);
});
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);
});
});