refactor: refs #8422 implement checkRedirectionFromPopup command and refactor tests for improved readability
gitea/salix-front/pipeline/pr-dev This commit is unstable
Details
gitea/salix-front/pipeline/pr-dev This commit is unstable
Details
This commit is contained in:
parent
e84107dcbb
commit
9a0211787a
|
@ -93,7 +93,7 @@ async function save() {
|
|||
delete dms.value.files;
|
||||
return response;
|
||||
} catch (e) {
|
||||
throw new Error(e.message);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -267,7 +267,7 @@ function deleteDms(dmsFk) {
|
|||
rows.value.splice(index, 1);
|
||||
notify(t('globals.dataDeleted'), 'positive');
|
||||
} catch (e) {
|
||||
throw new Error(e.message);
|
||||
throw e;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ const importDms = async () => {
|
|||
dmsId.value = null;
|
||||
emit('onDataSaved');
|
||||
} catch (e) {
|
||||
throw new Error(e.message);
|
||||
throw e;
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
|
|
@ -34,7 +34,7 @@ const importDms = async () => {
|
|||
dmsId.value = null;
|
||||
emit('onDataSaved');
|
||||
} catch (e) {
|
||||
throw new Error(e.message);
|
||||
throw e;
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
|
|
@ -73,139 +73,102 @@ describe('RouteAutonomous', () => {
|
|||
});
|
||||
|
||||
it('Should redirect to the summary when clicking a route', () => {
|
||||
cy.get(selectors.routeId)
|
||||
.click()
|
||||
.invoke('text')
|
||||
.then((routeId) => {
|
||||
routeId = routeId.trim();
|
||||
cy.url().should('match', urls.summaryRouteUrlRegex);
|
||||
cy.containContent(selectors.descriptorRouteSubtitle, routeId);
|
||||
});
|
||||
cy.checkRedirectionFromPopUp({
|
||||
selectorToClick: selectors.routeId,
|
||||
expectedUrlRegex: urls.summaryRouteUrlRegex,
|
||||
expectedTextSelector: selectors.descriptorRouteSubtitle,
|
||||
});
|
||||
});
|
||||
|
||||
describe('Agency route pop-ups', () => {
|
||||
it('Should redirect to the agency route summary from the agency route descriptor pop-up', () => {
|
||||
cy.get(selectors.agencyRoute)
|
||||
.click()
|
||||
.invoke('text')
|
||||
.then((agencyName) => {
|
||||
agencyName = agencyName.trim();
|
||||
cy.get(selectors.descriptorGoToSummaryBtn).click();
|
||||
cy.url().should('match', urls.summaryAgencyUrlRegex);
|
||||
cy.containContent(
|
||||
selectors.descriptorAgencyAndSupplierTitle,
|
||||
agencyName,
|
||||
);
|
||||
});
|
||||
cy.checkRedirectionFromPopUp({
|
||||
selectorToClick: selectors.agencyRoute,
|
||||
steps: [selectors.descriptorGoToSummaryBtn],
|
||||
expectedUrlRegex: urls.summaryAgencyUrlRegex,
|
||||
expectedTextSelector: selectors.descriptorAgencyAndSupplierTitle,
|
||||
});
|
||||
});
|
||||
|
||||
it('Should redirect to the agency route summary from summary pop-up from the agency route descriptor pop-up', () => {
|
||||
cy.get(selectors.agencyRoute)
|
||||
.click()
|
||||
.invoke('text')
|
||||
.then((agencyName) => {
|
||||
agencyName = agencyName.trim();
|
||||
cy.get(selectors.descriptorOpenSummaryBtn).click();
|
||||
cy.get(selectors.summaryGoToSummaryBtn).click();
|
||||
cy.url().should('match', urls.summaryAgencyUrlRegex);
|
||||
cy.containContent(
|
||||
selectors.descriptorAgencyAndSupplierTitle,
|
||||
agencyName,
|
||||
);
|
||||
});
|
||||
cy.checkRedirectionFromPopUp({
|
||||
selectorToClick: selectors.agencyRoute,
|
||||
steps: [
|
||||
selectors.descriptorOpenSummaryBtn,
|
||||
selectors.summaryGoToSummaryBtn,
|
||||
],
|
||||
expectedUrlRegex: urls.summaryAgencyUrlRegex,
|
||||
expectedTextSelector: selectors.descriptorAgencyAndSupplierTitle,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Agency route pop-ups', () => {
|
||||
it('Should redirect to the agency agreement summary from the agency agreement descriptor pop-up', () => {
|
||||
cy.get(selectors.agencyAgreement)
|
||||
.click()
|
||||
.invoke('text')
|
||||
.then((agencyName) => {
|
||||
agencyName = agencyName.trim();
|
||||
cy.get(selectors.descriptorGoToSummaryBtn).click();
|
||||
cy.url().should('match', urls.summaryAgencyUrlRegex);
|
||||
cy.containContent(
|
||||
selectors.descriptorAgencyAndSupplierTitle,
|
||||
agencyName,
|
||||
);
|
||||
});
|
||||
cy.checkRedirectionFromPopUp({
|
||||
selectorToClick: selectors.agencyAgreement,
|
||||
steps: [selectors.descriptorGoToSummaryBtn],
|
||||
expectedUrlRegex: urls.summaryAgencyUrlRegex,
|
||||
expectedTextSelector: selectors.descriptorAgencyAndSupplierTitle,
|
||||
});
|
||||
});
|
||||
|
||||
it('Should redirect to the agency agreement summary from summary pop-up from the agency agreement descriptor pop-up', () => {
|
||||
cy.get(selectors.agencyAgreement)
|
||||
.click()
|
||||
.invoke('text')
|
||||
.then((agencyName) => {
|
||||
agencyName = agencyName.trim();
|
||||
cy.get(selectors.descriptorOpenSummaryBtn).click();
|
||||
cy.get(selectors.summaryGoToSummaryBtn).click();
|
||||
cy.url().should('match', urls.summaryAgencyUrlRegex);
|
||||
cy.containContent(
|
||||
selectors.descriptorAgencyAndSupplierTitle,
|
||||
agencyName,
|
||||
);
|
||||
});
|
||||
cy.checkRedirectionFromPopUp({
|
||||
selectorToClick: selectors.agencyAgreement,
|
||||
steps: [
|
||||
selectors.descriptorOpenSummaryBtn,
|
||||
selectors.summaryGoToSummaryBtn,
|
||||
],
|
||||
expectedUrlRegex: urls.summaryAgencyUrlRegex,
|
||||
expectedTextSelector: selectors.descriptorAgencyAndSupplierTitle,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Received pop-ups', () => {
|
||||
it('Should redirect to the invoice in summary from the received descriptor pop-up', () => {
|
||||
cy.get(selectors.received)
|
||||
.click()
|
||||
.invoke('text')
|
||||
.then((invoice) => {
|
||||
invoice = invoice.trim();
|
||||
cy.get(selectors.descriptorGoToSummaryBtn).click();
|
||||
cy.url().should('match', urls.summaryInvoiceInUrlRegex);
|
||||
cy.containContent(selectors.descriptorInvoiceInTitle, invoice);
|
||||
});
|
||||
cy.checkRedirectionFromPopUp({
|
||||
selectorToClick: selectors.received,
|
||||
steps: [selectors.descriptorGoToSummaryBtn],
|
||||
expectedUrlRegex: urls.summaryInvoiceInUrlRegex,
|
||||
expectedTextSelector: selectors.descriptorInvoiceInTitle,
|
||||
});
|
||||
});
|
||||
|
||||
it('Should redirect to the invoiceIn summary from summary pop-up from the received descriptor pop-up', () => {
|
||||
cy.get(selectors.received)
|
||||
.click()
|
||||
.invoke('text')
|
||||
.then((invoice) => {
|
||||
invoice = invoice.trim();
|
||||
cy.get(selectors.descriptorOpenSummaryBtn).click();
|
||||
cy.get(selectors.summaryGoToSummaryBtn).click();
|
||||
cy.url().should('match', urls.summaryInvoiceInUrlRegex);
|
||||
cy.containContent(selectors.descriptorInvoiceInTitle, invoice);
|
||||
});
|
||||
cy.checkRedirectionFromPopUp({
|
||||
selectorToClick: selectors.received,
|
||||
steps: [
|
||||
selectors.descriptorOpenSummaryBtn,
|
||||
selectors.summaryGoToSummaryBtn,
|
||||
],
|
||||
expectedUrlRegex: urls.summaryInvoiceInUrlRegex,
|
||||
expectedTextSelector: selectors.descriptorInvoiceInTitle,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Autonomous pop-ups', () => {
|
||||
it('Should redirect to the supplier summary from the received descriptor pop-up', () => {
|
||||
cy.get(selectors.autonomous)
|
||||
.click()
|
||||
.invoke('text')
|
||||
.then((supplier) => {
|
||||
supplier = supplier.trim();
|
||||
cy.get(selectors.descriptorGoToSummaryBtn).click();
|
||||
cy.url().should('match', urls.summarySupplierUrlRegex);
|
||||
cy.containContent(
|
||||
selectors.descriptorAgencyAndSupplierTitle,
|
||||
supplier,
|
||||
);
|
||||
});
|
||||
cy.checkRedirectionFromPopUp({
|
||||
selectorToClick: selectors.autonomous,
|
||||
steps: [selectors.descriptorGoToSummaryBtn],
|
||||
expectedUrlRegex: urls.summarySupplierUrlRegex,
|
||||
expectedTextSelector: selectors.descriptorAgencyAndSupplierTitle,
|
||||
});
|
||||
});
|
||||
|
||||
it('Should redirect to the supplier summary from summary pop-up from the autonomous descriptor pop-up', () => {
|
||||
cy.get(selectors.autonomous)
|
||||
.click()
|
||||
.invoke('text')
|
||||
.then((supplier) => {
|
||||
supplier = supplier.trim();
|
||||
cy.get(selectors.descriptorOpenSummaryBtn).click();
|
||||
cy.get(selectors.summaryGoToSummaryBtn).click();
|
||||
cy.url().should('match', urls.summarySupplierUrlRegex);
|
||||
cy.containContent(
|
||||
selectors.descriptorAgencyAndSupplierTitle,
|
||||
supplier,
|
||||
);
|
||||
});
|
||||
cy.checkRedirectionFromPopUp({
|
||||
selectorToClick: selectors.autonomous,
|
||||
steps: [
|
||||
selectors.descriptorOpenSummaryBtn,
|
||||
selectors.summaryGoToSummaryBtn,
|
||||
],
|
||||
expectedUrlRegex: urls.summarySupplierUrlRegex,
|
||||
expectedTextSelector: selectors.descriptorAgencyAndSupplierTitle,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -12,7 +12,9 @@ describe('Vehicle DMS', () => {
|
|||
firstRowId: 'tr:first-child > :nth-child(2) > .q-tr > :nth-child(1) > span',
|
||||
lastRowWorkerLink: 'tr:last-child > :nth-child(8) > .q-tr > .link',
|
||||
descriptorTitle: '.descriptor .title',
|
||||
descriptorOpenSummaryBtn: '.q-menu .descriptor [data-cy="openSummaryBtn"]',
|
||||
descriptorGoToSummaryBtn: '.q-menu .descriptor [data-cy="goToSummaryBtn"]',
|
||||
summaryGoToSummaryBtn: '.summaryHeader [data-cy="goToSummaryBtn"]',
|
||||
summaryTitle: '.summaryHeader',
|
||||
referenceInput: 'Reference_input',
|
||||
companySelect: 'Company_select',
|
||||
|
@ -98,15 +100,26 @@ describe('Vehicle DMS', () => {
|
|||
cy.containContent(selectors.lastRowReference, 'Vehicle:3333-BAT');
|
||||
});
|
||||
|
||||
it('Should redirect to worker summary from worker descriptor pop-up', () => {
|
||||
cy.get(selectors.lastRowWorkerLink)
|
||||
.click()
|
||||
.invoke('text')
|
||||
.then((workerName) => {
|
||||
workerName = workerName.trim();
|
||||
cy.get(selectors.descriptorGoToSummaryBtn).click();
|
||||
cy.url().should('match', workerSummaryUrlRegex);
|
||||
cy.containContent(selectors.descriptorTitle, workerName);
|
||||
describe('Worker pop-ups', () => {
|
||||
it('Should redirect to worker summary from worker descriptor pop-up', () => {
|
||||
cy.checkRedirectionFromPopUp({
|
||||
selectorToClick: selectors.lastRowWorkerLink,
|
||||
steps: [selectors.descriptorGoToSummaryBtn],
|
||||
expectedUrlRegex: workerSummaryUrlRegex,
|
||||
expectedTextSelector: selectors.descriptorTitle,
|
||||
});
|
||||
});
|
||||
|
||||
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,
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
},
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue