client basic data, add address and item clone fixes plus add address notes path and create item

This commit is contained in:
Carlos Jimenez 2018-02-26 16:06:49 +01:00
parent c2eda39745
commit 84f9ac57f3
6 changed files with 191 additions and 67 deletions

View File

@ -153,7 +153,21 @@ export default {
searchButton: `${components.vnSearchBar} > vn-icon-button > button`,
closeItemSummaryPreview: 'body > vn-app > vn-vertical > vn-vertical > ui-view > vn-item-list:nth-child(1) > div > vn-dialog > div > button > vn-icon'
},
itemCreateView: {
name: `${components.vnTextfield}[name="name"]`,
typeSelect: `${components.vnAutocomplete}[field="$ctrl.item.typeFk"] > vn-vertical > ${components.vnTextfield}`,
typeSelectOptionOne: `${components.vnAutocomplete}[field="$ctrl.item.typeFk"] > vn-vertical > vn-drop-down > vn-vertical > vn-auto > ul > li:nth-child(2)`,
intrastatSelect: `${components.vnAutocomplete}[field="$ctrl.item.intrastatFk"] > vn-vertical > ${components.vnTextfield}`,
intrastatSelectOptionOne: `${components.vnAutocomplete}[field="$ctrl.item.intrastatFk"] > vn-vertical > vn-drop-down > vn-vertical > vn-auto > ul > li:nth-child(2)`,
originSelect: `${components.vnAutocomplete}[field="$ctrl.item.originFk"] > vn-vertical > ${components.vnTextfield}`,
originSelectOptionOne: `${components.vnAutocomplete}[field="$ctrl.item.originFk"] > vn-vertical > vn-drop-down > vn-vertical > vn-auto > ul > li:nth-child(2)`,
expenceSelect: `${components.vnAutocomplete}[field="$ctrl.item.expenceFk"] > vn-vertical > ${components.vnTextfield}`,
expenceSelectOptionOne: `${components.vnAutocomplete}[field="$ctrl.item.expenceFk"] > vn-vertical > vn-drop-down > vn-vertical > vn-auto > ul > li:nth-child(2)`,
createButton: `${components.vnSubmit}`
},
itemBasicData: {
goToItemIndexButton: 'body > vn-app > vn-vertical > vn-vertical > ui-view > vn-item-card > vn-main-block > vn-horizontal > vn-auto > vn-item-descriptor > vn-card > div > vn-vertical > vn-auto.descriptor-header.pointer > img',
basicDataButton: `${components.vnMenuItem}[ui-sref="item.card.data"]`,
typeSelect: `${components.vnAutocomplete}[field="$ctrl.item.typeFk"] > vn-vertical > ${components.vnTextfield}`,
typeSelectOptionTwo: `${components.vnAutocomplete}[field="$ctrl.item.typeFk"] > vn-vertical > vn-drop-down > vn-vertical:not(.ng-hide) > vn-auto:nth-child(2) > ul > li:nth-child(2)`,

View File

@ -179,7 +179,7 @@ describe('Edit basicData path', () => {
.wait(200)
.getInputValue(selectors.clientBasicData.salesPersonInput)
.then(result => {
expect(result).toEqual('account account');
expect(result).toEqual('accessory accessory');
});
});

View File

@ -198,7 +198,7 @@ describe('Add address path', () => {
.waitToClick(selectors.clientAddresses.saveButton)
.waitForSnackbar()
.then(result => {
expect(result).toContain('Error');
expect(result).toContain('Some fields are invalid');
});
});
});

View File

@ -16,10 +16,10 @@ describe('Add address notes path', () => {
});
});
it('should search for the user Bruce Banner', () => {
it('should search for the user Petter Parker', () => {
return nightmare
.wait(selectors.clientsIndex.searchResult)
.type(selectors.clientsIndex.searchClientInput, 'Bruce Banner')
.type(selectors.clientsIndex.searchClientInput, 'Petter Parker')
.click(selectors.clientsIndex.searchButton)
.waitForNumberOfElements(selectors.clientsIndex.searchResult, 1)
.countSearchResults(selectors.clientsIndex.searchResult)
@ -30,7 +30,7 @@ describe('Add address notes path', () => {
it(`should click on the search result to access to the client addresses`, () => {
return nightmare
.waitForTextInElement(selectors.clientsIndex.searchResult, 'Bruce Banner')
.waitForTextInElement(selectors.clientsIndex.searchResult, 'Petter Parker')
.waitToClick(selectors.clientsIndex.searchResult)
.waitToClick(selectors.clientAddresses.addressesButton)
.waitForURL('addresses/list')
@ -42,7 +42,7 @@ describe('Add address notes path', () => {
it(`should click on the edit icon of the default address`, () => {
return nightmare
.waitForTextInElement(selectors.clientAddresses.defaultAddress, 'Somewhere in Thailand')
.waitForTextInElement(selectors.clientAddresses.defaultAddress, '20 Ingram Street')
.waitToClick(selectors.clientAddresses.firstEditButton)
.waitForURL('/edit')
.url()
@ -51,13 +51,41 @@ describe('Add address notes path', () => {
});
});
// it('should add as many notes as observation types', () => {
// return nightmare
// .waitToClick(selectors.clientAddresses.defaultCheckboxInput)
// .waitToClick(selectors.clientFiscalData.saveButton)
// .waitForSnackbar()
// .then(result => {
// expect(result).toContain('Some fields are invalid');
// })
// });
it('should not save a description without observation type', () => {
return nightmare
.wait(selectors.clientAddresses.firstObservationDescriptionInput)
.type(selectors.clientAddresses.firstObservationDescriptionInput, 'first description')
.waitToClick(selectors.clientAddresses.saveButton)
.waitForSnackbar()
.then(result => {
expect(result).toContain('No changes to save');
});
});
it('should not save an observation type without description type', () => {
return nightmare
.clearInput(selectors.clientAddresses.firstObservationDescriptionInput)
.waitToClick(selectors.clientAddresses.firstObservationTypeSelect)
.waitToClick(selectors.clientAddresses.firstObservationTypeSelectOptionOne)
.waitForTextInInput(selectors.clientAddresses.firstObservationTypeSelect, 'observation one')
.waitToClick(selectors.clientAddresses.saveButton)
.waitForSnackbar()
.then(result => {
expect(result).toContain('No changes to save');
});
});
it('should show an error if there are empty fields', () => {
return nightmare
.type(selectors.clientAddresses.firstObservationDescriptionInput, 'first description')
.waitToClick(selectors.clientAddresses.addAddressNoteButton)
.wait(selectors.clientAddresses.secondObservationDescriptionInput)
.type(selectors.clientAddresses.secondObservationDescriptionInput, 'second description')
.waitToClick(selectors.clientAddresses.saveButton)
.waitForSnackbar()
.then(result => {
expect(result).toContain('No changes to save');
});
});
});

View File

@ -1,52 +0,0 @@
import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/helpers';
describe('Item clone path', () => {
const nightmare = createNightmare();
it('should access to the items index by clicking the items button', () => {
return nightmare
.click(selectors.moduleAccessView.itemsSectionButton)
.wait(selectors.itemsIndex.createItemButton)
.parsedUrl()
.then(url => {
expect(url.hash).toEqual('#!/item/list');
});
});
it('should search for the item Iron Patriot', () => {
return nightmare
.wait(selectors.itemsIndex.searchResult)
.type(selectors.itemsIndex.searchItemInput, 'Iron Patriot')
.click(selectors.itemsIndex.searchButton)
.waitForNumberOfElements(selectors.itemsIndex.searchResult, 1)
.countSearchResults(selectors.itemsIndex.searchResult)
.then(result => {
expect(result).toEqual(1);
});
});
it(`should clone the Iron Patriot`, () => {
return nightmare
.waitForTextInElement(selectors.itemsIndex.searchResult, 'Iron Patriot')
.click(selectors.itemsIndex.searchResultCloneButton)
.waitToClick(selectors.itemsIndex.acceptClonationAlertButton)
.waitForURL('tags')
.parsedUrl()
.then(url => {
expect(url.hash).toContain('tags');
});
});
it('should search for the item Iron Patriot and find two', () => {
return nightmare
.wait(selectors.itemsIndex.searchResult)
.type(selectors.itemsIndex.searchItemInput, 'Iron Patriot')
.click(selectors.itemsIndex.searchButton)
.waitForNumberOfElements(selectors.itemsIndex.searchResult, 2)
.countSearchResults(selectors.itemsIndex.searchResult)
.then(result => {
expect(result).toEqual(2);
});
});
});

View File

@ -0,0 +1,134 @@
import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/helpers';
describe('Item', () => {
const nightmare = createNightmare();
describe('create path', () => {
it('should access to the items index by clicking the items button', () => {
return nightmare
.click(selectors.moduleAccessView.itemsSectionButton)
.wait(selectors.itemsIndex.createItemButton)
.parsedUrl()
.then(url => {
expect(url.hash).toEqual('#!/item/list');
});
});
it(`should search for the item Infinity Gauntlet to confirm it isn't created yet`, () => {
return nightmare
.wait(selectors.itemsIndex.searchResult)
.type(selectors.itemsIndex.searchItemInput, 'Infinity Gauntlet')
.click(selectors.itemsIndex.searchButton)
.waitForNumberOfElements(selectors.itemsIndex.searchResult, 0)
.countSearchResults(selectors.itemsIndex.searchResult)
.then(result => {
expect(result).toEqual(0);
});
});
it('should access to the create item view by clicking the create floating button', () => {
return nightmare
.click(selectors.itemsIndex.createItemButton)
.wait(selectors.itemCreateView.createButton)
.parsedUrl()
.then(url => {
expect(url.hash).toEqual('#!/item/create');
});
});
it('should create the Infinity Gauntlet item', () => {
return nightmare
.type(selectors.itemCreateView.name, 'Infinity Gauntlet')
.waitToClick(selectors.itemCreateView.typeSelect)
.waitToClick(selectors.itemCreateView.typeSelectOptionOne)
.waitToClick(selectors.itemCreateView.intrastatSelect)
.waitToClick(selectors.itemCreateView.intrastatSelectOptionOne)
.waitToClick(selectors.itemCreateView.originSelect)
.waitToClick(selectors.itemCreateView.originSelectOptionOne)
.waitToClick(selectors.itemCreateView.expenceSelect)
.waitToClick(selectors.itemCreateView.expenceSelectOptionOne)
.click(selectors.itemCreateView.createButton)
.waitForSnackbar()
.then(result => {
expect(result).toContain('Data saved!');
});
});
it('should confirm Infinity Gauntlet item was created', () => {
return nightmare
.wait(selectors.itemBasicData.nameInput)
.getInputValue(selectors.itemBasicData.nameInput)
.then(result => {
expect(result).toBe('Infinity Gauntlet');
return nightmare
.getInputValue(selectors.itemBasicData.typeSelect);
})
.then(result => {
expect(result).toBe('Crisantemo');
return nightmare
.getInputValue(selectors.itemBasicData.intrastatSelect);
})
.then(result => {
expect(result).toBe('Plantas vivas: Esqueje/injerto, Vid');
return nightmare
.getInputValue(selectors.itemBasicData.originSelect);
})
.then(result => {
expect(result).toBe('Spain');
return nightmare
.getInputValue(selectors.itemBasicData.expenceSelect);
})
.then(result => {
expect(result).toBe('loan');
});
});
});
describe('clone path', () => {
it('should access to the items index by clicking the items button', () => {
return nightmare
.click(selectors.itemBasicData.goToItemIndexButton)
.wait(selectors.itemsIndex.createItemButton)
.parsedUrl()
.then(url => {
expect(url.hash).toEqual('#!/item/list');
});
});
it(`should search for the item Infinity Gauntlet`, () => {
return nightmare
.wait(selectors.itemsIndex.searchResult)
.type(selectors.itemsIndex.searchItemInput, 'Infinity Gauntlet')
.click(selectors.itemsIndex.searchButton)
.waitForNumberOfElements(selectors.itemsIndex.searchResult, 1)
.countSearchResults(selectors.itemsIndex.searchResult)
.then(result => {
expect(result).toEqual(1);
});
});
it(`should clone the Infinity Gauntlet`, () => {
return nightmare
.waitForTextInElement(selectors.itemsIndex.searchResult, 'Infinity Gauntlet')
.click(selectors.itemsIndex.searchResultCloneButton)
.waitToClick(selectors.itemsIndex.acceptClonationAlertButton)
.waitForURL('tags')
.parsedUrl()
.then(url => {
expect(url.hash).toContain('tags');
});
});
it('should search for the item Infinity Gauntlet and find two', () => {
return nightmare
.wait(selectors.itemsIndex.searchResult)
.type(selectors.itemsIndex.searchItemInput, 'Infinity Gauntlet')
.click(selectors.itemsIndex.searchButton)
.waitForNumberOfElements(selectors.itemsIndex.searchResult, 2)
.countSearchResults(selectors.itemsIndex.searchResult)
.then(result => {
expect(result).toEqual(2);
});
});
});
});