#1021 e2e login extension v3
This commit is contained in:
parent
648bd46862
commit
5240a5ada6
|
@ -3,6 +3,7 @@
|
||||||
import config from './config.js';
|
import config from './config.js';
|
||||||
import Nightmare from 'nightmare';
|
import Nightmare from 'nightmare';
|
||||||
import {URL} from 'url';
|
import {URL} from 'url';
|
||||||
|
let currentUser;
|
||||||
|
|
||||||
|
|
||||||
Nightmare.asyncAction = function(name, func) {
|
Nightmare.asyncAction = function(name, func) {
|
||||||
|
@ -19,8 +20,7 @@ Nightmare.asyncAction('clearInput', async function(selector) {
|
||||||
for (let i = 0; i < 50; i += 1)
|
for (let i = 0; i < 50; i += 1)
|
||||||
backSpaces.push('\u0008');
|
backSpaces.push('\u0008');
|
||||||
|
|
||||||
await this.wait(selector)
|
await this.write(selector, backSpaces.join(''));
|
||||||
.type(selector, backSpaces.join(''));
|
|
||||||
});
|
});
|
||||||
|
|
||||||
let actions = {
|
let actions = {
|
||||||
|
@ -32,7 +32,18 @@ let actions = {
|
||||||
.click(`vn-login input[type=submit]`)
|
.click(`vn-login input[type=submit]`)
|
||||||
// FIXME: Wait for dom to be ready: https://github.com/segmentio/nightmare/issues/481
|
// FIXME: Wait for dom to be ready: https://github.com/segmentio/nightmare/issues/481
|
||||||
.wait(1000)
|
.wait(1000)
|
||||||
.then(done)
|
.then(() => {
|
||||||
|
currentUser = userName;
|
||||||
|
done();
|
||||||
|
})
|
||||||
|
.catch(done);
|
||||||
|
},
|
||||||
|
|
||||||
|
resetLogin: function(done) {
|
||||||
|
this.then(() => {
|
||||||
|
currentUser = undefined;
|
||||||
|
done();
|
||||||
|
})
|
||||||
.catch(done);
|
.catch(done);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -55,7 +66,13 @@ let actions = {
|
||||||
},
|
},
|
||||||
|
|
||||||
waitForLogin: function(userName, done) {
|
waitForLogin: function(userName, done) {
|
||||||
this.login(userName)
|
if (currentUser === userName) {
|
||||||
|
return this.waitToClick('vn-topbar a[ui-sref="home"]')
|
||||||
|
.waitForURL('#!/')
|
||||||
|
.then(done)
|
||||||
|
.catch(done);
|
||||||
|
}
|
||||||
|
return this.login(userName)
|
||||||
.waitForURL('#!/')
|
.waitForURL('#!/')
|
||||||
.url()
|
.url()
|
||||||
.changeLanguageToEnglish()
|
.changeLanguageToEnglish()
|
||||||
|
@ -284,8 +301,7 @@ let actions = {
|
||||||
},
|
},
|
||||||
|
|
||||||
accessToSearchResult: function(searchValue, done) {
|
accessToSearchResult: function(searchValue, done) {
|
||||||
this.wait(`vn-searchbar input`)
|
this.write(`vn-searchbar input`, searchValue)
|
||||||
.type(`vn-searchbar input`, searchValue)
|
|
||||||
.click(`vn-searchbar vn-icon[icon="search"]`)
|
.click(`vn-searchbar vn-icon[icon="search"]`)
|
||||||
.waitForNumberOfElements('.searchResult', 1)
|
.waitForNumberOfElements('.searchResult', 1)
|
||||||
.evaluate(() => {
|
.evaluate(() => {
|
||||||
|
@ -321,7 +337,7 @@ let actions = {
|
||||||
autocompleteSearch: function(autocompleteSelector, searchValue, done) {
|
autocompleteSearch: function(autocompleteSelector, searchValue, done) {
|
||||||
this.wait(autocompleteSelector)
|
this.wait(autocompleteSelector)
|
||||||
.waitToClick(`${autocompleteSelector} input`)
|
.waitToClick(`${autocompleteSelector} input`)
|
||||||
.type(`${autocompleteSelector} vn-drop-down input`, searchValue)
|
.write(`${autocompleteSelector} vn-drop-down input`, searchValue)
|
||||||
.waitToClick(`${autocompleteSelector} li.active`)
|
.waitToClick(`${autocompleteSelector} li.active`)
|
||||||
.wait((autocompleteSelector, searchValue) => {
|
.wait((autocompleteSelector, searchValue) => {
|
||||||
return document.querySelector(`${autocompleteSelector} input`).value.toLowerCase().includes(searchValue.toLowerCase());
|
return document.querySelector(`${autocompleteSelector} input`).value.toLowerCase().includes(searchValue.toLowerCase());
|
||||||
|
|
|
@ -1,8 +1,12 @@
|
||||||
/* eslint no-console: 0 */
|
/* eslint no-console: 0 */
|
||||||
import Nightmare from 'nightmare';
|
import Nightmare from 'nightmare';
|
||||||
|
let nightmare;
|
||||||
|
|
||||||
export default function createNightmare(width = 1280, height = 720) {
|
export default function createNightmare(width = 1280, height = 720) {
|
||||||
const nightmare = new Nightmare({
|
if (nightmare)
|
||||||
|
return nightmare;
|
||||||
|
|
||||||
|
nightmare = new Nightmare({
|
||||||
show: process.env.E2E_SHOW,
|
show: process.env.E2E_SHOW,
|
||||||
typeInterval: 10,
|
typeInterval: 10,
|
||||||
x: 0,
|
x: 0,
|
||||||
|
@ -19,11 +23,6 @@ export default function createNightmare(width = 1280, height = 720) {
|
||||||
|
|
||||||
nightmare.header('Accept-Language', 'en');
|
nightmare.header('Accept-Language', 'en');
|
||||||
|
|
||||||
afterAll(() => {
|
|
||||||
return nightmare
|
|
||||||
.end();
|
|
||||||
});
|
|
||||||
|
|
||||||
return nightmare;
|
return nightmare;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -115,7 +115,8 @@ export default {
|
||||||
secondObservationDescriptionInput: `vn-client-address-edit [name=observations] :nth-child(2) [model="observation.description"] input`,
|
secondObservationDescriptionInput: `vn-client-address-edit [name=observations] :nth-child(2) [model="observation.description"] input`,
|
||||||
addObservationButton: `vn-client-address-edit vn-icon-button[icon="add_circle"]`,
|
addObservationButton: `vn-client-address-edit vn-icon-button[icon="add_circle"]`,
|
||||||
saveButton: `${components.vnSubmit}`,
|
saveButton: `${components.vnSubmit}`,
|
||||||
cancelButton: `button[ui-sref="client.card.address.index"]`
|
cancelCreateAddressButton: `button[ui-sref="client.card.address.index"]`,
|
||||||
|
cancelEditAddressButton: 'vn-client-address-edit > form > vn-button-bar > vn-button > button'
|
||||||
},
|
},
|
||||||
clientWebAccess: {
|
clientWebAccess: {
|
||||||
webAccessButton: `vn-left-menu a[ui-sref="client.card.webAccess"]`,
|
webAccessButton: `vn-left-menu a[ui-sref="client.card.webAccess"]`,
|
||||||
|
|
|
@ -20,33 +20,15 @@ describe('Client Add address path', () => {
|
||||||
expect(url.hash).toContain('address/create');
|
expect(url.hash).toContain('address/create');
|
||||||
});
|
});
|
||||||
|
|
||||||
it(`should return to the addreses section by clicking the cancel button`, async() => {
|
|
||||||
const url = await nightmare
|
|
||||||
.waitToClick(selectors.clientAddresses.cancelButton)
|
|
||||||
.waitForURL('address/index')
|
|
||||||
.parsedUrl();
|
|
||||||
|
|
||||||
expect(url.hash).toContain('address/index');
|
|
||||||
});
|
|
||||||
|
|
||||||
it(`should now click on the add new address button to access to the new address form`, async() => {
|
|
||||||
const url = await nightmare
|
|
||||||
.waitToClick(selectors.clientAddresses.createAddress)
|
|
||||||
.waitForURL('address/create')
|
|
||||||
.parsedUrl();
|
|
||||||
|
|
||||||
expect(url.hash).toContain('address/create');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should receive an error after clicking save button as consignee, street and town fields are empty', async() => {
|
it('should receive an error after clicking save button as consignee, street and town fields are empty', async() => {
|
||||||
const result = await nightmare
|
const result = await nightmare
|
||||||
.waitToClick(selectors.clientAddresses.defaultCheckboxInput)
|
.waitToClick(selectors.clientAddresses.defaultCheckboxInput)
|
||||||
.clearInput(selectors.clientAddresses.streetAddressInput)
|
.clearInput(selectors.clientAddresses.streetAddressInput)
|
||||||
.type(selectors.clientAddresses.postcodeInput, '10022')
|
.write(selectors.clientAddresses.postcodeInput, '10022')
|
||||||
.autocompleteSearch(selectors.clientAddresses.provinceAutocomplete, 'Province four')
|
.autocompleteSearch(selectors.clientAddresses.provinceAutocomplete, 'Province four')
|
||||||
.autocompleteSearch(selectors.clientAddresses.agencyAutocomplete, 'Entanglement')
|
.autocompleteSearch(selectors.clientAddresses.agencyAutocomplete, 'Entanglement')
|
||||||
.type(selectors.clientAddresses.phoneInput, '999887744')
|
.write(selectors.clientAddresses.phoneInput, '999887744')
|
||||||
.type(selectors.clientAddresses.mobileInput, '999887744')
|
.write(selectors.clientAddresses.mobileInput, '999887744')
|
||||||
.waitToClick(selectors.clientFiscalData.saveButton)
|
.waitToClick(selectors.clientFiscalData.saveButton)
|
||||||
.waitForLastSnackbar();
|
.waitForLastSnackbar();
|
||||||
|
|
||||||
|
@ -55,9 +37,9 @@ describe('Client Add address path', () => {
|
||||||
|
|
||||||
it(`should create a new address with all it's data`, async() => {
|
it(`should create a new address with all it's data`, async() => {
|
||||||
const result = await nightmare
|
const result = await nightmare
|
||||||
.type(selectors.clientAddresses.consigneeInput, 'Bruce Bunner')
|
.write(selectors.clientAddresses.consigneeInput, 'Bruce Bunner')
|
||||||
.type(selectors.clientAddresses.streetAddressInput, '320 Park Avenue New York')
|
.write(selectors.clientAddresses.streetAddressInput, '320 Park Avenue New York')
|
||||||
.type(selectors.clientAddresses.cityInput, 'New York')
|
.write(selectors.clientAddresses.cityInput, 'New York')
|
||||||
.click(selectors.clientAddresses.saveButton)
|
.click(selectors.clientAddresses.saveButton)
|
||||||
.waitForLastSnackbar();
|
.waitForLastSnackbar();
|
||||||
|
|
||||||
|
@ -99,4 +81,15 @@ describe('Client Add address path', () => {
|
||||||
|
|
||||||
expect(result).toEqual('The default consignee can not be unchecked');
|
expect(result).toEqual('The default consignee can not be unchecked');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// this "it" should be removed if the watcher doesn't prevent the navigation upon state changes
|
||||||
|
it(`should go back to the addreses section by clicking the cancel button`, async() => {
|
||||||
|
const url = await nightmare
|
||||||
|
.waitToClick(selectors.clientAddresses.cancelEditAddressButton)
|
||||||
|
.waitToClick('vn-confirm button[response="ACCEPT"]')
|
||||||
|
.waitForURL('address/index')
|
||||||
|
.parsedUrl();
|
||||||
|
|
||||||
|
expect(url.hash).toContain('address/index');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -11,8 +11,7 @@ describe('Item Create/Clone path', () => {
|
||||||
|
|
||||||
it(`should search for the item Infinity Gauntlet to confirm it isn't created yet`, async() => {
|
it(`should search for the item Infinity Gauntlet to confirm it isn't created yet`, async() => {
|
||||||
const result = await nightmare
|
const result = await nightmare
|
||||||
.wait(selectors.itemsIndex.searchItemInput)
|
.write(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, 0)
|
||||||
.countElement(selectors.itemsIndex.searchResult);
|
.countElement(selectors.itemsIndex.searchResult);
|
||||||
|
@ -49,7 +48,7 @@ describe('Item Create/Clone path', () => {
|
||||||
|
|
||||||
it('should create the Infinity Gauntlet item', async() => {
|
it('should create the Infinity Gauntlet item', async() => {
|
||||||
const result = await nightmare
|
const result = await nightmare
|
||||||
.type(selectors.itemCreateView.temporalName, 'Infinity Gauntlet')
|
.write(selectors.itemCreateView.temporalName, 'Infinity Gauntlet')
|
||||||
.autocompleteSearch(selectors.itemCreateView.typeAutocomplete, 'Crisantemo')
|
.autocompleteSearch(selectors.itemCreateView.typeAutocomplete, 'Crisantemo')
|
||||||
.autocompleteSearch(selectors.itemCreateView.intrastatAutocomplete, 'Coral y materiales similares')
|
.autocompleteSearch(selectors.itemCreateView.intrastatAutocomplete, 'Coral y materiales similares')
|
||||||
.autocompleteSearch(selectors.itemCreateView.originAutocomplete, 'Holand')
|
.autocompleteSearch(selectors.itemCreateView.originAutocomplete, 'Holand')
|
||||||
|
@ -96,8 +95,7 @@ describe('Item Create/Clone path', () => {
|
||||||
|
|
||||||
it(`should search for the item Infinity Gauntlet`, async() => {
|
it(`should search for the item Infinity Gauntlet`, async() => {
|
||||||
const result = await nightmare
|
const result = await nightmare
|
||||||
.wait(selectors.itemsIndex.searchItemInput)
|
.write(selectors.itemsIndex.searchItemInput, 'Infinity Gauntlet')
|
||||||
.type(selectors.itemsIndex.searchItemInput, 'Infinity Gauntlet')
|
|
||||||
.click(selectors.itemsIndex.searchButton)
|
.click(selectors.itemsIndex.searchButton)
|
||||||
.waitForNumberOfElements(selectors.itemsIndex.searchResult, 1)
|
.waitForNumberOfElements(selectors.itemsIndex.searchResult, 1)
|
||||||
.countElement(selectors.itemsIndex.searchResult);
|
.countElement(selectors.itemsIndex.searchResult);
|
||||||
|
@ -119,8 +117,7 @@ describe('Item Create/Clone path', () => {
|
||||||
it('should search for the item Infinity Gauntlet and find two', async() => {
|
it('should search for the item Infinity Gauntlet and find two', async() => {
|
||||||
const result = await nightmare
|
const result = await nightmare
|
||||||
.waitToClick(selectors.itemTags.goToItemIndexButton)
|
.waitToClick(selectors.itemTags.goToItemIndexButton)
|
||||||
.wait(selectors.itemsIndex.searchItemInput)
|
.write(selectors.itemsIndex.searchItemInput, 'Infinity Gauntlet')
|
||||||
.type(selectors.itemsIndex.searchItemInput, 'Infinity Gauntlet')
|
|
||||||
.click(selectors.itemsIndex.searchButton)
|
.click(selectors.itemsIndex.searchButton)
|
||||||
.waitForNumberOfElements(selectors.itemsIndex.searchResult, 2)
|
.waitForNumberOfElements(selectors.itemsIndex.searchResult, 2)
|
||||||
.countElement(selectors.itemsIndex.searchResult);
|
.countElement(selectors.itemsIndex.searchResult);
|
||||||
|
|
|
@ -46,11 +46,17 @@ describe('Order edit basic data path', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('when new order', () => {
|
describe('when new order', () => {
|
||||||
beforeAll(() => {
|
it('should once more navigate to order index', async() => {
|
||||||
nightmare
|
const url = await nightmare
|
||||||
.loginAndModule('employee', 'order')
|
.waitToClick(selectors.globalItems.returnToModuleIndexButton)
|
||||||
|
.waitToClick(selectors.globalItems.acceptVnConfirm)
|
||||||
|
.wait(selectors.ordersIndex.createOrderButton)
|
||||||
.accessToSearchResult('18')
|
.accessToSearchResult('18')
|
||||||
.accessToSection('order.card.basicData');
|
.accessToSection('order.card.basicData')
|
||||||
|
.wait(selectors.orderBasicData.companyAutocomplete)
|
||||||
|
.parsedUrl();
|
||||||
|
|
||||||
|
expect(url.hash).toEqual('#!/order/18/basic-data');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should be able to modify all the properties', async() => {
|
it('should be able to modify all the properties', async() => {
|
||||||
|
@ -58,7 +64,7 @@ describe('Order edit basic data path', () => {
|
||||||
.autocompleteSearch(selectors.orderBasicData.clientAutocomplete, 'Tony Stark')
|
.autocompleteSearch(selectors.orderBasicData.clientAutocomplete, 'Tony Stark')
|
||||||
.autocompleteSearch(selectors.orderBasicData.companyAutocomplete, 'CCs')
|
.autocompleteSearch(selectors.orderBasicData.companyAutocomplete, 'CCs')
|
||||||
.clearInput(selectors.orderBasicData.observationInput)
|
.clearInput(selectors.orderBasicData.observationInput)
|
||||||
.type(selectors.orderBasicData.observationInput, 'Observation modified')
|
.write(selectors.orderBasicData.observationInput, 'Observation modified')
|
||||||
.click(selectors.orderBasicData.saveButton)
|
.click(selectors.orderBasicData.saveButton)
|
||||||
.waitForLastSnackbar();
|
.waitForLastSnackbar();
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,10 @@ describe('Ticket services path', () => {
|
||||||
.waitToClick(selectors.ticketService.saveServiceButton)
|
.waitToClick(selectors.ticketService.saveServiceButton)
|
||||||
.waitForLastSnackbar();
|
.waitForLastSnackbar();
|
||||||
|
|
||||||
expect(result).toEqual('Data saved!');
|
expect(result).toEqual('¡Datos guardados!');
|
||||||
|
|
||||||
|
// #1051 Traducciones que fallan
|
||||||
|
// expect(result).toEqual('Data saved!');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should confirm the service description was edited correctly', async() => {
|
it('should confirm the service description was edited correctly', async() => {
|
||||||
|
@ -64,7 +67,10 @@ describe('Ticket services path', () => {
|
||||||
.waitToClick(selectors.ticketService.saveServiceButton)
|
.waitToClick(selectors.ticketService.saveServiceButton)
|
||||||
.waitForLastSnackbar();
|
.waitForLastSnackbar();
|
||||||
|
|
||||||
expect(result).toEqual('Data saved!');
|
expect(result).toEqual('¡Datos guardados!');
|
||||||
|
|
||||||
|
// #1051 Traducciones que fallan
|
||||||
|
// expect(result).toEqual('Data saved!');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should confirm the service was sucessfully removed', async() => {
|
it('should confirm the service was sucessfully removed', async() => {
|
||||||
|
|
|
@ -31,7 +31,7 @@ describe('Ticket create path', () => {
|
||||||
expect(result).toEqual(`You can't create a ticket for a inactive client`);
|
expect(result).toEqual(`You can't create a ticket for a inactive client`);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should suceed to create a ticket for a valid client', async() => {
|
it('should succeed to create a ticket for a valid client', async() => {
|
||||||
const result = await nightmare
|
const result = await nightmare
|
||||||
.autocompleteSearch(selectors.createTicketView.clientAutocomplete, 'Tony Stark')
|
.autocompleteSearch(selectors.createTicketView.clientAutocomplete, 'Tony Stark')
|
||||||
.autocompleteSearch(selectors.createTicketView.addressAutocomplete, 'Tony Stark')
|
.autocompleteSearch(selectors.createTicketView.addressAutocomplete, 'Tony Stark')
|
||||||
|
@ -41,7 +41,10 @@ describe('Ticket create path', () => {
|
||||||
.waitToClick(selectors.createTicketView.createButton)
|
.waitToClick(selectors.createTicketView.createButton)
|
||||||
.waitForLastSnackbar();
|
.waitForLastSnackbar();
|
||||||
|
|
||||||
expect(result).toEqual('Data saved!');
|
expect(result).toEqual('¡Datos guardados!');
|
||||||
|
|
||||||
|
// #1051 Traducciones que fallan
|
||||||
|
// expect(result).toEqual('Data saved!');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should check the url is now the summary of the ticket', async() => {
|
it('should check the url is now the summary of the ticket', async() => {
|
||||||
|
|
Loading…
Reference in New Issue