Merge pull request '3317-client_create add businessType' (#776) from 3317-client_create into dev
gitea/salix/pipeline/head This commit looks good Details

Reviewed-on: #776
Reviewed-by: Carlos Jimenez Ruiz <carlosjr@verdnatura.es>
This commit is contained in:
Carlos Jimenez Ruiz 2021-11-15 09:34:19 +00:00
commit 7f64f4d8ad
6 changed files with 50 additions and 17 deletions

View File

@ -119,6 +119,7 @@ export default {
name: 'vn-client-create vn-textfield[ng-model="$ctrl.client.name"]', name: 'vn-client-create vn-textfield[ng-model="$ctrl.client.name"]',
taxNumber: 'vn-client-create vn-textfield[ng-model="$ctrl.client.fi"]', taxNumber: 'vn-client-create vn-textfield[ng-model="$ctrl.client.fi"]',
socialName: 'vn-client-create vn-textfield[ng-model="$ctrl.client.socialName"]', socialName: 'vn-client-create vn-textfield[ng-model="$ctrl.client.socialName"]',
businessType: 'vn-client-create vn-autocomplete[ng-model="$ctrl.client.businessTypeFk"]',
street: 'vn-client-create vn-textfield[ng-model="$ctrl.client.street"]', street: 'vn-client-create vn-textfield[ng-model="$ctrl.client.street"]',
addPostCode: 'vn-client-create vn-datalist[ng-model="$ctrl.client.postcode"] vn-icon-button[icon="add_circle"]', addPostCode: 'vn-client-create vn-datalist[ng-model="$ctrl.client.postcode"] vn-icon-button[icon="add_circle"]',
addProvince: 'vn-autocomplete[ng-model="$ctrl.location.provinceFk"] vn-icon-button[icon="add_circle"]', addProvince: 'vn-autocomplete[ng-model="$ctrl.location.provinceFk"] vn-icon-button[icon="add_circle"]',

View File

@ -27,16 +27,19 @@ describe('Client create path', () => {
await page.waitForState('client.create'); await page.waitForState('client.create');
}); });
it('should receive an error when clicking the create button having name and Business name fields empty', async() => { it('should receive an error when clicking the create button having name and Business name fields empty',
async() => {
await page.write(selectors.createClientView.taxNumber, '74451390E'); await page.write(selectors.createClientView.taxNumber, '74451390E');
await page.write(selectors.createClientView.userName, 'CaptainMarvel'); await page.write(selectors.createClientView.userName, 'CaptainMarvel');
await page.write(selectors.createClientView.email, 'CarolDanvers@verdnatura.es'); await page.write(selectors.createClientView.email, 'CarolDanvers@verdnatura.es');
await page.autocompleteSearch(selectors.createClientView.salesPerson, 'salesPerson'); await page.autocompleteSearch(selectors.createClientView.salesPerson, 'salesPerson');
await page.autocompleteSearch(selectors.createClientView.businessType, 'florist');
await page.waitToClick(selectors.createClientView.createButton); await page.waitToClick(selectors.createClientView.createButton);
const message = await page.waitForSnackbar(); const message = await page.waitForSnackbar();
expect(message.text).toContain('Some fields are invalid'); expect(message.text).toContain('Some fields are invalid');
}); }
);
it(`should create a new province`, async() => { it(`should create a new province`, async() => {
await page.waitToClick(selectors.createClientView.addPostCode); await page.waitToClick(selectors.createClientView.addPostCode);
@ -80,9 +83,18 @@ describe('Client create path', () => {
expect(message.text).toContain('Some fields are invalid'); expect(message.text).toContain('Some fields are invalid');
}); });
it(`should attempt to create a new user with all it's data but wrong postal code`, async() => { it(`should attempt to create a new user with all it's data but wrong business type`, async() => {
await page.clearInput(selectors.createClientView.email); await page.clearInput(selectors.createClientView.email);
await page.write(selectors.createClientView.email, 'CarolDanvers@verdnatura.es'); await page.write(selectors.createClientView.email, 'CarolDanvers@verdnatura.es');
await page.clearInput(selectors.createClientView.businessType);
await page.waitToClick(selectors.createClientView.createButton);
const message = await page.waitForSnackbar();
expect(message.text).toContain('Some fields are invalid');
});
it(`should attempt to create a new user with all it's data but wrong postal code`, async() => {
await page.autocompleteSearch(selectors.createClientView.businessType, 'florist');
await page.clearInput(selectors.createClientView.postcode); await page.clearInput(selectors.createClientView.postcode);
await page.write(selectors.createClientView.postcode, '479999'); await page.write(selectors.createClientView.postcode, '479999');
await page.waitToClick(selectors.createClientView.createButton); await page.waitToClick(selectors.createClientView.createButton);

View File

@ -50,7 +50,8 @@ module.exports = function(Self) {
city: data.city, city: data.city,
provinceFk: data.provinceFk, provinceFk: data.provinceFk,
countryFk: data.countryFk, countryFk: data.countryFk,
isEqualizated: data.isEqualizated isEqualizated: data.isEqualizated,
businessTypeFk: data.businessTypeFk
}, myOptions); }, myOptions);
const address = await models.Address.create({ const address = await models.Address.create({

View File

@ -8,7 +8,8 @@ describe('Client Create', () => {
name: 'Wade', name: 'Wade',
socialName: 'Deadpool Marvel', socialName: 'Deadpool Marvel',
street: 'Wall Street', street: 'Wall Street',
city: 'New York' city: 'New York',
businessTypeFk: 'florist'
}; };
it(`should not find Deadpool as he's not created yet`, async() => { it(`should not find Deadpool as he's not created yet`, async() => {
@ -45,6 +46,7 @@ describe('Client Create', () => {
expect(client.email).toEqual(newAccount.email); expect(client.email).toEqual(newAccount.email);
expect(client.fi).toEqual(newAccount.fi); expect(client.fi).toEqual(newAccount.fi);
expect(client.socialName).toEqual(newAccount.socialName); expect(client.socialName).toEqual(newAccount.socialName);
expect(client.businessTypeFk).toEqual(newAccount.businessTypeFk);
await tx.rollback(); await tx.rollback();
} catch (e) { } catch (e) {

View File

@ -130,6 +130,13 @@
"mysql": { "mysql": {
"columnName": "transactionTypeSageFk" "columnName": "transactionTypeSageFk"
} }
},
"businessTypeFk": {
"type": "string",
"mysql": {
"columnName": "businessTypeFk"
},
"required": true
} }
}, },
"relations": { "relations": {

View File

@ -26,18 +26,28 @@
</vn-autocomplete> </vn-autocomplete>
</vn-horizontal> </vn-horizontal>
<vn-horizontal> <vn-horizontal>
<vn-textfield <vn-autocomplete
vn-two vn-id="businessTypeFk"
label="Business name" ng-model="$ctrl.client.businessTypeFk"
ng-model="$ctrl.client.socialName" url="BusinessTypes"
show-field="description"
value-field="code"
label="Business type"
rule> rule>
</vn-textfield> </vn-autocomplete>
<vn-textfield <vn-textfield
label="Tax number" label="Tax number"
ng-model="$ctrl.client.fi" ng-model="$ctrl.client.fi"
rule> rule>
</vn-textfield> </vn-textfield>
</vn-horizontal> </vn-horizontal>
<vn-horizontal>
<vn-textfield
label="Business name"
ng-model="$ctrl.client.socialName"
rule>
</vn-textfield>
</vn-horizontal>
<vn-horizontal> <vn-horizontal>
<vn-textfield <vn-textfield
vn-two vn-two