describe('FixedAssetInvoice', () => { const getLinkSelector = (colField) => `tr:first-child > [data-col-field="${colField}"] > .no-padding > .link`; const selectors = { firstRowSupplier: getLinkSelector('supplierFk'), firstRowInvoice: getLinkSelector('supplierRef'), descriptorSupplierTitle: '[data-cy="vnDescriptor_description"]', descriptorInvoiceInTitle: '[data-cy="vnDescriptor_title"]', descriptorOpenSummaryBtn: '.q-menu > .descriptor [data-cy="openSummaryBtn"]', descriptorGoToSummaryBtn: '.q-menu > .descriptor [data-cy="goToSummaryBtn"]', summaryGoToSummaryBtn: '.summaryHeader [data-cy="goToSummaryBtn"]', unassignBtn: 'tableAction-0', }; const supplierSummaryUrlRegex = /supplier\/\d+\/summary/; const invoiceInSummaryUrlRegex = /invoice-in\/\d+\/summary/; beforeEach(() => { cy.viewport(1920, 1080); cy.login('administrative'); cy.visit(`/#/fixed-asset/1/invoice`); }); it('Should assign a new invoice', () => { const data = { 'Invoice nÂș': { val: '1243', type: 'select' }, Amount: { val: '1000' }, }; cy.addBtnClick(); cy.fillInForm(data); cy.dataCy('FormModelPopup_save').click(); cy.checkNotification('Data created'); }); it('Should unassign an invoice', () => { cy.dataCy(selectors.unassignBtn).last().click(); cy.clickConfirm(); cy.checkNotification('Unassigned invoice'); }); describe('Supplier pop-ups', () => { it('Should redirect to the supplier summary from the supplier descriptor pop-up', () => { cy.checkRedirectionFromPopUp({ selectorToClick: selectors.firstRowSupplier, steps: [selectors.descriptorGoToSummaryBtn], expectedUrlRegex: supplierSummaryUrlRegex, expectedTextSelector: selectors.descriptorSupplierTitle, }); }); it('Should redirect to the supplier summary from summary pop-up from the supplier descriptor pop-up', () => { cy.checkRedirectionFromPopUp({ selectorToClick: selectors.firstRowSupplier, steps: [ selectors.descriptorOpenSummaryBtn, selectors.summaryGoToSummaryBtn, ], expectedUrlRegex: supplierSummaryUrlRegex, expectedTextSelector: selectors.descriptorSupplierTitle, }); }); }); describe('Invoice pop-ups', () => { it('Should redirect to the invoiceIn summary from the invoice descriptor pop-up', () => { cy.checkRedirectionFromPopUp({ selectorToClick: selectors.firstRowInvoice, steps: [selectors.descriptorGoToSummaryBtn], expectedUrlRegex: invoiceInSummaryUrlRegex, expectedTextSelector: selectors.descriptorInvoiceInTitle, }); }); it('Should redirect to the invoiceIn summary from summary pop-up from the invoice descriptor pop-up', () => { cy.checkRedirectionFromPopUp({ selectorToClick: selectors.firstRowInvoice, steps: [ selectors.descriptorOpenSummaryBtn, selectors.summaryGoToSummaryBtn, ], expectedUrlRegex: invoiceInSummaryUrlRegex, expectedTextSelector: selectors.descriptorInvoiceInTitle, }); }); }); });