describe('Cmr list', () => { const getLinkSelector = (colField) => `tr:first-child > [data-col-field="${colField}"] > .no-padding > .link`; const selectors = { ticket: getLinkSelector('ticketFk'), client: getLinkSelector('clientFk'), lastRowSelectCheckBox: '.q-virtual-scroll__content > tr:last-child > :nth-child(1) > .q-checkbox', downloadBtn: '#subToolbar > .q-btn', viewCmr: 'tableAction-0', descriptorOpenSummaryBtn: '.descriptor [data-cy="openSummaryBtn"]', summaryTitle: '.summaryHeader', descriptorId: '.descriptor .subtitle', descriptorTitle: '.descriptor .title', summaryGoToSummaryBtn: '.summaryHeader [data-cy="goToSummaryBtn"]', descriptorGoToSummaryBtn: '.descriptor [data-cy="goToSummaryBtn"]', removeFilter: '.q-chip__icon--remove', }; const data = { ticket: '1', client: 'Bruce Wayne', }; beforeEach(() => { cy.viewport(1920, 1080); cy.login('developer'); cy.visit('/#/route/cmr'); cy.typeSearchbar('{enter}'); cy.get(selectors.removeFilter).click(); }); it('Should download selected cmr', () => { const downloadsFolder = Cypress.config('downloadsFolder'); cy.get(selectors.lastRowSelectCheckBox).should('be.visible').click(); cy.get(selectors.downloadBtn).should('be.visible').click(); cy.wait(3000); const fileName = 'cmrs.zip'; cy.readFile(`${downloadsFolder}/${fileName}`).should('exist'); }); it('Should open selected cmr pdf', () => { cy.window().then((win) => { cy.stub(win, 'open').as('windowOpen'); }); cy.dataCy(selectors.viewCmr).last().click(); cy.get('@windowOpen').should('be.calledWithMatch', '\/api\/Cmrs\/3'); }); describe('Ticket pop-ups', () => { it('Should redirect to the ticket summary from the ticket descriptor pop-up', () => { cy.get(selectors.ticket).should('be.visible').click(); cy.containContent(selectors.descriptorId, data.ticket); cy.get(selectors.descriptorGoToSummaryBtn).should('be.visible').click(); cy.url().should('include', '/ticket/1/summary'); cy.containContent(selectors.summaryTitle, data.client); }); it('Should redirect to the ticket summary from summary pop-up from the ticket descriptor pop-up', () => { cy.get(selectors.ticket).should('be.visible').click(); cy.containContent(selectors.descriptorId, data.ticket); cy.get(selectors.descriptorOpenSummaryBtn).should('be.visible').click(); cy.containContent(selectors.summaryTitle, data.client); cy.get(selectors.summaryGoToSummaryBtn).should('be.visible').click(); cy.url().should('include', '/ticket/1/summary'); cy.containContent(selectors.summaryTitle, data.client); }); }); describe('Client pop-ups', () => { it('Should redirect to the client summary from the client descriptor pop-up', () => { cy.get(selectors.client).should('be.visible').click(); cy.containContent(selectors.descriptorTitle, data.client); cy.get(selectors.descriptorGoToSummaryBtn).should('be.visible').click(); cy.url().should('include', '/customer/1101/summary'); cy.containContent(selectors.summaryTitle, data.client); }); it('Should redirect to the client summary from summary pop-up from the client descriptor pop-up', () => { cy.get(selectors.client).should('be.visible').click(); cy.containContent(selectors.descriptorTitle, data.client); cy.get(selectors.descriptorOpenSummaryBtn).should('be.visible').click(); cy.containContent(selectors.summaryTitle, data.client); cy.get(selectors.summaryGoToSummaryBtn).should('be.visible').click(); cy.url().should('include', '/customer/1101/summary'); cy.containContent(selectors.summaryTitle, data.client); }); }); });