modified all e2e paths to ensure the app language is in english before runing tests plus refactors

This commit is contained in:
Carlos Jimenez 2017-12-07 15:40:16 +01:00
parent 92fe65b898
commit 323c69858b
5 changed files with 96 additions and 25 deletions

View File

@ -127,6 +127,22 @@ Nightmare.action('waitForTextInElement', function(selector, name, done) {
.then(done); .then(done);
}); });
Nightmare.action('changeLanguageToEnglish', function(done) {
this.wait(selectors.globalItems.languageButton)
.evaluate(selector => {
return document.querySelector(selector).title;
}, selectors.globalItems.languageButton)
.then(result => {
if (result === 'Cambiar idioma') {
this.click(selectors.globalItems.languageButton)
.then(done);
}
if (result != 'Cambiar idioma') {
this.then(done);
}
});
});
Nightmare.action('waitForSnackbarReset', function(done) { Nightmare.action('waitForSnackbarReset', function(done) {
this.wait(() => { this.wait(() => {
return document.querySelector('vn-snackbar').innerText === ''; return document.querySelector('vn-snackbar').innerText === '';

View File

@ -10,6 +10,7 @@ export default {
globalItems: { globalItems: {
topBar: `${components.vnTopbar}`, topBar: `${components.vnTopbar}`,
logOutButton: `${components.vnIcon}[icon="exit_to_app"]`, logOutButton: `${components.vnIcon}[icon="exit_to_app"]`,
languageButton: `${components.vnIcon}[icon="language"]`,
snackbarIsActive: '.mdl-snackbar--active > .mdl-snackbar__text', snackbarIsActive: '.mdl-snackbar--active > .mdl-snackbar__text',
applicationsMenuButton: `${components.vnIcon}[icon="apps"]`, applicationsMenuButton: `${components.vnIcon}[icon="apps"]`,
applicationsMenuVisible: `${components.vnMainMenu} .is-visible > div`, applicationsMenuVisible: `${components.vnMainMenu} .is-visible > div`,

View File

@ -31,6 +31,24 @@ describe('create client path', () => {
.catch(catchErrors(done)); .catch(catchErrors(done));
}); });
it('should make sure the language is English', done => {
nightmare
.wait(selectors.globalItems.languageButton)
.evaluate(selector => {
return document.querySelector(selector).title;
}, selectors.globalItems.languageButton)
.then(result => {
if (result === 'Cambiar idioma') {
nightmare.click(selectors.globalItems.languageButton)
.then(done);
}
if (result != 'Cambiar idioma') {
nightmare
.then(done);
}
});
});
it('should access to the clients index by clicking the clients button', done => { it('should access to the clients index by clicking the clients button', done => {
nightmare nightmare
.click(selectors.moduleAccessView.clientsSectionButton) .click(selectors.moduleAccessView.clientsSectionButton)
@ -75,7 +93,7 @@ describe('create client path', () => {
.wait(selectors.globalItems.snackbarIsActive) .wait(selectors.globalItems.snackbarIsActive)
.getInnerText(selectors.globalItems.snackbarIsActive) .getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => { .then(result => {
expect(result).toEqual('No hay cambios que guardar'); expect(result).toEqual('No changes to save');
done(); done();
}) })
.catch(catchErrors(done)); .catch(catchErrors(done));
@ -149,7 +167,7 @@ describe('create client path', () => {
.wait(selectors.globalItems.snackbarIsActive) .wait(selectors.globalItems.snackbarIsActive)
.getInnerText(selectors.globalItems.snackbarIsActive) .getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => { .then(result => {
expect(result).toEqual(`Algunos campos no son válidos`); expect(result).toEqual('Some fields are invalid');
done(); done();
}) })
.catch(catchErrors(done)); .catch(catchErrors(done));
@ -184,7 +202,7 @@ describe('create client path', () => {
.wait(selectors.globalItems.snackbarIsActive) .wait(selectors.globalItems.snackbarIsActive)
.getInnerText(selectors.globalItems.snackbarIsActive) .getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => { .then(result => {
expect(result).toContain(`¡Datos guardados!`); expect(result).toContain('Data saved!');
done(); done();
}) })
.catch(catchErrors(done)); .catch(catchErrors(done));

View File

@ -31,6 +31,24 @@ describe('Edit basicData path', () => {
.catch(catchErrors(done)); .catch(catchErrors(done));
}); });
it('should make sure the language is English', done => {
nightmare
.wait(selectors.globalItems.languageButton)
.evaluate(selector => {
return document.querySelector(selector).title;
}, selectors.globalItems.languageButton)
.then(result => {
if (result === 'Cambiar idioma') {
nightmare.click(selectors.globalItems.languageButton)
.then(done);
}
if (result != 'Cambiar idioma') {
nightmare
.then(done);
}
});
});
it('should click on the Clients button of the top bar menu', done => { it('should click on the Clients button of the top bar menu', done => {
nightmare nightmare
.waitToClick(selectors.globalItems.applicationsMenuButton) .waitToClick(selectors.globalItems.applicationsMenuButton)
@ -81,7 +99,7 @@ describe('Edit basicData path', () => {
.wait(selectors.globalItems.snackbarIsActive) .wait(selectors.globalItems.snackbarIsActive)
.getInnerText(selectors.globalItems.snackbarIsActive) .getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => { .then(result => {
expect(result).toEqual('¡Datos guardados!'); expect(result).toEqual('Data saved!');
done(); done();
}) })
.catch(catchErrors(done)); .catch(catchErrors(done));
@ -111,7 +129,7 @@ describe('Edit basicData path', () => {
.wait(selectors.globalItems.snackbarIsActive) .wait(selectors.globalItems.snackbarIsActive)
.getInnerText(selectors.globalItems.snackbarIsActive) .getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => { .then(result => {
expect(result).toEqual('¡Datos guardados!'); expect(result).toEqual('Data saved!');
done(); done();
}) })
.catch(catchErrors(done)); .catch(catchErrors(done));
@ -141,7 +159,7 @@ describe('Edit basicData path', () => {
.wait(selectors.globalItems.snackbarIsActive) .wait(selectors.globalItems.snackbarIsActive)
.getInnerText(selectors.globalItems.snackbarIsActive) .getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => { .then(result => {
expect(result).toEqual('¡Datos guardados!'); expect(result).toEqual('Data saved!');
done(); done();
}) })
.catch(catchErrors(done)); .catch(catchErrors(done));
@ -171,7 +189,7 @@ describe('Edit basicData path', () => {
.wait(selectors.globalItems.snackbarIsActive) .wait(selectors.globalItems.snackbarIsActive)
.getInnerText(selectors.globalItems.snackbarIsActive) .getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => { .then(result => {
expect(result).toEqual('¡Datos guardados!'); expect(result).toEqual('Data saved!');
done(); done();
}) })
.catch(catchErrors(done)); .catch(catchErrors(done));
@ -201,7 +219,7 @@ describe('Edit basicData path', () => {
.wait(selectors.globalItems.snackbarIsActive) .wait(selectors.globalItems.snackbarIsActive)
.getInnerText(selectors.globalItems.snackbarIsActive) .getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => { .then(result => {
expect(result).toEqual('¡Datos guardados!'); expect(result).toEqual('Data saved!');
done(); done();
}) })
.catch(catchErrors(done)); .catch(catchErrors(done));
@ -231,7 +249,7 @@ describe('Edit basicData path', () => {
.wait(selectors.globalItems.snackbarIsActive) .wait(selectors.globalItems.snackbarIsActive)
.getInnerText(selectors.globalItems.snackbarIsActive) .getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => { .then(result => {
expect(result).toEqual('¡Datos guardados!'); expect(result).toEqual('Data saved!');
done(); done();
}) })
.catch(catchErrors(done)); .catch(catchErrors(done));
@ -261,7 +279,7 @@ describe('Edit basicData path', () => {
.wait(selectors.globalItems.snackbarIsActive) .wait(selectors.globalItems.snackbarIsActive)
.getInnerText(selectors.globalItems.snackbarIsActive) .getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => { .then(result => {
expect(result).toEqual('¡Datos guardados!'); expect(result).toEqual('Data saved!');
done(); done();
}) })
.catch(catchErrors(done)); .catch(catchErrors(done));

View File

@ -31,6 +31,24 @@ describe('Edit fiscalData path', () => {
.catch(catchErrors(done)); .catch(catchErrors(done));
}); });
it('should make sure the language is English', done => {
nightmare
.wait(selectors.globalItems.languageButton)
.evaluate(selector => {
return document.querySelector(selector).title;
}, selectors.globalItems.languageButton)
.then(result => {
if (result === 'Cambiar idioma') {
nightmare.click(selectors.globalItems.languageButton)
.then(done);
}
if (result != 'Cambiar idioma') {
nightmare
.then(done);
}
});
});
it('should click on the Clients button of the top bar menu', done => { it('should click on the Clients button of the top bar menu', done => {
nightmare nightmare
.waitToClick(selectors.globalItems.applicationsMenuButton) .waitToClick(selectors.globalItems.applicationsMenuButton)
@ -82,7 +100,7 @@ describe('Edit fiscalData path', () => {
.wait(selectors.globalItems.snackbarIsActive) .wait(selectors.globalItems.snackbarIsActive)
.getInnerText(selectors.globalItems.snackbarIsActive) .getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => { .then(result => {
expect(result).toEqual('¡Datos guardados!'); expect(result).toEqual('Data saved!');
done(); done();
}) })
.catch(catchErrors(done)); .catch(catchErrors(done));
@ -112,7 +130,7 @@ describe('Edit fiscalData path', () => {
.wait(selectors.globalItems.snackbarIsActive) .wait(selectors.globalItems.snackbarIsActive)
.getInnerText(selectors.globalItems.snackbarIsActive) .getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => { .then(result => {
expect(result).toEqual('¡Datos guardados!'); expect(result).toEqual('Data saved!');
done(); done();
}) })
.catch(catchErrors(done)); .catch(catchErrors(done));
@ -140,7 +158,7 @@ describe('Edit fiscalData path', () => {
.wait(selectors.globalItems.snackbarIsActive) .wait(selectors.globalItems.snackbarIsActive)
.getInnerText(selectors.globalItems.snackbarIsActive) .getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => { .then(result => {
expect(result).toEqual('¡Datos guardados!'); expect(result).toEqual('Data saved!');
done(); done();
}) })
.catch(catchErrors(done)); .catch(catchErrors(done));
@ -153,7 +171,7 @@ describe('Edit fiscalData path', () => {
.wait(selectors.globalItems.snackbarIsActive) .wait(selectors.globalItems.snackbarIsActive)
.getInnerText(selectors.globalItems.snackbarIsActive) .getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => { .then(result => {
expect(result).toEqual('¡Datos guardados!'); expect(result).toEqual('Data saved!');
done(); done();
}) })
.catch(catchErrors(done)); .catch(catchErrors(done));
@ -185,7 +203,7 @@ describe('Edit fiscalData path', () => {
.wait(selectors.globalItems.snackbarIsActive) .wait(selectors.globalItems.snackbarIsActive)
.getInnerText(selectors.globalItems.snackbarIsActive) .getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => { .then(result => {
expect(result).toEqual('¡Datos guardados!'); expect(result).toEqual('Data saved!');
done(); done();
}) })
.catch(catchErrors(done)); .catch(catchErrors(done));
@ -215,7 +233,7 @@ describe('Edit fiscalData path', () => {
.wait(selectors.globalItems.snackbarIsActive) .wait(selectors.globalItems.snackbarIsActive)
.getInnerText(selectors.globalItems.snackbarIsActive) .getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => { .then(result => {
expect(result).toEqual('¡Datos guardados!'); expect(result).toEqual('Data saved!');
done(); done();
}) })
.catch(catchErrors(done)); .catch(catchErrors(done));
@ -245,7 +263,7 @@ describe('Edit fiscalData path', () => {
.wait(selectors.globalItems.snackbarIsActive) .wait(selectors.globalItems.snackbarIsActive)
.getInnerText(selectors.globalItems.snackbarIsActive) .getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => { .then(result => {
expect(result).toEqual('¡Datos guardados!'); expect(result).toEqual('Data saved!');
done(); done();
}) })
.catch(catchErrors(done)); .catch(catchErrors(done));
@ -275,7 +293,7 @@ describe('Edit fiscalData path', () => {
.wait(selectors.globalItems.snackbarIsActive) .wait(selectors.globalItems.snackbarIsActive)
.getInnerText(selectors.globalItems.snackbarIsActive) .getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => { .then(result => {
expect(result).toEqual(`¡Datos guardados!`); expect(result).toEqual('Data saved!');
done(); done();
}) })
.catch(catchErrors(done)); .catch(catchErrors(done));
@ -305,7 +323,7 @@ describe('Edit fiscalData path', () => {
.wait(selectors.globalItems.snackbarIsActive) .wait(selectors.globalItems.snackbarIsActive)
.getInnerText(selectors.globalItems.snackbarIsActive) .getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => { .then(result => {
expect(result).toEqual(`¡Datos guardados!`); expect(result).toEqual('Data saved!');
done(); done();
}) })
.catch(catchErrors(done)); .catch(catchErrors(done));
@ -333,7 +351,7 @@ describe('Edit fiscalData path', () => {
.wait(selectors.globalItems.snackbarIsActive) .wait(selectors.globalItems.snackbarIsActive)
.getInnerText(selectors.globalItems.snackbarIsActive) .getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => { .then(result => {
expect(result).toEqual('¡Datos guardados!'); expect(result).toEqual('Data saved!');
done(); done();
}) })
.catch(catchErrors(done)); .catch(catchErrors(done));
@ -363,7 +381,7 @@ describe('Edit fiscalData path', () => {
.wait(selectors.globalItems.snackbarIsActive) .wait(selectors.globalItems.snackbarIsActive)
.getInnerText(selectors.globalItems.snackbarIsActive) .getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => { .then(result => {
expect(result).toEqual('¡Datos guardados!'); expect(result).toEqual('Data saved!');
done(); done();
}) })
.catch(catchErrors(done)); .catch(catchErrors(done));
@ -393,7 +411,7 @@ describe('Edit fiscalData path', () => {
.wait(selectors.globalItems.snackbarIsActive) .wait(selectors.globalItems.snackbarIsActive)
.getInnerText(selectors.globalItems.snackbarIsActive) .getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => { .then(result => {
expect(result).toEqual('¡Datos guardados!'); expect(result).toEqual('Data saved!');
done(); done();
}) })
.catch(catchErrors(done)); .catch(catchErrors(done));
@ -423,7 +441,7 @@ describe('Edit fiscalData path', () => {
.wait(selectors.globalItems.snackbarIsActive) .wait(selectors.globalItems.snackbarIsActive)
.getInnerText(selectors.globalItems.snackbarIsActive) .getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => { .then(result => {
expect(result).toEqual('¡Datos guardados!'); expect(result).toEqual('Data saved!');
done(); done();
}) })
.catch(catchErrors(done)); .catch(catchErrors(done));
@ -453,7 +471,7 @@ describe('Edit fiscalData path', () => {
.wait(selectors.globalItems.snackbarIsActive) .wait(selectors.globalItems.snackbarIsActive)
.getInnerText(selectors.globalItems.snackbarIsActive) .getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => { .then(result => {
expect(result).toEqual('¡Datos guardados!'); expect(result).toEqual('Data saved!');
done(); done();
}) })
.catch(catchErrors(done)); .catch(catchErrors(done));
@ -483,7 +501,7 @@ describe('Edit fiscalData path', () => {
.wait(selectors.globalItems.snackbarIsActive) .wait(selectors.globalItems.snackbarIsActive)
.getInnerText(selectors.globalItems.snackbarIsActive) .getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => { .then(result => {
expect(result).toEqual('¡Datos guardados!'); expect(result).toEqual('Data saved!');
done(); done();
}) })
.catch(catchErrors(done)); .catch(catchErrors(done));