refs #5517 E2E fixes
gitea/salix/pipeline/head There was a failure building this commit Details

This commit is contained in:
Juan Ferrer 2023-04-24 12:59:56 +02:00
parent 081b4af6d6
commit a053764122
5 changed files with 130 additions and 194 deletions

View File

@ -218,6 +218,23 @@ let actions = {
return handle.jsonValue(); 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) { waitPropertyLength: async function(selector, property, minLength) {
await this.waitForFunction((selector, property, minLength) => { await this.waitForFunction((selector, property, minLength) => {
const element = document.querySelector(selector); const element = document.querySelector(selector);

View File

@ -283,12 +283,6 @@ export default {
cancelEditAddressButton: 'vn-client-address-edit > form > vn-button-bar > vn-button > button', cancelEditAddressButton: 'vn-client-address-edit > form > vn-button-bar > vn-button > button',
watcher: 'vn-client-address-edit vn-watcher' 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: { clientNotes: {
addNoteFloatButton: 'vn-float-button', addNoteFloatButton: 'vn-float-button',
note: 'vn-textarea[ng-model="$ctrl.note.text"]', note: 'vn-textarea[ng-model="$ctrl.note.text"]',
@ -312,15 +306,6 @@ export default {
clientMandate: { clientMandate: {
firstMandateText: 'vn-client-mandate vn-card vn-table vn-tbody > vn-tr' 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: { clientBalance: {
company: 'vn-client-balance-index vn-autocomplete[ng-model="$ctrl.companyId"]', company: 'vn-client-balance-index vn-autocomplete[ng-model="$ctrl.companyId"]',
newPaymentButton: `vn-float-button`, newPaymentButton: `vn-float-button`,
@ -1361,18 +1346,6 @@ export default {
notes: 'vn-supplier-basic-data vn-textarea[ng-model="$ctrl.supplier.note"]', notes: 'vn-supplier-basic-data vn-textarea[ng-model="$ctrl.supplier.note"]',
saveButton: 'vn-supplier-basic-data button[type="submit"]', 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: { supplierBillingData: {
payMethod: 'vn-supplier-billing-data vn-autocomplete[ng-model="$ctrl.supplier.payMethodFk"]', payMethod: 'vn-supplier-billing-data vn-autocomplete[ng-model="$ctrl.supplier.payMethodFk"]',
payDem: 'vn-supplier-billing-data vn-autocomplete[ng-model="$ctrl.supplier.payDemFk"]', payDem: 'vn-supplier-billing-data vn-autocomplete[ng-model="$ctrl.supplier.payDemFk"]',

View File

@ -1,88 +1,56 @@
/* eslint max-len: ["error", { "code": 150 }]*/
import selectors from '../../helpers/selectors';
import getBrowser from '../../helpers/puppeteer'; 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 browser;
let page; let page;
beforeAll(async() => { beforeAll(async() => {
browser = await getBrowser(); browser = await getBrowser();
page = browser.page; page = browser.page;
await page.loginAndModule('salesPerson', 'client'); await page.loginAndModule('salesPerson', 'client');
await page.accessToSearchResult('max'); await page.accessToSearchResult('max');
await page.accessToSection('client.card.webAccess');
}); });
afterAll(async() => { afterAll(async() => {
await browser.close(); await browser.close();
}); });
it('should uncheck the Enable web access checkbox', async() => { it('should modify and save web access attributes', async() => {
await page.waitToClick(selectors.clientWebAccess.enableWebAccessCheckbox); await page.accessToSection('client.card.webAccess');
await page.waitToClick(selectors.clientWebAccess.saveButton); await page.click($.enableWebAccess);
const message = await page.waitForSnackbar(); 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'); 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'); 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() => { expect(enableMessage.type).toBe('success');
let namePreviousValue = await page expect(modifyMessage.type).toBe('success');
.waitToGetProperty(selectors.clientLog.namePreviousValue, 'innerText');
let nameCurrentValue = await page
.waitToGetProperty(selectors.clientLog.nameCurrentValue, 'innerText');
expect(namePreviousValue).toEqual('MaxEisenhardt'); expect(hasAccess).toBe('unchecked');
expect(nameCurrentValue).toEqual('Legion'); 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() => { expect(logName).toEqual('Legion');
let activePreviousValue = await page expect(logActive).toEqual('✗');
.waitToGetProperty(selectors.clientLog.activePreviousValue, 'innerText');
let activeCurrentValue = await page
.waitToGetProperty(selectors.clientLog.activeCurrentValue, 'innerText');
expect(activePreviousValue).toEqual('✓');
expect(activeCurrentValue).toEqual('✗');
}); });
}); });

View File

@ -1,7 +1,21 @@
import selectors from '../../helpers/selectors.js';
import getBrowser from '../../helpers/puppeteer'; 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 browser;
let page; let page;
@ -10,102 +24,44 @@ describe('Supplier fiscal data path', () => {
page = browser.page; page = browser.page;
await page.loginAndModule('administrative', 'supplier'); await page.loginAndModule('administrative', 'supplier');
await page.accessToSearchResult('2'); await page.accessToSearchResult('2');
await page.accessToSection('supplier.card.fiscalData');
}); });
afterAll(async() => { afterAll(async() => {
await browser.close(); await browser.close();
}); });
it('should attempt to edit the fiscal data but fail as the tax number is invalid', async() => { it('should attempt to edit the fiscal data and check data is saved', async() => {
await page.clearInput(selectors.supplierFiscalData.city); await page.accessToSection('supplier.card.fiscalData');
await page.clearInput(selectors.supplierFiscalData.province); await page.clearInput($inputs.province);
await page.clearInput(selectors.supplierFiscalData.country); await page.clearInput($inputs.country);
await page.clearInput(selectors.supplierFiscalData.postCode); await page.clearInput($inputs.postcode);
await page.write(selectors.supplierFiscalData.city, 'Valencia'); await page.overwrite($inputs.city, 'Valencia');
await page.waitForTimeout(1000); // must repeat this action twice or fails. also #2699 may be a cool solution to this. await page.overwrite($inputs.socialName, 'Farmer King SL');
await page.clearInput(selectors.supplierFiscalData.city); await page.overwrite($inputs.taxNumber, 'Wrong tax number');
await page.write(selectors.supplierFiscalData.city, 'Valencia'); await page.overwrite($inputs.account, '0123456789');
await page.clearInput(selectors.supplierFiscalData.socialName); await page.autocompleteSearch($inputs.sageWithholding, 'retencion estimacion objetiva');
await page.write(selectors.supplierFiscalData.socialName, 'Farmer King SL'); await page.autocompleteSearch($inputs.sageTaxType, 'operaciones no sujetas');
await page.clearInput(selectors.supplierFiscalData.taxNumber); await page.click($.saveButton);
await page.write(selectors.supplierFiscalData.taxNumber, 'Wrong tax number'); const errorMessage = await page.waitForSnackbar();
await page.clearInput(selectors.supplierFiscalData.account); await page.overwrite($inputs.taxNumber, '12345678Z');
await page.write(selectors.supplierFiscalData.account, '0123456789'); await page.click($.saveButton);
await page.autocompleteSearch(selectors.supplierFiscalData.sageWihholding, 'retencion estimacion objetiva'); const successMessage = await page.waitForSnackbar();
await page.autocompleteSearch(selectors.supplierFiscalData.sageTaxType, 'operaciones no sujetas');
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'); await page.reloadSection('supplier.card.fiscalData');
}); const values = await page.getValues($inputs);
it('should check the socialName was edited', async() => { expect(errorMessage.text).toContain('Invalid Tax number');
const result = await page.waitToGetProperty(selectors.supplierFiscalData.socialName, 'value'); expect(successMessage.type).toBe('success');
expect(values).toEqual({
expect(result).toEqual('Farmer King SL'); province: 'Province one (España)',
}); country: 'España',
postcode: '46000',
it('should check the taxNumber was edited', async() => { city: 'Valencia',
const result = await page.waitToGetProperty(selectors.supplierFiscalData.taxNumber, 'value'); socialName: 'Farmer King SL',
taxNumber: '12345678Z',
expect(result).toEqual('12345678Z'); account: '0123456789',
}); sageWithholding: 'RETENCION ESTIMACION OBJETIVA',
sageTaxType: 'Operaciones no sujetas'
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');
}); });
}); });

View File

@ -42,6 +42,7 @@
vn-two vn-two
vn-focus vn-focus
label="Social name" label="Social name"
name="socialName"
ng-model="$ctrl.supplier.name" ng-model="$ctrl.supplier.name"
info="Only letters, numbers and spaces can be used" info="Only letters, numbers and spaces can be used"
required="true" required="true"
@ -50,6 +51,7 @@
<vn-textfield <vn-textfield
vn-one vn-one
label="Tax number" label="Tax number"
name="taxNumber"
ng-model="$ctrl.supplier.nif" ng-model="$ctrl.supplier.nif"
required="true" required="true"
rule> rule>
@ -59,35 +61,42 @@
<vn-textfield <vn-textfield
vn-one vn-one
label="Account" label="Account"
name="account"
ng-model="$ctrl.supplier.account" ng-model="$ctrl.supplier.account"
insertable="true" insertable="true"
max-length="10" max-length="10"
rule> rule>
</vn-textfield> </vn-textfield>
<vn-autocomplete vn-one <vn-autocomplete
vn-one
label="Sage tax type"
name="sageTaxType"
ng-model="$ctrl.supplier.sageTaxTypeFk" ng-model="$ctrl.supplier.sageTaxTypeFk"
data="sageTaxTypes" data="sageTaxTypes"
show-field="vat" show-field="vat"
value-field="id" value-field="id"
label="Sage tax type"
rule> rule>
</vn-autocomplete> </vn-autocomplete>
</vn-horizontal> </vn-horizontal>
<vn-horizontal> <vn-horizontal>
<vn-autocomplete vn-one <vn-autocomplete
vn-one
label="Sage withholding"
name="sageWithholding"
ng-model="$ctrl.supplier.sageWithholdingFk" ng-model="$ctrl.supplier.sageWithholdingFk"
data="sageWithholdings" data="sageWithholdings"
show-field="withholding" show-field="withholding"
value-field="id" value-field="id"
label="Sage withholding"
rule> rule>
</vn-autocomplete> </vn-autocomplete>
<vn-autocomplete vn-one <vn-autocomplete
vn-one
label="Sage transaction type"
name="sageTransactionType"
ng-model="$ctrl.supplier.sageTransactionTypeFk" ng-model="$ctrl.supplier.sageTransactionTypeFk"
url="SageTransactionTypes" url="SageTransactionTypes"
show-field="transaction" show-field="transaction"
value-field="id" value-field="id"
label="Sage transaction type"
search-function="{or: [{id: $search}, {transaction: {like: '%'+ $search +'%'}}]}" search-function="{or: [{id: $search}, {transaction: {like: '%'+ $search +'%'}}]}"
order="transaction" order="transaction"
rule> rule>
@ -95,12 +104,14 @@
</vn-autocomplete> </vn-autocomplete>
</vn-horizontal> </vn-horizontal>
<vn-horizontal> <vn-horizontal>
<vn-autocomplete vn-one <vn-autocomplete
vn-one
label="Supplier activity"
name="supplierActivity"
ng-model="$ctrl.supplier.supplierActivityFk" ng-model="$ctrl.supplier.supplierActivityFk"
data="supplierActivities" data="supplierActivities"
show-field="name" show-field="name"
value-field="code" value-field="code"
label="Supplier activity"
rule> rule>
</vn-autocomplete> </vn-autocomplete>
<vn-textfield <vn-textfield
@ -118,8 +129,10 @@
rule rule
vn-focus> vn-focus>
</vn-textfield> </vn-textfield>
<vn-datalist vn-one <vn-datalist
vn-one
label="Postcode" label="Postcode"
name="postcode"
ng-model="$ctrl.supplier.postCode" ng-model="$ctrl.supplier.postCode"
selection="$ctrl.postcode" selection="$ctrl.postcode"
url="Postcodes/location" url="Postcodes/location"
@ -144,8 +157,11 @@
</vn-datalist> </vn-datalist>
</vn-horizontal> </vn-horizontal>
<vn-horizontal> <vn-horizontal>
<vn-datalist vn-id="town" vn-one <vn-datalist
vn-one
vn-id="town"
label="City" label="City"
name="city"
ng-model="$ctrl.supplier.city" ng-model="$ctrl.supplier.city"
selection="$ctrl.town" selection="$ctrl.town"
url="Towns/location" url="Towns/location"
@ -159,8 +175,11 @@
({{province.country.country}}) ({{province.country.country}})
</tpl-item> </tpl-item>
</vn-datalist> </vn-datalist>
<vn-autocomplete vn-id="province" vn-one <vn-autocomplete
vn-one
vn-id="province"
label="Province" label="Province"
name="province"
ng-model="$ctrl.supplier.provinceFk" ng-model="$ctrl.supplier.provinceFk"
selection="$ctrl.province" selection="$ctrl.province"
data="provincesLocation" data="provincesLocation"
@ -172,12 +191,15 @@
</vn-autocomplete> </vn-autocomplete>
</vn-horizontal> </vn-horizontal>
<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" ng-model="$ctrl.supplier.countryFk"
data="countries" data="countries"
show-field="country" show-field="country"
value-field="id" value-field="id"
label="Country"
rule> rule>
</vn-autocomplete> </vn-autocomplete>
<vn-two class="vn-pl-xs"> <vn-two class="vn-pl-xs">