fixed url() problems for e2e create clients path, plus extension implementation.

This commit is contained in:
Carlos 2017-09-18 17:28:47 +02:00
parent 59a533473c
commit 26a1d7fb29
2 changed files with 12 additions and 3 deletions

View File

@ -10,8 +10,9 @@ function child(selector, childNumber) {
Nightmare.action('login', function(done) { Nightmare.action('login', function(done) {
try { try {
this.goto(`${config.url}auth/?apiKey=salix`) this.goto(`${config.url}auth/?apiKey=salix`)
.wait(selectors.login.textFieldInput)
.write(`${child(selectors.login.textFieldInput, 1)}`, 'nightmare') .write(`${child(selectors.login.textFieldInput, 1)}`, 'nightmare')
.write(`${child(selectors.login.textFieldInput, 2)}`, 'nightmare') .write(`${child(selectors.login.textFieldInput, 2)}`, 'nightmarePassword')
.click(selectors.login.submitButton) .click(selectors.login.submitButton)
.then(done); .then(done);
} catch (err) { } catch (err) {
@ -121,3 +122,10 @@ Nightmare.action('waitForSnackbarReset', function(done) {
}) })
.then(done); .then(done);
}); });
Nightmare.action('waitForURL', function(hashURL, done) {
this.wait(hash => {
return document.location.hash === hash;
}, hashURL)
.then(done);
});

View File

@ -3,6 +3,7 @@ import createNightmare from '../helpers/nightmare';
import selectors from '../helpers/selectors.js'; import selectors from '../helpers/selectors.js';
import {catchErrors} from '../../services/utils/jasmineHelpers'; import {catchErrors} from '../../services/utils/jasmineHelpers';
const nightmare = createNightmare(); const nightmare = createNightmare();
const moduleAccessViewHashURL = '#!/';
jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000; jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000;
@ -10,10 +11,10 @@ describe('Clients path', () => {
it('should log in', done => { it('should log in', done => {
nightmare nightmare
.login() .login()
.wait(selectors.globalItems.topBar) .waitForURL(moduleAccessViewHashURL)
.url() .url()
.then(url => { .then(url => {
expect(url).toBe(config.url + '#!/'); expect(url).toBe(config.url + moduleAccessViewHashURL);
done(); done();
}) })
.catch(catchErrors(done)); .catch(catchErrors(done));