describe('Route', () => { const getSelector = (colField) => `tr:last-child > [data-col-field="${colField}"] > .no-padding > .link`; const selectors = { lastRow: 'tr:last-child > [data-col-field="workerFk"]', workerLink: getSelector('workerFk'), agencyLink: getSelector('agencyModeFk'), vehicleLink: getSelector('vehicleFk'), assignedTicketsBtn: 'tableAction-0', rowSummaryBtn: 'tableAction-1', summaryTitle: '.summaryHeader', descriptorTitle: '.descriptor .title', descriptorOpenSummaryBtn: '.descriptor [data-cy="openSummaryBtn"]', descriptorGoToSummaryBtn: '.descriptor [data-cy="goToSummaryBtn"]', SummaryGoToSummaryBtn: '.summaryHeader [data-cy="goToSummaryBtn"]', }; const data = { Worker: { val: 'logistic', type: 'select' }, Agency: { val: 'Walking', type: 'select' }, Vehicle: { val: '3333-BAT', type: 'select' }, Description: { val: 'routeTest' }, }; const summaryUrl = '/summary'; beforeEach(() => { cy.viewport(1920, 1080); cy.login('developer'); cy.visit(`/#/route/list`); cy.typeSearchbar('{enter}'); }); it('Should list routes', () => { cy.get('.q-table') .children() .should('be.visible') .should('have.length.greaterThan', 0); }); it('Should create new route', () => { cy.addBtnClick(); cy.fillInForm(data); cy.dataCy('FormModelPopup_save').should('be.visible').click(); cy.checkNotification('Data created'); cy.url().should('include', summaryUrl); cy.get(selectors.summaryTitle) .invoke('text') .then((text) => { expect(text).to.include(data.Description.val); }); }); it('Should open route summary by clicking a route', () => { cy.get(selectors.lastRow).should('be.visible').click(); cy.url().should('include', summaryUrl); cy.get(selectors.summaryTitle) .invoke('text') .then((text) => { expect(text).to.include(data.Description.val); }); }); it('Should redirect to the summary from the route pop-up summary', () => { cy.dataCy(selectors.rowSummaryBtn).last().should('be.visible').click(); cy.get(selectors.summaryTitle) .invoke('text') .then((text) => { expect(text).to.include(data.Description.val); }); cy.get(selectors.SummaryGoToSummaryBtn).click(); cy.get(selectors.summaryTitle) .invoke('text') .then((text) => { expect(text).to.include(data.Description.val); }); }); it('Should redirect to the route assigned tickets from the row assignedTicketsBtn', () => { cy.dataCy(selectors.assignedTicketsBtn).first().should('be.visible').click(); cy.url().should('include', '1/tickets'); cy.get('.q-table') .children() .should('be.visible') .should('have.length.greaterThan', 0); }); describe('Worker pop-ups', () => { it('Should redirect to summary from the worker pop-up descriptor', () => { cy.get(selectors.workerLink).click(); cy.get(selectors.descriptorTitle) .invoke('text') .then((text) => { expect(text).to.include(data.Worker.val); }); cy.get(selectors.descriptorGoToSummaryBtn).click(); cy.get(selectors.summaryTitle) .invoke('text') .then((text) => { expect(text).to.include(data.Worker.val); }); }); it('Should redirect to the summary from the worker pop-up summary', () => { cy.get(selectors.workerLink).click(); cy.get(selectors.descriptorTitle) .invoke('text') .then((text) => { expect(text).to.include(data.Worker.val); }); cy.get(selectors.descriptorOpenSummaryBtn).click(); cy.get(selectors.summaryTitle) .invoke('text') .then((text) => { expect(text).to.include(data.Worker.val); }); cy.get(selectors.SummaryGoToSummaryBtn).click(); cy.get(selectors.summaryTitle) .invoke('text') .then((text) => { expect(text).to.include(data.Worker.val); }); }); }); describe('Agency pop-ups', () => { it('Should redirect to summary from the agency pop-up descriptor', () => { cy.get(selectors.agencyLink).click(); cy.get(selectors.descriptorTitle) .invoke('text') .then((text) => { expect(text).to.include(data.Agency.val); }); cy.get(selectors.descriptorGoToSummaryBtn).click(); cy.get(selectors.summaryTitle) .invoke('text') .then((text) => { expect(text).to.include(data.Agency.val); }); }); it('Should redirect to the summary from the agency pop-up summary', () => { cy.get(selectors.agencyLink).click(); cy.get(selectors.descriptorTitle) .invoke('text') .then((text) => { expect(text).to.include(data.Agency.val); }); cy.get(selectors.descriptorOpenSummaryBtn).click(); cy.get(selectors.summaryTitle) .invoke('text') .then((text) => { expect(text).to.include(data.Agency.val); }); cy.get(selectors.SummaryGoToSummaryBtn).click(); cy.get(selectors.summaryTitle) .invoke('text') .then((text) => { expect(text).to.include(data.Agency.val); }); }); }); describe('Vehicle pop-ups', () => { it('Should redirect to summary from the vehicle pop-up descriptor', () => { cy.get(selectors.vehicleLink).click(); cy.get(selectors.descriptorTitle) .invoke('text') .then((text) => { expect(text).to.include(data.Vehicle.val); }); cy.get(selectors.descriptorGoToSummaryBtn).click(); cy.get(selectors.summaryTitle) .invoke('text') .then((text) => { expect(text).to.include(data.Vehicle.val); }); }); it('Should redirect to the summary from the vehicle pop-up summary', () => { cy.get(selectors.vehicleLink).click(); cy.get(selectors.descriptorTitle) .invoke('text') .then((text) => { expect(text).to.include(data.Vehicle.val); }); cy.get(selectors.descriptorOpenSummaryBtn).click(); cy.get(selectors.summaryTitle) .invoke('text') .then((text) => { expect(text).to.include(data.Vehicle.val); }); cy.get(selectors.SummaryGoToSummaryBtn).click(); cy.get(selectors.summaryTitle) .invoke('text') .then((text) => { expect(text).to.include(data.Vehicle.val); }); }); }); });