refactor: refs #8422 enhance error handling in save function and update selectors in tests
gitea/salix-front/pipeline/pr-dev There was a failure building this commit Details

This commit is contained in:
Jose Antonio Tubau 2025-03-18 15:54:47 +01:00
parent 22d912ba76
commit 5d356428d3
3 changed files with 17 additions and 16 deletions

View File

@ -81,12 +81,16 @@ function getUrl() {
} }
async function save() { async function save() {
const body = mapperDms(dms.value); try {
const response = await axios.post(getUrl(), body[0], body[1]); const body = mapperDms(dms.value);
emit('onDataSaved', body[1].params, response); const response = await axios.post(getUrl(), body[0], body[1]);
notify(t('globals.dataSaved'), 'positive'); emit('onDataSaved', body[1].params, response);
delete dms.value.files; notify(t('globals.dataSaved'), 'positive');
return response; delete dms.value.files;
return response;
} catch (e) {
throw new Error(e.message);
}
} }
function defaultData() { function defaultData() {

View File

@ -43,7 +43,6 @@ const importDms = async () => {
@on-fetch="(data) => (dmsOptions = data)" @on-fetch="(data) => (dmsOptions = data)"
/> />
<FormModelPopup <FormModelPopup
url-create="genera"
model="DmsImport" model="DmsImport"
:title="t('vehicle.dms.selectDocId')" :title="t('vehicle.dms.selectDocId')"
:form-initial-data="{}" :form-initial-data="{}"

View File

@ -11,18 +11,16 @@ describe('Vehicle DMS', () => {
'tr:first-child > :nth-child(5) > .q-tr > :nth-child(1) > span', 'tr:first-child > :nth-child(5) > .q-tr > :nth-child(1) > span',
firstRowId: 'tr:first-child > :nth-child(2) > .q-tr > :nth-child(1) > span', firstRowId: 'tr:first-child > :nth-child(2) > .q-tr > :nth-child(1) > span',
lastRowWorkerLink: 'tr:last-child > :nth-child(8) > .q-tr > .link', lastRowWorkerLink: 'tr:last-child > :nth-child(8) > .q-tr > .link',
workerDescriptorPopupTitle: descriptorTitle: '.descriptor .title',
'.q-menu > .descriptor > .body > .q-list > .q-item__label--header > .title > span', descriptorGoToSummaryBtn: '.descriptor [data-cy="goToSummaryBtn"]',
workerDescriptorGoToSummary: summaryTitle: '.summaryHeader',
'[href="#/worker/5/summary"] > .q-btn > .q-btn__content > .q-icon',
summaryTitle: '.summaryHeader > div',
referenceInput: 'Reference_input', referenceInput: 'Reference_input',
companySelect: 'Company_select', companySelect: 'Company_select',
warehouseSelect: 'Warehouse_select', warehouseSelect: 'Warehouse_select',
typeSelect: 'Type_select', typeSelect: 'Type_select',
fileInput: 'VnDms_inputFile', fileInput: 'VnDms_inputFile',
importBtn: 'importBtn', importBtn: 'importBtn',
addBtn: 'addDmsBtn', addBtn: 'addButton',
saveFormBtn: 'FormModelPopup_save', saveFormBtn: 'FormModelPopup_save',
}; };
@ -103,8 +101,8 @@ describe('Vehicle DMS', () => {
it('Should redirect to worker summary from worker descriptor pop-up', () => { it('Should redirect to worker summary from worker descriptor pop-up', () => {
cy.get(selectors.lastRowWorkerLink).click(); cy.get(selectors.lastRowWorkerLink).click();
cy.get(selectors.workerDescriptorPopupTitle).should('contain', 'administrative'); cy.get(selectors.descriptorTitle).should('contain', 'administrative');
cy.get(selectors.workerDescriptorGoToSummary).click(); cy.get(selectors.descriptorGoToSummaryBtn).click();
cy.get(selectors.summaryTitle).should('contain', 'administrative'); cy.containContent(selectors.summaryTitle, 'administrative');
}); });
}); });