clients path refactor, intermitent errors should be fixed pending tests on windows environment.
This commit is contained in:
parent
700be7c5a6
commit
e68c05d9f1
|
@ -1,7 +1,6 @@
|
|||
import config from './config.js';
|
||||
import Nightmare from 'nightmare';
|
||||
import selectors from './selectors.js';
|
||||
const components = selectors.components;
|
||||
|
||||
function child(selector, childNumber) {
|
||||
let aux = selector.split(' ');
|
||||
|
@ -11,10 +10,9 @@ function child(selector, childNumber) {
|
|||
Nightmare.action('login', function(done) {
|
||||
try {
|
||||
this.goto(`${config.url}auth/?apiKey=salix`)
|
||||
.wait(`${components.textFieldInput}`)
|
||||
.write(`${child(components.textFieldInput, 1)}`, 'nightmare')
|
||||
.write(`${child(components.textFieldInput, 2)}`, 'nithmarePassword')
|
||||
.click(components.submitButton)
|
||||
.write(`${child(selectors.login.textFieldInput, 1)}`, 'nightmare')
|
||||
.write(`${child(selectors.login.textFieldInput, 2)}`, 'nightmarePassword')
|
||||
.click(selectors.login.submitButton)
|
||||
.then(done);
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
|
@ -40,7 +38,7 @@ Nightmare.action('clearInput', function(selector, done) {
|
|||
|
||||
Nightmare.action('write', function(selector, text, done) {
|
||||
this.wait(selector)
|
||||
.insert(selector, text)
|
||||
.type(selector, text)
|
||||
.then(done);
|
||||
});
|
||||
|
||||
|
|
|
@ -1,10 +1,27 @@
|
|||
// eslint max-len: ["error", 500]
|
||||
// eslint key-spacing: ["error", 500]
|
||||
export default {
|
||||
components: {
|
||||
login: {
|
||||
textFieldInput: 'vn-textfield > div > input',
|
||||
topBar: 'vn-topbar',
|
||||
submitButton: 'vn-submit > input[type="submit"]'
|
||||
},
|
||||
globalItems: {
|
||||
topBar: 'vn-topbar',
|
||||
snackbar: 'body > vn-app > vn-vertical > vn-snackbar > div > div'
|
||||
},
|
||||
moduleAccessView: {
|
||||
clientsSectionButton: 'body > vn-app > vn-vertical > vn-vertical > vn-home > vn-vertical > vn-module-container > a:nth-child(1)'
|
||||
},
|
||||
clientsView: {
|
||||
createClientButton: 'body > vn-app > vn-vertical > vn-vertical > vn-client-index > div > a > vn-float-button > button'
|
||||
},
|
||||
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(2) > vn-textfield:nth-child(3) > div > input',
|
||||
UserName: '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(4) > div > input',
|
||||
email: '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(5) > div > input',
|
||||
createButton: 'body > vn-app > vn-vertical > vn-vertical > vn-client-create > form > div > vn-button-bar > vn-button > button'
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -1,39 +1,39 @@
|
|||
import config from '../helpers/config.js';
|
||||
import createNightmare from '../helpers/nightmare';
|
||||
import selectors from '../helpers/selectors.js';
|
||||
let components = selectors.components;
|
||||
|
||||
import {catchErrors} from '../../services/utils/jasmineHelpers';
|
||||
const nightmare = createNightmare();
|
||||
|
||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 5000;
|
||||
|
||||
describe('Clients path', () => {
|
||||
it('should log in', done => {
|
||||
nightmare
|
||||
.login()
|
||||
.wait(2000)
|
||||
.wait(200)
|
||||
.wait(selectors.globalItems.topBar)
|
||||
.url()
|
||||
.then(url => {
|
||||
expect(url).toBe(config.url + '#!/');
|
||||
done();
|
||||
});
|
||||
})
|
||||
.catch(catchErrors(done));
|
||||
});
|
||||
|
||||
it('should access to the clients index by clicking the clients button', done => {
|
||||
nightmare
|
||||
.click('body > vn-app > vn-vertical > vn-vertical > vn-home > vn-vertical > vn-module-container > a:nth-child(1)')
|
||||
.wait(1000)
|
||||
.click(selectors.moduleAccessView.clientsSectionButton)
|
||||
.wait(selectors.clientsView.createClientButton)
|
||||
.url()
|
||||
.then(url => {
|
||||
expect(url).toBe(config.url + '#!/clients');
|
||||
done();
|
||||
});
|
||||
})
|
||||
.catch(catchErrors(done));
|
||||
});
|
||||
|
||||
it('should access to the create client by clicking the create-client button', done => {
|
||||
it('should access to the create client view by clicking the create-client floating button', done => {
|
||||
nightmare
|
||||
.click('body > vn-app > vn-vertical > vn-vertical > vn-client-index > div > a')
|
||||
.wait(1000)
|
||||
.click(selectors.clientsView.createClientButton)
|
||||
.wait()
|
||||
.url()
|
||||
.then(url => {
|
||||
expect(url).toBe(config.url + '#!/create');
|
||||
|
@ -43,9 +43,9 @@ describe('Clients path', () => {
|
|||
|
||||
it('should receive an error when clicking the create button having all the form fields empty', done => {
|
||||
nightmare
|
||||
.click('body > vn-app > vn-vertical > vn-vertical > vn-client-create > form > div > vn-button-bar > vn-button > button')
|
||||
.wait('body > vn-app > vn-vertical > vn-snackbar > div > div')
|
||||
.getInnerText('body > vn-app > vn-vertical > vn-snackbar > div > div')
|
||||
.click(selectors.createClientView.createButton)
|
||||
.wait(selectors.globalItems.snackbar)
|
||||
.getInnerText(selectors.globalItems.snackbar)
|
||||
.then(result => {
|
||||
expect(result).toBe('No hay cambios que guardar');
|
||||
done();
|
||||
|
|
Loading…
Reference in New Issue