#833 e2e ticket.request

This commit is contained in:
Carlos Jimenez 2018-11-21 14:09:22 +01:00
parent c0a3a66e6f
commit a3be9a1b6d
3 changed files with 165 additions and 182 deletions

View File

@ -445,17 +445,19 @@ export default {
total: 'vn-ticket-components tfoot > tr:nth-child(3) > td' total: 'vn-ticket-components tfoot > tr:nth-child(3) > td'
}, },
ticketRequests: { ticketRequests: {
requestButton: `vn-left-menu a[ui-sref="ticket.card.request"]`, requestButton: `vn-left-menu a[ui-sref="ticket.card.request.index"]`,
addRequestButton: `vn-ticket-request vn-icon[icon="add_circle"]`, addRequestButton: `vn-ticket-request-index > a > vn-float-button > button`,
request: 'vn-ticket-request > form > vn-card > div > vn-horizontal', request: 'vn-ticket-request-index > form > vn-card > div > vn-horizontal > vn-table > div > vn-tbody > vn-tr',
fifthDescriptionInput: `vn-ticket-request > form > vn-card > div > vn-horizontal:nth-child(6) > vn-textfield:nth-child(1) > div > div > div.infix > input`, descriptionInput: `vn-ticket-request-create > form > div > vn-card > div > vn-horizontal:nth-child(2) > vn-textfield > div > div > div.infix > input`,
fifthQuantityInput: `vn-ticket-request > form > vn-card > div > vn-horizontal:nth-child(6) > vn-textfield:nth-child(2) > div > div > div.infix > input`, atenderSelect: `vn-ticket-request-create > form > div > vn-card > div > vn-horizontal:nth-child(2) > vn-autocomplete > div > div > input`,
fifthAtenderSelect: `vn-ticket-request > form > vn-card > div > vn-horizontal:nth-child(6) > vn-autocomplete > div > div > input`, atenderSelectFirstOption: `vn-ticket-request-create > form > div > vn-card > div > vn-horizontal:nth-child(2) > vn-autocomplete > vn-drop-down > vn-popover > div > div.content > div > div.list > ul > li:nth-child(1)`,
fifthAtenderSelectFirstOption: `vn-ticket-request > form > vn-card > div > vn-horizontal:nth-child(6) > vn-autocomplete vn-drop-down ul > li:nth-child(1)`, atenderSelectSecondOption: `vn-ticket-request-create > form > div > vn-card > div > vn-horizontal:nth-child(2) > vn-autocomplete > vn-drop-down > vn-popover > div > div.content > div > div.list > ul > li:nth-child(2)`,
fifthAtenderSelectSecondOption: `vn-ticket-request > form > vn-card > div > vn-horizontal:nth-child(6) > vn-autocomplete vn-drop-down ul > li:nth-child(2)`, quantityInput: `vn-ticket-request-create > form > div > vn-card > div > vn-horizontal:nth-child(3) > vn-textfield:nth-child(1) > div > div > div.infix > input`,
fifthPriceInput: `vn-ticket-request > form > vn-card > div > vn-horizontal:nth-child(6) > vn-textfield:nth-child(4) > div > div > div.infix > input`, priceInput: `vn-ticket-request-create > form > div > vn-card > div > vn-horizontal:nth-child(3) > vn-textfield:nth-child(2) > div > div > div.infix > input`,
fifthRemoveRequestButton: `vn-ticket-request vn-horizontal:nth-child(6) vn-icon[icon="remove_circle_outline"]`, firstRemoveRequestButton: `vn-ticket-request-index vn-icon[icon="delete"]:nth-child(1)`,
saveButton: `${components.vnSubmit}` saveButton: `vn-ticket-request-create > form > div > vn-button-bar > vn-submit[label="Create"] input`,
firstDescription: 'vn-ticket-request-index > form > vn-card > div > vn-horizontal > vn-table > div > vn-tbody > vn-tr:nth-child(1) > vn-td:nth-child(2)',
}, },
createStateView: { createStateView: {
stateInput: `vn-autocomplete[field="$ctrl.ticket.stateFk"] > div > div > input`, stateInput: `vn-autocomplete[field="$ctrl.ticket.stateFk"] > div > div > input`,

View File

@ -1,143 +1,145 @@
import selectors from '../../helpers/selectors.js'; import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare'; import createNightmare from '../../helpers/nightmare';
describe('Item Create path', () => { describe('Item Create/Clone path', () => {
const nightmare = createNightmare(); const nightmare = createNightmare();
beforeAll(() => { describe('create', () => {
nightmare beforeAll(() => {
.waitForLogin('buyer'); nightmare
.waitForLogin('buyer');
});
it('should access to the items index by clicking the items button', async () => {
const url = await nightmare
.click(selectors.moduleAccessView.itemsSectionButton)
.wait(selectors.itemsIndex.createItemButton)
.parsedUrl();
expect(url.hash).toEqual('#!/item/index');
});
it(`should search for the item Infinity Gauntlet to confirm it isn't created yet`, async () => {
const result = await nightmare
.wait(selectors.itemsIndex.searchResult)
.type(selectors.itemsIndex.searchItemInput, 'Infinity Gauntlet')
.click(selectors.itemsIndex.searchButton)
.waitForNumberOfElements(selectors.itemsIndex.searchResult, 0)
.countElement(selectors.itemsIndex.searchResult);
expect(result).toEqual(0);
});
it('should access to the create item view by clicking the create floating button', async () => {
const url = await nightmare
.click(selectors.itemsIndex.createItemButton)
.wait(selectors.itemCreateView.createButton)
.parsedUrl();
expect(url.hash).toEqual('#!/item/create');
});
it('should return to the item index by clickig the cancel button', async () => {
const url = await nightmare
.click(selectors.itemCreateView.cancelButton)
.wait(selectors.itemsIndex.createItemButton)
.parsedUrl();
expect(url.hash).toEqual('#!/item/index');
});
it('should now access to the create item view by clicking the create floating button', async () => {
const url = await nightmare
.click(selectors.itemsIndex.createItemButton)
.wait(selectors.itemCreateView.createButton)
.parsedUrl();
expect(url.hash).toEqual('#!/item/create');
});
it('should create the Infinity Gauntlet item', async () => {
const result = await nightmare
.type(selectors.itemCreateView.name, 'Infinity Gauntlet')
.waitToClick(selectors.itemCreateView.typeSelect)
.waitToClick(selectors.itemCreateView.typeSelectOptionThree)
.waitToClick(selectors.itemCreateView.intrastatSelect)
.waitToClick(selectors.itemCreateView.intrastatSelectOptionOne)
.waitToClick(selectors.itemCreateView.originSelect)
.waitToClick(selectors.itemCreateView.originSelectOptionOne)
.click(selectors.itemCreateView.createButton)
.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});
it('should confirm Infinity Gauntlet item was created', async () => {
let result = await nightmare
.wait(selectors.itemBasicData.nameInput)
.getInputValue(selectors.itemBasicData.nameInput);
expect(result).toEqual('Infinity Gauntlet');
result = await nightmare
.getInputValue(selectors.itemBasicData.typeSelect);
expect(result).toEqual('Crisantemo');
result = await nightmare
.waitProperty(selectors.itemBasicData.intrastatSelect, 'value')
.getProperty(selectors.itemBasicData.intrastatSelect, 'value');
expect(result).toEqual('6021010 Plantas vivas: Esqueje/injerto, Vid');
result = await nightmare
.getInputValue(selectors.itemBasicData.originSelect);
expect(result).toEqual('Spain');
});
}); });
it('should access to the items index by clicking the items button', async () => { describe('clone', () => {
const url = await nightmare it('should return to the items index by clicking the return to items button', async () => {
.click(selectors.moduleAccessView.itemsSectionButton) const url = await nightmare
.wait(selectors.itemsIndex.createItemButton) .click(selectors.itemBasicData.goToItemIndexButton)
.parsedUrl(); .wait(selectors.itemsIndex.createItemButton)
.waitForURL('#!/item/index')
.parsedUrl();
expect(url.hash).toEqual('#!/item/index'); expect(url.hash).toContain('#!/item/index');
}); });
it(`should search for the item Infinity Gauntlet to confirm it isn't created yet`, async () => { it(`should search for the item Infinity Gauntlet`, async () => {
const result = await nightmare const result = await nightmare
.wait(selectors.itemsIndex.searchResult) .wait(selectors.itemsIndex.searchResult)
.type(selectors.itemsIndex.searchItemInput, 'Infinity Gauntlet') .type(selectors.itemsIndex.searchItemInput, 'Infinity Gauntlet')
.click(selectors.itemsIndex.searchButton) .click(selectors.itemsIndex.searchButton)
.waitForNumberOfElements(selectors.itemsIndex.searchResult, 0) .waitForNumberOfElements(selectors.itemsIndex.searchResult, 1)
.countElement(selectors.itemsIndex.searchResult); .countElement(selectors.itemsIndex.searchResult);
expect(result).toEqual(0); expect(result).toEqual(1);
}); });
it('should access to the create item view by clicking the create floating button', async () => { it(`should clone the Infinity Gauntlet`, async () => {
const url = await nightmare const url = await nightmare
.click(selectors.itemsIndex.createItemButton) .waitForTextInElement(selectors.itemsIndex.searchResult, 'Infinity Gauntlet')
.wait(selectors.itemCreateView.createButton) .click(selectors.itemsIndex.searchResultCloneButton)
.parsedUrl(); .waitToClick(selectors.itemsIndex.acceptClonationAlertButton)
.waitForURL('tags')
.parsedUrl();
expect(url.hash).toEqual('#!/item/create'); expect(url.hash).toContain('tags');
}); });
it('should return to the item index by clickig the cancel button', async () => { it('should search for the item Infinity Gauntlet and find two', async () => {
const url = await nightmare const result = await nightmare
.click(selectors.itemCreateView.cancelButton) .waitToClick(selectors.itemTags.goToItemIndexButton)
.wait(selectors.itemsIndex.createItemButton) .wait(selectors.itemsIndex.searchResult)
.parsedUrl(); .type(selectors.itemsIndex.searchItemInput, 'Infinity Gauntlet')
.click(selectors.itemsIndex.searchButton)
.waitForNumberOfElements(selectors.itemsIndex.searchResult, 2)
.countElement(selectors.itemsIndex.searchResult);
expect(url.hash).toEqual('#!/item/index'); expect(result).toEqual(2);
}); });
it('should now access to the create item view by clicking the create floating button', async () => {
const url = await nightmare
.click(selectors.itemsIndex.createItemButton)
.wait(selectors.itemCreateView.createButton)
.parsedUrl();
expect(url.hash).toEqual('#!/item/create');
});
it('should create the Infinity Gauntlet item', async () => {
const result = await nightmare
.type(selectors.itemCreateView.name, 'Infinity Gauntlet')
.waitToClick(selectors.itemCreateView.typeSelect)
.waitToClick(selectors.itemCreateView.typeSelectOptionThree)
.waitToClick(selectors.itemCreateView.intrastatSelect)
.waitToClick(selectors.itemCreateView.intrastatSelectOptionOne)
.waitToClick(selectors.itemCreateView.originSelect)
.waitToClick(selectors.itemCreateView.originSelectOptionOne)
.click(selectors.itemCreateView.createButton)
.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});
it('should confirm Infinity Gauntlet item was created', async () => {
let result = await nightmare
.wait(selectors.itemBasicData.nameInput)
.getInputValue(selectors.itemBasicData.nameInput);
expect(result).toEqual('Infinity Gauntlet');
result = await nightmare
.getInputValue(selectors.itemBasicData.typeSelect);
expect(result).toEqual('Crisantemo');
result = await nightmare
.waitProperty(selectors.itemBasicData.intrastatSelect, 'value')
.getProperty(selectors.itemBasicData.intrastatSelect, 'value');
expect(result).toEqual('6021010 Plantas vivas: Esqueje/injerto, Vid');
result = await nightmare
.getInputValue(selectors.itemBasicData.originSelect);
expect(result).toEqual('Spain');
});
});
describe('Clone path', () => {
it('should return to the items index by clicking the return to items button', async () => {
const url = await nightmare
.click(selectors.itemBasicData.goToItemIndexButton)
.wait(selectors.itemsIndex.createItemButton)
.waitForURL('#!/item/index')
.parsedUrl();
expect(url.hash).toContain('#!/item/index');
});
it(`should search for the item Infinity Gauntlet`, async () => {
const result = await nightmare
.wait(selectors.itemsIndex.searchResult)
.type(selectors.itemsIndex.searchItemInput, 'Infinity Gauntlet')
.click(selectors.itemsIndex.searchButton)
.waitForNumberOfElements(selectors.itemsIndex.searchResult, 1)
.countElement(selectors.itemsIndex.searchResult);
expect(result).toEqual(1);
});
it(`should clone the Infinity Gauntlet`, async () => {
const url = await nightmare
.waitForTextInElement(selectors.itemsIndex.searchResult, 'Infinity Gauntlet')
.click(selectors.itemsIndex.searchResultCloneButton)
.waitToClick(selectors.itemsIndex.acceptClonationAlertButton)
.waitForURL('tags')
.parsedUrl();
expect(url.hash).toContain('tags');
});
it('should search for the item Infinity Gauntlet and find two', async () => {
const result = await nightmare
.waitToClick(selectors.itemTags.goToItemIndexButton)
.wait(selectors.itemsIndex.searchResult)
.type(selectors.itemsIndex.searchItemInput, 'Infinity Gauntlet')
.click(selectors.itemsIndex.searchButton)
.waitForNumberOfElements(selectors.itemsIndex.searchResult, 2)
.countElement(selectors.itemsIndex.searchResult);
expect(result).toEqual(2);
}); });
}); });

View File

@ -1,7 +1,7 @@
import selectors from '../../helpers/selectors.js'; import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare'; import createNightmare from '../../helpers/nightmare';
xdescribe('Ticket purchase request path', () => { describe('Ticket purchase request path', () => {
const nightmare = createNightmare(); const nightmare = createNightmare();
beforeAll(() => { beforeAll(() => {
@ -45,74 +45,53 @@ xdescribe('Ticket purchase request path', () => {
it(`should add a new request`, async () => { it(`should add a new request`, async () => {
const result = await nightmare const result = await nightmare
.waitToClick(selectors.ticketRequests.addRequestButton) .waitToClick(selectors.ticketRequests.addRequestButton)
.wait(selectors.ticketRequests.fifthDescriptionInput) .wait(selectors.ticketRequests.descriptionInput)
.type(selectors.ticketRequests.fifthDescriptionInput, 'New stuff') .type(selectors.ticketRequests.descriptionInput, 'New stuff')
.type(selectors.ticketRequests.fifthQuantityInput, 99) .type(selectors.ticketRequests.quantityInput, 99)
.waitToClick(selectors.ticketRequests.fifthAtenderSelect) .waitToClick(selectors.ticketRequests.atenderSelect)
.waitToClick(selectors.ticketRequests.fifthAtenderSelectSecondOption) .waitToClick(selectors.ticketRequests.atenderSelectSecondOption)
.type(selectors.ticketRequests.fifthPriceInput, 999) .type(selectors.ticketRequests.priceInput, 999)
.waitToClick(selectors.ticketRequests.saveButton) .waitToClick(selectors.ticketRequests.saveButton)
.waitForLastSnackbar(); .waitForLastSnackbar();
expect(result).toEqual('Data saved!'); expect(result).toEqual('Data saved!');
}); });
it(`should have been redirected to the request index`, async () => {
const url = await nightmare
.waitForURL('/request')
.url();
expect(url).toContain('/request');
});
it(`should confirm the new request was added`, async () => { it(`should confirm the new request was added`, async () => {
const result = await nightmare const result = await nightmare
.waitToClick(selectors.ticketBasicData.basicDataButton) .waitToClick(selectors.ticketBasicData.basicDataButton)
.wait(selectors.ticketBasicData.clientSelect) .wait(selectors.ticketBasicData.clientSelect)
.waitToClick(selectors.ticketRequests.requestButton) .waitToClick(selectors.ticketRequests.requestButton)
.waitForTextInInput(selectors.ticketRequests.fifthDescriptionInput, 'New Stuff') .waitProperty(selectors.ticketRequests.firstDescription, 'innerText')
.getProperty(selectors.ticketRequests.fifthDescriptionInput, 'value'); .getProperty(selectors.ticketRequests.firstDescription, 'innerText');
expect(result).toEqual('New stuff'); expect(result).toEqual('New stuff');
}); });
it(`should edit the added request`, async () => {
const result = await nightmare
.clearInput(selectors.ticketRequests.fifthDescriptionInput)
.type(selectors.ticketRequests.fifthDescriptionInput, 'Cool stuff')
.clearInput(selectors.ticketRequests.fifthQuantityInput)
.type(selectors.ticketRequests.fifthQuantityInput, 55)
.waitToClick(selectors.ticketRequests.fifthAtenderSelect)
.waitToClick(selectors.ticketRequests.fifthAtenderSelectFirstOption)
.clearInput(selectors.ticketRequests.fifthPriceInput)
.type(selectors.ticketRequests.fifthPriceInput, 55)
.waitToClick(selectors.ticketRequests.saveButton)
.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});
it(`should confirm the new request was added`, async () => {
const result = await nightmare
.waitToClick(selectors.ticketBasicData.basicDataButton)
.wait(selectors.ticketBasicData.clientSelect)
.waitToClick(selectors.ticketRequests.requestButton)
.waitForTextInInput(selectors.ticketRequests.fifthDescriptionInput, 'Cool Stuff')
.getProperty(selectors.ticketRequests.fifthDescriptionInput, 'value');
expect(result).toEqual('Cool stuff');
});
it(`should delete the added request`, async () => { it(`should delete the added request`, async () => {
const result = await nightmare const result = await nightmare
.waitToClick(selectors.ticketRequests.fifthRemoveRequestButton) .waitToClick(selectors.ticketRequests.firstRemoveRequestButton)
.waitToClick(selectors.ticketRequests.saveButton)
.waitForLastSnackbar(); .waitForLastSnackbar();
expect(result).toEqual('Data saved!'); expect(result).toEqual('Data saved!');
}); });
it(`should confirm the request was deleted`, async () => {
it(`should confirm the new request was deleted`, async () => {
const result = await nightmare const result = await nightmare
.waitToClick(selectors.ticketBasicData.basicDataButton) .waitToClick(selectors.ticketBasicData.basicDataButton)
.wait(selectors.ticketBasicData.clientSelect) .wait(selectors.ticketBasicData.clientSelect)
.waitToClick(selectors.ticketRequests.requestButton) .waitToClick(selectors.ticketRequests.requestButton)
.wait(selectors.ticketRequests.request) .wait(selectors.ticketRequests.addRequestButton)
.countElement(selectors.ticketRequests.request); .exists(selectors.ticketRequests.request);
expect(result).toEqual(4); expect(result).toBeFalsy();
}); });
}); });