E2E merge

This commit is contained in:
Juan Ferrer Toribio 2018-02-20 13:48:25 +01:00
parent 1dfafe0d44
commit e491b2a7b3
16 changed files with 68 additions and 188 deletions

View File

@ -3,8 +3,19 @@
<div class="box">
<img src="./logo.svg"/>
<form name="form" ng-submit="$ctrl.submit()">
<vn-textfield vn-id="userField" label="User" model="$ctrl.user" vn-focus></vn-textfield>
<vn-textfield label="Password" model="$ctrl.password" type="password"></vn-textfield>
<vn-textfield
label="User"
model="$ctrl.user"
name="user"
vn-id="userField"
vn-focus>
</vn-textfield>
<vn-textfield
label="Password"
model="$ctrl.password"
name="password"
type="password">
</vn-textfield>
<div class="footer">
<vn-submit label="Enter"></vn-submit>
<div class="spinner-wrapper">

View File

@ -1,14 +1,22 @@
<div style="position: fixed; top: 0; right: 0; padding: .8em 1.5em; z-index: 10;">
<vn-icon icon="apps" id="apps" translate-attr="{title: 'Applications'}"></vn-icon>
<ul for="apps" class="mdl-menu mdl-js-menu mdl-menu--bottom-right" pad-small>
<vn-icon
id="apps"
icon="apps"
translate-attr="{title: 'Applications'}">
</vn-icon>
<ul id="apps-menu" for="apps" class="mdl-menu mdl-js-menu mdl-menu--bottom-right" pad-small>
<li ng-repeat="mod in ::$ctrl.modules" class="mdl-menu__item" ui-sref="{{::mod.route.state}}">
<vn-icon ng-if="::mod.icon && !mod.icon.startsWith('/')" icon="{{::mod.icon}}"></vn-icon>
<img ng-if="::mod.icon && mod.icon.startsWith('/')" ng-src="{{::mod.icon}}" />
<span translate="{{::mod.name}}"></span>
</li>
</ul>
<vn-icon id="lang-button" icon="language" translate-attr="{title: 'Change language'}"></vn-icon>
<ul id="langs" for="lang-button" class="mdl-menu mdl-js-menu mdl-menu--bottom-right" pad-small>
<vn-icon
id="lang"
icon="language"
translate-attr="{title: 'Change language'}">
</vn-icon>
<ul id="langs-menu" for="lang" class="mdl-menu mdl-js-menu mdl-menu--bottom-right" pad-small>
<li
ng-repeat="lang in ::$ctrl.langs"
name="{{::lang}}"
@ -17,7 +25,12 @@
<span>{{::lang}}</span>
</li>
</ul>
<vn-icon icon="exit_to_app" translate-attr="{title: 'Logout'}" ng-click="$ctrl.onLogoutClick()"></vn-icon>
<vn-icon
id="logout"
icon="exit_to_app"
translate-attr="{title: 'Logout'}"
ng-click="$ctrl.onLogoutClick()">
</vn-icon>
<!--
TODO: Keep it commented until they are functional

View File

@ -1,34 +1,29 @@
import config from './config.js';
import Nightmare from 'nightmare';
import selectors from './selectors.js';
import {URL} from 'url';
function child(selector, childNumber) {
let aux = selector.split(' ');
return selector.replace(aux[0], `${aux[0]}:nth-child(${childNumber})`);
}
Nightmare.action('login', function(done) {
this.goto(`${config.url}auth/?apiKey=salix`)
.wait(selectors.login.textFieldInput)
.write(`${child(selectors.login.textFieldInput, 1)}`, 'JessicaJones')
.write(`${child(selectors.login.textFieldInput, 2)}`, 'nightmare')
.click(selectors.login.submitButton)
.wait(1000) // should create an extension like: https://github.com/segmentio/nightmare/issues/481 to wait for dom to be ready.
.wait(`vn-login input[name=user]`)
.write(`vn-login input[name=user]`, 'JessicaJones')
.write(`vn-login input[name=password]`, 'nightmare')
.click(`vn-login input[type=submit]`)
// FIXME: Wait for dom to be ready: https://github.com/segmentio/nightmare/issues/481
.wait(1000)
.then(done);
});
Nightmare.action('changeLanguageToEnglish', function(done) {
this.wait('#lang-button')
this.wait('#lang')
.evaluate(selector => {
return document.querySelector(selector).title;
}, '#lang-button')
}, '#lang')
.then(title => {
if (title === 'Change language') {
this.then(done);
} else {
this.click('#lang-button')
.click('#langs > li[name="en"]')
this.click('#lang')
.click('#langs-menu > li[name="en"]')
.then(done);
}
});

View File

@ -3,15 +3,9 @@
import components from './components_selectors.js';
export default {
login: {
textFieldInput: `${components.vnTextfield}`,
submitButton: `${components.vnSubmit}`
},
globalItems: {
topBar: `${components.vnTopbar}`,
logOutButton: `${components.vnIcon}[icon="exit_to_app"]`,
snackbarIsActive: 'vn-snackbar .text',
applicationsMenuButton: `${components.vnIcon}[icon="apps"]`,
logOutButton: `#logout`,
applicationsMenuButton: `#apps`,
applicationsMenuVisible: `${components.vnMainMenu} .is-visible > div`,
clientsButton: `${components.vnMainMenu} > div > ul > li:nth-child(1)`
},
@ -97,8 +91,8 @@ export default {
agenctySecondOption: `${components.vnAutocomplete}[field="$ctrl.address.agencyFk"] > vn-vertical > vn-drop-down > vn-vertical:not(.ng-hide) > vn-auto:nth-child(2) > ul > li:nth-child(2)`,
phoneInput: `${components.vnTextfield}[name="phone"]`,
mobileInput: `${components.vnTextfield}[name="mobile"]`,
defaultAddress: 'body > vn-app > vn-vertical > vn-vertical > vn-client-card > vn-main-block > vn-horizontal > vn-one > vn-vertical > ui-view > vn-client-addresses > vn-vertical > vn-card > div > vn-vertical > vn-horizontal:nth-child(2) > vn-one > vn-horizontal > vn-one > div:nth-child(2)',
secondMakeDefaultStar: 'body > vn-app > vn-vertical > vn-vertical > vn-client-card > vn-main-block > vn-horizontal > vn-one > vn-vertical > ui-view > vn-client-addresses > vn-vertical > vn-card > div > vn-vertical > vn-horizontal:nth-child(3) > vn-one > vn-horizontal > vn-none > i',
defaultAddress: 'vn-client-addresses > vn-vertical > vn-card > div > vn-vertical > vn-horizontal:nth-child(2) > vn-one > vn-horizontal > vn-one > div:nth-child(2)',
secondMakeDefaultStar: 'vn-client-addresses > vn-vertical > vn-card > div > vn-vertical > vn-horizontal:nth-child(3) > vn-one > vn-horizontal > vn-none > i',
firstEditButton: `${components.vnIconButton}[icon='edit']`,
secondEditButton: `vn-horizontal:nth-child(3) > vn-one > vn-horizontal > a > ${components.vnIconButton}[icon='edit']`,
activeCheckbox: `${components.vnCheck}[label='Enabled'] > label > input`,
@ -116,14 +110,14 @@ export default {
addNoteFloatButton: `${components.vnFloatButton}`,
noteInput: `${components.vnTextarea}[label="Note"]`,
saveButton: `${components.vnSubmit}`,
firstNoteText: 'body > vn-app > vn-vertical > vn-vertical > vn-client-card > vn-main-block > vn-horizontal > vn-one > vn-vertical > ui-view > vn-client-notes > vn-card > div > vn-vertical > vn-one:nth-child(2) > vn-horizontal.ng-binding'
firstNoteText: 'vn-client-notes > vn-card > div > vn-vertical > vn-one:nth-child(2) > vn-horizontal.ng-binding'
},
clientCredit: {
creditButton: `${components.vnMenuItem}[ui-sref="clientCard.credit.list"]`,
addCreditFloatButton: `${components.vnFloatButton}`,
creditInput: `${components.vnTextfield}[name="credit"]`,
saveButton: `${components.vnSubmit}`,
firstCreditText: 'body > vn-app > vn-vertical > vn-vertical > vn-client-card > vn-main-block > vn-horizontal > vn-one > vn-vertical > ui-view > vn-client-credit-list > vn-card > div > vn-vertical > vn-one > vn-horizontal:nth-child(1) > vn-one'
firstCreditText: 'vn-client-credit-list > vn-card > div > vn-vertical > vn-one > vn-horizontal:nth-child(1) > vn-one'
},
clientGreuge: {
greugeButton: `${components.vnMenuItem}[ui-sref="clientCard.greuge.list"]`,
@ -133,11 +127,11 @@ export default {
typeInput: `${components.vnAutocomplete}[field="$ctrl.greuge.greugeTypeFk"] > vn-vertical > ${components.vnTextfield}`,
typeSecondOption: `${components.vnAutocomplete}[field="$ctrl.greuge.greugeTypeFk"] > vn-vertical > vn-drop-down > vn-vertical > vn-auto:nth-child(2) > ul > li`,
saveButton: `${components.vnSubmit}`,
firstGreugeText: 'body > vn-app > vn-vertical > vn-vertical > vn-client-card > vn-main-block > vn-horizontal > vn-one > vn-vertical > ui-view > vn-client-greuge-list > vn-card > div > vn-vertical > vn-one > vn-horizontal'
firstGreugeText: 'vn-client-greuge-list > vn-card > div > vn-vertical > vn-one > vn-horizontal'
},
clientMandate: {
mandateButton: `${components.vnMenuItem}[ui-sref="clientCard.mandate"]`,
firstMandateText: 'body > vn-app > vn-vertical > vn-vertical > vn-client-card > vn-main-block > vn-horizontal > vn-one > vn-vertical > vn-client-mandate > vn-card > div > vn-vertical > vn-one > vn-horizontal'
firstMandateText: 'vn-client-mandate > vn-card > div > vn-vertical > vn-one > vn-horizontal'
},
itemsIndex: {
createItemButton: `${components.vnFloatButton}`,

View File

@ -161,12 +161,4 @@ describe('create client path', () => {
expect(result).toEqual(1);
});
});
describe('closing browser', () => {
it('should close the browser', done => {
nightmare
.end()
.then(done);
});
});
});

View File

@ -206,12 +206,4 @@ describe('Edit basicData path', () => {
expect(result).toEqual('Metropolis newspaper');
});
});
describe('closing browser', () => {
it('should close the browser', done => {
nightmare
.end()
.then(done);
});
});
});

View File

@ -439,12 +439,4 @@ describe('Edit fiscalData path', () => {
expect(value).toBeTruthy();
});
});
describe('closing browser', () => {
it('should close the browser', done => {
nightmare
.end()
.then(done);
});
});
});

View File

@ -197,12 +197,4 @@ describe('Edit pay method path', () => {
expect(value).toBeFalsy();
});
});
describe('closing browser', () => {
it('should close the browser', done => {
nightmare
.end()
.then(done);
});
});
});

View File

@ -201,12 +201,4 @@ describe('Add address path', () => {
expect(result).toContain('Error');
});
});
describe('closing browser', () => {
it('should close the browser', done => {
nightmare
.end()
.then(done);
});
});
});

View File

@ -60,12 +60,4 @@ describe('Add address notes path', () => {
// expect(result).toContain('Some fields are invalid');
// })
// });
describe('closing browser', () => {
it('should close the browser', done => {
nightmare
.end()
.then(done);
});
});
});

View File

@ -88,12 +88,4 @@ describe('Edit web access path', () => {
expect(result).toEqual('Hulk');
});
});
describe('closing browser', () => {
it('should close the browser', done => {
nightmare
.end()
.then(done);
});
});
});

View File

@ -68,12 +68,4 @@ describe('Add notes path', () => {
expect(value).toEqual('Meeting with Black Widow 21st 9am');
});
});
describe('closing browser', () => {
it('should close the browser', done => {
nightmare
.end()
.then(done);
});
});
});

View File

@ -69,12 +69,4 @@ describe('Add credit path', () => {
expect(value).toContain(999);
});
});
describe('closing browser', () => {
it('should close the browser', done => {
nightmare
.end()
.then(done);
});
});
});

View File

@ -114,12 +114,4 @@ describe('Add greuge path', () => {
expect(value).toContain('Diff');
});
});
describe('closing browser', () => {
it('should close the browser', done => {
nightmare
.end()
.then(done);
});
});
});

View File

@ -50,12 +50,4 @@ describe('mandate path', () => {
expect(value).toContain('CORE');
});
});
describe('closing browser', () => {
it('should close the browser', done => {
nightmare
.end()
.then(done);
});
});
});

View File

@ -1,48 +1,21 @@
import config from '../../helpers/config.js';
import createNightmare from '../../helpers/nightmare';
import selectors from '../../helpers/selectors.js';
import {catchErrors} from '../../../services/utils/jasmineHelpers';
const nightmare = createNightmare();
const moduleAccessViewHashURL = '#!/';
jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000;
import createNightmare from '../../helpers/helpers';
describe('create item barcodes path', () => {
it('should log in', done => {
nightmare
.login()
.waitForURL(moduleAccessViewHashURL)
.url()
.then(url => {
expect(url).toEqual(config.url + moduleAccessViewHashURL);
done();
})
.catch(catchErrors(done));
});
const nightmare = createNightmare();
it('should make sure the language is English', done => {
nightmare
.changeLanguageToEnglish()
.then(() => {
done();
})
.catch(catchErrors(done));
});
it('should access to the items index by clicking the items button', done => {
nightmare
it('should access to the items index by clicking the items button', () => {
return nightmare
.click(selectors.moduleAccessView.itemsSectionButton)
.wait(selectors.itemsIndex.createItemButton)
.url()
.urlParsed()
.then(url => {
expect(url).toEqual(config.url + '#!/item/list');
done();
})
.catch(catchErrors(done));
expect(url.hash).toEqual('#!/item/list');
});
});
it('should search for the item Gem of Time', done => {
nightmare
it('should search for the item Gem of Time', () => {
return nightmare
.wait(selectors.itemsIndex.searchResult)
.type(selectors.itemsIndex.searchItemInput, 'Gem of Time')
.click(selectors.itemsIndex.searchButton)
@ -50,13 +23,11 @@ describe('create item barcodes path', () => {
.countSearchResults(selectors.itemsIndex.searchResult)
.then(result => {
expect(result).toEqual(1);
done();
})
.catch(catchErrors(done));
});
});
it(`should click on the search result to access to the item barcodes`, done => {
nightmare
it(`should click on the search result to access to the item barcodes`, () => {
return nightmare
.waitForTextInElement(selectors.itemsIndex.searchResult, 'Gem of Time')
.waitToClick(selectors.itemsIndex.searchResult)
.waitToClick(selectors.itemBarcodes.barcodeButton)
@ -64,29 +35,23 @@ describe('create item barcodes path', () => {
.url()
.then(url => {
expect(url).toContain('barcode');
done();
})
.catch(catchErrors(done));
});
});
it(`should click create a new code and delete a former one`, done => {
nightmare
it(`should click create a new code and delete a former one`, () => {
return nightmare
.waitToClick(selectors.itemBarcodes.addBarcodeButton)
.type(selectors.itemBarcodes.fourthCodeInput, '5')
.click(selectors.itemBarcodes.firstCodeRemoveButton)
.click(selectors.itemBarcodes.submitBarcodesButton)
.wait(selectors.globalItems.snackbarIsActive)
.getInnerText(selectors.globalItems.snackbarIsActive)
.waitForSnackbar()
.then(result => {
expect(result).toContain('Data saved!');
done();
})
.catch(catchErrors(done));
});
});
it(`should confirm the barcode 5 is created and it is now the third barcode as the first was deleted`, done => {
nightmare
.waitForSnackbarReset()
it(`should confirm the barcode 5 is created and it is now the third barcode as the first was deleted`, () => {
return nightmare
.click(selectors.itemBasicData.basicDataButton)
.wait(selectors.itemBasicData.nameInput)
.click(selectors.itemBarcodes.barcodeButton)
@ -94,16 +59,6 @@ describe('create item barcodes path', () => {
.getInputValue(selectors.itemBarcodes.thirdCodeInput)
.then(result => {
expect(result).toEqual('5');
done();
})
.catch(catchErrors(done));
});
describe('closing browser', () => {
it('should close the browser', done => {
nightmare
.end()
.then(done);
});
});
});