This commit is contained in:
parent
081b4af6d6
commit
a053764122
|
@ -218,6 +218,23 @@ let actions = {
|
|||
return handle.jsonValue();
|
||||
},
|
||||
|
||||
getValue: async function(selector) {
|
||||
return await this.waitToGetProperty(selector, 'value');
|
||||
},
|
||||
|
||||
getValues: async function(selectorMap) {
|
||||
const values = {};
|
||||
for (const key in selectorMap)
|
||||
values[key] = await this.waitToGetProperty(selectorMap[key], 'value');
|
||||
return values;
|
||||
},
|
||||
|
||||
innerText: async function(selector) {
|
||||
const element = await this.$(selector);
|
||||
const handle = await element.getProperty('innerText');
|
||||
return handle.jsonValue();
|
||||
},
|
||||
|
||||
waitPropertyLength: async function(selector, property, minLength) {
|
||||
await this.waitForFunction((selector, property, minLength) => {
|
||||
const element = document.querySelector(selector);
|
||||
|
|
|
@ -283,12 +283,6 @@ export default {
|
|||
cancelEditAddressButton: 'vn-client-address-edit > form > vn-button-bar > vn-button > button',
|
||||
watcher: 'vn-client-address-edit vn-watcher'
|
||||
},
|
||||
clientWebAccess: {
|
||||
enableWebAccessCheckbox: 'vn-check[label="Enable web access"]',
|
||||
userName: 'vn-client-web-access vn-textfield[ng-model="$ctrl.account.name"]',
|
||||
email: 'vn-client-web-access vn-textfield[ng-model="$ctrl.account.email"]',
|
||||
saveButton: 'button[type=submit]'
|
||||
},
|
||||
clientNotes: {
|
||||
addNoteFloatButton: 'vn-float-button',
|
||||
note: 'vn-textarea[ng-model="$ctrl.note.text"]',
|
||||
|
@ -312,15 +306,6 @@ export default {
|
|||
clientMandate: {
|
||||
firstMandateText: 'vn-client-mandate vn-card vn-table vn-tbody > vn-tr'
|
||||
},
|
||||
clientLog: {
|
||||
lastModificationPreviousValue: 'vn-client-log vn-tr table tr td.before',
|
||||
lastModificationCurrentValue: 'vn-client-log vn-tr table tr td.after',
|
||||
namePreviousValue: 'vn-client-log vn-tr table tr:nth-child(1) td.before',
|
||||
nameCurrentValue: 'vn-client-log vn-tr table tr:nth-child(1) td.after',
|
||||
activePreviousValue: 'vn-client-log vn-tr:nth-child(2) table tr:nth-child(2) td.before',
|
||||
activeCurrentValue: 'vn-client-log vn-tr:nth-child(2) table tr:nth-child(2) td.after'
|
||||
|
||||
},
|
||||
clientBalance: {
|
||||
company: 'vn-client-balance-index vn-autocomplete[ng-model="$ctrl.companyId"]',
|
||||
newPaymentButton: `vn-float-button`,
|
||||
|
@ -1361,18 +1346,6 @@ export default {
|
|||
notes: 'vn-supplier-basic-data vn-textarea[ng-model="$ctrl.supplier.note"]',
|
||||
saveButton: 'vn-supplier-basic-data button[type="submit"]',
|
||||
},
|
||||
supplierFiscalData: {
|
||||
socialName: 'vn-supplier-fiscal-data vn-textfield[ng-model="$ctrl.supplier.name"]',
|
||||
taxNumber: 'vn-supplier-fiscal-data vn-textfield[ng-model="$ctrl.supplier.nif"]',
|
||||
account: 'vn-supplier-fiscal-data vn-textfield[ng-model="$ctrl.supplier.account"]',
|
||||
sageTaxType: 'vn-supplier-fiscal-data vn-autocomplete[ng-model="$ctrl.supplier.sageTaxTypeFk"]',
|
||||
sageWihholding: 'vn-supplier-fiscal-data vn-autocomplete[ng-model="$ctrl.supplier.sageWithholdingFk"]',
|
||||
postCode: 'vn-supplier-fiscal-data vn-datalist[ng-model="$ctrl.supplier.postCode"]',
|
||||
city: 'vn-supplier-fiscal-data vn-datalist[ng-model="$ctrl.supplier.city"]',
|
||||
province: 'vn-supplier-fiscal-data vn-autocomplete[ng-model="$ctrl.supplier.provinceFk"]',
|
||||
country: 'vn-supplier-fiscal-data vn-autocomplete[ng-model="$ctrl.supplier.countryFk"]',
|
||||
saveButton: 'vn-supplier-fiscal-data button[type="submit"]',
|
||||
},
|
||||
supplierBillingData: {
|
||||
payMethod: 'vn-supplier-billing-data vn-autocomplete[ng-model="$ctrl.supplier.payMethodFk"]',
|
||||
payDem: 'vn-supplier-billing-data vn-autocomplete[ng-model="$ctrl.supplier.payDemFk"]',
|
||||
|
|
|
@ -1,88 +1,56 @@
|
|||
/* eslint max-len: ["error", { "code": 150 }]*/
|
||||
import selectors from '../../helpers/selectors';
|
||||
import getBrowser from '../../helpers/puppeteer';
|
||||
|
||||
describe('Client Edit web access path', () => {
|
||||
const $ = {
|
||||
enableWebAccess: 'vn-client-web-access vn-check[label="Enable web access"]',
|
||||
userName: 'vn-client-web-access vn-textfield[ng-model="$ctrl.account.name"]',
|
||||
email: 'vn-client-web-access vn-textfield[ng-model="$ctrl.account.email"]',
|
||||
saveButton: 'vn-client-web-access button[type=submit]',
|
||||
nameValue: 'vn-client-log tbody:nth-child(2) .basic-json:nth-child(1) vn-json-value',
|
||||
activeValue: 'vn-client-log tbody:nth-child(3) .basic-json:nth-child(2) vn-json-value'
|
||||
};
|
||||
|
||||
describe('Client web access path', () => {
|
||||
let browser;
|
||||
let page;
|
||||
|
||||
beforeAll(async() => {
|
||||
browser = await getBrowser();
|
||||
page = browser.page;
|
||||
await page.loginAndModule('salesPerson', 'client');
|
||||
await page.accessToSearchResult('max');
|
||||
await page.accessToSection('client.card.webAccess');
|
||||
});
|
||||
|
||||
afterAll(async() => {
|
||||
await browser.close();
|
||||
});
|
||||
|
||||
it('should uncheck the Enable web access checkbox', async() => {
|
||||
await page.waitToClick(selectors.clientWebAccess.enableWebAccessCheckbox);
|
||||
await page.waitToClick(selectors.clientWebAccess.saveButton);
|
||||
const message = await page.waitForSnackbar();
|
||||
it('should modify and save web access attributes', async() => {
|
||||
await page.accessToSection('client.card.webAccess');
|
||||
await page.click($.enableWebAccess);
|
||||
await page.click($.saveButton);
|
||||
const enableMessage = await page.waitForSnackbar();
|
||||
await page.overwrite($.userName, 'Legion');
|
||||
await page.overwrite($.email, 'legion@marvel.com');
|
||||
await page.click($.saveButton);
|
||||
const modifyMessage = await page.waitForSnackbar();
|
||||
|
||||
expect(message.text).toContain('Data saved!');
|
||||
});
|
||||
|
||||
it(`should update the name`, async() => {
|
||||
await page.clearInput(selectors.clientWebAccess.userName);
|
||||
await page.write(selectors.clientWebAccess.userName, 'Legion');
|
||||
await page.waitToClick(selectors.clientWebAccess.saveButton);
|
||||
const message = await page.waitForSnackbar();
|
||||
|
||||
expect(message.text).toContain('Data saved!');
|
||||
});
|
||||
|
||||
it(`should update the email`, async() => {
|
||||
await page.clearInput(selectors.clientWebAccess.email);
|
||||
await page.write(selectors.clientWebAccess.email, 'legion@marvel.com');
|
||||
await page.waitToClick(selectors.clientWebAccess.saveButton);
|
||||
const message = await page.waitForSnackbar();
|
||||
|
||||
expect(message.text).toContain('Data saved!');
|
||||
});
|
||||
|
||||
it('should reload the section and confirm web access is now unchecked', async() => {
|
||||
await page.reloadSection('client.card.webAccess');
|
||||
const result = await page.checkboxState(selectors.clientWebAccess.enableWebAccessCheckbox);
|
||||
const hasAccess = await page.checkboxState($.enableWebAccess);
|
||||
const userName = await page.getValue($.userName);
|
||||
const email = await page.getValue($.email);
|
||||
|
||||
expect(result).toBe('unchecked');
|
||||
});
|
||||
|
||||
it('should confirm web access name have been updated', async() => {
|
||||
const result = await page.waitToGetProperty(selectors.clientWebAccess.userName, 'value');
|
||||
|
||||
expect(result).toEqual('Legion');
|
||||
});
|
||||
|
||||
it('should confirm web access email have been updated', async() => {
|
||||
const result = await page.waitToGetProperty(selectors.clientWebAccess.email, 'value');
|
||||
|
||||
expect(result).toEqual('legion@marvel.com');
|
||||
});
|
||||
|
||||
it(`should navigate to the log section`, async() => {
|
||||
await page.accessToSection('client.card.log');
|
||||
});
|
||||
const logName = await page.innerText($.nameValue);
|
||||
const logActive = await page.innerText($.activeValue);
|
||||
|
||||
it(`should confirm the last log shows the updated client name and no modifications on active checkbox`, async() => {
|
||||
let namePreviousValue = await page
|
||||
.waitToGetProperty(selectors.clientLog.namePreviousValue, 'innerText');
|
||||
let nameCurrentValue = await page
|
||||
.waitToGetProperty(selectors.clientLog.nameCurrentValue, 'innerText');
|
||||
expect(enableMessage.type).toBe('success');
|
||||
expect(modifyMessage.type).toBe('success');
|
||||
|
||||
expect(namePreviousValue).toEqual('MaxEisenhardt');
|
||||
expect(nameCurrentValue).toEqual('Legion');
|
||||
});
|
||||
expect(hasAccess).toBe('unchecked');
|
||||
expect(userName).toEqual('Legion');
|
||||
expect(email).toEqual('legion@marvel.com');
|
||||
|
||||
it(`should confirm the penultimate log shows the updated active and no modifications on client name`, async() => {
|
||||
let activePreviousValue = await page
|
||||
.waitToGetProperty(selectors.clientLog.activePreviousValue, 'innerText');
|
||||
let activeCurrentValue = await page
|
||||
.waitToGetProperty(selectors.clientLog.activeCurrentValue, 'innerText');
|
||||
|
||||
expect(activePreviousValue).toEqual('✓');
|
||||
expect(activeCurrentValue).toEqual('✗');
|
||||
expect(logName).toEqual('Legion');
|
||||
expect(logActive).toEqual('✗');
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,7 +1,21 @@
|
|||
import selectors from '../../helpers/selectors.js';
|
||||
import getBrowser from '../../helpers/puppeteer';
|
||||
|
||||
describe('Supplier fiscal data path', () => {
|
||||
const $ = {
|
||||
saveButton: 'vn-supplier-fiscal-data button[type="submit"]',
|
||||
};
|
||||
const $inputs = {
|
||||
province: 'vn-supplier-fiscal-data [name="province"]',
|
||||
country: 'vn-supplier-fiscal-data [name="country"]',
|
||||
postcode: 'vn-supplier-fiscal-data [name="postcode"]',
|
||||
city: 'vn-supplier-fiscal-data [name="city"]',
|
||||
socialName: 'vn-supplier-fiscal-data [name="socialName"]',
|
||||
taxNumber: 'vn-supplier-fiscal-data [name="taxNumber"]',
|
||||
account: 'vn-supplier-fiscal-data [name="account"]',
|
||||
sageWithholding: 'vn-supplier-fiscal-data [ng-model="$ctrl.supplier.sageWithholdingFk"]',
|
||||
sageTaxType: 'vn-supplier-fiscal-data [ng-model="$ctrl.supplier.sageTaxTypeFk"]'
|
||||
};
|
||||
|
||||
fdescribe('Supplier fiscal data path', () => {
|
||||
let browser;
|
||||
let page;
|
||||
|
||||
|
@ -10,102 +24,44 @@ describe('Supplier fiscal data path', () => {
|
|||
page = browser.page;
|
||||
await page.loginAndModule('administrative', 'supplier');
|
||||
await page.accessToSearchResult('2');
|
||||
await page.accessToSection('supplier.card.fiscalData');
|
||||
});
|
||||
|
||||
afterAll(async() => {
|
||||
await browser.close();
|
||||
});
|
||||
|
||||
it('should attempt to edit the fiscal data but fail as the tax number is invalid', async() => {
|
||||
await page.clearInput(selectors.supplierFiscalData.city);
|
||||
await page.clearInput(selectors.supplierFiscalData.province);
|
||||
await page.clearInput(selectors.supplierFiscalData.country);
|
||||
await page.clearInput(selectors.supplierFiscalData.postCode);
|
||||
await page.write(selectors.supplierFiscalData.city, 'Valencia');
|
||||
await page.waitForTimeout(1000); // must repeat this action twice or fails. also #2699 may be a cool solution to this.
|
||||
await page.clearInput(selectors.supplierFiscalData.city);
|
||||
await page.write(selectors.supplierFiscalData.city, 'Valencia');
|
||||
await page.clearInput(selectors.supplierFiscalData.socialName);
|
||||
await page.write(selectors.supplierFiscalData.socialName, 'Farmer King SL');
|
||||
await page.clearInput(selectors.supplierFiscalData.taxNumber);
|
||||
await page.write(selectors.supplierFiscalData.taxNumber, 'Wrong tax number');
|
||||
await page.clearInput(selectors.supplierFiscalData.account);
|
||||
await page.write(selectors.supplierFiscalData.account, '0123456789');
|
||||
await page.autocompleteSearch(selectors.supplierFiscalData.sageWihholding, 'retencion estimacion objetiva');
|
||||
await page.autocompleteSearch(selectors.supplierFiscalData.sageTaxType, 'operaciones no sujetas');
|
||||
it('should attempt to edit the fiscal data and check data is saved', async() => {
|
||||
await page.accessToSection('supplier.card.fiscalData');
|
||||
await page.clearInput($inputs.province);
|
||||
await page.clearInput($inputs.country);
|
||||
await page.clearInput($inputs.postcode);
|
||||
await page.overwrite($inputs.city, 'Valencia');
|
||||
await page.overwrite($inputs.socialName, 'Farmer King SL');
|
||||
await page.overwrite($inputs.taxNumber, 'Wrong tax number');
|
||||
await page.overwrite($inputs.account, '0123456789');
|
||||
await page.autocompleteSearch($inputs.sageWithholding, 'retencion estimacion objetiva');
|
||||
await page.autocompleteSearch($inputs.sageTaxType, 'operaciones no sujetas');
|
||||
await page.click($.saveButton);
|
||||
const errorMessage = await page.waitForSnackbar();
|
||||
await page.overwrite($inputs.taxNumber, '12345678Z');
|
||||
await page.click($.saveButton);
|
||||
const successMessage = await page.waitForSnackbar();
|
||||
|
||||
await page.waitToClick(selectors.supplierFiscalData.saveButton);
|
||||
const message = await page.waitForSnackbar();
|
||||
|
||||
expect(message.text).toContain('Invalid Tax number');
|
||||
});
|
||||
|
||||
it('should save the changes as the tax number is valid this time', async() => {
|
||||
await page.clearInput(selectors.supplierFiscalData.taxNumber);
|
||||
await page.write(selectors.supplierFiscalData.taxNumber, '12345678Z');
|
||||
|
||||
await page.waitToClick(selectors.supplierFiscalData.saveButton);
|
||||
const message = await page.waitForSnackbar();
|
||||
|
||||
expect(message.text).toContain('Data saved!');
|
||||
});
|
||||
|
||||
it('should reload the section', async() => {
|
||||
await page.reloadSection('supplier.card.fiscalData');
|
||||
});
|
||||
const values = await page.getValues($inputs);
|
||||
|
||||
it('should check the socialName was edited', async() => {
|
||||
const result = await page.waitToGetProperty(selectors.supplierFiscalData.socialName, 'value');
|
||||
|
||||
expect(result).toEqual('Farmer King SL');
|
||||
});
|
||||
|
||||
it('should check the taxNumber was edited', async() => {
|
||||
const result = await page.waitToGetProperty(selectors.supplierFiscalData.taxNumber, 'value');
|
||||
|
||||
expect(result).toEqual('12345678Z');
|
||||
});
|
||||
|
||||
it('should check the account was edited', async() => {
|
||||
const result = await page.waitToGetProperty(selectors.supplierFiscalData.account, 'value');
|
||||
|
||||
expect(result).toEqual('0123456789');
|
||||
});
|
||||
|
||||
it('should check the sageWihholding was edited', async() => {
|
||||
const result = await page.waitToGetProperty(selectors.supplierFiscalData.sageWihholding, 'value');
|
||||
|
||||
expect(result).toEqual('RETENCION ESTIMACION OBJETIVA');
|
||||
});
|
||||
|
||||
it('should check the sageTaxType was edited', async() => {
|
||||
const result = await page.waitToGetProperty(selectors.supplierFiscalData.sageTaxType, 'value');
|
||||
|
||||
expect(result).toEqual('Operaciones no sujetas');
|
||||
});
|
||||
|
||||
it('should check the postCode was edited', async() => {
|
||||
const result = await page.waitToGetProperty(selectors.supplierFiscalData.postCode, 'value');
|
||||
|
||||
expect(result).toEqual('46000');
|
||||
});
|
||||
|
||||
it('should check the city was edited', async() => {
|
||||
const result = await page.waitToGetProperty(selectors.supplierFiscalData.city, 'value');
|
||||
|
||||
expect(result).toEqual('Valencia');
|
||||
});
|
||||
|
||||
it('should check the province was edited', async() => {
|
||||
const result = await page.waitToGetProperty(selectors.supplierFiscalData.province, 'value');
|
||||
|
||||
expect(result).toEqual('Province one (España)');
|
||||
});
|
||||
|
||||
it('should check the country was edited', async() => {
|
||||
const result = await page.waitToGetProperty(selectors.supplierFiscalData.country, 'value');
|
||||
|
||||
expect(result).toEqual('España');
|
||||
expect(errorMessage.text).toContain('Invalid Tax number');
|
||||
expect(successMessage.type).toBe('success');
|
||||
expect(values).toEqual({
|
||||
province: 'Province one (España)',
|
||||
country: 'España',
|
||||
postcode: '46000',
|
||||
city: 'Valencia',
|
||||
socialName: 'Farmer King SL',
|
||||
taxNumber: '12345678Z',
|
||||
account: '0123456789',
|
||||
sageWithholding: 'RETENCION ESTIMACION OBJETIVA',
|
||||
sageTaxType: 'Operaciones no sujetas'
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
vn-two
|
||||
vn-focus
|
||||
label="Social name"
|
||||
name="socialName"
|
||||
ng-model="$ctrl.supplier.name"
|
||||
info="Only letters, numbers and spaces can be used"
|
||||
required="true"
|
||||
|
@ -50,6 +51,7 @@
|
|||
<vn-textfield
|
||||
vn-one
|
||||
label="Tax number"
|
||||
name="taxNumber"
|
||||
ng-model="$ctrl.supplier.nif"
|
||||
required="true"
|
||||
rule>
|
||||
|
@ -59,35 +61,42 @@
|
|||
<vn-textfield
|
||||
vn-one
|
||||
label="Account"
|
||||
name="account"
|
||||
ng-model="$ctrl.supplier.account"
|
||||
insertable="true"
|
||||
max-length="10"
|
||||
rule>
|
||||
</vn-textfield>
|
||||
<vn-autocomplete vn-one
|
||||
<vn-autocomplete
|
||||
vn-one
|
||||
label="Sage tax type"
|
||||
name="sageTaxType"
|
||||
ng-model="$ctrl.supplier.sageTaxTypeFk"
|
||||
data="sageTaxTypes"
|
||||
show-field="vat"
|
||||
value-field="id"
|
||||
label="Sage tax type"
|
||||
rule>
|
||||
</vn-autocomplete>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-autocomplete vn-one
|
||||
<vn-autocomplete
|
||||
vn-one
|
||||
label="Sage withholding"
|
||||
name="sageWithholding"
|
||||
ng-model="$ctrl.supplier.sageWithholdingFk"
|
||||
data="sageWithholdings"
|
||||
show-field="withholding"
|
||||
value-field="id"
|
||||
label="Sage withholding"
|
||||
rule>
|
||||
</vn-autocomplete>
|
||||
<vn-autocomplete vn-one
|
||||
<vn-autocomplete
|
||||
vn-one
|
||||
label="Sage transaction type"
|
||||
name="sageTransactionType"
|
||||
ng-model="$ctrl.supplier.sageTransactionTypeFk"
|
||||
url="SageTransactionTypes"
|
||||
show-field="transaction"
|
||||
value-field="id"
|
||||
label="Sage transaction type"
|
||||
search-function="{or: [{id: $search}, {transaction: {like: '%'+ $search +'%'}}]}"
|
||||
order="transaction"
|
||||
rule>
|
||||
|
@ -95,12 +104,14 @@
|
|||
</vn-autocomplete>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-autocomplete vn-one
|
||||
<vn-autocomplete
|
||||
vn-one
|
||||
label="Supplier activity"
|
||||
name="supplierActivity"
|
||||
ng-model="$ctrl.supplier.supplierActivityFk"
|
||||
data="supplierActivities"
|
||||
show-field="name"
|
||||
value-field="code"
|
||||
label="Supplier activity"
|
||||
rule>
|
||||
</vn-autocomplete>
|
||||
<vn-textfield
|
||||
|
@ -118,8 +129,10 @@
|
|||
rule
|
||||
vn-focus>
|
||||
</vn-textfield>
|
||||
<vn-datalist vn-one
|
||||
<vn-datalist
|
||||
vn-one
|
||||
label="Postcode"
|
||||
name="postcode"
|
||||
ng-model="$ctrl.supplier.postCode"
|
||||
selection="$ctrl.postcode"
|
||||
url="Postcodes/location"
|
||||
|
@ -144,8 +157,11 @@
|
|||
</vn-datalist>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-datalist vn-id="town" vn-one
|
||||
<vn-datalist
|
||||
vn-one
|
||||
vn-id="town"
|
||||
label="City"
|
||||
name="city"
|
||||
ng-model="$ctrl.supplier.city"
|
||||
selection="$ctrl.town"
|
||||
url="Towns/location"
|
||||
|
@ -159,8 +175,11 @@
|
|||
({{province.country.country}})
|
||||
</tpl-item>
|
||||
</vn-datalist>
|
||||
<vn-autocomplete vn-id="province" vn-one
|
||||
<vn-autocomplete
|
||||
vn-one
|
||||
vn-id="province"
|
||||
label="Province"
|
||||
name="province"
|
||||
ng-model="$ctrl.supplier.provinceFk"
|
||||
selection="$ctrl.province"
|
||||
data="provincesLocation"
|
||||
|
@ -172,12 +191,15 @@
|
|||
</vn-autocomplete>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-autocomplete vn-id="country" vn-two
|
||||
<vn-autocomplete
|
||||
vn-two
|
||||
vn-id="country"
|
||||
label="Country"
|
||||
name="country"
|
||||
ng-model="$ctrl.supplier.countryFk"
|
||||
data="countries"
|
||||
show-field="country"
|
||||
value-field="id"
|
||||
label="Country"
|
||||
rule>
|
||||
</vn-autocomplete>
|
||||
<vn-two class="vn-pl-xs">
|
||||
|
|
Loading…
Reference in New Issue