#1916 Implementar Puppeteer
gitea/salix/puppeteer This commit looks good Details

This commit is contained in:
Carlos Jimenez Ruiz 2019-12-31 12:00:16 +01:00
parent e922a05e50
commit 6bf5b4c735
23 changed files with 757 additions and 783 deletions

View File

@ -2,8 +2,6 @@
{ {
// Carácter predeterminado de final de línea. // Carácter predeterminado de final de línea.
"files.eol": "\n", "files.eol": "\n",
"vsicons.presets.angular": false,
"eslint.autoFixOnSave": true,
"editor.codeActionsOnSave": { "editor.codeActionsOnSave": {
"source.fixAll.eslint": true "source.fixAll.eslint": true
} }

View File

@ -1,6 +1,20 @@
/* eslint no-invalid-this: "off" */ /* eslint no-invalid-this: "off" */
import {url as defaultURL} from './config';
let currentUser;
let actions = { let actions = {
clickIfExists: async function(selector) {
let exists;
try {
exists = await this.waitForSelector(selector, {timeout: 500});
} catch (error) {
exists = false;
}
if (exists) await this.waitToClick(selector);
return exists;
},
parsedUrl: async function() { parsedUrl: async function() {
return new URL(await this.url()); return new URL(await this.url());
}, },
@ -21,30 +35,48 @@ let actions = {
if (lang !== 'English') if (lang !== 'English')
await this.autocompleteSearch(langSelector, 'English'); await this.autocompleteSearch(langSelector, 'English');
await this.waitFor(250); // tryed {visible: true}, page 'mutation' and waitForSelector unsuccessfully... await this.keyboard.press('Escape');
await this.mouse.down();
await this.waitForSelector(langSelector, {hidden: true}); await this.waitForSelector(langSelector, {hidden: true});
}, },
doLogin: async function(userName, password = 'nightmare') { doLogin: async function(userName, password = 'nightmare') {
await this.wait(`vn-login [name=user]`); await this.wait(`vn-login [ng-model="$ctrl.user"]`);
await this.clearInput(`vn-login [name=user]`); await this.clearInput(`vn-login [ng-model="$ctrl.user"]`);
await this.write(`vn-login [name=user]`, userName); await this.type(`vn-login [ng-model="$ctrl.user"]`, userName);
await this.clearInput(`vn-login [name=password]`); await this.clearInput(`vn-login [ng-model="$ctrl.password"]`);
await this.write(`vn-login [name=password]`, password); await this.write(`vn-login [ng-model="$ctrl.password"]`, password);
await this.click('vn-login button[type=submit]'); await this.click('vn-login button[type=submit]');
}, },
login: async function(userName) { login: async function(userName) {
if (currentUser !== userName) {
let userPanelOpen = await this.evaluate(() => {
return document.querySelector('.user-popover');
});
if (!userPanelOpen)
await this.clickIfExists('#user');
await this.clickIfExists('#logout');
try {
await this.waitForURL('#!/login');
} catch (e) {
await this.goto(`${defaultURL}/#!/login`);
}
await this.doLogin(userName); await this.doLogin(userName);
await this.wait(() => { await this.wait(() => {
return document.location.hash === '#!/'; return document.location.hash === '#!/';
}, {}); }, {});
await this.changeLanguageToEnglish(); await this.changeLanguageToEnglish();
},
waitForLogin: async function(userName) { currentUser = userName;
await this.login(userName); } else {
await this.wait(() => {
return document.location.hash === '#!/';
}, {});
await this.changeLanguageToEnglish();
await this.waitToClick('a[ui-sref=home]');
}
}, },
selectModule: async function(moduleName) { selectModule: async function(moduleName) {
@ -94,12 +126,17 @@ let actions = {
clearInput: async function(selector) { clearInput: async function(selector) {
await this.wait(selector); await this.wait(selector);
return await this.evaluate(selector => { let field = await this.evaluate(selector => {
let $ctrl = document.querySelector(selector).closest('.vn-field').$ctrl; return document.querySelector(selector).closest('.vn-field').$ctrl.field;
$ctrl.field = null;
$ctrl.$.$apply();
$ctrl.input.dispatchEvent(new Event('change'));
}, selector); }, selector);
if (field != null && field != '') {
let coords = await this.evaluate(selector => {
let rect = document.querySelector(selector).getBoundingClientRect();
return {x: rect.x + (rect.width / 2), y: rect.y + (rect.height / 2)};
}, selector);
await this.mouse.move(coords.x, coords.y);
await this.waitToClick(`${selector} [icon="clear"]`);
}
}, },
getProperty: async function(selector, property) { getProperty: async function(selector, property) {
@ -134,8 +171,8 @@ let actions = {
}, },
write: async function(selector, text) { write: async function(selector, text) {
await this.wait(selector); await this.wait(selector, {});
await this.type(selector, text); await this.type(`${selector} input`, text);
}, },
waitToClick: async function(selector) { waitToClick: async function(selector) {
@ -278,43 +315,31 @@ let actions = {
}, {}, hashURL); }, {}, hashURL);
}, },
waitForShapes: async function(selector) { hideSnackbar: async function() {
await this.wait(selector); await this.waitToClick('#shapes .shown button');
return await this.evaluate(selector => {
const shapes = document.querySelectorAll(selector);
const shapesList = [];
for (const shape of shapes)
shapesList.push(shape.innerText);
return shapesList;
}, selector);
},
waitForSnackbar: async function() {
await this.wait(500);
return await this.waitForShapes('vn-snackbar .shape .text');
}, },
waitForLastShape: async function(selector) { waitForLastShape: async function(selector) {
await this.wait(selector); await this.wait(selector);
return await this.evaluate(selector => { let snackBarText = await this.evaluate(selector => {
const shape = document.querySelector(selector); const shape = document.querySelector(selector);
return shape.innerText; return shape.innerText;
}, selector); }, selector);
await this.hideSnackbar();
return snackBarText;
}, },
waitForLastSnackbar: async function() { waitForLastSnackbar: async function() {
await this.wait(500); await this.wait(2000); // this needs a refactor to be somehow dynamic ie: page.waitForResponse(urlOrPredicate[, options]) or something to fire waitForLastShape once the request is completed
await this.waitForSpinnerLoad(); await this.waitForSpinnerLoad();
return await this.waitForLastShape('vn-snackbar .shape .text'); return await this.waitForLastShape('vn-snackbar .shown .text');
}, },
accessToSearchResult: async function(searchValue) { accessToSearchResult: async function(searchValue) {
await this.clearInput('vn-searchbar input'); await this.clearInput('vn-searchbar');
await this.write('vn-searchbar input', searchValue); await this.write('vn-searchbar', searchValue);
await this.click('vn-searchbar vn-icon[icon="search"]'); await this.waitToClick('vn-searchbar vn-icon[icon="search"]');
await this.waitForNumberOfElements('.search-result', 1); await this.waitForNumberOfElements('.search-result', 1);
let result = await this.evaluate(() => { let result = await this.evaluate(() => {
return document.querySelector('ui-view vn-card vn-table') != null; return document.querySelector('ui-view vn-card vn-table') != null;
@ -327,23 +352,30 @@ let actions = {
accessToSection: async function(sectionRoute) { accessToSection: async function(sectionRoute) {
await this.wait(`vn-left-menu`); await this.wait(`vn-left-menu`);
letnested = await this.evaluate(sectionRoute => { let nested = await this.evaluate(sectionRoute => {
return document.querySelector(`vn-left-menu li li > a[ui-sref="${sectionRoute}"]`) != null; return document.querySelector(`vn-left-menu li li > a[ui-sref="${sectionRoute}"]`) != null;
}, sectionRoute); }, sectionRoute);
if (nested) { if (nested) {
await this.waitToClick('vn-left-menu vn-item-section > vn-icon[icon=keyboard_arrow_down]'); await this.waitToClick('vn-left-menu vn-item-section > vn-icon[icon=keyboard_arrow_down]');
await this.wait('vn-left-menu .expanded'); await this.wait('vn-left-menu .expanded');
} }
await this.waitToClick(`vn-left-menu li > a[ui-sref="${sectionRoute}"]`); await this.evaluate(sectionRoute => {
await this.waitForSpinnerLoad(); let navButton = document.querySelector(`vn-left-menu li > a[ui-sref="${sectionRoute}"]`);
navButton.scrollIntoViewIfNeeded();
return navButton.click();
}, sectionRoute);
}, },
autocompleteSearch: async function(autocompleteSelector, searchValue) { autocompleteSearch: async function(autocompleteSelector, searchValue) {
await this.waitFor(100); // time in which the autocomplete data loads
await this.waitToClick(`${autocompleteSelector} input`); await this.waitToClick(`${autocompleteSelector} input`);
await this.write(`.vn-drop-down.shown input`, searchValue); await this.write(`.vn-drop-down.shown input`, searchValue);
await this.waitFor(100); // ul to repaint
await this.waitToClick(`.vn-drop-down.shown li.active`); await this.waitToClick(`.vn-drop-down.shown li.active`);
await this.waitFor(100); // input to asign value
await this.wait((autocompleteSelector, searchValue) => { await this.wait((autocompleteSelector, searchValue) => {
return document.querySelector(`${autocompleteSelector} input`).value return document.querySelector(`${autocompleteSelector} input`).value
.toLowerCase() .toLowerCase()
@ -355,7 +387,11 @@ let actions = {
}, },
reloadSection: async function(sectionRoute) { reloadSection: async function(sectionRoute) {
await this.waitToClick('vn-icon[icon="desktop_windows"]'); await this.evaluate(() => {
let summayButton = document.querySelector('vn-icon[icon="desktop_windows"]');
summayButton.scrollIntoViewIfNeeded();
return summayButton.click();
});
await this.wait('vn-card.summary'); await this.wait('vn-card.summary');
await this.waitToClick(`vn-left-menu li > a[ui-sref="${sectionRoute}"]`); await this.waitToClick(`vn-left-menu li > a[ui-sref="${sectionRoute}"]`);
}, },
@ -404,10 +440,10 @@ let actions = {
waitForWatcherData: async function(selector) { waitForWatcherData: async function(selector) {
await this.wait(selector); await this.wait(selector);
await this.wait(selector => { await this.wait(selector => {
const watcher = document.querySelector(selector); let watcher = document.querySelector(selector);
let orgData = watcher.$ctrl.orgData; let orgData = watcher.$ctrl.orgData;
return !angular.equals({}, orgData) && orgData != null; return !angular.equals({}, orgData) && orgData != null;
}, selector); }, {}, selector);
await this.waitForSpinnerLoad(); await this.waitForSpinnerLoad();
} }
}; };

View File

@ -12,15 +12,18 @@ export function getBrowser() {
async function openPage(url = defaultURL) { async function openPage(url = defaultURL) {
if (!browser) { if (!browser) {
browser = await Puppeteer.launch({ browser = await Puppeteer.launch({
args: [
'--start-maximized'
// '--start-fullscreen'
],
defaultViewport: null, defaultViewport: null,
headless: false, headless: false,
slowMo: 0, // slow down by ms slowMo: 0, // slow down by ms
// devtools: true,
}); });
} }
const page = await browser.newPage(); const page = await browser.newPage();
await page._client.send('Network.clearBrowserCookies'); await page.setDefaultTimeout(5000);
await page.goto(url); await page.goto(url, {waitUntil: 'networkidle0'});
page.on('console', msg => { page.on('console', msg => {
let type = msg.type(); let type = msg.type();

View File

@ -15,29 +15,29 @@ export default {
userLocalCompany: '.user-popover vn-autocomplete[ng-model="$ctrl.localCompanyFk"]', userLocalCompany: '.user-popover vn-autocomplete[ng-model="$ctrl.localCompanyFk"]',
userWarehouse: '.user-popover vn-autocomplete[ng-model="$ctrl.warehouseFk"]', userWarehouse: '.user-popover vn-autocomplete[ng-model="$ctrl.warehouseFk"]',
userCompany: '.user-popover vn-autocomplete[ng-model="$ctrl.companyFk"]', userCompany: '.user-popover vn-autocomplete[ng-model="$ctrl.companyFk"]',
userConfigFirstAutocompleteClear: '#localWarehouse .icons > vn-icon[icon=clear]', userConfigFirstAutocomplete: '#localWarehouse',
userConfigSecondAutocompleteClear: '#localBank .icons > vn-icon[icon=clear]', userConfigSecondAutocomplete: '#localBank',
userConfigThirdAutocompleteClear: '#localCompany .icons > vn-icon[icon=clear]', userConfigThirdAutocomplete: '#localCompany',
acceptButton: '.vn-confirm.shown button[response=accept]' acceptButton: '.vn-confirm.shown button[response=accept]'
}, },
clientsIndex: { clientsIndex: {
searchClientInput: 'vn-topbar [name="searchString"]', searchClientInput: 'vn-topbar',
searchButton: 'vn-searchbar vn-icon[icon="search"]', searchButton: 'vn-searchbar vn-icon[icon="search"]',
searchResult: 'vn-client-index .vn-item', searchResult: 'vn-client-index .vn-item',
createClientButton: `vn-float-button`, createClientButton: `vn-float-button`,
othersButton: 'vn-left-menu li[name="Others"] > a' othersButton: 'vn-left-menu li[name="Others"] > a'
}, },
createClientView: { createClientView: {
name: `vn-client-create [name="name"]`, name: `vn-client-create [ng-model="$ctrl.client.name"]`,
taxNumber: 'vn-client-create [name="fi"]', taxNumber: 'vn-client-create [ng-model="$ctrl.client.fi"]',
socialName: 'vn-client-create [name="socialName"]', socialName: 'vn-client-create [ng-model="$ctrl.client.socialName"]',
street: 'vn-client-create [name="street"]', street: 'vn-client-create [ng-model="$ctrl.client.street"]',
postcode: 'vn-client-create [name="postcode"]', postcode: 'vn-client-create [ng-model="$ctrl.client.postcode"]',
city: 'vn-client-create [name="city"]', city: 'vn-client-create [ng-model="$ctrl.client.city"]',
province: `vn-autocomplete[ng-model="$ctrl.client.provinceFk"]`, province: `vn-autocomplete[ng-model="$ctrl.client.provinceFk"]`,
country: `vn-autocomplete[ng-model="$ctrl.client.countryFk"]`, country: `vn-autocomplete[ng-model="$ctrl.client.countryFk"]`,
userName: 'vn-client-create [name="userName"]', userName: 'vn-client-create [ng-model="$ctrl.client.userName"]',
email: 'vn-client-create [name="email"]', email: 'vn-client-create [ng-model="$ctrl.client.email"]',
salesPersonAutocomplete: `vn-autocomplete[ng-model="$ctrl.client.salesPersonFk"]`, salesPersonAutocomplete: `vn-autocomplete[ng-model="$ctrl.client.salesPersonFk"]`,
createButton: `button[type=submit]`, createButton: `button[type=submit]`,
cancelButton: 'vn-button[href="#!/client/index"]' cancelButton: 'vn-button[href="#!/client/index"]'
@ -48,24 +48,24 @@ export default {
}, },
clientBasicData: { clientBasicData: {
basicDataButton: 'vn-left-menu a[ui-sref="client.card.basicData"]', basicDataButton: 'vn-left-menu a[ui-sref="client.card.basicData"]',
phoneInput: 'vn-client-basic-data [name="phone"]', nameInput: 'vn-client-basic-data [ng-model="$ctrl.client.name"]',
mobileInput: 'vn-client-basic-data [name="mobile"]', contactInput: 'vn-client-basic-data [ng-model="$ctrl.client.contact"]',
nameInput: 'vn-textfield[ng-model="$ctrl.client.name"]', phoneInput: 'vn-client-basic-data [ng-model="$ctrl.client.phone"]',
contactInput: 'vn-textfield[ng-model="$ctrl.client.contact"]', mobileInput: 'vn-client-basic-data [ng-model="$ctrl.client.mobile"]',
emailInput: 'vn-textfield[ng-model="$ctrl.client.email"]', emailInput: 'vn-client-basic-data [ng-model="$ctrl.client.email"]',
salesPersonAutocomplete: 'vn-autocomplete[ng-model="$ctrl.client.salesPersonFk"]', salesPersonAutocomplete: 'vn-autocomplete[ng-model="$ctrl.client.salesPersonFk"]',
channelAutocomplete: 'vn-autocomplete[ng-model="$ctrl.client.contactChannelFk"]', channelAutocomplete: 'vn-autocomplete[ng-model="$ctrl.client.contactChannelFk"]',
saveButton: `button[type=submit]` saveButton: `button[type=submit]`
}, },
clientFiscalData: { clientFiscalData: {
fiscalDataButton: 'vn-left-menu a[ui-sref="client.card.fiscalData"]', fiscalDataButton: 'vn-left-menu a[ui-sref="client.card.fiscalData"]',
socialNameInput: 'vn-client-fiscal-data [name="socialName"]', socialNameInput: 'vn-client-fiscal-data [ng-model="$ctrl.client.socialName"]',
fiscalIdInput: 'vn-client-fiscal-data [name="fi"]', fiscalIdInput: 'vn-client-fiscal-data [ng-model="$ctrl.client.fi"]',
equalizationTaxCheckbox: 'vn-check[ng-model="$ctrl.client.isEqualizated"]', equalizationTaxCheckbox: 'vn-check[ng-model="$ctrl.client.isEqualizated"]',
acceptPropagationButton: '.vn-confirm.shown button[response=accept]', acceptPropagationButton: '.vn-confirm.shown button[response=accept]',
addressInput: 'vn-client-fiscal-data [name="street"]', addressInput: 'vn-client-fiscal-data [ng-model="$ctrl.client.street"]',
postcodeInput: 'vn-client-fiscal-data [name="postcode"]', postcodeInput: 'vn-client-fiscal-data [ng-model="$ctrl.client.postcode"]',
cityInput: 'vn-client-fiscal-data [name="city"]', cityInput: 'vn-client-fiscal-data [ng-model="$ctrl.client.city"]',
provinceAutocomplete: 'vn-autocomplete[ng-model="$ctrl.client.provinceFk"]', provinceAutocomplete: 'vn-autocomplete[ng-model="$ctrl.client.provinceFk"]',
countryAutocomplete: 'vn-autocomplete[ng-model="$ctrl.client.countryFk"]', countryAutocomplete: 'vn-autocomplete[ng-model="$ctrl.client.countryFk"]',
activeCheckbox: 'vn-check[label="Active"]', activeCheckbox: 'vn-check[label="Active"]',
@ -80,17 +80,17 @@ export default {
}, },
clientBillingData: { clientBillingData: {
payMethodAutocomplete: 'vn-client-billing-data vn-autocomplete[ng-model="$ctrl.client.payMethodFk"]', payMethodAutocomplete: 'vn-client-billing-data vn-autocomplete[ng-model="$ctrl.client.payMethodFk"]',
IBANInput: 'vn-client-billing-data [name="iban"]', IBANInput: 'vn-client-billing-data [ng-model="$ctrl.client.iban"]',
dueDayInput: 'vn-client-billing-data [name="dueDay"]', dueDayInput: 'vn-client-billing-data [ng-model="$ctrl.client.dueDay"]',
receivedCoreLCRCheckbox: 'vn-client-billing-data vn-check[label="Received LCR"]', receivedCoreLCRCheckbox: 'vn-client-billing-data vn-check[label="Received LCR"]',
receivedCoreVNLCheckbox: 'vn-client-billing-data vn-check[label="Received core VNL"]', receivedCoreVNLCheckbox: 'vn-client-billing-data vn-check[label="Received core VNL"]',
receivedB2BVNLCheckbox: 'vn-client-billing-data vn-check[label="Received B2B VNL"]', receivedB2BVNLCheckbox: 'vn-client-billing-data vn-check[label="Received B2B VNL"]',
swiftBicAutocomplete: 'vn-client-billing-data vn-autocomplete[ng-model="$ctrl.client.bankEntityFk"]', swiftBicAutocomplete: 'vn-client-billing-data vn-autocomplete[ng-model="$ctrl.client.bankEntityFk"]',
clearswiftBicButton: 'vn-client-billing-data vn-autocomplete[ng-model="$ctrl.client.bankEntityFk"] .icons > vn-icon[icon=clear]', clearswiftBicButton: 'vn-client-billing-data vn-autocomplete[ng-model="$ctrl.client.bankEntityFk"] .icons > vn-icon[icon=clear]',
newBankEntityButton: 'vn-client-billing-data vn-icon-button[vn-tooltip="New bank entity"] > button', newBankEntityButton: 'vn-client-billing-data vn-icon-button[vn-tooltip="New bank entity"] > button',
newBankEntityName: '.vn-dialog.shown [name="name"]', newBankEntityName: '.vn-dialog.shown [ng-model="$ctrl.newBankEntity.name"]',
newBankEntityBIC: '.vn-dialog.shown [name="bic"]', newBankEntityBIC: '.vn-dialog.shown [ng-model="$ctrl.newBankEntity.bic"]',
newBankEntityCode: '.vn-dialog.shown [name="id"]', newBankEntityCode: '.vn-dialog.shown [ng-model="$ctrl.newBankEntity.id"]',
acceptBankEntityButton: '.vn-dialog.shown button[response="accept"]', acceptBankEntityButton: '.vn-dialog.shown button[response="accept"]',
saveButton: `button[type=submit]`, saveButton: `button[type=submit]`,
watcher: 'vn-client-billing-data vn-watcher' watcher: 'vn-client-billing-data vn-watcher'
@ -99,14 +99,14 @@ export default {
addressesButton: 'vn-left-menu a[ui-sref="client.card.address.index"]', addressesButton: 'vn-left-menu a[ui-sref="client.card.address.index"]',
createAddress: `vn-client-address-index vn-float-button`, createAddress: `vn-client-address-index vn-float-button`,
defaultCheckboxInput: 'vn-check[label="Default"]', defaultCheckboxInput: 'vn-check[label="Default"]',
consigneeInput: '[name="nickname"]', consigneeInput: '[ng-model="$ctrl.address.nickname"]',
streetAddressInput: '[name="street"]', streetAddressInput: '[ng-model="$ctrl.address.street"]',
postcodeInput: '[name="postalCode"]', postcodeInput: '[ng-model="$ctrl.address.postalCode"]',
cityInput: '[name="city"]', cityInput: '[ng-model="$ctrl.address.city"]',
provinceAutocomplete: 'vn-autocomplete[ng-model="$ctrl.address.provinceFk"]', provinceAutocomplete: 'vn-autocomplete[ng-model="$ctrl.address.provinceFk"]',
agencyAutocomplete: 'vn-autocomplete[ng-model="$ctrl.address.agencyModeFk"]', agencyAutocomplete: 'vn-autocomplete[ng-model="$ctrl.address.agencyModeFk"]',
phoneInput: '[name="phone"]', phoneInput: '[ng-model="$ctrl.address.phone"]',
mobileInput: '[name="mobile"]', mobileInput: '[ng-model="$ctrl.address.mobile"]',
defaultAddress: 'vn-client-address-index div:nth-child(1) div[name="street"]', defaultAddress: 'vn-client-address-index div:nth-child(1) div[name="street"]',
secondMakeDefaultStar: 'vn-client-address-index vn-card div:nth-child(2) vn-icon-button[icon="star_border"]', secondMakeDefaultStar: 'vn-client-address-index vn-card div:nth-child(2) vn-icon-button[icon="star_border"]',
firstEditAddress: 'vn-client-address-index div:nth-child(1) > a', firstEditAddress: 'vn-client-address-index div:nth-child(1) > a',
@ -114,9 +114,9 @@ export default {
activeCheckbox: 'vn-check[label="Enabled"]', activeCheckbox: 'vn-check[label="Enabled"]',
equalizationTaxCheckbox: 'vn-client-address-edit vn-check[label="Is equalizated"]', equalizationTaxCheckbox: 'vn-client-address-edit vn-check[label="Is equalizated"]',
firstObservationTypeAutocomplete: 'vn-client-address-edit [name=observations] vn-horizontal:nth-child(1) [ng-model="observation.observationTypeFk"]', firstObservationTypeAutocomplete: 'vn-client-address-edit [name=observations] vn-horizontal:nth-child(1) [ng-model="observation.observationTypeFk"]',
firstObservationDescriptionInput: 'vn-client-address-edit [name=observations] vn-horizontal:nth-child(1) [name="description"]', firstObservationDescriptionInput: 'vn-client-address-edit [name=observations] vn-horizontal:nth-child(1) [ng-model="observation.description"]',
secondObservationTypeAutocomplete: 'vn-client-address-edit [name=observations] vn-horizontal:nth-child(2) [ng-model="observation.observationTypeFk"]', secondObservationTypeAutocomplete: 'vn-client-address-edit [name=observations] vn-horizontal:nth-child(2) [ng-model="observation.observationTypeFk"]',
secondObservationDescriptionInput: 'vn-client-address-edit [name=observations] vn-horizontal:nth-child(2) [name="description"]', secondObservationDescriptionInput: 'vn-client-address-edit [name=observations] vn-horizontal:nth-child(2) [ng-model="observation.description"]',
addObservationButton: 'vn-client-address-edit div[name="observations"] vn-icon-button[icon="add_circle"]', addObservationButton: 'vn-client-address-edit div[name="observations"] vn-icon-button[icon="add_circle"]',
saveButton: 'button[type=submit]', saveButton: 'button[type=submit]',
cancelCreateAddressButton: 'button[ui-sref="client.card.address.index"]', cancelCreateAddressButton: 'button[ui-sref="client.card.address.index"]',
@ -126,25 +126,25 @@ export default {
clientWebAccess: { clientWebAccess: {
webAccessButton: 'vn-left-menu a[ui-sref="client.card.webAccess"]', webAccessButton: 'vn-left-menu a[ui-sref="client.card.webAccess"]',
enableWebAccessCheckbox: 'vn-check[label="Enable web access"]', enableWebAccessCheckbox: 'vn-check[label="Enable web access"]',
userNameInput: 'vn-client-web-access [name="name"]', userNameInput: 'vn-client-web-access [ng-model="$ctrl.account.name"]',
saveButton: 'button[type=submit]' saveButton: 'button[type=submit]'
}, },
clientNotes: { clientNotes: {
addNoteFloatButton: 'vn-float-button', addNoteFloatButton: 'vn-float-button',
noteInput: 'vn-textarea[label="Note"]', noteInput: '[ng-model="$ctrl.note.text"]',
saveButton: 'button[type=submit]', saveButton: 'button[type=submit]',
firstNoteText: 'vn-client-note .text' firstNoteText: 'vn-client-note .text'
}, },
clientCredit: { clientCredit: {
addCreditFloatButton: 'vn-float-button', addCreditFloatButton: 'vn-float-button',
creditInput: 'vn-client-credit-create [name="credit"]', creditInput: 'vn-client-credit-create [ng-model="$ctrl.client.credit"]',
saveButton: 'button[type=submit]', saveButton: 'button[type=submit]',
firstCreditText: 'vn-client-credit-index vn-card vn-table vn-tbody > vn-tr' firstCreditText: 'vn-client-credit-index vn-card vn-table vn-tbody > vn-tr'
}, },
clientGreuge: { clientGreuge: {
addGreugeFloatButton: 'vn-float-button', addGreugeFloatButton: 'vn-float-button',
amountInput: 'vn-client-greuge-create [name="amount"]', amountInput: 'vn-client-greuge-create [ng-model="$ctrl.greuge.amount"]',
descriptionInput: 'vn-client-greuge-create [name="description"]', descriptionInput: 'vn-client-greuge-create [ng-model="$ctrl.greuge.description"]',
typeAutocomplete: 'vn-autocomplete[ng-model="$ctrl.greuge.greugeTypeFk"]', typeAutocomplete: 'vn-autocomplete[ng-model="$ctrl.greuge.greugeTypeFk"]',
saveButton: 'button[type=submit]', saveButton: 'button[type=submit]',
firstGreugeText: 'vn-client-greuge-index vn-card vn-table vn-tbody > vn-tr' firstGreugeText: 'vn-client-greuge-index vn-card vn-table vn-tbody > vn-tr'
@ -165,9 +165,9 @@ export default {
clientBalance: { clientBalance: {
balanceButton: 'vn-left-menu a[ui-sref="client.card.balance.index"]', balanceButton: 'vn-left-menu a[ui-sref="client.card.balance.index"]',
companyAutocomplete: 'vn-client-balance-index vn-autocomplete[ng-model="$ctrl.companyFk"]', companyAutocomplete: 'vn-client-balance-index vn-autocomplete[ng-model="$ctrl.companyFk"]',
newPaymentButton: `vn-float-button`, newPaymentButton: 'vn-float-button',
newPaymentBank: '.vn-dialog.shown vn-autocomplete[ng-model="$ctrl.receipt.bankFk"]', newPaymentBank: '.vn-dialog.shown vn-autocomplete[ng-model="$ctrl.receipt.bankFk"]',
newPaymentAmountInput: '.vn-dialog.shown [name="amountPaid"]', newPaymentAmountInput: '.vn-dialog.shown [ng-model="$ctrl.receipt.amountPaid"]',
saveButton: '.vn-dialog.shown vn-button[label="Save"]', saveButton: '.vn-dialog.shown vn-button[label="Save"]',
firstBalanceLine: 'vn-client-balance-index vn-tbody > vn-tr:nth-child(1) > vn-td:nth-child(8)' firstBalanceLine: 'vn-client-balance-index vn-tbody > vn-tr:nth-child(1) > vn-td:nth-child(8)'

View File

@ -1,6 +1,6 @@
import openPage from '../../helpers/puppeteer'; import openPage from '../../helpers/puppeteer';
fdescribe('Login path', async() => { describe('Login path', async() => {
let page; let page;
beforeAll(async() => { beforeAll(async() => {
page = await openPage(); page = await openPage();
@ -33,9 +33,7 @@ fdescribe('Login path', async() => {
it('should log in', async() => { it('should log in', async() => {
await page.doLogin('employee', 'nightmare'); await page.doLogin('employee', 'nightmare');
await page.wait(2000); await page.waitForNavigation();
await page.waitToClick('vn-login button[type=submit]');
await page.wait('#user');
let url = await page.parsedUrl(); let url = await page.parsedUrl();
expect(url.hash).toEqual('#!/'); expect(url.hash).toEqual('#!/');

View File

@ -1,7 +1,7 @@
import selectors from '../../helpers/selectors'; import selectors from '../../helpers/selectors';
import openPage from '../../helpers/puppeteer'; import openPage from '../../helpers/puppeteer';
fdescribe('Client create path', async() => { describe('Client create path', async() => {
let page; let page;
beforeAll(async() => { beforeAll(async() => {
page = await openPage(); page = await openPage();
@ -109,11 +109,9 @@ fdescribe('Client create path', async() => {
}); });
it(`should search for the user Carol Danvers to confirm it exists`, async() => { it(`should search for the user Carol Danvers to confirm it exists`, async() => {
await page.write(selectors.clientsIndex.searchClientInput, 'Carol Danvers'); await page.accessToSearchResult('Carol Danvers');
await page.waitToClick(selectors.clientsIndex.searchButton); const url = await page.parsedUrl();
await page.waitForNumberOfElements(selectors.clientsIndex.searchResult, 1);
const result = await page.countElement(selectors.clientsIndex.searchResult);
expect(result).toEqual(1); expect(url.hash).toEqual('#!/client/114/summary');
}); });
}); });

View File

@ -6,8 +6,8 @@ describe('Client Edit basicData path', () => {
beforeAll(async() => { beforeAll(async() => {
page = await openPage(); page = await openPage();
await page.loginAndModule('employee', 'client'); await page.loginAndModule('employee', 'client');
// await page.accessToSearchResult('Bruce Wayne'); await page.accessToSearchResult('Bruce Wayne');
// await page.accessToSection('client.card.basicData'); await page.accessToSection('client.card.basicData');
}); });
afterAll(async() => { afterAll(async() => {
@ -16,9 +16,8 @@ describe('Client Edit basicData path', () => {
describe('as employee', () => { describe('as employee', () => {
it('should not be able to change the salesPerson', async() => { it('should not be able to change the salesPerson', async() => {
const result = await nightmare await page.wait(selectors.clientBasicData.nameInput);
.wait(selectors.clientBasicData.nameInput) const result = await page.evaluate(selector => {
.evaluate(selector => {
return document.querySelector(selector).disabled; return document.querySelector(selector).disabled;
}, `${selectors.clientBasicData.salesPersonAutocomplete} input`); }, `${selectors.clientBasicData.salesPersonAutocomplete} input`);
@ -26,44 +25,60 @@ describe('Client Edit basicData path', () => {
}); });
it('should edit the client basic data but leave salesPerson untainted', async() => { it('should edit the client basic data but leave salesPerson untainted', async() => {
const result = await nightmare await page.clearInput(selectors.clientBasicData.nameInput);
.clearInput(selectors.clientBasicData.nameInput) await page.write(selectors.clientBasicData.nameInput, 'Ptonomy Wallace');
.write(selectors.clientBasicData.nameInput, 'Ptonomy Wallace') await page.clearInput(selectors.clientBasicData.contactInput);
.clearInput(selectors.clientBasicData.contactInput) await page.write(selectors.clientBasicData.contactInput, 'David Haller');
.write(selectors.clientBasicData.contactInput, 'David Haller') await page.clearInput(selectors.clientBasicData.phoneInput);
.clearInput(selectors.clientBasicData.emailInput) await page.write(selectors.clientBasicData.phoneInput, '987654321');
.write(selectors.clientBasicData.emailInput, 'PWallace@verdnatura.es') await page.clearInput(selectors.clientBasicData.mobileInput);
.autocompleteSearch(selectors.clientBasicData.channelAutocomplete, 'Rumors on the streets') await page.write(selectors.clientBasicData.mobileInput, '123456789');
.waitToClick(selectors.clientBasicData.saveButton) await page.clearInput(selectors.clientBasicData.emailInput);
.waitForLastSnackbar(); await page.write(selectors.clientBasicData.emailInput, 'PWallace@verdnatura.es');
await page.autocompleteSearch(selectors.clientBasicData.channelAutocomplete, 'Rumors on the streets');
await page.waitToClick(selectors.clientBasicData.saveButton);
const result = await page.waitForLastSnackbar();
expect(result).toEqual('Data saved!'); expect(result).toEqual('Data saved!');
}); });
it('should confirm the name have been edited', async() => { it('should confirm the name have been edited', async() => {
const result = await nightmare await page.reloadSection('client.card.basicData');
.reloadSection('client.card.basicData') const result = await page.waitToGetProperty(selectors.clientBasicData.nameInput, 'value');
.waitToGetProperty(selectors.clientBasicData.nameInput, 'value');
expect(result).toEqual('Ptonomy Wallace'); expect(result).toEqual('Ptonomy Wallace');
}); });
it('should confirm the contact name have been edited', async() => { it('should confirm the contact name have been edited', async() => {
const result = await nightmare const result = await page
.waitToGetProperty(selectors.clientBasicData.contactInput, 'value'); .waitToGetProperty(selectors.clientBasicData.contactInput, 'value');
expect(result).toEqual('David Haller'); expect(result).toEqual('David Haller');
}); });
it('should confirm the landline phone number have been added', async() => {
const result = await page
.waitToGetProperty(selectors.clientBasicData.phoneInput, 'value');
expect(result).toEqual('987654321');
});
it('should confirm the mobile phone number have been added', async() => {
const result = await page
.waitToGetProperty(selectors.clientBasicData.mobileInput, 'value');
expect(result).toEqual('123456789');
});
it('should confirm the email have been edited', async() => { it('should confirm the email have been edited', async() => {
const result = await nightmare const result = await page
.waitToGetProperty(selectors.clientBasicData.emailInput, 'value'); .waitToGetProperty(selectors.clientBasicData.emailInput, 'value');
expect(result).toEqual('PWallace@verdnatura.es'); expect(result).toEqual('PWallace@verdnatura.es');
}); });
it('should confirm the channel have been selected', async() => { it('should confirm the channel have been selected', async() => {
const result = await nightmare const result = await page
.waitToGetProperty(`${selectors.clientBasicData.channelAutocomplete} input`, 'value'); .waitToGetProperty(`${selectors.clientBasicData.channelAutocomplete} input`, 'value');
expect(result).toEqual('Rumors on the streets'); expect(result).toEqual('Rumors on the streets');
@ -71,17 +86,15 @@ describe('Client Edit basicData path', () => {
}); });
describe('as salesAssistant', () => { describe('as salesAssistant', () => {
beforeAll(() => { beforeAll(async() => {
nightmare await page.loginAndModule('salesASsistant', 'client');
.loginAndModule('salesASsistant', 'client') await page.accessToSearchResult('Ptonomy Wallace');
.accessToSearchResult('Ptonomy Wallace') await page.accessToSection('client.card.basicData');
.accessToSection('client.card.basicData');
}); });
it('should be able to change the salesPerson', async() => { it('should be able to change the salesPerson', async() => {
const result = await nightmare await page.wait(selectors.clientBasicData.nameInput);
.wait(selectors.clientBasicData.nameInput) const result = await page.evaluate(selector => {
.evaluate(selector => {
return document.querySelector(selector).disabled; return document.querySelector(selector).disabled;
}, `${selectors.clientBasicData.salesPersonAutocomplete} input`); }, `${selectors.clientBasicData.salesPersonAutocomplete} input`);
@ -89,52 +102,68 @@ describe('Client Edit basicData path', () => {
}); });
it('should edit the client basic data including salesPerson', async() => { it('should edit the client basic data including salesPerson', async() => {
const result = await nightmare await page.clearInput(selectors.clientBasicData.nameInput);
.clearInput(selectors.clientBasicData.nameInput) await page.write(selectors.clientBasicData.nameInput, 'Ororo Munroe');
.write(selectors.clientBasicData.nameInput, 'Ororo Munroe') await page.clearInput(selectors.clientBasicData.contactInput);
.clearInput(selectors.clientBasicData.contactInput) await page.write(selectors.clientBasicData.contactInput, 'Black Panther');
.write(selectors.clientBasicData.contactInput, 'Black Panther') await page.clearInput(selectors.clientBasicData.phoneInput);
.clearInput(selectors.clientBasicData.emailInput) await page.write(selectors.clientBasicData.phoneInput, '123456789');
.write(selectors.clientBasicData.emailInput, 'Storm@verdnatura.es') await page.clearInput(selectors.clientBasicData.mobileInput);
.autocompleteSearch(selectors.clientBasicData.salesPersonAutocomplete, 'replenisherNick') await page.write(selectors.clientBasicData.mobileInput, '987654321');
.autocompleteSearch(selectors.clientBasicData.channelAutocomplete, 'Metropolis newspaper') await page.clearInput(selectors.clientBasicData.emailInput);
.waitToClick(selectors.clientBasicData.saveButton) await page.write(selectors.clientBasicData.emailInput, 'Storm@verdnatura.es');
.waitForLastSnackbar(); await page.autocompleteSearch(selectors.clientBasicData.salesPersonAutocomplete, 'replenisherNick');
await page.autocompleteSearch(selectors.clientBasicData.channelAutocomplete, 'Metropolis newspaper');
await page.waitToClick(selectors.clientBasicData.saveButton);
const result = await page.waitForLastSnackbar();
expect(result).toEqual('Data saved!'); expect(result).toEqual('Data saved!');
}); });
it('should now confirm the name have been edited', async() => { it('should now confirm the name have been edited', async() => {
const result = await nightmare await page.reloadSection('client.card.basicData');
.reloadSection('client.card.basicData') const result = await page.waitToGetProperty(selectors.clientBasicData.nameInput, 'value');
.waitToGetProperty(selectors.clientBasicData.nameInput, 'value');
expect(result).toEqual('Ororo Munroe'); expect(result).toEqual('Ororo Munroe');
}); });
it('should now confirm the contact name have been edited', async() => { it('should now confirm the contact name have been edited', async() => {
const result = await nightmare const result = await page
.waitToGetProperty(selectors.clientBasicData.contactInput, 'value'); .waitToGetProperty(selectors.clientBasicData.contactInput, 'value');
expect(result).toEqual('Black Panther'); expect(result).toEqual('Black Panther');
}); });
it('should now confirm the landline phone number have been added', async() => {
const result = await page
.waitToGetProperty(selectors.clientBasicData.phoneInput, 'value');
expect(result).toEqual('123456789');
});
it('should now confirm the mobile phone number have been added', async() => {
const result = await page
.waitToGetProperty(selectors.clientBasicData.mobileInput, 'value');
expect(result).toEqual('987654321');
});
it('should now confirm the email have been edited', async() => { it('should now confirm the email have been edited', async() => {
const result = await nightmare const result = await page
.waitToGetProperty(selectors.clientBasicData.emailInput, 'value'); .waitToGetProperty(selectors.clientBasicData.emailInput, 'value');
expect(result).toEqual('Storm@verdnatura.es'); expect(result).toEqual('Storm@verdnatura.es');
}); });
it('should confirm the sales person have been selected', async() => { it('should confirm the sales person have been selected', async() => {
const result = await nightmare const result = await page
.waitToGetProperty(`${selectors.clientBasicData.salesPersonAutocomplete} input`, 'value'); .waitToGetProperty(`${selectors.clientBasicData.salesPersonAutocomplete} input`, 'value');
expect(result).toEqual('replenisherNick'); expect(result).toEqual('replenisherNick');
}); });
it('should now confirm the channel have been selected', async() => { it('should now confirm the channel have been selected', async() => {
const result = await nightmare const result = await page
.waitToGetProperty(`${selectors.clientBasicData.channelAutocomplete} input`, 'value'); .waitToGetProperty(`${selectors.clientBasicData.channelAutocomplete} input`, 'value');
expect(result).toEqual('Metropolis newspaper'); expect(result).toEqual('Metropolis newspaper');

View File

@ -2,313 +2,284 @@ import selectors from '../../helpers/selectors.js';
import openPage from '../../helpers/puppeteer'; import openPage from '../../helpers/puppeteer';
describe('Client Edit fiscalData path', () => { describe('Client Edit fiscalData path', () => {
const nightmare = createNightmare(); let page;
describe('as employee', () => { beforeAll(async() => {
beforeAll(() => { page = await openPage();
nightmare await page.loginAndModule('employee', 'client');
.loginAndModule('employee', 'client') await page.accessToSearchResult('Bruce Banner');
.accessToSearchResult('Bruce Banner') await page.accessToSection('client.card.address.index');
.accessToSection('client.card.address.index');
}); });
afterAll(async() => {
page.close();
});
describe('as employee', () => {
// Confirms all addresses have EQtax false for future propagation test step 1 // Confirms all addresses have EQtax false for future propagation test step 1
it(`should click on the 1st edit icon to check EQtax isnt checked`, async() => { it(`should click on the 1st edit icon to check EQtax isnt checked`, async() => {
const result = await nightmare await page.waitToClick(selectors.clientAddresses.firstEditAddress);
.waitToClick(selectors.clientAddresses.firstEditAddress) const result = await page.checkboxState(selectors.clientAddresses.equalizationTaxCheckbox);
.checkboxState(selectors.clientAddresses.equalizationTaxCheckbox);
expect(result).toBe('unchecked'); expect(result).toBe('unchecked');
}); });
// Confirms all addresses have EQtax false for future propagation test step 2 // Confirms all addresses have EQtax false for future propagation test step 2
it(`should go back to addresses then select the second one and confirm the EQtax isnt checked`, async() => { it(`should go back to addresses then select the second one and confirm the EQtax isnt checked`, async() => {
const result = await nightmare await page.waitToClick(selectors.clientAddresses.addressesButton);
.waitToClick(selectors.clientAddresses.addressesButton) await page.waitToClick(selectors.clientAddresses.secondEditAddress);
.waitToClick(selectors.clientAddresses.secondEditAddress) const result = await page.checkboxState(selectors.clientAddresses.equalizationTaxCheckbox);
.checkboxState(selectors.clientAddresses.equalizationTaxCheckbox);
expect(result).toBe('unchecked'); expect(result).toBe('unchecked');
}); });
it(`should click on the fiscal data button`, async() => { it(`should click on the fiscal data button`, async() => {
const url = await nightmare await page.waitToClick(selectors.clientFiscalData.fiscalDataButton);
.waitToClick(selectors.clientFiscalData.fiscalDataButton) await page.waitForURL('fiscal-data');
.waitForURL('fiscal-data') const url = await page.parsedUrl();
.parsedUrl();
expect(url.hash).toContain('fiscal-data'); expect(url.hash).toContain('fiscal-data');
}); });
it('should not be able to edit the verified data checkbox', async() => { it('should not be able to edit the verified data checkbox', async() => {
const result = await nightmare await page.wait(selectors.clientFiscalData.verifiedDataCheckbox);
.wait(selectors.clientFiscalData.verifiedDataCheckbox) const result = await page.isDisabled(selectors.clientFiscalData.verifiedDataCheckbox);
.isDisabled(selectors.clientFiscalData.verifiedDataCheckbox);
expect(result).toBeTruthy(); expect(result).toBeTruthy();
}); });
}); });
describe('as administrative', () => { describe('as administrative', () => {
beforeAll(() => { beforeAll(async() => {
nightmare await page.loginAndModule('administrative', 'client');
.loginAndModule('administrative', 'client') await page.accessToSearchResult('Bruce Banner');
.accessToSearchResult('Bruce Banner') await page.accessToSection('client.card.fiscalData');
.accessToSection('client.card.fiscalData');
}); });
it(`should edit the fiscal data but fail as the fiscal id ain't valid`, async() => { it(`should edit the fiscal data but fail as the fiscal id ain't valid`, async() => {
const result = await nightmare await page.wait(selectors.clientFiscalData.socialNameInput);
.wait(selectors.clientFiscalData.socialNameInput) await page.clearInput(selectors.clientFiscalData.socialNameInput);
.clearInput(selectors.clientFiscalData.socialNameInput) await page.write(selectors.clientFiscalData.socialNameInput, 'SMASH');
.write(selectors.clientFiscalData.socialNameInput, 'SMASH') await page.clearInput(selectors.clientFiscalData.fiscalIdInput);
.clearInput(selectors.clientFiscalData.fiscalIdInput) await page.write(selectors.clientFiscalData.fiscalIdInput, 'INVALID!');
.write(selectors.clientFiscalData.fiscalIdInput, 'INVALID!') await page.clearInput(selectors.clientFiscalData.addressInput);
.clearInput(selectors.clientFiscalData.addressInput) await page.write(selectors.clientFiscalData.addressInput, 'Somewhere edited');
.write(selectors.clientFiscalData.addressInput, 'Somewhere edited') await page.autocompleteSearch(selectors.clientFiscalData.countryAutocomplete, 'España');
.autocompleteSearch(selectors.clientFiscalData.countryAutocomplete, 'España') await page.autocompleteSearch(selectors.clientFiscalData.provinceAutocomplete, 'Province one');
.autocompleteSearch(selectors.clientFiscalData.provinceAutocomplete, 'Province one') await page.clearInput(selectors.clientFiscalData.cityInput);
.clearInput(selectors.clientFiscalData.cityInput) await page.write(selectors.clientFiscalData.cityInput, 'Valencia');
.write(selectors.clientFiscalData.cityInput, 'Valencia') await page.clearInput(selectors.clientFiscalData.postcodeInput);
.clearInput(selectors.clientFiscalData.postcodeInput) await page.write(selectors.clientFiscalData.postcodeInput, '46000');
.write(selectors.clientFiscalData.postcodeInput, '46000') await page.waitToClick(selectors.clientFiscalData.activeCheckbox);
.waitToClick(selectors.clientFiscalData.activeCheckbox) await page.waitToClick(selectors.clientFiscalData.frozenCheckbox);
.waitToClick(selectors.clientFiscalData.frozenCheckbox) await page.waitToClick(selectors.clientFiscalData.hasToInvoiceCheckbox);
.waitToClick(selectors.clientFiscalData.hasToInvoiceCheckbox) await page.waitToClick(selectors.clientFiscalData.viesCheckbox);
.waitToClick(selectors.clientFiscalData.viesCheckbox) await page.waitToClick(selectors.clientFiscalData.invoiceByMailCheckbox);
.waitToClick(selectors.clientFiscalData.invoiceByMailCheckbox) await page.waitToClick(selectors.clientFiscalData.invoiceByAddressCheckbox);
.waitToClick(selectors.clientFiscalData.invoiceByAddressCheckbox) await page.waitToClick(selectors.clientFiscalData.equalizationTaxCheckbox);
.waitToClick(selectors.clientFiscalData.equalizationTaxCheckbox) await page.waitToClick(selectors.clientFiscalData.verifiedDataCheckbox);
.waitToClick(selectors.clientFiscalData.verifiedDataCheckbox) await page.waitToClick(selectors.clientFiscalData.saveButton);
.waitToClick(selectors.clientFiscalData.saveButton) const result = await page.waitForLastSnackbar();
.waitForLastSnackbar();
expect(result).toEqual('Invalid Tax number'); expect(result).toEqual('Invalid Tax number');
}); });
it(`should edit the fiscal this time with a valid fiscal id`, async() => { it(`should edit the fiscal this time with a valid fiscal id`, async() => {
const result = await nightmare await page.clearInput(selectors.clientFiscalData.fiscalIdInput);
.clearInput(selectors.clientFiscalData.fiscalIdInput) await page.write(selectors.clientFiscalData.fiscalIdInput, '94980061C');
.write(selectors.clientFiscalData.fiscalIdInput, '94980061C') await page.waitToClick(selectors.clientFiscalData.saveButton);
.waitToClick(selectors.clientFiscalData.saveButton) const result = await page.waitForLastSnackbar();
.waitForLastSnackbar();
expect(result).toEqual('Data saved!'); expect(result).toEqual('Data saved!');
}); });
it('should propagate the Equalization tax', async() => { it('should propagate the Equalization tax', async() => {
const result = await nightmare await page.waitToClick(selectors.clientFiscalData.acceptPropagationButton);
.waitToClick(selectors.clientFiscalData.acceptPropagationButton) const result = await page.waitForLastSnackbar();
.waitForLastSnackbar();
expect(result).toEqual('Equivalent tax spreaded'); expect(result).toEqual('Equivalent tax spreaded');
}); });
it('should receive an error if the fiscal id contains A or B at the beginning', async() => { it('should receive an error if the fiscal id contains A or B at the beginning', async() => {
const result = await nightmare await page.waitToClick(selectors.clientFiscalData.viesCheckbox);
.waitToClick(selectors.clientFiscalData.viesCheckbox) await page.clearInput(selectors.clientFiscalData.fiscalIdInput);
.clearInput(selectors.clientFiscalData.fiscalIdInput) await page.write(selectors.clientFiscalData.fiscalIdInput, 'A94980061C');
.write(selectors.clientFiscalData.fiscalIdInput, 'A94980061C') await page.waitToClick(selectors.clientFiscalData.saveButton);
.waitToClick(selectors.clientFiscalData.saveButton) const result = await page.waitForLastSnackbar();
.waitForLastSnackbar();
expect(result).toEqual('Cannot check Equalization Tax in this NIF/CIF'); expect(result).toEqual('Cannot check Equalization Tax in this NIF/CIF');
}); });
it('should finally edit the fixcal data correctly as VIES isnt checked and fiscal id is valid for EQtax', async() => { it('should finally edit the fixcal data correctly as VIES isnt checked and fiscal id is valid for EQtax', async() => {
const result = await nightmare await page.clearInput(selectors.clientFiscalData.fiscalIdInput);
.clearInput(selectors.clientFiscalData.fiscalIdInput) await page.write(selectors.clientFiscalData.fiscalIdInput, '94980061C');
.write(selectors.clientFiscalData.fiscalIdInput, '94980061C') await page.waitToClick(selectors.clientFiscalData.saveButton);
.waitToClick(selectors.clientFiscalData.saveButton) const result = await page.waitForLastSnackbar();
.waitForLastSnackbar();
expect(result).toEqual('Data saved!'); expect(result).toEqual('Data saved!');
}); });
// confirm all addresses have now EQtax checked step 1 // confirm all addresses have now EQtax checked step 1
it(`should click on the addresses button to access to the client's addresses`, async() => { it(`should click on the addresses button to access to the client's addresses`, async() => {
const url = await nightmare await page.waitToClick(selectors.clientAddresses.addressesButton);
.waitToClick(selectors.clientAddresses.addressesButton) await page.waitForURL('/address/index');
.waitForURL('/address/index') const url = await page.parsedUrl();
.parsedUrl();
expect(url.hash).toContain('/address/index'); expect(url.hash).toContain('/address/index');
}); });
// confirm all addresses have now EQtax checked step 2 // confirm all addresses have now EQtax checked step 2
it(`should click on the 1st edit icon to confirm EQtax is checked`, async() => { it(`should click on the 1st edit icon to confirm EQtax is checked`, async() => {
const result = await nightmare await page.waitToClick(selectors.clientAddresses.firstEditAddress);
.waitToClick(selectors.clientAddresses.firstEditAddress) await page.waitForWatcherData(selectors.clientAddresses.watcher);
.waitForWatcherData(selectors.clientAddresses.watcher) const result = await page.checkboxState(selectors.clientAddresses.equalizationTaxCheckbox);
.checkboxState(selectors.clientAddresses.equalizationTaxCheckbox);
expect(result).toBe('checked'); expect(result).toBe('checked');
}); });
// confirm all addresses have now EQtax checked step 3 // confirm all addresses have now EQtax checked step 3
it(`should go back to addresses then select the second one and confirm the EQtax is checked`, async() => { it(`should go back to addresses then select the second one and confirm the EQtax is checked`, async() => {
const result = await nightmare await page.waitToClick(selectors.clientAddresses.addressesButton);
.waitToClick(selectors.clientAddresses.addressesButton) await page.waitToClick(selectors.clientAddresses.secondEditAddress);
.waitToClick(selectors.clientAddresses.secondEditAddress) await page.waitForWatcherData(selectors.clientAddresses.watcher);
.waitForWatcherData(selectors.clientAddresses.watcher) const result = await page.checkboxState(selectors.clientAddresses.equalizationTaxCheckbox);
.checkboxState(selectors.clientAddresses.equalizationTaxCheckbox);
expect(result).toBe('checked'); expect(result).toBe('checked');
}); });
it('should navigate back to fiscal data and uncheck EQtax then check VIES', async() => { it('should navigate back to fiscal data and uncheck EQtax then check VIES', async() => {
const result = await nightmare await page.waitToClick(selectors.clientFiscalData.fiscalDataButton);
.waitToClick(selectors.clientFiscalData.fiscalDataButton) await page.waitToClick(selectors.clientFiscalData.viesCheckbox);
.waitToClick(selectors.clientFiscalData.viesCheckbox) await page.waitToClick(selectors.clientFiscalData.equalizationTaxCheckbox);
.waitToClick(selectors.clientFiscalData.equalizationTaxCheckbox) await page.waitToClick(selectors.clientFiscalData.saveButton);
.waitToClick(selectors.clientFiscalData.saveButton) const result = await page.waitForLastSnackbar();
.waitForLastSnackbar();
expect(result).toEqual('Data saved!'); expect(result).toEqual('Data saved!');
}); });
it('should propagate the Equalization tax changes', async() => { it('should propagate the Equalization tax changes', async() => {
const result = await nightmare await page.waitToClick(selectors.clientFiscalData.acceptPropagationButton);
.waitToClick(selectors.clientFiscalData.acceptPropagationButton) const result = await page.waitForLastSnackbar();
.waitForLastSnackbar();
expect(result).toEqual('Equivalent tax spreaded'); expect(result).toEqual('Equivalent tax spreaded');
}); });
it('should confirm its name have been edited', async() => { it('should confirm its name have been edited', async() => {
const result = await nightmare await page.waitToClick(selectors.clientFiscalData.fiscalDataButton);
.waitToClick(selectors.clientFiscalData.fiscalDataButton) const result = await page.waitToGetProperty(selectors.clientFiscalData.socialNameInput, 'value');
.waitToGetProperty(selectors.clientFiscalData.socialNameInput, 'value');
expect(result).toEqual('SMASH'); expect(result).toEqual('SMASH');
}); });
it('should confirm the fiscal id have been edited', async() => { it('should confirm the fiscal id have been edited', async() => {
const result = await nightmare const result = await page.waitToGetProperty(selectors.clientFiscalData.fiscalIdInput, 'value');
.waitToGetProperty(selectors.clientFiscalData.fiscalIdInput, 'value');
expect(result).toEqual('94980061C'); expect(result).toEqual('94980061C');
}); });
it('should confirm the address have been edited', async() => { it('should confirm the address have been edited', async() => {
const result = await nightmare const result = await page.waitToGetProperty(selectors.clientFiscalData.addressInput, 'value');
.waitToGetProperty(selectors.clientFiscalData.addressInput, 'value');
expect(result).toEqual('Somewhere edited'); expect(result).toEqual('Somewhere edited');
}); });
it('should confirm the postcode have been edited', async() => { it('should confirm the postcode have been edited', async() => {
const result = await nightmare const result = await page.waitToGetProperty(`${selectors.clientFiscalData.postcodeInput}`, 'value');
.waitToGetProperty(`${selectors.clientFiscalData.postcodeInput}`, 'value');
expect(result).toContain('46000'); expect(result).toContain('46000');
}); });
it('should confirm the city have been autocompleted', async() => { it('should confirm the city have been autocompleted', async() => {
const result = await nightmare const result = await page.waitToGetProperty(`${selectors.clientFiscalData.cityInput}`, 'value');
.waitToGetProperty(`${selectors.clientFiscalData.cityInput}`, 'value');
expect(result).toEqual('Valencia'); expect(result).toEqual('Valencia');
}); });
it(`should confirm the province have been autocompleted`, async() => { it(`should confirm the province have been autocompleted`, async() => {
const result = await nightmare const result = await page.waitToGetProperty(`${selectors.clientFiscalData.provinceAutocomplete} input`, 'value');
.waitToGetProperty(`${selectors.clientFiscalData.provinceAutocomplete} input`, 'value');
expect(result).toEqual('Province one'); expect(result).toEqual('Province one');
}); });
it('should confirm the country have been autocompleted', async() => { it('should confirm the country have been autocompleted', async() => {
const result = await nightmare const result = await page.waitToGetProperty(`${selectors.clientFiscalData.countryAutocomplete} input`, 'value');
.waitToGetProperty(`${selectors.clientFiscalData.countryAutocomplete} input`, 'value');
expect(result).toEqual('España'); expect(result).toEqual('España');
}); });
it('should confirm active checkbox is unchecked', async() => { it('should confirm active checkbox is unchecked', async() => {
const result = await nightmare const result = await page.checkboxState(selectors.clientFiscalData.activeCheckbox);
.checkboxState(selectors.clientFiscalData.activeCheckbox);
expect(result).toBe('unchecked'); expect(result).toBe('unchecked');
}); });
it('should confirm frozen checkbox is checked', async() => { it('should confirm frozen checkbox is checked', async() => {
const result = await nightmare const result = await page.checkboxState(selectors.clientFiscalData.frozenCheckbox);
.checkboxState(selectors.clientFiscalData.frozenCheckbox);
expect(result).toBe('checked'); expect(result).toBe('checked');
}); });
it('should confirm Has to invoice checkbox is unchecked', async() => { it('should confirm Has to invoice checkbox is unchecked', async() => {
const result = await nightmare const result = await page.checkboxState(selectors.clientFiscalData.hasToInvoiceCheckbox);
.checkboxState(selectors.clientFiscalData.hasToInvoiceCheckbox);
expect(result).toBe('unchecked'); expect(result).toBe('unchecked');
}); });
it('should confirm Vies checkbox is checked', async() => { it('should confirm Vies checkbox is checked', async() => {
const result = await nightmare const result = await page.checkboxState(selectors.clientFiscalData.viesCheckbox);
.checkboxState(selectors.clientFiscalData.viesCheckbox);
expect(result).toBe('checked'); expect(result).toBe('checked');
}); });
it('should confirm Invoice by mail checkbox is unchecked', async() => { it('should confirm Invoice by mail checkbox is unchecked', async() => {
const result = await nightmare const result = await page.checkboxState(selectors.clientFiscalData.invoiceByMailCheckbox);
.checkboxState(selectors.clientFiscalData.invoiceByMailCheckbox);
expect(result).toBe('unchecked'); expect(result).toBe('unchecked');
}); });
it('should confirm invoice by address checkbox is unchecked', async() => { it('should confirm invoice by address checkbox is unchecked', async() => {
const result = await nightmare const result = await page.checkboxState(selectors.clientFiscalData.invoiceByAddressCheckbox);
.checkboxState(selectors.clientFiscalData.invoiceByAddressCheckbox);
expect(result).toBe('unchecked'); expect(result).toBe('unchecked');
}); });
it('should confirm Equalization tax checkbox is unchecked', async() => { it('should confirm Equalization tax checkbox is unchecked', async() => {
const result = await nightmare const result = await page.checkboxState(selectors.clientFiscalData.equalizationTaxCheckbox);
.checkboxState(selectors.clientFiscalData.equalizationTaxCheckbox);
expect(result).toBe('unchecked'); expect(result).toBe('unchecked');
}); });
it('should confirm Verified data checkbox is checked', async() => { it('should confirm Verified data checkbox is checked', async() => {
const result = await nightmare const result = await page.checkboxState(selectors.clientFiscalData.verifiedDataCheckbox);
.checkboxState(selectors.clientFiscalData.verifiedDataCheckbox);
expect(result).toBe('checked'); expect(result).toBe('checked');
}); });
// confirm invoice by address checkbox gets checked if the EQtax differs between addresses step 1 // confirm invoice by address checkbox gets checked if the EQtax differs between addresses step 1
it(`should click on the addresses button to access to the client's addresses`, async() => { it(`should click on the addresses button to access to the client's addresses`, async() => {
const url = await nightmare await page.waitToClick(selectors.clientAddresses.addressesButton);
.waitToClick(selectors.clientAddresses.addressesButton) await page.waitForURL('/address/index');
.waitForURL('/address/index') const url = await page.parsedUrl();
.parsedUrl();
expect(url.hash).toContain('/address/index'); expect(url.hash).toContain('/address/index');
}); });
// confirm invoice by address checkbox gets checked if the EQtax differs between addresses step 2 // confirm invoice by address checkbox gets checked if the EQtax differs between addresses step 2
it(`should click on the 1st edit icon to access the address details and uncheck EQtax checkbox`, async() => { it(`should click on the 1st edit icon to access the address details and uncheck EQtax checkbox`, async() => {
const result = await nightmare await page.waitToClick(selectors.clientAddresses.firstEditAddress);
.waitToClick(selectors.clientAddresses.firstEditAddress) await page.waitForTextInInput(selectors.clientAddresses.cityInput, 'Silla');
.waitForTextInInput(selectors.clientAddresses.cityInput, 'Silla') await page.waitToClick(selectors.clientAddresses.equalizationTaxCheckbox);
.waitToClick(selectors.clientAddresses.equalizationTaxCheckbox) await page.waitToClick(selectors.clientAddresses.saveButton);
.waitToClick(selectors.clientAddresses.saveButton) const result = await page.waitForLastSnackbar();
.waitForLastSnackbar();
expect(result).toEqual('Data saved!'); expect(result).toEqual('Data saved!');
}); });
// confirm invoice by address checkbox gets checked if the EQtax differs between addresses step 3 // confirm invoice by address checkbox gets checked if the EQtax differs between addresses step 3
it('should navigate back to fiscal data to confirm invoice by address is now checked', async() => { it('should navigate back to fiscal data to confirm invoice by address is now checked', async() => {
const result = await nightmare await page.waitToClick(selectors.clientFiscalData.fiscalDataButton);
.waitToClick(selectors.clientFiscalData.fiscalDataButton) await page.waitForWatcherData(selectors.clientFiscalData.watcher);
.waitForWatcherData(selectors.clientFiscalData.watcher) const result = await page.checkboxState(selectors.clientFiscalData.invoiceByAddressCheckbox);
.checkboxState(selectors.clientFiscalData.invoiceByAddressCheckbox);
expect(result).toBe('checked'); expect(result).toBe('checked');
}); });

View File

@ -2,120 +2,101 @@ import selectors from '../../helpers/selectors.js';
import openPage from '../../helpers/puppeteer'; import openPage from '../../helpers/puppeteer';
describe('Client Edit billing data path', () => { describe('Client Edit billing data path', () => {
const nightmare = createNightmare(); let page;
beforeAll(async() => {
page = await openPage();
await page.loginAndModule('administrative', 'client');
await page.accessToSearchResult('Bruce Banner');
await page.accessToSection('client.card.billingData');
});
beforeAll(() => { afterAll(async() => {
nightmare page.close();
.loginAndModule('administrative', 'client')
.accessToSearchResult('Bruce Banner')
.accessToSection('client.card.billingData');
}); });
it(`should attempt to edit the billing data without an IBAN but fail`, async() => { it(`should attempt to edit the billing data without an IBAN but fail`, async() => {
const snackbarMessage = await nightmare await page.autocompleteSearch(selectors.clientBillingData.payMethodAutocomplete, 'PayMethod with IBAN');
.autocompleteSearch(selectors.clientBillingData.payMethodAutocomplete, 'PayMethod with IBAN') await page.autocompleteSearch(selectors.clientBillingData.swiftBicAutocomplete, 'BBKKESMMMMM');
.autocompleteSearch(selectors.clientBillingData.swiftBicAutocomplete, 'BBKKESMMMMM') await page.clearInput(selectors.clientBillingData.dueDayInput);
.clearInput(selectors.clientBillingData.dueDayInput) await page.write(selectors.clientBillingData.dueDayInput, '60');
.write(selectors.clientBillingData.dueDayInput, '60') await page.waitForTextInInput(selectors.clientBillingData.dueDayInput, '60');
.waitForTextInInput(selectors.clientBillingData.dueDayInput, '60') await page.waitToClick(selectors.clientBillingData.receivedCoreLCRCheckbox);
.waitToClick(selectors.clientBillingData.receivedCoreLCRCheckbox) await page.waitToClick(selectors.clientBillingData.receivedCoreVNLCheckbox);
.waitToClick(selectors.clientBillingData.receivedCoreVNLCheckbox) await page.waitToClick(selectors.clientBillingData.receivedB2BVNLCheckbox);
.waitToClick(selectors.clientBillingData.receivedB2BVNLCheckbox) await page.waitToClick(selectors.clientBillingData.saveButton);
.waitToClick(selectors.clientBillingData.saveButton) let snackbarMessage = await page.waitForLastSnackbar();
.waitForLastSnackbar();
expect(snackbarMessage).toEqual('That payment method requires an IBAN'); expect(snackbarMessage).toEqual('That payment method requires an IBAN');
}); });
it(`should add the IBAN but fail as it requires a BIC code`, async() => {
const snackbarMessage = await nightmare
.waitToClick(selectors.clientBillingData.clearswiftBicButton)
.clearInput(selectors.clientBillingData.IBANInput)
.write(selectors.clientBillingData.IBANInput, 'FR9121000418450200051332')
.waitForTextInInput(selectors.clientBillingData.IBANInput, 'FR9121000418450200051332')
.wait(1000)
.waitToClick(selectors.clientBillingData.saveButton)
.waitForLastSnackbar();
expect(snackbarMessage).toEqual('That payment method requires a BIC');
});
it(`should create a new BIC code`, async() => { it(`should create a new BIC code`, async() => {
const newcode = await nightmare await page.waitToClick(selectors.clientBillingData.newBankEntityButton);
.waitToClick(selectors.clientBillingData.newBankEntityButton) await page.write(selectors.clientBillingData.newBankEntityName, 'Gotham City Bank');
.write(selectors.clientBillingData.newBankEntityName, 'Gotham City Bank') await page.write(selectors.clientBillingData.newBankEntityCode, '9999');
.write(selectors.clientBillingData.newBankEntityCode, 9999) await page.write(selectors.clientBillingData.newBankEntityBIC, 'GTHMCT');
.write(selectors.clientBillingData.newBankEntityBIC, 'GTHMCT') await page.waitToClick(selectors.clientBillingData.acceptBankEntityButton);
.waitToClick(selectors.clientBillingData.acceptBankEntityButton) await page.waitForTextInInput(`${selectors.clientBillingData.swiftBicAutocomplete} input`, 'Gotham City Bank');
.waitToGetProperty(`${selectors.clientBillingData.swiftBicAutocomplete} input`, 'value'); let newcode = await page.waitToGetProperty(`${selectors.clientBillingData.swiftBicAutocomplete} input`, 'value');
expect(newcode).toEqual('GTHMCT Gotham City Bank'); expect(newcode).toEqual('GTHMCT Gotham City Bank');
}); });
it(`should confirm the IBAN pay method is sucessfully saved`, async() => { it(`should confirm the IBAN pay method was sucessfully saved`, async() => {
const payMethod = await nightmare let payMethod = await page.waitToGetProperty(`${selectors.clientBillingData.payMethodAutocomplete} input`, 'value');
.waitToGetProperty(`${selectors.clientBillingData.payMethodAutocomplete} input`, 'value');
expect(payMethod).toEqual('PayMethod with IBAN'); expect(payMethod).toEqual('PayMethod with IBAN');
}); });
it(`should clear the BIC code field, update the IBAN to see how he BIC code autocompletes`, async() => { it(`should clear the BIC code field, update the IBAN to see how he BIC code autocompletes`, async() => {
const AutomaticCode = await nightmare await page.write(selectors.clientBillingData.IBANInput, 'ES9121000418450200051332');
.clearInput(selectors.clientBillingData.IBANInput) await page.keyboard.press('Tab');
.write(selectors.clientBillingData.IBANInput, 'ES9121000418450200051332') await page.keyboard.press('Tab');
.waitForTextInInput(`${selectors.clientBillingData.swiftBicAutocomplete} input`, 'caixesbb') await page.waitForTextInInput(`${selectors.clientBillingData.swiftBicAutocomplete} input`, 'caixesbb');
.waitToGetProperty(`${selectors.clientBillingData.swiftBicAutocomplete} input`, 'value'); let automaticCode = await page.waitToGetProperty(`${selectors.clientBillingData.swiftBicAutocomplete} input`, 'value');
expect(AutomaticCode).toEqual('CAIXESBB Caixa Bank'); expect(automaticCode).toEqual('CAIXESBB Caixa Bank');
}); });
it(`should save the form with all its new data`, async() => { it(`should save the form with all its new data`, async() => {
const snackbarMessages = await nightmare await page.waitForWatcherData(selectors.clientBillingData.watcher);
.waitForWatcherData(selectors.clientBillingData.watcher) await page.waitToClick(selectors.clientBillingData.saveButton);
.waitToClick(selectors.clientBillingData.saveButton) let snackbarMessage = await page.waitForLastSnackbar();
.waitForSnackbar();
expect(snackbarMessages).toEqual(jasmine.arrayContaining(['Data saved!'])); expect(snackbarMessage).toEqual('Notification sent!');
}); });
it('should confirm the due day have been edited', async() => { it('should confirm the due day have been edited', async() => {
const dueDate = await nightmare let dueDate = await page.waitToGetProperty(selectors.clientBillingData.dueDayInput, 'value');
.waitToGetProperty(selectors.clientBillingData.dueDayInput, 'value');
expect(dueDate).toEqual('60'); expect(dueDate).toEqual('60');
}); });
it('should confirm the IBAN was saved', async() => { it('should confirm the IBAN was saved', async() => {
const IBAN = await nightmare let IBAN = await page.waitToGetProperty(selectors.clientBillingData.IBANInput, 'value');
.waitToGetProperty(selectors.clientBillingData.IBANInput, 'value');
expect(IBAN).toEqual('ES9121000418450200051332'); expect(IBAN).toEqual('ES9121000418450200051332');
}); });
it('should confirm the swift / BIC code was saved', async() => { it('should confirm the swift / BIC code was saved', async() => {
const code = await nightmare let code = await page.waitToGetProperty(`${selectors.clientBillingData.swiftBicAutocomplete} input`, 'value');
.waitToGetProperty(`${selectors.clientBillingData.swiftBicAutocomplete} input`, 'value');
expect(code).toEqual('CAIXESBB Caixa Bank'); expect(code).toEqual('CAIXESBB Caixa Bank');
}); });
it('should confirm Received LCR checkbox is checked', async() => { it('should confirm Received LCR checkbox is checked', async() => {
const result = await nightmare let result = await page.checkboxState(selectors.clientBillingData.receivedCoreLCRCheckbox);
.checkboxState(selectors.clientBillingData.receivedCoreLCRCheckbox);
expect(result).toBe('checked'); expect(result).toBe('checked');
}); });
it('should confirm Received core VNL checkbox is unchecked', async() => { it('should confirm Received core VNL checkbox is unchecked', async() => {
const result = await nightmare let result = await page.checkboxState(selectors.clientBillingData.receivedCoreVNLCheckbox);
.checkboxState(selectors.clientBillingData.receivedCoreVNLCheckbox);
expect(result).toBe('unchecked'); expect(result).toBe('unchecked');
}); });
it('should confirm Received B2B VNL checkbox is unchecked', async() => { it('should confirm Received B2B VNL checkbox is unchecked', async() => {
const result = await nightmare let result = await page.checkboxState(selectors.clientBillingData.receivedB2BVNLCheckbox);
.checkboxState(selectors.clientBillingData.receivedB2BVNLCheckbox);
expect(result).toBe('unchecked'); expect(result).toBe('unchecked');
}); });

View File

@ -2,118 +2,108 @@ import selectors from '../../helpers/selectors.js';
import openPage from '../../helpers/puppeteer'; import openPage from '../../helpers/puppeteer';
describe('Client Add address path', () => { describe('Client Add address path', () => {
const nightmare = createNightmare(); let page;
beforeAll(async() => {
page = await openPage();
await page.loginAndModule('employee', 'client');
await page.accessToSearchResult('Bruce Banner');
await page.accessToSection('client.card.address.index');
});
beforeAll(() => { afterAll(async() => {
nightmare page.close();
.loginAndModule('employee', 'client')
.accessToSearchResult('Bruce Banner')
.accessToSection('client.card.address.index');
}); });
it(`should click on the add new address button to access to the new address form`, async() => { it(`should click on the add new address button to access to the new address form`, async() => {
const url = await nightmare await page.waitToClick(selectors.clientAddresses.createAddress);
.waitToClick(selectors.clientAddresses.createAddress) await page.waitForURL('address/create');
.waitForURL('address/create') const url = await page.parsedUrl();
.parsedUrl();
expect(url.hash).toContain('address/create'); expect(url.hash).toContain('address/create');
}); });
it('should receive an error after clicking save button as consignee, street and town fields are empty', async() => { it('should receive an error after clicking save button as consignee, street and town fields are empty', async() => {
const result = await nightmare await page.waitToClick(selectors.clientAddresses.defaultCheckboxInput);
.waitToClick(selectors.clientAddresses.defaultCheckboxInput) await page.clearInput(selectors.clientAddresses.streetAddressInput);
.clearInput(selectors.clientAddresses.streetAddressInput) await page.autocompleteSearch(selectors.clientAddresses.provinceAutocomplete, 'Province one');
.autocompleteSearch(selectors.clientAddresses.provinceAutocomplete, 'Province one') await page.clearInput(selectors.clientAddresses.cityInput);
.clearInput(selectors.clientAddresses.cityInput) await page.write(selectors.clientAddresses.cityInput, 'Valencia');
.write(selectors.clientAddresses.cityInput, 'Valencia') await page.clearInput(selectors.clientAddresses.postcodeInput);
.clearInput(selectors.clientAddresses.postcodeInput) await page.write(selectors.clientAddresses.postcodeInput, '46000');
.write(selectors.clientAddresses.postcodeInput, '46000') await page.autocompleteSearch(selectors.clientAddresses.agencyAutocomplete, 'Entanglement');
.autocompleteSearch(selectors.clientAddresses.agencyAutocomplete, 'Entanglement') await page.write(selectors.clientAddresses.phoneInput, '999887744');
.write(selectors.clientAddresses.phoneInput, '999887744') await page.write(selectors.clientAddresses.mobileInput, '999887744');
.write(selectors.clientAddresses.mobileInput, '999887744') await page.waitToClick(selectors.clientFiscalData.saveButton);
.waitToClick(selectors.clientFiscalData.saveButton) const result = await page.waitForLastSnackbar();
.waitForLastSnackbar();
expect(result).toEqual('Some fields are invalid'); expect(result).toEqual('Some fields are invalid');
}); });
it('should confirm the postcode have been edited', async() => { it('should confirm the postcode have been edited', async() => {
const result = await nightmare const result = await page.waitToGetProperty(`${selectors.clientAddresses.postcodeInput}`, 'value');
.waitToGetProperty(`${selectors.clientAddresses.postcodeInput}`, 'value');
expect(result).toContain('46000'); expect(result).toContain('46000');
}); });
it('should confirm the city have been autocompleted', async() => { it('should confirm the city have been autocompleted', async() => {
const result = await nightmare const result = await page.waitToGetProperty(`${selectors.clientAddresses.cityInput}`, 'value');
.waitToGetProperty(`${selectors.clientAddresses.cityInput}`, 'value');
expect(result).toEqual('Valencia'); expect(result).toEqual('Valencia');
}); });
it(`should confirm the province have been autocompleted`, async() => { it(`should confirm the province have been autocompleted`, async() => {
const result = await nightmare const result = await page.waitToGetProperty(`${selectors.clientAddresses.provinceAutocomplete} input`, 'value');
.waitToGetProperty(`${selectors.clientAddresses.provinceAutocomplete} input`, 'value');
expect(result).toEqual('Province one'); expect(result).toEqual('Province one');
}); });
it(`should create a new address with all it's data`, async() => { it(`should create a new address with all it's data`, async() => {
const result = await nightmare await page.write(selectors.clientAddresses.consigneeInput, 'Bruce Bunner');
.write(selectors.clientAddresses.consigneeInput, 'Bruce Bunner') await page.write(selectors.clientAddresses.streetAddressInput, '320 Park Avenue New York');
.write(selectors.clientAddresses.streetAddressInput, '320 Park Avenue New York') await page.waitToClick(selectors.clientAddresses.saveButton);
.waitToClick(selectors.clientAddresses.saveButton) const result = await page.waitForLastSnackbar();
.waitForLastSnackbar();
expect(result).toEqual('Data saved!'); expect(result).toEqual('Data saved!');
}); });
it(`should click on the addresses button confirm the new address exists and it's the default one`, async() => { it(`should click on the addresses button confirm the new address exists and it's the default one`, async() => {
const result = await nightmare const result = await page.waitToGetProperty(selectors.clientAddresses.defaultAddress, 'innerText');
// .waitToClick(selectors.clientAddresses.addressesButton)
.waitToGetProperty(selectors.clientAddresses.defaultAddress, 'innerText');
expect(result).toContain('320 Park Avenue New York'); expect(result).toContain('320 Park Avenue New York');
}); });
it(`should click on the make default icon of the second address then confirm it is the default one now`, async() => { it(`should click on the make default icon of the second address then confirm it is the default one now`, async() => {
const result = await nightmare await page.waitToClick(selectors.clientAddresses.secondMakeDefaultStar);
.waitToClick(selectors.clientAddresses.secondMakeDefaultStar) await page.waitForTextInElement(selectors.clientAddresses.defaultAddress, 'Somewhere in Thailand');
.waitForTextInElement(selectors.clientAddresses.defaultAddress, 'Somewhere in Thailand') const result = await page.waitToGetProperty(selectors.clientAddresses.defaultAddress, 'innerText');
.waitToGetProperty(selectors.clientAddresses.defaultAddress, 'innerText');
expect(result).toContain('Somewhere in Thailand'); expect(result).toContain('Somewhere in Thailand');
}); });
it(`should click on the edit icon of the default address`, async() => { it(`should click on the edit icon of the default address`, async() => {
const url = await nightmare await page.waitForTextInElement(selectors.clientAddresses.defaultAddress, 'Somewhere in Thailand');
.waitForTextInElement(selectors.clientAddresses.defaultAddress, 'Somewhere in Thailand') await page.waitToClick(selectors.clientAddresses.firstEditAddress);
.waitToClick(selectors.clientAddresses.firstEditAddress) await page.waitForURL('/edit');
.waitForURL('/edit') const url = await page.parsedUrl();
.parsedUrl();
expect(url.hash).toContain('/edit'); expect(url.hash).toContain('/edit');
}); });
it(`should click on the active checkbox and receive an error to save it because it is the default address`, async() => { it(`should click on the active checkbox and receive an error to save it because it is the default address`, async() => {
const result = await nightmare await page.waitForWatcherData(selectors.clientAddresses.watcher);
.waitForWatcherData(selectors.clientAddresses.watcher) await page.waitToClick(selectors.clientAddresses.activeCheckbox);
.waitToClick(selectors.clientAddresses.activeCheckbox) await page.waitToClick(selectors.clientAddresses.saveButton);
.waitToClick(selectors.clientAddresses.saveButton) const result = await page.waitForLastSnackbar();
.waitForLastSnackbar();
expect(result).toEqual('The default consignee can not be unchecked'); expect(result).toEqual('The default consignee can not be unchecked');
}); });
// this "it" should be removed if the watcher doesn't prevent the navigation upon state changes
it(`should go back to the addreses section by clicking the cancel button`, async() => { it(`should go back to the addreses section by clicking the cancel button`, async() => {
const url = await nightmare await page.waitToClick(selectors.clientAddresses.cancelEditAddressButton);
.waitToClick(selectors.clientAddresses.cancelEditAddressButton) await page.waitToClick('.vn-confirm.shown button[response="accept"]');
.waitToClick('.vn-confirm.shown button[response="accept"]') await page.waitForURL('address/index');
.waitForURL('address/index') const url = await page.parsedUrl();
.parsedUrl();
expect(url.hash).toContain('address/index'); expect(url.hash).toContain('address/index');
}); });

View File

@ -2,53 +2,52 @@ import selectors from '../../helpers/selectors.js';
import openPage from '../../helpers/puppeteer'; import openPage from '../../helpers/puppeteer';
describe('Client add address notes path', () => { describe('Client add address notes path', () => {
const nightmare = createNightmare(); let page;
beforeAll(async() => {
page = await openPage();
await page.loginAndModule('employee', 'client');
await page.accessToSearchResult('Petter Parker');
await page.accessToSection('client.card.address.index');
});
beforeAll(() => { afterAll(async() => {
nightmare page.close();
.loginAndModule('employee', 'client')
.accessToSearchResult('Petter Parker')
.accessToSection('client.card.address.index');
}); });
it(`should click on the edit icon of the default address`, async() => { it(`should click on the edit icon of the default address`, async() => {
const url = await nightmare await page.waitForTextInElement(selectors.clientAddresses.defaultAddress, '20 Ingram Street');
.waitForTextInElement(selectors.clientAddresses.defaultAddress, '20 Ingram Street') await page.waitToClick(selectors.clientAddresses.firstEditAddress);
.waitToClick(selectors.clientAddresses.firstEditAddress) await page.waitForURL('/edit');
.waitForURL('/edit') const url = await page.parsedUrl();
.parsedUrl();
expect(url.hash).toContain('/edit'); expect(url.hash).toContain('/edit');
}); });
it('should not save a description without observation type', async() => { it('should not save a description without observation type', async() => {
const result = await nightmare await page.waitToClick(selectors.clientAddresses.addObservationButton);
.waitToClick(selectors.clientAddresses.addObservationButton) await page.write(selectors.clientAddresses.firstObservationDescriptionInput, 'first description');
.write(selectors.clientAddresses.firstObservationDescriptionInput, 'first description') await page.waitToClick(selectors.clientAddresses.saveButton);
.waitToClick(selectors.clientAddresses.saveButton) const result = await page.waitForLastSnackbar();
.waitForLastSnackbar();
expect(result).toEqual('Some fields are invalid'); expect(result).toEqual('Some fields are invalid');
}); });
it('should not save an observation type without description', async() => { it('should not save an observation type without description', async() => {
const result = await nightmare await page.clearInput(selectors.clientAddresses.firstObservationDescriptionInput);
.clearInput(selectors.clientAddresses.firstObservationDescriptionInput) await page.autocompleteSearch(selectors.clientAddresses.firstObservationTypeAutocomplete, 'comercial');
.autocompleteSearch(selectors.clientAddresses.firstObservationTypeAutocomplete, 'comercial') await page.waitToClick(selectors.clientAddresses.saveButton);
.waitToClick(selectors.clientAddresses.saveButton) const result = await page.waitForLastSnackbar();
.waitForLastSnackbar();
expect(result).toEqual('Some fields are invalid'); expect(result).toEqual('Some fields are invalid');
}); });
it('should create two new observations', async() => { it('should create two new observations', async() => {
const result = await nightmare await page.write(selectors.clientAddresses.firstObservationDescriptionInput, 'first description');
.write(selectors.clientAddresses.firstObservationDescriptionInput, 'first description') await page.waitToClick(selectors.clientAddresses.addObservationButton);
.waitToClick(selectors.clientAddresses.addObservationButton) await page.autocompleteSearch(selectors.clientAddresses.secondObservationTypeAutocomplete, 'observation one');
.autocompleteSearch(selectors.clientAddresses.secondObservationTypeAutocomplete, 'observation one') await page.write(selectors.clientAddresses.secondObservationDescriptionInput, 'second description');
.write(selectors.clientAddresses.secondObservationDescriptionInput, 'second description') await page.waitToClick(selectors.clientAddresses.saveButton);
.waitToClick(selectors.clientAddresses.saveButton) const result = await page.waitForLastSnackbar();
.waitForLastSnackbar();
expect(result).toEqual('Data saved!'); expect(result).toEqual('Data saved!');
}); });

View File

@ -2,40 +2,40 @@ import selectors from '../../helpers/selectors.js';
import openPage from '../../helpers/puppeteer'; import openPage from '../../helpers/puppeteer';
describe('Client Edit web access path', () => { describe('Client Edit web access path', () => {
const nightmare = createNightmare(); let page;
beforeAll(async() => {
page = await openPage();
await page.loginAndModule('employee', 'client');
await page.accessToSearchResult('Bruce Banner');
await page.accessToSection('client.card.webAccess');
});
beforeAll(() => { afterAll(async() => {
nightmare page.close();
.loginAndModule('employee', 'client')
.accessToSearchResult('Bruce Banner')
.accessToSection('client.card.webAccess');
}); });
it(`should uncheck the Enable web access checkbox and update the name`, async() => { it(`should uncheck the Enable web access checkbox and update the name`, async() => {
const result = await nightmare await page.waitToClick(selectors.clientWebAccess.enableWebAccessCheckbox);
.waitToClick(selectors.clientWebAccess.enableWebAccessCheckbox) await page.clearInput(selectors.clientWebAccess.userNameInput);
.clearInput(selectors.clientWebAccess.userNameInput) await page.write(selectors.clientWebAccess.userNameInput, 'Hulk');
.write(selectors.clientWebAccess.userNameInput, 'Hulk') await page.waitToClick(selectors.clientWebAccess.saveButton);
.waitToClick(selectors.clientWebAccess.saveButton) const result = await page.waitForLastSnackbar();
.waitForLastSnackbar();
expect(result).toEqual('Data saved!'); expect(result).toEqual('Data saved!');
}); });
it('should confirm web access is now unchecked', async() => { it('should confirm web access is now unchecked', async() => {
const result = await nightmare await page.waitToClick(selectors.clientBasicData.basicDataButton);
.waitToClick(selectors.clientBasicData.basicDataButton) await page.wait(selectors.clientBasicData.nameInput);
.wait(selectors.clientBasicData.nameInput) await page.waitToClick(selectors.clientsIndex.othersButton);
.waitToClick(selectors.clientsIndex.othersButton) await page.waitToClick(selectors.clientWebAccess.webAccessButton);
.waitToClick(selectors.clientWebAccess.webAccessButton) const result = await page.checkboxState(selectors.clientWebAccess.enableWebAccessCheckbox);
.checkboxState(selectors.clientWebAccess.enableWebAccessCheckbox);
expect(result).toBe('unchecked'); expect(result).toBe('unchecked');
}); });
it('should confirm web access name have been updated', async() => { it('should confirm web access name have been updated', async() => {
const result = await nightmare const result = await page.waitToGetProperty(selectors.clientWebAccess.userNameInput, 'value');
.waitToGetProperty(selectors.clientWebAccess.userNameInput, 'value');
expect(result).toEqual('Hulk'); expect(result).toEqual('Hulk');
}); });

View File

@ -2,36 +2,36 @@ import selectors from '../../helpers/selectors.js';
import openPage from '../../helpers/puppeteer'; import openPage from '../../helpers/puppeteer';
describe('Client Add notes path', () => { describe('Client Add notes path', () => {
const nightmare = createNightmare(); let page;
beforeAll(async() => {
page = await openPage();
await page.loginAndModule('employee', 'client');
await page.accessToSearchResult('Bruce Banner');
await page.accessToSection('client.card.note.index');
});
beforeAll(() => { afterAll(async() => {
nightmare page.close();
.loginAndModule('employee', 'client')
.accessToSearchResult('Bruce Banner')
.accessToSection('client.card.note.index');
}); });
it(`should click on the add note button`, async() => { it(`should click on the add note button`, async() => {
const url = await nightmare await page.waitToClick(selectors.clientNotes.addNoteFloatButton);
.waitToClick(selectors.clientNotes.addNoteFloatButton) await page.waitForURL('/note/create');
.waitForURL('/note/create') const url = await page.parsedUrl();
.parsedUrl();
expect(url.hash).toContain('/note/create'); expect(url.hash).toContain('/note/create');
}); });
it(`should create a note`, async() => { it(`should create a note`, async() => {
const result = await nightmare await page.write(selectors.clientNotes.noteInput, 'Meeting with Black Widow 21st 9am');
.write(selectors.clientNotes.noteInput, 'Meeting with Black Widow 21st 9am') await page.waitToClick(selectors.clientNotes.saveButton);
.waitToClick(selectors.clientNotes.saveButton) const result = await page.waitForLastSnackbar();
.waitForLastSnackbar();
expect(result).toEqual('Data saved!'); expect(result).toEqual('Data saved!');
}); });
it('should confirm the note was created', async() => { it('should confirm the note was created', async() => {
const result = await nightmare const result = await page.waitToGetProperty(selectors.clientNotes.firstNoteText, 'innerText');
.waitToGetProperty(selectors.clientNotes.firstNoteText, 'innerText');
expect(result).toEqual('Meeting with Black Widow 21st 9am'); expect(result).toEqual('Meeting with Black Widow 21st 9am');
}); });

View File

@ -2,37 +2,37 @@ import selectors from '../../helpers/selectors.js';
import openPage from '../../helpers/puppeteer'; import openPage from '../../helpers/puppeteer';
describe('Client Add credit path', () => { describe('Client Add credit path', () => {
const nightmare = createNightmare(); let page;
beforeAll(async() => {
page = await openPage();
await page.loginAndModule('salesAssistant', 'client');
await page.accessToSearchResult('Hank Pym');
await page.accessToSection('client.card.credit.index');
});
beforeAll(() => { afterAll(async() => {
nightmare page.close();
.loginAndModule('salesAssistant', 'client')
.accessToSearchResult('Hank Pym')
.accessToSection('client.card.credit.index');
}); });
it(`should click on the add credit button`, async() => { it(`should click on the add credit button`, async() => {
const url = await nightmare await page.waitToClick(selectors.clientCredit.addCreditFloatButton);
.waitToClick(selectors.clientCredit.addCreditFloatButton) await page.waitForURL('/credit/create');
.waitForURL('/credit/create') const url = await page.parsedUrl();
.parsedUrl();
expect(url.hash).toContain('/credit/create'); expect(url.hash).toContain('/credit/create');
}); });
it(`should edit the credit`, async() => { it(`should edit the credit`, async() => {
const result = await nightmare await page.clearInput(selectors.clientCredit.creditInput);
.clearInput(selectors.clientCredit.creditInput) await page.write(selectors.clientCredit.creditInput, '999');
.write(selectors.clientCredit.creditInput, 999) await page.waitToClick(selectors.clientCredit.saveButton);
.waitToClick(selectors.clientCredit.saveButton) const result = await page.waitForLastSnackbar();
.waitForLastSnackbar();
expect(result).toEqual('Data saved!'); expect(result).toEqual('Data saved!');
}); });
it('should confirm the credit was updated', async() => { it('should confirm the credit was updated', async() => {
const result = await nightmare const result = await page.waitToGetProperty(selectors.clientCredit.firstCreditText, 'innerText');
.waitToGetProperty(selectors.clientCredit.firstCreditText, 'innerText');
expect(result).toContain(999); expect(result).toContain(999);
expect(result).toContain('salesAssistant'); expect(result).toContain('salesAssistant');

View File

@ -2,47 +2,46 @@ import selectors from '../../helpers/selectors.js';
import openPage from '../../helpers/puppeteer'; import openPage from '../../helpers/puppeteer';
describe('Client Add greuge path', () => { describe('Client Add greuge path', () => {
const nightmare = createNightmare(); let page;
beforeAll(async() => {
page = await openPage();
await page.loginAndModule('salesAssistant', 'client');
await page.accessToSearchResult('Petter Parker');
await page.accessToSection('client.card.greuge.index');
});
beforeAll(() => { afterAll(async() => {
nightmare page.close();
.loginAndModule('salesAssistant', 'client')
.accessToSearchResult('Petter Parker')
.accessToSection('client.card.greuge.index');
}); });
it(`should click on the add greuge button`, async() => { it(`should click on the add greuge button`, async() => {
const url = await nightmare await page.waitToClick(selectors.clientGreuge.addGreugeFloatButton);
.waitToClick(selectors.clientGreuge.addGreugeFloatButton) await page.waitForURL('greuge/create');
.waitForURL('greuge/create') const url = await page.parsedUrl();
.parsedUrl();
expect(url.hash).toContain('greuge/create'); expect(url.hash).toContain('greuge/create');
}); });
it(`should receive an error if all fields are empty but date and type on submit`, async() => { it(`should receive an error if all fields are empty but date and type on submit`, async() => {
const result = await nightmare await page.autocompleteSearch(selectors.clientGreuge.typeAutocomplete, 'Diff');
.autocompleteSearch(selectors.clientGreuge.typeAutocomplete, 'Diff') await page.waitToClick(selectors.clientGreuge.saveButton);
.waitToClick(selectors.clientGreuge.saveButton) const result = await page.waitForLastSnackbar();
.waitForLastSnackbar();
expect(result).toEqual('Some fields are invalid'); expect(result).toEqual('Some fields are invalid');
}); });
it(`should create a new greuge with all its data`, async() => { it(`should create a new greuge with all its data`, async() => {
const result = await nightmare await page.write(selectors.clientGreuge.amountInput, '999');
.write(selectors.clientGreuge.amountInput, 999) await page.waitForTextInInput(selectors.clientGreuge.amountInput, '999');
.waitForTextInInput(selectors.clientGreuge.amountInput, '999') await page.write(selectors.clientGreuge.descriptionInput, 'new armor for Batman!');
.write(selectors.clientGreuge.descriptionInput, 'new armor for Batman!') await page.waitToClick(selectors.clientGreuge.saveButton);
.waitToClick(selectors.clientGreuge.saveButton) const result = await page.waitForLastSnackbar();
.waitForLastSnackbar();
expect(result).toEqual('Data saved!'); expect(result).toEqual('Data saved!');
}); });
it('should confirm the greuge was added to the list', async() => { it('should confirm the greuge was added to the list', async() => {
const result = await nightmare const result = await page.waitToGetProperty(selectors.clientGreuge.firstGreugeText, 'innerText');
.waitToGetProperty(selectors.clientGreuge.firstGreugeText, 'innerText');
expect(result).toContain(999); expect(result).toContain(999);
expect(result).toContain('new armor for Batman!'); expect(result).toContain('new armor for Batman!');

View File

@ -2,17 +2,20 @@ import selectors from '../../helpers/selectors.js';
import openPage from '../../helpers/puppeteer'; import openPage from '../../helpers/puppeteer';
describe('Client mandate path', () => { describe('Client mandate path', () => {
const nightmare = createNightmare(); let page;
beforeAll(async() => {
page = await openPage();
await page.loginAndModule('salesPerson', 'client');
await page.accessToSearchResult('Petter Parker');
await page.accessToSection('client.card.mandate');
});
beforeAll(() => { afterAll(async() => {
nightmare page.close();
.loginAndModule('salesPerson', 'client')
.accessToSearchResult('Petter Parker')
.accessToSection('client.card.mandate');
}); });
it('should confirm the client has a mandate of the CORE type', async() => { it('should confirm the client has a mandate of the CORE type', async() => {
const result = await nightmare const result = await page
.waitToGetProperty(selectors.clientMandate.firstMandateText, 'innerText'); .waitToGetProperty(selectors.clientMandate.firstMandateText, 'innerText');
expect(result).toContain('1'); expect(result).toContain('1');

View File

@ -2,177 +2,162 @@ import selectors from '../../helpers/selectors.js';
import openPage from '../../helpers/puppeteer'; import openPage from '../../helpers/puppeteer';
describe('Client lock verified data path', () => { describe('Client lock verified data path', () => {
const nightmare = createNightmare(); let page;
beforeAll(async() => {
describe('as salesPerson', () => { page = await openPage();
beforeAll(() => { await page.loginAndModule('salesPerson', 'client');
nightmare await page.accessToSearchResult('Hank Pym');
.loginAndModule('salesPerson', 'client') await page.accessToSection('client.card.fiscalData');
.accessToSearchResult('Hank Pym')
.accessToSection('client.card.fiscalData');
}); });
afterAll(async() => {
page.close();
});
describe('as salesPerson', () => {
it('should confirm verified data button is disabled for salesPerson', async() => { it('should confirm verified data button is disabled for salesPerson', async() => {
const result = await nightmare await page.wait(200);
.wait(200) await page.wait(selectors.clientFiscalData.verifiedDataCheckbox);
.wait(selectors.clientFiscalData.verifiedDataCheckbox) const result = await page.isDisabled(selectors.clientFiscalData.verifiedDataCheckbox);
.isDisabled(selectors.clientFiscalData.verifiedDataCheckbox);
expect(result).toBeTruthy(); expect(result).toBeTruthy();
}); });
it('should edit the social name', async() => { it('should edit the social name', async() => {
const result = await nightmare await page.wait(selectors.clientFiscalData.socialNameInput);
.wait(selectors.clientFiscalData.socialNameInput) await page.clearInput(selectors.clientFiscalData.socialNameInput);
.clearInput(selectors.clientFiscalData.socialNameInput) await page.write(selectors.clientFiscalData.socialNameInput, 'Captain America Civil War');
.write(selectors.clientFiscalData.socialNameInput, 'Captain America Civil War') await page.waitToClick(selectors.clientFiscalData.saveButton);
.waitToClick(selectors.clientFiscalData.saveButton) const result = await page.waitForLastSnackbar();
.waitForLastSnackbar();
expect(result).toEqual('Data saved!'); expect(result).toEqual('Data saved!');
}); });
it('should confirm the social name have been edited', async() => { it('should confirm the social name have been edited', async() => {
const result = await nightmare await page.reloadSection('client.card.fiscalData');
.reloadSection('client.card.fiscalData') const result = await page.waitToGetProperty(selectors.clientFiscalData.socialNameInput, 'value');
.waitToGetProperty(selectors.clientFiscalData.socialNameInput, 'value');
expect(result).toEqual('Captain America Civil War'); expect(result).toEqual('Captain America Civil War');
}); });
}); });
describe('as administrative', () => { describe('as administrative', () => {
beforeAll(() => { beforeAll(async() => {
nightmare await page.loginAndModule('administrative', 'client');
.loginAndModule('administrative', 'client') await page.accessToSearchResult('Hank Pym');
.accessToSearchResult('Hank Pym') await page.accessToSection('client.card.fiscalData');
.accessToSection('client.card.fiscalData');
}); });
it('should confirm verified data button is enabled for administrative', async() => { it('should confirm verified data button is enabled for administrative', async() => {
const result = await nightmare const result = await page.isDisabled(selectors.clientFiscalData.verifiedDataCheckbox);
.isDisabled(selectors.clientFiscalData.verifiedDataCheckbox);
expect(result).toBeFalsy(); expect(result).toBeFalsy();
}); });
it('should check the Verified data checkbox', async() => { it('should check the Verified data checkbox', async() => {
const result = await nightmare await page.waitToClick(selectors.clientFiscalData.verifiedDataCheckbox);
.waitToClick(selectors.clientFiscalData.verifiedDataCheckbox) await page.waitToClick(selectors.clientFiscalData.saveButton);
.waitToClick(selectors.clientFiscalData.saveButton) const result = await page.waitForLastSnackbar();
.waitForLastSnackbar();
expect(result).toEqual('Data saved!'); expect(result).toEqual('Data saved!');
}); });
it('should confirm Verified data checkbox is checked', async() => { it('should confirm Verified data checkbox is checked', async() => {
const isChecked = await nightmare await page.reloadSection('client.card.fiscalData');
.reloadSection('client.card.fiscalData') const isChecked = await page.checkboxState(selectors.clientFiscalData.verifiedDataCheckbox);
.checkboxState(selectors.clientFiscalData.verifiedDataCheckbox);
expect(isChecked).toEqual('checked'); expect(isChecked).toEqual('checked');
}); });
it('should again edit the social name', async() => { it('should again edit the social name', async() => {
const result = await nightmare await page.wait(selectors.clientFiscalData.socialNameInput);
.wait(selectors.clientFiscalData.socialNameInput) await page.clearInput(selectors.clientFiscalData.socialNameInput);
.clearInput(selectors.clientFiscalData.socialNameInput) await page.write(selectors.clientFiscalData.socialNameInput, 'Ant man and the Wasp');
.write(selectors.clientFiscalData.socialNameInput, 'Ant man and the Wasp') await page.waitToClick(selectors.clientFiscalData.saveButton);
.waitToClick(selectors.clientFiscalData.saveButton) const result = await page.waitForLastSnackbar();
.waitForLastSnackbar();
expect(result).toEqual('Data saved!'); expect(result).toEqual('Data saved!');
}); });
it('should again confirm the social name have been edited', async() => { it('should again confirm the social name have been edited', async() => {
const result = await nightmare await page.reloadSection('client.card.fiscalData');
.reloadSection('client.card.fiscalData') const result = await page.waitToGetProperty(selectors.clientFiscalData.socialNameInput, 'value');
.waitToGetProperty(selectors.clientFiscalData.socialNameInput, 'value');
expect(result).toEqual('Ant man and the Wasp'); expect(result).toEqual('Ant man and the Wasp');
}); });
}); });
describe('as salesPerson second run', () => { describe('as salesPerson second run', () => {
beforeAll(() => { beforeAll(async() => {
nightmare await page.loginAndModule('salesPerson', 'client');
.loginAndModule('salesPerson', 'client') await page.accessToSearchResult('Hank Pym');
.accessToSearchResult('Hank Pym') await page.accessToSection('client.card.fiscalData');
.accessToSection('client.card.fiscalData');
}); });
it('should confirm verified data button is disabled once again for salesPerson', async() => { it('should confirm verified data button is disabled once again for salesPerson', async() => {
const isDisabled = await nightmare const isDisabled = await page.isDisabled(selectors.clientFiscalData.verifiedDataCheckbox);
.isDisabled(selectors.clientFiscalData.verifiedDataCheckbox);
expect(isDisabled).toBeTruthy(); expect(isDisabled).toBeTruthy();
}); });
it('should not be able to save change throwing a verified data error', async() => { it('should not be able to save change throwing a verified data error', async() => {
const result = await nightmare await page.clearInput(selectors.clientFiscalData.socialNameInput);
.clearInput(selectors.clientFiscalData.socialNameInput) await page.write(selectors.clientFiscalData.socialNameInput, 'This wont happen');
.write(selectors.clientFiscalData.socialNameInput, 'This wont happen') await page.waitToClick(selectors.clientFiscalData.saveButton);
.waitToClick(selectors.clientFiscalData.saveButton) const result = await page.waitForLastSnackbar();
.waitForLastSnackbar();
expect(result).toEqual(jasmine.arrayContaining([`You can't make changes on a client with verified data`])); expect(result).toEqual(jasmine.arrayContaining([`You can't make changes on a client with verified data`]));
}); });
}); });
describe('as salesAssistant', () => { describe('as salesAssistant', () => {
beforeAll(() => { beforeAll(async() => {
nightmare await page.forceReloadSection('client.card.fiscalData');
.forceReloadSection('client.card.fiscalData') await page.loginAndModule('salesAssistant', 'client');
.loginAndModule('salesAssistant', 'client') await page.accessToSearchResult('Hank Pym');
.accessToSearchResult('Hank Pym') await page.accessToSection('client.card.fiscalData');
.accessToSection('client.card.fiscalData');
}); });
it('should confirm verified data button is enabled for salesAssistant', async() => { it('should confirm verified data button is enabled for salesAssistant', async() => {
const isDisabled = await nightmare const isDisabled = await page.isDisabled(selectors.clientFiscalData.verifiedDataCheckbox);
.isDisabled(selectors.clientFiscalData.verifiedDataCheckbox);
expect(isDisabled).toBeFalsy(); expect(isDisabled).toBeFalsy();
}); });
it('should now edit the social name', async() => { it('should now edit the social name', async() => {
const result = await nightmare await page.clearInput(selectors.clientFiscalData.socialNameInput);
.clearInput(selectors.clientFiscalData.socialNameInput) await page.write(selectors.clientFiscalData.socialNameInput, 'new social name edition');
.write(selectors.clientFiscalData.socialNameInput, 'new social name edition') await page.waitToClick(selectors.clientFiscalData.saveButton);
.waitToClick(selectors.clientFiscalData.saveButton) const result = await page.waitForLastSnackbar();
.waitForLastSnackbar();
expect(result).toEqual('Data saved!'); expect(result).toEqual('Data saved!');
}); });
it('should now confirm the social name have been edited once and for all', async() => { it('should now confirm the social name have been edited once and for all', async() => {
const result = await nightmare await page.reloadSection('client.card.fiscalData');
.reloadSection('client.card.fiscalData') const result = await page.waitToGetProperty(selectors.clientFiscalData.socialNameInput, 'value');
.waitToGetProperty(selectors.clientFiscalData.socialNameInput, 'value');
expect(result).toEqual('new social name edition'); expect(result).toEqual('new social name edition');
}); });
}); });
describe('as salesPerson third run', () => { describe('as salesPerson third run', () => {
beforeAll(() => { beforeAll(async() => {
nightmare await page.loginAndModule('salesPerson', 'client');
.loginAndModule('salesPerson', 'client') await page.accessToSearchResult('Hank Pym');
.accessToSearchResult('Hank Pym') await page.accessToSection('client.card.fiscalData');
.accessToSection('client.card.fiscalData');
}); });
it('should confirm verified data button is enabled once again', async() => { it('should confirm verified data button is enabled once again', async() => {
const isDisabled = await nightmare const isDisabled = await page;
.isDisabled(selectors.clientFiscalData.verifiedDataCheckbox); await page.isDisabled(selectors.clientFiscalData.verifiedDataCheckbox);
expect(isDisabled).toBeTruthy(); expect(isDisabled).toBeTruthy();
}); });
it('should confirm the form is enabled for salesPerson', async() => { it('should confirm the form is enabled for salesPerson', async() => {
const result = await nightmare await page.wait(selectors.clientFiscalData.socialNameInput);
.wait(selectors.clientFiscalData.socialNameInput) const result = await page.evaluate(selector => {
.evaluate(selector => {
return document.querySelector(selector).disabled; return document.querySelector(selector).disabled;
}, 'vn-textfield[ng-model="$ctrl.client.socialName"] > div'); }, 'vn-textfield[ng-model="$ctrl.client.socialName"] > div');

View File

@ -2,47 +2,48 @@ import selectors from '../../helpers/selectors.js';
import openPage from '../../helpers/puppeteer'; import openPage from '../../helpers/puppeteer';
describe('Client log path', () => { describe('Client log path', () => {
const nightmare = createNightmare(); let page;
beforeAll(async() => {
page = await openPage();
await page.loginAndModule('employee', 'client');
await page.accessToSearchResult('DavidCharlesHaller');
await page.accessToSection('client.card.basicData');
});
beforeAll(() => { afterAll(async() => {
nightmare page.close();
.loginAndModule('employee', 'client')
.accessToSearchResult('DavidCharlesHaller')
.accessToSection('client.card.basicData');
}); });
it('should update the clients name', async() => { it('should update the clients name', async() => {
let result = await nightmare await page.clearInput(selectors.clientBasicData.nameInput);
.clearInput(selectors.clientBasicData.nameInput) await page.write(selectors.clientBasicData.nameInput, 'this is a test');
.write(selectors.clientBasicData.nameInput, 'this is a test') await page.waitToClick(selectors.clientBasicData.saveButton);
.waitToClick(selectors.clientBasicData.saveButton) let result = await page.waitForLastSnackbar();
.waitForLastSnackbar();
expect(result).toEqual('Data saved!'); expect(result).toEqual('Data saved!');
}); });
it('should navigate to the log section', async() => { it('should navigate to the log section', async() => {
let url = await nightmare await page.waitToClick(selectors.clientLog.logButton);
.waitToClick(selectors.clientLog.logButton) await page.waitForURL('log');
.waitForURL('log') let url = await page.parsedUrl();
.parsedUrl();
expect(url.hash).toContain('log'); expect(url.hash).toContain('log');
}); });
it('should check the previous value of the last logged change', async() => { it('should check the previous value of the last logged change', async() => {
let lastModificationPreviousValue = await nightmare let lastModificationPreviousValue = await page
.waitToGetProperty(selectors.clientLog.lastModificationPreviousValue, 'innerText'); .waitToGetProperty(selectors.clientLog.lastModificationPreviousValue, 'innerText');
expect(lastModificationPreviousValue).toContain('DavidCharlesHaller'); expect(lastModificationPreviousValue).toContain('DavidCharlesHaller');
}); });
it('should check the current value of the last logged change', async() => { it('should check the current value of the last logged change', async() => {
let lastModificationPreviousValue = await nightmare let lastModificationPreviousValue = await page
.waitToGetProperty(selectors.clientLog.lastModificationPreviousValue, 'innerText'); .waitToGetProperty(selectors.clientLog.lastModificationPreviousValue, 'innerText');
let lastModificationCurrentValue = await nightmare let lastModificationCurrentValue = await page.
.waitToGetProperty(selectors.clientLog.lastModificationCurrentValue, 'innerText'); waitToGetProperty(selectors.clientLog.lastModificationCurrentValue, 'innerText');
expect(lastModificationPreviousValue).toEqual('name: DavidCharlesHaller'); expect(lastModificationPreviousValue).toEqual('name: DavidCharlesHaller');

View File

@ -1,66 +1,66 @@
import selectors from '../../helpers/selectors.js'; import selectors from '../../helpers/selectors.js';
import openPage from '../../helpers/puppeteer'; import openPage from '../../helpers/puppeteer';
describe('Client balance path', () => { fdescribe('Client balance path', () => {
const nightmare = createNightmare(); let page;
beforeAll(async() => {
page = await openPage();
await page.loginAndModule('administrative', 'client');
await page.accessToSearchResult('Petter Parker');
}, 30000);
beforeAll(() => { afterAll(async() => {
nightmare page.close();
.loginAndModule('administrative', 'client')
.accessToSearchResult('Petter Parker');
}); });
it('should now edit the local user config data', async() => { it('should now edit the local user config data', async() => {
let result = await nightmare await page.waitToClick(selectors.globalItems.userMenuButton);
.waitToClick(selectors.globalItems.userMenuButton) await page.autocompleteSearch(selectors.globalItems.userLocalCompany, 'CCs');
.autocompleteSearch(selectors.globalItems.userLocalCompany, 'CCs') let result = await page.waitForLastSnackbar();
.waitForLastSnackbar();
expect(result).toEqual('Data saved!'); expect(result).toEqual('Data saved!');
}); });
it('should access to the balance section to check the data shown matches the local settings', async() => { it('should access to the balance section to check the data shown matches the local settings', async() => {
let result = await nightmare await page.accessToSection('client.card.balance.index');
.accessToSection('client.card.balance.index') let result = await page.waitToGetProperty(`${selectors.clientBalance.companyAutocomplete} input`, 'value');
.waitToGetProperty(`${selectors.clientBalance.companyAutocomplete} input`, 'value');
expect(result).toEqual('CCs'); expect(result).toEqual('CCs');
}); });
it('should now clear the user local settings', async() => { it('should now clear the user local settings', async() => {
let result = await nightmare await page.waitToClick(selectors.globalItems.userMenuButton);
.waitToClick(selectors.globalItems.userMenuButton) await page.clearInput(selectors.globalItems.userConfigThirdAutocomplete);
.waitToClick(selectors.globalItems.userConfigThirdAutocompleteClear) let result = await page.waitForLastSnackbar();
.waitForLastSnackbar();
expect(result).toEqual('Data saved!'); expect(result).toEqual('Data saved!');
}); });
it('should click the new payment button', async() => { it('should click the new payment button', async() => {
let url = await nightmare await page.keyboard.press('Escape');
.reloadSection('client.card.balance.index') await page.reloadSection('client.card.balance.index');
.waitToClick(selectors.clientBalance.newPaymentButton) await page.waitToClick(selectors.clientBalance.newPaymentButton);
.waitForURL('/balance') await page.waitForURL('/balance');
.parsedUrl(); let url = await page.parsedUrl();
expect(url.hash).toContain('/balance'); expect(url.hash).toContain('/balance');
}); });
it('should create a new payment that clears the debt', async() => { it('should create a new payment that clears the debt', async() => {
let result = await nightmare await page.waitFor(1000);
.autocompleteSearch(selectors.clientBalance.newPaymentBank, 'Pay on receipt') await page.autocompleteSearch(selectors.clientBalance.newPaymentBank, 'Pay on receipt');
.waitToClick(selectors.clientBalance.saveButton) await page.waitToClick(selectors.clientBalance.saveButton);
.waitForLastSnackbar(); let result = await page.waitForLastSnackbar();
expect(result).toContain('Data saved!'); expect(result).toContain('Data saved!');
}); });
it('should check balance is now 0 and the company is now VNL becouse the user local settings were removed', async() => { it('should check balance is now 0 and the company is now VNL becouse the user local settings were removed', async() => {
let company = await nightmare await page.waitForSpinnerLoad();
.waitForSpinnerLoad() let company = await page
.waitToGetProperty(`${selectors.clientBalance.companyAutocomplete} input`, 'value'); .waitToGetProperty(`${selectors.clientBalance.companyAutocomplete} input`, 'value');
let firstBalanceLine = await nightmare let firstBalanceLine = await page
.waitToGetProperty(selectors.clientBalance.firstBalanceLine, 'innerText'); .waitToGetProperty(selectors.clientBalance.firstBalanceLine, 'innerText');
@ -69,94 +69,78 @@ describe('Client balance path', () => {
}); });
it('should now click the new payment button', async() => { it('should now click the new payment button', async() => {
let url = await nightmare await page.waitToClick(selectors.clientBalance.newPaymentButton);
.waitToClick(selectors.clientBalance.newPaymentButton) await page.waitForURL('/balance');
.waitForURL('/balance') let url = await page.parsedUrl();
.parsedUrl();
expect(url.hash).toContain('/balance'); expect(url.hash).toContain('/balance');
}); });
it('should create a new payment that sets the balance to positive value', async() => { it('should create a new payment that sets the balance to positive value', async() => {
let result = await nightmare await page.clearInput(selectors.clientBalance.newPaymentAmountInput);
.clearInput(selectors.clientBalance.newPaymentAmountInput) await page.write(selectors.clientBalance.newPaymentAmountInput, '100');
.write(selectors.clientBalance.newPaymentAmountInput, '100') await page.waitToClick(selectors.clientBalance.saveButton);
.waitToClick(selectors.clientBalance.saveButton) let result = await page.waitForLastSnackbar();
.waitForLastSnackbar();
expect(result).toContain('Data saved!'); expect(result).toContain('Data saved!');
}); });
it('should check balance is now -100', async() => { it('should check balance is now -100', async() => {
let result = await nightmare let result = await page
.waitToGetProperty(selectors.clientBalance.firstBalanceLine, 'innerText'); .waitToGetProperty(selectors.clientBalance.firstBalanceLine, 'innerText');
expect(result).toContain('-€100.00'); expect(result).toContain('-€100.00');
}); });
it('should again click the new payment button', async() => {
let url = await nightmare
.waitToClick(selectors.clientBalance.newPaymentButton)
.waitForURL('/balance')
.parsedUrl();
expect(url.hash).toContain('/balance');
});
it('should create a new payment that sets the balance back to the original negative value', async() => { it('should create a new payment that sets the balance back to the original negative value', async() => {
let result = await nightmare await page.waitToClick(selectors.clientBalance.newPaymentButton);
.clearInput(selectors.clientBalance.newPaymentAmountInput) await page.waitFor(4000);
.write(selectors.clientBalance.newPaymentAmountInput, '-150') await page.clearInput(selectors.clientBalance.newPaymentAmountInput);
.waitToClick(selectors.clientBalance.saveButton) await page.write(selectors.clientBalance.newPaymentAmountInput, '-150');
.waitForLastSnackbar(); await page.waitToClick(selectors.clientBalance.saveButton);
let result = await page.waitForLastSnackbar();
expect(result).toContain('Data saved!'); expect(result).toContain('Data saved!');
}); });
it('should check balance is now 50', async() => { it('should check balance is now 50', async() => {
let result = await nightmare let result = await page
.waitToGetProperty(selectors.clientBalance.firstBalanceLine, 'innerText'); .waitToGetProperty(selectors.clientBalance.firstBalanceLine, 'innerText');
expect(result).toEqual('€50.00'); expect(result).toEqual('€50.00');
}); });
it('should now click on the Clients button of the top bar menu', async() => { it('should now click on the Clients button of the top bar menu', async() => {
let url = await nightmare await page.login('employee');
.waitForLogin('employee') await page.waitToClick(selectors.globalItems.applicationsMenuButton);
.waitToClick(selectors.globalItems.applicationsMenuButton) await page.wait(selectors.globalItems.applicationsMenuVisible);
.wait(selectors.globalItems.applicationsMenuVisible) await page.waitToClick(selectors.globalItems.clientsButton);
.waitToClick(selectors.globalItems.clientsButton) await page.wait(selectors.clientsIndex.createClientButton);
.wait(selectors.clientsIndex.createClientButton) let url = await page.parsedUrl();
.parsedUrl();
expect(url.hash).toEqual('#!/client/index'); expect(url.hash).toEqual('#!/client/index');
}); });
it('should now search for the user Petter Parker', async() => { it('should now search for the user Petter Parker', async() => {
let resultCount = await nightmare await page.write(selectors.clientsIndex.searchClientInput, 'Petter Parker');
.write(selectors.clientsIndex.searchClientInput, 'Petter Parker') await page.waitToClick(selectors.clientsIndex.searchButton);
.waitToClick(selectors.clientsIndex.searchButton) await page.waitForNumberOfElements(selectors.clientsIndex.searchResult, 1);
.waitForNumberOfElements(selectors.clientsIndex.searchResult, 1) let resultCount = await page.countElement(selectors.clientsIndex.searchResult);
.countElement(selectors.clientsIndex.searchResult);
expect(resultCount).toEqual(1); expect(resultCount).toEqual(1);
}); });
it(`should click on the search result to access to the client's balance`, async() => { it(`should click on the search result to access to the client's balance`, async() => {
let url = await nightmare await page.waitForTextInElement(selectors.clientsIndex.searchResult, 'Petter Parker');
.waitForTextInElement(selectors.clientsIndex.searchResult, 'Petter Parker') await page.waitToClick(selectors.clientsIndex.searchResult);
.waitToClick(selectors.clientsIndex.searchResult) await page.waitToClick(selectors.clientBalance.balanceButton);
.waitToClick(selectors.clientBalance.balanceButton) await page.waitForURL('/balance');
.waitForURL('/balance') let url = await page.parsedUrl();
.parsedUrl();
expect(url.hash).toContain('/balance'); expect(url.hash).toContain('/balance');
}); });
it('should not be able to click the new payment button as it isnt present', async() => { it('should not be able to click the new payment button as it isnt present', async() => {
let result = await nightmare await page.waitFor(selectors.clientBalance.newPaymentButton, {hidden: true});
.exists(selectors.clientBalance.newPaymentButton);
expect(result).toBeFalsy();
}); });
}); });

View File

@ -2,29 +2,37 @@ import selectors from '../../helpers/selectors.js';
import openPage from '../../helpers/puppeteer'; import openPage from '../../helpers/puppeteer';
describe('User config', () => { describe('User config', () => {
const nightmare = createNightmare(); let page;
beforeAll(async() => {
page = await openPage();
});
afterAll(async() => {
page.close();
});
describe('as salesPerson', () => { describe('as salesPerson', () => {
beforeAll(() => { it('should login', async() => {
nightmare await page.login('salesPerson');
.waitForLogin('salesPerson');
}); });
it('should now open the user config form to check the settings', async() => { it('should now open the user config form to check the settings', async() => {
let userLocalWarehouse = await nightmare await page.waitToClick(selectors.globalItems.userMenuButton);
.waitToClick(selectors.globalItems.userMenuButton)
let userLocalWarehouse = await page
.getProperty(`${selectors.globalItems.userLocalWarehouse} input`, 'value'); .getProperty(`${selectors.globalItems.userLocalWarehouse} input`, 'value');
let userLocalBank = await nightmare
let userLocalBank = await page
.getProperty(`${selectors.globalItems.userLocalBank} input`, 'value'); .getProperty(`${selectors.globalItems.userLocalBank} input`, 'value');
let userLocalCompany = await nightmare let userLocalCompany = await page
.getProperty(`${selectors.globalItems.userLocalCompany} input`, 'value'); .getProperty(`${selectors.globalItems.userLocalCompany} input`, 'value');
let userWarehouse = await nightmare let userWarehouse = await page
.waitToGetProperty(`${selectors.globalItems.userWarehouse} input`, 'value'); .waitToGetProperty(`${selectors.globalItems.userWarehouse} input`, 'value');
let userCompany = await nightmare let userCompany = await page
.waitToGetProperty(`${selectors.globalItems.userCompany} input`, 'value'); .waitToGetProperty(`${selectors.globalItems.userCompany} input`, 'value');
expect(userLocalWarehouse).toEqual(''); expect(userLocalWarehouse).toEqual('');
@ -36,26 +44,25 @@ describe('User config', () => {
}); });
describe('as employee', () => { describe('as employee', () => {
beforeAll(() => { it('should log in', async() => {
nightmare await page.login('employee');
.waitForLogin('employee');
}); });
it('should open the user config form to check the settings', async() => { it('should open the user config form to check the settings', async() => {
let userLocalWarehouse = await nightmare await page.waitToClick(selectors.globalItems.userMenuButton);
.waitToClick(selectors.globalItems.userMenuButton) let userLocalWarehouse = await page
.getProperty(`${selectors.globalItems.userLocalWarehouse} input`, 'value'); .getProperty(`${selectors.globalItems.userLocalWarehouse} input`, 'value');
let userLocalBank = await nightmare let userLocalBank = await page
.getProperty(`${selectors.globalItems.userLocalBank} input`, 'value'); .getProperty(`${selectors.globalItems.userLocalBank} input`, 'value');
let userLocalCompany = await nightmare let userLocalCompany = await page
.getProperty(`${selectors.globalItems.userLocalCompany} input`, 'value'); .getProperty(`${selectors.globalItems.userLocalCompany} input`, 'value');
let userWarehouse = await nightmare let userWarehouse = await page
.waitToGetProperty(`${selectors.globalItems.userWarehouse} input`, 'value'); .waitToGetProperty(`${selectors.globalItems.userWarehouse} input`, 'value');
let userCompany = await nightmare let userCompany = await page
.waitToGetProperty(`${selectors.globalItems.userCompany} input`, 'value'); .waitToGetProperty(`${selectors.globalItems.userCompany} input`, 'value');
expect(userLocalWarehouse).toEqual(''); expect(userLocalWarehouse).toEqual('');
@ -66,37 +73,35 @@ describe('User config', () => {
}); });
it('should now edit the user config data', async() => { it('should now edit the user config data', async() => {
let result = await nightmare await page.autocompleteSearch(selectors.globalItems.userLocalWarehouse, 'Warehouse Four');
.autocompleteSearch(selectors.globalItems.userLocalWarehouse, 'Warehouse Four') await page.autocompleteSearch(selectors.globalItems.userLocalBank, 'Pay on receipt');
.autocompleteSearch(selectors.globalItems.userLocalBank, 'Pay on receipt') await page.autocompleteSearch(selectors.globalItems.userLocalCompany, 'VNL');
.autocompleteSearch(selectors.globalItems.userLocalCompany, 'VNL') let result = await page.waitForLastSnackbar();
.waitForLastSnackbar();
expect(result).toEqual('Data saved!'); expect(result).toEqual('Data saved!');
}); });
}); });
describe('as salesPerson 2nd run', () => { describe('as salesPerson 2nd run', () => {
beforeAll(() => { it('should log in once more', async() => {
nightmare await page.login('salesPerson');
.waitForLogin('salesPerson');
}); });
it('should again open the user config form to check the local settings', async() => { it('should again open the user config form to check the local settings', async() => {
let userLocalWarehouse = await nightmare await page.waitToClick(selectors.globalItems.userMenuButton);
.waitToClick(selectors.globalItems.userMenuButton) let userLocalWarehouse = await page
.waitToGetProperty(`${selectors.globalItems.userLocalWarehouse} input`, 'value'); .waitToGetProperty(`${selectors.globalItems.userLocalWarehouse} input`, 'value');
let userLocalBank = await nightmare let userLocalBank = await page
.waitToGetProperty(`${selectors.globalItems.userLocalBank} input`, 'value'); .waitToGetProperty(`${selectors.globalItems.userLocalBank} input`, 'value');
let userLocalCompany = await nightmare let userLocalCompany = await page
.waitToGetProperty(`${selectors.globalItems.userLocalCompany} input`, 'value'); .waitToGetProperty(`${selectors.globalItems.userLocalCompany} input`, 'value');
let userWarehouse = await nightmare let userWarehouse = await page
.waitToGetProperty(`${selectors.globalItems.userWarehouse} input`, 'value'); .waitToGetProperty(`${selectors.globalItems.userWarehouse} input`, 'value');
let userCompany = await nightmare let userCompany = await page
.waitToGetProperty(`${selectors.globalItems.userCompany} input`, 'value'); .waitToGetProperty(`${selectors.globalItems.userCompany} input`, 'value');
expect(userLocalWarehouse).toContain('Warehouse Four'); expect(userLocalWarehouse).toContain('Warehouse Four');
@ -107,12 +112,10 @@ describe('User config', () => {
}); });
it('should now clear the local settings', async() => { it('should now clear the local settings', async() => {
let result = await nightmare await page.clearInput(selectors.globalItems.userConfigFirstAutocomplete);
.waitToClick(selectors.globalItems.userMenuButton) await page.clearInput(selectors.globalItems.userConfigSecondAutocomplete);
.waitToClick(selectors.globalItems.userConfigFirstAutocompleteClear) await page.clearInput(selectors.globalItems.userConfigThirdAutocomplete);
.waitToClick(selectors.globalItems.userConfigSecondAutocompleteClear) let result = await page.waitForLastSnackbar();
.waitToClick(selectors.globalItems.userConfigThirdAutocompleteClear)
.waitForLastSnackbar();
expect(result).toEqual('Data saved!'); expect(result).toEqual('Data saved!');
}); });

View File

@ -2,39 +2,34 @@ import selectors from '../../helpers/selectors.js';
import openPage from '../../helpers/puppeteer'; import openPage from '../../helpers/puppeteer';
describe('Client web Payment', () => { describe('Client web Payment', () => {
const nightmare = createNightmare(); let page;
beforeAll(async() => {
describe('as employee', () => { page = await openPage();
beforeAll(() => { await page.loginAndModule('employee', 'client');
nightmare await page.accessToSearchResult('Tony Stark');
.loginAndModule('employee', 'client') await page.accessToSection('client.card.webPayment');
.accessToSearchResult('Tony Stark')
.accessToSection('client.card.webPayment');
}); });
it('should not be able to confirm payments', async() => { afterAll(async() => {
let exists = await nightmare page.close();
.exists(selectors.webPayment.confirmFirstPaymentButton); });
expect(exists).toBeFalsy(); describe('as employee', () => {
it('should not be able to confirm payments', async() => {
await page.waitFor(selectors.webPayment.confirmFirstPaymentButton, {hidden: true});
}); });
}); });
describe('as administrative', () => { describe('as administrative', () => {
beforeAll(() => { beforeAll(async() => {
nightmare await page.loginAndModule('administrative', 'client');
.loginAndModule('administrative', 'client') await page.accessToSearchResult('Tony Stark');
.accessToSearchResult('Tony Stark') await page.accessToSection('client.card.webPayment');
.accessToSection('client.card.webPayment');
}); });
it('should be able to confirm payments', async() => { it('should be able to confirm payments', async() => {
let exists = await nightmare await page.waitToClick(selectors.webPayment.confirmFirstPaymentButton);
.waitToClick(selectors.webPayment.confirmFirstPaymentButton) await page.waitFor(selectors.webPayment.firstPaymentConfirmed, {hidden: true});
.wait(selectors.webPayment.firstPaymentConfirmed)
.exists(selectors.webPayment.firstPaymentConfirmed);
expect(exists).toBeTruthy();
}); });
}); });
}); });

View File

@ -2,30 +2,31 @@ import selectors from '../../helpers/selectors.js';
import openPage from '../../helpers/puppeteer'; import openPage from '../../helpers/puppeteer';
describe('Client DMS', () => { describe('Client DMS', () => {
const nightmare = createNightmare(); let page;
beforeAll(async() => {
describe('as salesPerson', () => { page = await openPage();
beforeAll(() => { await page.loginAndModule('salesPerson', 'client');
nightmare await page.accessToSearchResult('Tony Stark');
.loginAndModule('salesPerson', 'client') await page.accessToSection('client.card.dms.index');
.accessToSearchResult('Tony Stark')
.accessToSection('client.card.dms.index');
}); });
afterAll(async() => {
page.close();
});
describe('as salesPerson', () => {
it('should delete de first file', async() => { it('should delete de first file', async() => {
let result = await nightmare await page.waitToClick(selectors.dms.deleteFileButton);
.waitToClick(selectors.dms.deleteFileButton) await page.waitToClick(selectors.dms.acceptDeleteButton);
.waitToClick(selectors.dms.acceptDeleteButton) let result = await page.waitForLastSnackbar();
.waitForLastSnackbar();
expect(result).toEqual('Data saved!'); expect(result).toEqual('Data saved!');
}); });
it(`should click on the first document line worker name making the descriptor visible`, async() => { it(`should click on the first document line worker name making the descriptor visible`, async() => {
const visible = await nightmare await page.waitToClick(selectors.dms.firstDocWorker);
.waitToClick(selectors.dms.firstDocWorker) await page.wait(selectors.dms.firstDocWorkerDescriptor);
.wait(selectors.dms.firstDocWorkerDescriptor) const visible = await page.isVisible(selectors.dms.firstDocWorkerDescriptor);
.isVisible(selectors.dms.firstDocWorkerDescriptor);
expect(visible).toBeTruthy(); expect(visible).toBeTruthy();
}); });

View File

@ -78,7 +78,7 @@ describe('Item regularize path', () => {
expect(url.hash).toEqual('#!/ticket/index'); expect(url.hash).toEqual('#!/ticket/index');
}); });
it('should now clear the user local settings', async() => { it('should clear the user local settings now', async() => {
let result = await nightmare let result = await nightmare
.waitToClick(selectors.globalItems.userMenuButton) .waitToClick(selectors.globalItems.userMenuButton)
.waitToClick(selectors.globalItems.userConfigFirstAutocompleteClear) .waitToClick(selectors.globalItems.userConfigFirstAutocompleteClear)