#8442 - createVehicleDms #1614

Merged
jtubau merged 47 commits from 8422-createVehicleDms into dev 2025-04-16 14:20:24 +00:00
1 changed files with 156 additions and 52 deletions
Showing only changes of commit a1e21d156b - Show all commits

View File

@ -1,11 +1,12 @@
describe.skip('RouteAutonomous', () => {
const getLinkSelector = (colField) =>
`tr:first-child > [data-col-field="${colField}"] > .no-padding > .link`;
describe('RouteAutonomous', () => {
const getLinkSelector = (colField, link = true) =>
`tr:first-child > [data-col-field="${colField}"] > .no-padding${link ? ' > .link' : ''}`;
const selectors = {
reference: 'Reference_input',
date: 'tr:first-child > [data-col-field="dated"]',
total: '.value > .text-h6',
routeId: getLinkSelector('routeFk', false),
agencyRoute: getLinkSelector('agencyModeName'),
agencyAgreement: getLinkSelector('agencyAgreement'),
received: getLinkSelector('invoiceInFk'),
autonomous: getLinkSelector('supplierName'),
firstRowCheckbox: '.q-virtual-scroll__content tr:first-child .q-checkbox__bg',
@ -13,22 +14,30 @@ describe.skip('RouteAutonomous', () => {
createInvoiceBtn: '.q-card > .q-btn',
saveFormBtn: 'FormModelPopup_save',
summaryIcon: 'tableAction-0',
summaryPopupBtn: '.header > :nth-child(2) > .q-btn__content > .q-icon',
summaryHeader: '.summaryHeader > :nth-child(2)',
descriptorHeader: '.summaryHeader > div',
descriptorTitle: '.q-item__label--header > .title > span',
summaryGoToSummaryBtn: '.header > .q-icon',
descriptorGoToSummaryBtn: '.descriptor > .header > a[href] > .q-btn',
descriptorRouteSubtitle: '[data-cy="vnDescriptor_subtitle"]',
descriptorAgencyAndSupplierTitle: '[data-cy="vnDescriptor_description"]',
descriptorInvoiceInTitle: '[data-cy="vnDescriptor_title"]',
descriptorOpenSummaryBtn: '.q-menu > .descriptor [data-cy="openSummaryBtn"]',
jtubau marked this conversation as resolved
Review

Si vas directo al dataCy no funciona?

Si vas directo al dataCy no funciona?
descriptorGoToSummaryBtn: '.q-menu > .descriptor [data-cy="goToSummaryBtn"]',
summaryGoToSummaryBtn: '.summaryHeader [data-cy="goToSummaryBtn"]',
};
const data = {
reference: 'Test invoice',
total: '€206.40',
supplier: 'PLANTS SL',
route: 'first route',
const newInvoice = {
Reference: { val: 'Test invoice' },
Company: { val: 'VNL', type: 'select' },
Warehouse: { val: 'Warehouse One', type: 'select' },
Type: { val: 'Vehiculos', type: 'select' },
Description: { val: 'Test description' },
};
const summaryUrl = '/summary';
const total = '€206.40';
const urls = {
summaryAgencyUrlRegex: /agency\/\d+\/summary/,
summaryInvoiceInUrlRegex: /invoice-in\/\d+\/summary/,
summarySupplierUrlRegex: /supplier\/\d+\/summary/,
summaryRouteUrlRegex: /route\/\d+\/summary/,
};
const dataSaved = 'Data saved';
beforeEach(() => {
@ -48,7 +57,7 @@ describe.skip('RouteAutonomous', () => {
it('Should create invoice in to selected route', () => {
cy.get(selectors.firstRowCheckbox).click();
cy.get(selectors.createInvoiceBtn).click();
cy.dataCy(selectors.reference).type(data.reference);
cy.fillInForm(newInvoice);
cy.dataCy('attachFile').click();
cy.get('.q-file').selectFile('test/cypress/fixtures/image.jpg', {
force: true,
@ -60,62 +69,157 @@ describe.skip('RouteAutonomous', () => {
it('Should display the total price of the selected rows', () => {
cy.get(selectors.firstRowCheckbox).click();
cy.get(selectors.secondRowCheckbox).click();
cy.validateContent(selectors.total, data.total);
cy.validateContent(selectors.total, total);
});
it('Should redirect to the summary when clicking a route', () => {
cy.get(selectors.date).click();
cy.get(selectors.summaryHeader).should('contain', data.route);
cy.url().should('include', summaryUrl);
cy.get(selectors.routeId)
.click()
.invoke('text')
.then((routeId) => {
routeId = routeId.trim();
cy.url().should('match', urls.summaryRouteUrlRegex);
cy.containContent(selectors.descriptorRouteSubtitle, routeId);
});
});
describe('Agency route pop-ups', () => {
jtubau marked this conversation as resolved Outdated

Veo mucha duplicidad en los tests de los popups, crea una fn que puedas reutilizar

Veo mucha duplicidad en los tests de los popups, crea una fn que puedas reutilizar
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,
);
});
});
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,
);
});
});
});
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,
);
});
});
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,
);
});
});
});
describe('Received pop-ups', () => {
it('Should redirect to invoice in summary from the received descriptor pop-up', () => {
cy.get(selectors.received).click();
cy.validateContent(selectors.descriptorTitle, data.reference);
cy.get(selectors.descriptorGoToSummaryBtn).click();
cy.get(selectors.descriptorHeader).should('contain', data.supplier);
cy.url().should('include', summaryUrl);
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);
});
});
it('Should redirect to the invoiceIn summary from summary pop-up from the received descriptor pop-up', () => {
cy.get(selectors.received).click();
cy.validateContent(selectors.descriptorTitle, data.reference);
cy.get(selectors.summaryPopupBtn).click();
cy.get(selectors.descriptorHeader).should('contain', data.supplier);
cy.get(selectors.summaryGoToSummaryBtn).click();
cy.get(selectors.descriptorHeader).should('contain', data.supplier);
cy.url().should('include', summaryUrl);
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);
});
});
});
describe('Autonomous pop-ups', () => {
it('Should redirect to the supplier summary from the received descriptor pop-up', () => {
cy.get(selectors.autonomous).click();
cy.validateContent(selectors.descriptorTitle, data.supplier);
cy.get(selectors.descriptorGoToSummaryBtn).click();
cy.get(selectors.summaryHeader).should('contain', data.supplier);
cy.url().should('include', summaryUrl);
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,
);
});
});
it('Should redirect to the supplier summary from summary pop-up from the autonomous descriptor pop-up', () => {
cy.get(selectors.autonomous).click();
cy.get(selectors.descriptorTitle).should('contain', data.supplier);
cy.get(selectors.summaryPopupBtn).click();
cy.get(selectors.summaryHeader).should('contain', data.supplier);
cy.get(selectors.summaryGoToSummaryBtn).click();
cy.get(selectors.summaryHeader).should('contain', data.supplier);
cy.url().should('include', summaryUrl);
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,
);
});
});
});
describe('Route pop-ups', () => {
it('Should redirect to the summary from the route summary pop-up', () => {
cy.dataCy(selectors.summaryIcon).first().click();
cy.get(selectors.summaryHeader).should('contain', data.route);
cy.get(selectors.summaryGoToSummaryBtn).click();
cy.get(selectors.summaryHeader).should('contain', data.route);
cy.url().should('include', summaryUrl);
cy.get(selectors.routeId)
.invoke('text')
.then((routeId) => {
routeId = routeId.trim();
cy.dataCy(selectors.summaryIcon).first().click();
cy.get(selectors.summaryGoToSummaryBtn).click();
cy.url().should('match', urls.summaryRouteUrlRegex);
cy.containContent(selectors.descriptorRouteSubtitle, routeId);
});
});
});
});