refactor: refs #8422 implement checkRedirectionFromPopup command and refactor tests for improved readability
gitea/salix-front/pipeline/pr-dev This commit is unstable Details

This commit is contained in:
Jose Antonio Tubau 2025-04-11 09:01:47 +02:00
parent e84107dcbb
commit 9a0211787a
7 changed files with 110 additions and 115 deletions

View File

@ -93,7 +93,7 @@ async function save() {
delete dms.value.files; delete dms.value.files;
return response; return response;
} catch (e) { } catch (e) {
throw new Error(e.message); throw e;
} }
} }

View File

@ -267,7 +267,7 @@ function deleteDms(dmsFk) {
rows.value.splice(index, 1); rows.value.splice(index, 1);
notify(t('globals.dataDeleted'), 'positive'); notify(t('globals.dataDeleted'), 'positive');
} catch (e) { } catch (e) {
throw new Error(e.message); throw e;
} }
}); });
} }

View File

@ -33,7 +33,7 @@ const importDms = async () => {
dmsId.value = null; dmsId.value = null;
emit('onDataSaved'); emit('onDataSaved');
} catch (e) { } catch (e) {
throw new Error(e.message); throw e;
} }
}; };
</script> </script>

View File

@ -34,7 +34,7 @@ const importDms = async () => {
dmsId.value = null; dmsId.value = null;
emit('onDataSaved'); emit('onDataSaved');
} catch (e) { } catch (e) {
throw new Error(e.message); throw e;
} }
}; };
</script> </script>

View File

@ -73,139 +73,102 @@ describe('RouteAutonomous', () => {
}); });
it('Should redirect to the summary when clicking a route', () => { it('Should redirect to the summary when clicking a route', () => {
cy.get(selectors.routeId) cy.checkRedirectionFromPopUp({
.click() selectorToClick: selectors.routeId,
.invoke('text') expectedUrlRegex: urls.summaryRouteUrlRegex,
.then((routeId) => { expectedTextSelector: selectors.descriptorRouteSubtitle,
routeId = routeId.trim(); });
cy.url().should('match', urls.summaryRouteUrlRegex);
cy.containContent(selectors.descriptorRouteSubtitle, routeId);
});
}); });
describe('Agency route pop-ups', () => { describe('Agency route pop-ups', () => {
it('Should redirect to the agency route summary from the agency route descriptor pop-up', () => { it('Should redirect to the agency route summary from the agency route descriptor pop-up', () => {
cy.get(selectors.agencyRoute) cy.checkRedirectionFromPopUp({
.click() selectorToClick: selectors.agencyRoute,
.invoke('text') steps: [selectors.descriptorGoToSummaryBtn],
.then((agencyName) => { expectedUrlRegex: urls.summaryAgencyUrlRegex,
agencyName = agencyName.trim(); expectedTextSelector: selectors.descriptorAgencyAndSupplierTitle,
cy.get(selectors.descriptorGoToSummaryBtn).click(); });
cy.url().should('match', urls.summaryAgencyUrlRegex);
cy.containContent(
selectors.descriptorAgencyAndSupplierTitle,
agencyName,
);
});
}); });
it('Should redirect to the agency route summary from summary pop-up from the agency route descriptor pop-up', () => { it('Should redirect to the agency route summary from summary pop-up from the agency route descriptor pop-up', () => {
cy.get(selectors.agencyRoute) cy.checkRedirectionFromPopUp({
.click() selectorToClick: selectors.agencyRoute,
.invoke('text') steps: [
.then((agencyName) => { selectors.descriptorOpenSummaryBtn,
agencyName = agencyName.trim(); selectors.summaryGoToSummaryBtn,
cy.get(selectors.descriptorOpenSummaryBtn).click(); ],
cy.get(selectors.summaryGoToSummaryBtn).click(); expectedUrlRegex: urls.summaryAgencyUrlRegex,
cy.url().should('match', urls.summaryAgencyUrlRegex); expectedTextSelector: selectors.descriptorAgencyAndSupplierTitle,
cy.containContent( });
selectors.descriptorAgencyAndSupplierTitle,
agencyName,
);
});
}); });
}); });
describe('Agency route pop-ups', () => { describe('Agency route pop-ups', () => {
it('Should redirect to the agency agreement summary from the agency agreement descriptor pop-up', () => { it('Should redirect to the agency agreement summary from the agency agreement descriptor pop-up', () => {
cy.get(selectors.agencyAgreement) cy.checkRedirectionFromPopUp({
.click() selectorToClick: selectors.agencyAgreement,
.invoke('text') steps: [selectors.descriptorGoToSummaryBtn],
.then((agencyName) => { expectedUrlRegex: urls.summaryAgencyUrlRegex,
agencyName = agencyName.trim(); expectedTextSelector: selectors.descriptorAgencyAndSupplierTitle,
cy.get(selectors.descriptorGoToSummaryBtn).click(); });
cy.url().should('match', urls.summaryAgencyUrlRegex);
cy.containContent(
selectors.descriptorAgencyAndSupplierTitle,
agencyName,
);
});
}); });
it('Should redirect to the agency agreement summary from summary pop-up from the agency agreement descriptor pop-up', () => { it('Should redirect to the agency agreement summary from summary pop-up from the agency agreement descriptor pop-up', () => {
cy.get(selectors.agencyAgreement) cy.checkRedirectionFromPopUp({
.click() selectorToClick: selectors.agencyAgreement,
.invoke('text') steps: [
.then((agencyName) => { selectors.descriptorOpenSummaryBtn,
agencyName = agencyName.trim(); selectors.summaryGoToSummaryBtn,
cy.get(selectors.descriptorOpenSummaryBtn).click(); ],
cy.get(selectors.summaryGoToSummaryBtn).click(); expectedUrlRegex: urls.summaryAgencyUrlRegex,
cy.url().should('match', urls.summaryAgencyUrlRegex); expectedTextSelector: selectors.descriptorAgencyAndSupplierTitle,
cy.containContent( });
selectors.descriptorAgencyAndSupplierTitle,
agencyName,
);
});
}); });
}); });
describe('Received pop-ups', () => { describe('Received pop-ups', () => {
it('Should redirect to the invoice in summary from the received descriptor pop-up', () => { it('Should redirect to the invoice in summary from the received descriptor pop-up', () => {
cy.get(selectors.received) cy.checkRedirectionFromPopUp({
.click() selectorToClick: selectors.received,
.invoke('text') steps: [selectors.descriptorGoToSummaryBtn],
.then((invoice) => { expectedUrlRegex: urls.summaryInvoiceInUrlRegex,
invoice = invoice.trim(); expectedTextSelector: selectors.descriptorInvoiceInTitle,
cy.get(selectors.descriptorGoToSummaryBtn).click(); });
cy.url().should('match', urls.summaryInvoiceInUrlRegex);
cy.containContent(selectors.descriptorInvoiceInTitle, invoice);
});
}); });
it('Should redirect to the invoiceIn summary from summary pop-up from the received descriptor pop-up', () => { it('Should redirect to the invoiceIn summary from summary pop-up from the received descriptor pop-up', () => {
cy.get(selectors.received) cy.checkRedirectionFromPopUp({
.click() selectorToClick: selectors.received,
.invoke('text') steps: [
.then((invoice) => { selectors.descriptorOpenSummaryBtn,
invoice = invoice.trim(); selectors.summaryGoToSummaryBtn,
cy.get(selectors.descriptorOpenSummaryBtn).click(); ],
cy.get(selectors.summaryGoToSummaryBtn).click(); expectedUrlRegex: urls.summaryInvoiceInUrlRegex,
cy.url().should('match', urls.summaryInvoiceInUrlRegex); expectedTextSelector: selectors.descriptorInvoiceInTitle,
cy.containContent(selectors.descriptorInvoiceInTitle, invoice); });
});
}); });
}); });
describe('Autonomous pop-ups', () => { describe('Autonomous pop-ups', () => {
it('Should redirect to the supplier summary from the received descriptor pop-up', () => { it('Should redirect to the supplier summary from the received descriptor pop-up', () => {
cy.get(selectors.autonomous) cy.checkRedirectionFromPopUp({
.click() selectorToClick: selectors.autonomous,
.invoke('text') steps: [selectors.descriptorGoToSummaryBtn],
.then((supplier) => { expectedUrlRegex: urls.summarySupplierUrlRegex,
supplier = supplier.trim(); expectedTextSelector: selectors.descriptorAgencyAndSupplierTitle,
cy.get(selectors.descriptorGoToSummaryBtn).click(); });
cy.url().should('match', urls.summarySupplierUrlRegex);
cy.containContent(
selectors.descriptorAgencyAndSupplierTitle,
supplier,
);
});
}); });
it('Should redirect to the supplier summary from summary pop-up from the autonomous descriptor pop-up', () => { it('Should redirect to the supplier summary from summary pop-up from the autonomous descriptor pop-up', () => {
cy.get(selectors.autonomous) cy.checkRedirectionFromPopUp({
.click() selectorToClick: selectors.autonomous,
.invoke('text') steps: [
.then((supplier) => { selectors.descriptorOpenSummaryBtn,
supplier = supplier.trim(); selectors.summaryGoToSummaryBtn,
cy.get(selectors.descriptorOpenSummaryBtn).click(); ],
cy.get(selectors.summaryGoToSummaryBtn).click(); expectedUrlRegex: urls.summarySupplierUrlRegex,
cy.url().should('match', urls.summarySupplierUrlRegex); expectedTextSelector: selectors.descriptorAgencyAndSupplierTitle,
cy.containContent( });
selectors.descriptorAgencyAndSupplierTitle,
supplier,
);
});
}); });
}); });

View File

@ -12,7 +12,9 @@ describe('Vehicle DMS', () => {
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',
descriptorTitle: '.descriptor .title', descriptorTitle: '.descriptor .title',
descriptorOpenSummaryBtn: '.q-menu .descriptor [data-cy="openSummaryBtn"]',
descriptorGoToSummaryBtn: '.q-menu .descriptor [data-cy="goToSummaryBtn"]', descriptorGoToSummaryBtn: '.q-menu .descriptor [data-cy="goToSummaryBtn"]',
summaryGoToSummaryBtn: '.summaryHeader [data-cy="goToSummaryBtn"]',
summaryTitle: '.summaryHeader', summaryTitle: '.summaryHeader',
referenceInput: 'Reference_input', referenceInput: 'Reference_input',
companySelect: 'Company_select', companySelect: 'Company_select',
@ -98,15 +100,26 @@ describe('Vehicle DMS', () => {
cy.containContent(selectors.lastRowReference, 'Vehicle:3333-BAT'); cy.containContent(selectors.lastRowReference, 'Vehicle:3333-BAT');
}); });
it('Should redirect to worker summary from worker descriptor pop-up', () => { describe('Worker pop-ups', () => {
cy.get(selectors.lastRowWorkerLink) it('Should redirect to worker summary from worker descriptor pop-up', () => {
.click() cy.checkRedirectionFromPopUp({
.invoke('text') selectorToClick: selectors.lastRowWorkerLink,
.then((workerName) => { steps: [selectors.descriptorGoToSummaryBtn],
workerName = workerName.trim(); expectedUrlRegex: workerSummaryUrlRegex,
cy.get(selectors.descriptorGoToSummaryBtn).click(); expectedTextSelector: selectors.descriptorTitle,
cy.url().should('match', workerSummaryUrlRegex);
cy.containContent(selectors.descriptorTitle, workerName);
}); });
});
it('Should redirect to worker summary from summary pop-up from worker descriptor pop-up', () => {
cy.checkRedirectionFromPopUp({
selectorToClick: selectors.lastRowWorkerLink,
steps: [
selectors.descriptorOpenSummaryBtn,
selectors.summaryGoToSummaryBtn,
],
expectedUrlRegex: workerSummaryUrlRegex,
expectedTextSelector: selectors.descriptorTitle,
});
});
}); });
}); });

View File

@ -619,3 +619,22 @@ Cypress.Commands.add('validateScrollContent', (validations) => {
); );
}); });
}); });
Cypress.Commands.add(
'checkRedirectionFromPopup',
({ selectorToClick, steps = [], expectedUrlRegex, expectedTextSelector }) => {
cy.get(selectorToClick)
.click()
.invoke('text')
.then((label) => {
label = label.trim();
steps.forEach((stepSelector) => {
cy.get(stepSelector).should('be.visible').click();
});
cy.location().should('match', expectedUrlRegex);
cy.containContent(expectedTextSelector, label);
});
},
);