fix: refs #8583 basicData, business, summary

This commit is contained in:
Carlos Satorres 2025-02-24 11:25:15 +01:00
parent 6514490622
commit 8478ff768f
4 changed files with 118 additions and 9 deletions

View File

@ -8,6 +8,7 @@ import VnRow from 'components/ui/VnRow.vue';
import VnInput from 'src/components/common/VnInput.vue';
import VnSelect from 'src/components/common/VnSelect.vue';
import { useAdvancedSummary } from 'src/composables/useAdvancedSummary';
import { getDifferences, getUpdatedValues } from 'src/filters';
const { t } = useI18n();
const form = ref();
@ -17,6 +18,12 @@ const maritalStatus = [
{ code: 'M', name: t('Married') },
{ code: 'S', name: t('Single') },
];
function onBeforeSave(formData, originalData) {
return getUpdatedValues(
Object.keys(getDifferences(formData, originalData)),
formData,
);
}
</script>
<template>
<FetchData
@ -36,13 +43,7 @@ const maritalStatus = [
:url-update="`Workers/${$route.params.id}`"
auto-load
model="Worker"
@on-fetch="
async (data) => {
Object.assign(data, (await useAdvancedSummary('Workers', data.id)) ?? {});
await $nextTick();
if (form) form.hasChanges = false;
}
"
:mapper="onBeforeSave"
>
<template #form="{ data }">
<VnRow>
@ -86,6 +87,7 @@ const maritalStatus = [
option-label="name"
option-value="code"
v-model="data.maritalStatus"
data-cy="MaritalStatus"
/>
</VnRow>
@ -122,7 +124,7 @@ const maritalStatus = [
<VnInputDate :label="t('seniority')" v-model="data.seniority" />
</VnRow>
<VnRow>
<VnInput v-model="data.fi" :label="t('fi')" />
<VnInput v-model="data.fi" :label="t('fi')" data-cy="fi" />
<VnInputDate :label="t('birth')" v-model="data.birth" />
</VnRow>
<VnRow wrap>

View File

@ -0,0 +1,26 @@
describe('WorkerSummary', () => {
const maritalStatusSelect = '[data-cy="MaritalStatus"]';
const nif = '42572374H';
const fi = '[data-cy="fi"]';
beforeEach(() => {
cy.viewport(1280, 720);
cy.login('developer');
cy.visit('/#/worker/1107/basic-data');
});
it('should load worker summary', () => {
cy.get(maritalStatusSelect).type('Married');
cy.get(fi).type(nif);
cy.saveCard();
});
// it('should try descriptors', () => {
// cy.waitForElement('.summaryHeader');
// cy.get(departmentDescriptor).click();
// cy.get('.descriptor').should('be.visible');
// cy.get('.q-item > .q-item__label').should('include.text', '43');
// cy.get(roleDescriptor).click();
// cy.get('.descriptor').should('be.visible');
// cy.get('.q-item > .q-item__label').should('include.text', '19');
// });
});

View File

@ -0,0 +1,74 @@
describe('WorkerCreate', () => {
const externalRadio = '.q-radio:nth-child(2)';
const developerBossId = 120;
const payMethodCross =
':nth-child(9) > .q-select > .q-field__inner > .q-field__control > :nth-child(2)';
const saveBtn = '.q-mt-lg > .q-btn--standard';
const internalWithOutPay = {
Fi: { val: '78457139E' },
'Web user': { val: 'manolo' },
Name: { val: 'Manolo' },
'Last name': { val: 'Hurtado' },
'Personal email': { val: 'manolo@mydomain.com' },
Company: { val: 'VNL', type: 'select' },
Street: { val: 'S/ DEFAULTWORKERSTREET' },
Location: { val: 1, type: 'select' },
Phone: { val: '123456789' },
'Worker code': { val: 'DWW' },
Boss: { val: developerBossId, type: 'select' },
Birth: { val: '11-12-2022', type: 'date' },
};
const internal = {
Fi: { val: '78457139E' },
'Web user': { val: 'manolo' },
Name: { val: 'Manolo' },
'Last name': { val: 'Hurtado' },
'Personal email': { val: 'manolo@mydomain.com' },
Company: { val: 'VNL', type: 'select' },
Street: { val: 'S/ DEFAULTWORKERSTREET' },
Location: { val: 1, type: 'select' },
'Pay method': { val: 1, type: 'select' },
Phone: { val: '123456789' },
'Worker code': { val: 'DWW' },
Boss: { val: developerBossId, type: 'select' },
Birth: { val: '11-12-2022', type: 'date' },
};
const external = {
Fi: { val: 'Z4531219V' },
'Web user': { val: 'pepe' },
Name: { val: 'PEPE' },
'Last name': { val: 'GARCIA' },
'Personal email': { val: 'pepe@gmail.com' },
'Worker code': { val: 'PG' },
Boss: { val: developerBossId, type: 'select' },
};
beforeEach(() => {
cy.viewport(1280, 720);
cy.login('hr');
cy.visit('/#/worker/list');
cy.get('.q-page-sticky > div > .q-btn').click();
});
it('should throw an error if a pay method has not been selected', () => {
cy.fillInForm(internalWithOutPay);
cy.get(payMethodCross).click();
cy.get(saveBtn).click();
cy.checkNotification('Payment method is required');
});
it('should create an internal', () => {
cy.fillInForm(internal);
cy.get(saveBtn).click();
cy.checkNotification('Data created');
});
it('should create an external', () => {
cy.get(externalRadio).click();
cy.fillInForm(external);
cy.get(saveBtn).click();
cy.checkNotification('Data created');
});
});

View File

@ -1,5 +1,6 @@
describe('WorkerSummary', () => {
const departmentDescriptor = ':nth-child(1) > :nth-child(3) > .value > .link';
const roleDescriptor = ':nth-child(3) > :nth-child(4) > .value > .link';
beforeEach(() => {
cy.viewport(1280, 720);
cy.login('developer');
@ -15,7 +16,13 @@ describe('WorkerSummary', () => {
);
});
it('should try all descriptors', () => {
it('should try descriptors', () => {
cy.waitForElement('.summaryHeader');
cy.get(departmentDescriptor).click();
cy.get('.descriptor').should('be.visible');
cy.get('.q-item > .q-item__label').should('include.text', '43');
cy.get(roleDescriptor).click();
cy.get('.descriptor').should('be.visible');
cy.get('.q-item > .q-item__label').should('include.text', '19');
});
});