e2e big refactor on selectors

This commit is contained in:
Carlos 2017-11-07 09:09:59 +01:00
parent 736d4f804e
commit d4996ac363
3 changed files with 60 additions and 33 deletions

View File

@ -0,0 +1,16 @@
// eslint max-len: ["error", 500]
// eslint key-spacing: ["error", 500]
export default {
vnTextfield: 'vn-textfield > div > input',
vnSubmit: 'vn-submit > input',
vnTopbar: 'vn-topbar > header',
vnIcon: 'vn-icon',
vnMainMenu: 'vn-main-menu > div',
vnModuleContainer: 'vn-module-container > a',
vnSearchBar: 'vn-searchbar > form > vn-horizontal',
vnItemClient: 'vn-item-client',
vnFloatButton: 'vn-float-button > button',
vnMenuItem: 'vn-menu-item > li > a',
vnAutocomplete: 'vn-autocomplete'
};

View File

@ -1,46 +1,57 @@
// eslint max-len: ["error", 500]
// eslint key-spacing: ["error", 500]
import components from './selector_variables.js';
console.log(`${checkElement(components.vnAutocomplete, '$ctrl.client.contactChannelFk')}`);
function checkElement(selector, attributeValue) {
let aux = selector.split(' ');
if (aux[0] === 'vn-autocomplete') {
return selector.replace(aux[0], `${aux[0]}[field="${attributeValue}"]`);
}
if (aux[0] === 'vn-textfield') {
return selector.replace(aux[4], `${aux[4]}[name="${attributeValue}"]`);
}
}
export default {
login: {
textFieldInput: 'vn-textfield > div > input',
submitButton: 'vn-submit > input[type="submit"]'
textFieldInput: `${components.vnTextfield}`,
submitButton: `${components.vnSubmit}`
},
globalItems: {
topBar: 'vn-topbar',
logOutButton: 'body > vn-app > vn-vertical > vn-topbar > header > vn-main-menu > div > vn-icon:nth-child(4)',
topBar: `${components.vnTopbar}`,
logOutButton: `${components.vnIcon}[icon="exit_to_app"]`,
snackbarIsActive: '.mdl-snackbar--active > .mdl-snackbar__text',
applicationsMenuButton: '#apps > i',
applicationsMenuVisible: 'body > vn-app > vn-vertical > vn-topbar > header > vn-main-menu > div .is-visible > div',
clientsButton: 'body > vn-app > vn-vertical > vn-topbar > header > vn-main-menu > div > div > ul > li:nth-child(1)'
applicationsMenuButton: `${components.vnIcon}[icon="apps"]`,
applicationsMenuVisible: `${components.vnMainMenu} .is-visible > div`,
clientsButton: `${components.vnMainMenu} > div > ul > li:nth-child(1)`
},
moduleAccessView: {
clientsSectionButton: 'body > vn-app > vn-vertical > vn-vertical > vn-home > vn-vertical > vn-module-container > a:nth-child(1)'
clientsSectionButton: `${components.vnModuleContainer}[ui-sref="clients"]`
},
clientsIndex: {
searchClientInput: 'body > vn-app > vn-vertical > vn-vertical > vn-client-index > div > div > vn-card:nth-child(1) > div > vn-horizontal > vn-searchbar > form > vn-horizontal > vn-textfield > div > input',
searchButton: 'body > vn-app > vn-vertical > vn-vertical > vn-client-index > div > div > vn-card:nth-child(1) > div > vn-horizontal > vn-searchbar > form > vn-horizontal > vn-icon-button > button',
searchResult: 'body > vn-app > vn-vertical > vn-vertical > vn-client-index > div > div > vn-card:nth-child(2) > div > vn-item-client:nth-child(1) > a',
createClientButton: 'body > vn-app > vn-vertical > vn-vertical > vn-client-index > div > a > vn-float-button > button'
searchClientInput: `${components.vnTextfield}`,
searchButton: `${components.vnSearchBar} > vn-icon-button > button`,
searchResult: `${components.vnItemClient}:nth-child(1) > a`,
createClientButton: `${components.vnFloatButton}`
},
createClientView: {
name: 'body > vn-app > vn-vertical > vn-vertical > vn-client-create > form > div > vn-card > div > vn-vertical > vn-horizontal:nth-child(2) > vn-textfield:nth-child(1) > div > input',
taxNumber: 'body > vn-app > vn-vertical > vn-vertical > vn-client-create > form > div > vn-card > div > vn-vertical > vn-horizontal:nth-child(2) > vn-textfield:nth-child(2) > div > input',
businessName: 'body > vn-app > vn-vertical > vn-vertical > vn-client-create > form > div > vn-card > div > vn-vertical > vn-horizontal:nth-child(3) > vn-textfield:nth-child(1) > div > input',
userName: 'body > vn-app > vn-vertical > vn-vertical > vn-client-create > form > div > vn-card > div > vn-vertical > vn-horizontal:nth-child(3) > vn-textfield:nth-child(2) > div > input',
email: 'body > vn-app > vn-vertical > vn-vertical > vn-client-create > form > div > vn-card > div > vn-vertical > vn-horizontal:nth-child(4) > vn-textfield > div > input',
createButton: 'body > vn-app > vn-vertical > vn-vertical > vn-client-create > form > div > vn-button-bar > vn-button > button'
name: `${checkElement(components.vnTextfield, 'name')}`,
taxNumber: `${checkElement(components.vnTextfield, 'fi')}`,
socialName: `${checkElement(components.vnTextfield, 'socialName')}`,
userName: `${checkElement(components.vnTextfield, 'userName')}`,
email: `${checkElement(components.vnTextfield, 'email')}`,
createButton: `${components.vnSubmit}`
},
basicData: {
basicDataButton: 'body > vn-app > vn-vertical > vn-vertical > vn-client-card > vn-horizontal > vn-empty > vn-left-menu > vn-card > div > vn-vertical > vn-actions > vn-horizontal > ul > vn-menu-item:nth-child(1) > li > a',
nameInput: 'body > vn-app > vn-vertical > vn-vertical > vn-client-card > vn-horizontal > vn-auto > vn-vertical > vn-client-basic-data > form > vn-card > div > vn-vertical > vn-horizontal:nth-child(2) > vn-textfield:nth-child(1) > div > input',
taxNumberInput: 'body > vn-app > vn-vertical > vn-vertical > vn-client-card > vn-horizontal > vn-auto > vn-vertical > vn-client-basic-data > form > vn-card > div > vn-vertical > vn-horizontal:nth-child(2) > vn-textfield:nth-child(2) > div > input',
socialNameInput: 'body > vn-app > vn-vertical > vn-vertical > vn-client-card > vn-horizontal > vn-auto > vn-vertical > vn-client-basic-data > form > vn-card > div > vn-vertical > vn-horizontal:nth-child(2) > vn-textfield:nth-child(3) > div > input',
phoneInput: 'body > vn-app > vn-vertical > vn-vertical > vn-client-card > vn-horizontal > vn-auto > vn-vertical > vn-client-basic-data > form > vn-card > div > vn-vertical > vn-horizontal:nth-child(3) > vn-textfield:nth-child(1) > div > input',
mobileInput: 'body > vn-app > vn-vertical > vn-vertical > vn-client-card > vn-horizontal > vn-auto > vn-vertical > vn-client-basic-data > form > vn-card > div > vn-vertical > vn-horizontal:nth-child(3) > vn-textfield:nth-child(2) > div > input',
faxInput: 'body > vn-app > vn-vertical > vn-vertical > vn-client-card > vn-horizontal > vn-auto > vn-vertical > vn-client-basic-data > form > vn-card > div > vn-vertical > vn-horizontal:nth-child(3) > vn-textfield:nth-child(3) > div > input',
emailInput: 'body > vn-app > vn-vertical > vn-vertical > vn-client-card > vn-horizontal > vn-auto > vn-vertical > vn-client-basic-data > form > vn-card > div > vn-vertical > vn-horizontal:nth-child(4) > vn-textfield > div > input',
salesPersonInput: 'body > vn-app > vn-vertical > vn-vertical > vn-client-card > vn-horizontal > vn-auto > vn-vertical > vn-client-basic-data > form > vn-card > div > vn-vertical > vn-horizontal:nth-child(4) > vn-autocomplete:nth-child(2) > vn-vertical > vn-textfield > div > input',
basicDataButton: `${components.vnMenuItem}`,
nameInput: `${checkElement(components.vnTextfield, 'name')}`,
taxNumberInput: `${checkElement(components.vnTextfield, 'fi')}`,
socialNameInput: `${checkElement(components.vnTextfield, 'socialName')}`,
phoneInput: `${checkElement(components.vnTextfield, 'phone')}`,
mobileInput: `${checkElement(components.vnTextfield, 'mobile')}`,
faxInput: `${checkElement(components.vnTextfield, 'fax')}`,
emailInput: `${checkElement(components.vnTextfield, 'email')}`,
salesPersonInput: `${checkElement(components.vnAutocomplete, '$ctrl.client.salesPersonFk')}`,
channelInput: 'body > vn-app > vn-vertical > vn-vertical > vn-client-card > vn-horizontal > vn-auto > vn-vertical > vn-client-basic-data > form > vn-card > div > vn-vertical > vn-horizontal:nth-child(4) > vn-autocomplete:nth-child(3) > vn-vertical > vn-textfield > div > input',
channelMetropolisOption: 'body > vn-app > vn-vertical > vn-vertical > vn-client-card > vn-horizontal > vn-auto > vn-vertical > vn-client-basic-data > form > vn-card > div > vn-vertical > vn-horizontal:nth-child(4) > vn-autocomplete:nth-child(3) > vn-vertical > vn-drop-down > vn-vertical > vn-one:nth-child(2) > ul > li:nth-child(3)',
saveButton: 'body > vn-app > vn-vertical > vn-vertical > vn-client-card > vn-horizontal > vn-auto > vn-vertical > vn-client-basic-data > form > vn-button-bar > vn-submit > input'
@ -50,8 +61,8 @@ export default {
addressInput: 'body > vn-app > vn-vertical > vn-vertical > vn-client-card > vn-horizontal > vn-auto > vn-vertical > vn-client-fiscal-data > form > vn-card > div > vn-vertical > vn-horizontal:nth-child(3) > vn-textfield:nth-child(1) > div > input',
hasToInvoiceCheckboxLabel: 'body > vn-app > vn-vertical > vn-vertical > vn-client-card > vn-horizontal > vn-auto > vn-vertical > vn-client-fiscal-data > form > vn-card > div > vn-vertical > vn-horizontal:nth-child(2) > vn-one:nth-child(1) > vn-check > label',
hasToInvoiceCheckboxInput: 'body > vn-app > vn-vertical > vn-vertical > vn-client-card > vn-horizontal > vn-auto > vn-vertical > vn-client-fiscal-data > form > vn-card > div > vn-vertical > vn-horizontal:nth-child(2) > vn-one:nth-child(1) > vn-check > label > input',
printToInvoiceCheckboxLabel: '',
printInvoiceCheckboxInput: '',
// printToInvoiceCheckboxLabel: '',
// printInvoiceCheckboxInput: '',
saveButton: 'body > vn-app > vn-vertical > vn-vertical > vn-client-card > vn-horizontal > vn-auto > vn-vertical > vn-client-fiscal-data > form > vn-button-bar > vn-submit > input'
}
};

View File

@ -114,7 +114,7 @@ describe('create client path', () => {
nightmare
.waitForSnackbarReset()
.clearInput(selectors.createClientView.taxNumber)
.type(selectors.createClientView.businessName, 'Avengers team')
.type(selectors.createClientView.socialName, 'Avengers team')
.click(selectors.createClientView.createButton)
.wait(selectors.globalItems.snackbarIsActive)
.getInnerText(selectors.globalItems.snackbarIsActive)
@ -128,7 +128,7 @@ describe('create client path', () => {
it('should receive an error when clicking the create button having all the form fields empty but User Name', done => {
nightmare
.waitForSnackbarReset()
.clearInput(selectors.createClientView.businessName)
.clearInput(selectors.createClientView.socialName)
.type(selectors.createClientView.userName, 'CaptainMarvel')
.click(selectors.createClientView.createButton)
.wait(selectors.globalItems.snackbarIsActive)
@ -177,7 +177,7 @@ describe('create client path', () => {
.clearInput(selectors.createClientView.email)
.type(selectors.createClientView.name, 'Carol Danvers')
.type(selectors.createClientView.taxNumber, 'Avengers Tax Number')
.type(selectors.createClientView.businessName, 'AVG tax')
.type(selectors.createClientView.socialName, 'AVG tax')
.type(selectors.createClientView.userName, 'CaptainMarvel')
.type(selectors.createClientView.email, 'CarolDanvers@verdnatura.es')
.click(selectors.createClientView.createButton)