refactor: refs #8441 improved tests to avoid intermittency and failures due to interference from other tests
gitea/salix-front/pipeline/pr-dev This commit is unstable Details

This commit is contained in:
Jose Antonio Tubau 2025-04-03 09:09:40 +02:00
parent 622307697f
commit b950b4845b
3 changed files with 138 additions and 101 deletions

View File

@ -4,18 +4,16 @@ describe('Vehicle Invoice In', () => {
const selectors = { const selectors = {
firstRowSupplier: getLinkSelector('supplierFk'), firstRowSupplier: getLinkSelector('supplierFk'),
firstRowInvoice: getLinkSelector('supplierRef'), firstRowInvoice: getLinkSelector('supplierRef'),
descriptorTitle: '.q-menu > .descriptor .title', descriptorSupplierTitle: '[data-cy="vnDescriptor_description"]',
summaryTitle: '.summaryHeader', descriptorInvoiceInTitle: '[data-cy="vnDescriptor_title"]',
descriptorOpenSummaryBtn: '.q-menu > .descriptor [data-cy="openSummaryBtn"]', descriptorOpenSummaryBtn: '.q-menu > .descriptor [data-cy="openSummaryBtn"]',
descriptorGoToSummaryBtn: '.q-menu > .descriptor [data-cy="goToSummaryBtn"]', descriptorGoToSummaryBtn: '.q-menu > .descriptor [data-cy="goToSummaryBtn"]',
SummaryGoToSummaryBtn: '.summaryHeader [data-cy="goToSummaryBtn"]', summaryGoToSummaryBtn: '.summaryHeader [data-cy="goToSummaryBtn"]',
unassignBtn: 'tableAction-0', unassignBtn: 'tableAction-0',
}; };
const data = { const supplierSummaryUrlRegex = /supplier\/\d+\/summary/;
supplier: 'PLANTS SL', const invoiceInSummaryUrlRegex = /invoice-in\/\d+\/summary/;
invoice: '1234',
};
beforeEach(() => { beforeEach(() => {
cy.viewport(1920, 1080); cy.viewport(1920, 1080);
@ -32,58 +30,74 @@ describe('Vehicle Invoice In', () => {
it('Should assign a new invoice', () => { it('Should assign a new invoice', () => {
const data = { const data = {
'Invoice nº': { val: '5', type: 'select' }, 'Invoice nº': { val: '1235', type: 'select' },
Amount: { val: '1000' }, Amount: { val: '1000' },
}; };
cy.addBtnClick(); cy.addBtnClick();
cy.fillInForm(data); cy.fillInForm(data);
cy.dataCy('FormModelPopup_save').should('be.visible').click(); cy.dataCy('FormModelPopup_save').click();
cy.checkNotification('Data created'); cy.checkNotification('Data created');
}); });
it('Should unassign an invoice', () => { it('Should unassign an invoice', () => {
cy.dataCy(selectors.unassignBtn).should('be.visible').last().click(); cy.dataCy(selectors.unassignBtn).last().click();
cy.clickConfirm(); cy.clickConfirm();
cy.checkNotification('Unlinked invoice'); cy.checkNotification('Unlinked invoice');
}); });
describe('Supplier pop-ups', () => { describe('Supplier pop-ups', () => {
it('Should redirect to the supplier summary from the supplier descriptor pop-up', () => { it('Should redirect to the supplier summary from the supplier descriptor pop-up', () => {
cy.get(selectors.firstRowSupplier).should('be.visible').click(); cy.get(selectors.firstRowSupplier)
cy.containContent(selectors.descriptorTitle, data.supplier); .click()
cy.get(selectors.descriptorGoToSummaryBtn).should('be.visible').click(); .invoke('text')
cy.url().should('include', '/supplier/1/summary'); .then((supplierName) => {
cy.containContent(selectors.summaryTitle, data.supplier); supplierName = supplierName.trim();
cy.get(selectors.descriptorGoToSummaryBtn).click();
cy.url().should('match', supplierSummaryUrlRegex);
cy.containContent(selectors.descriptorSupplierTitle, supplierName);
});
}); });
it('Should redirect to the supplier summary from summary pop-up from the supplier descriptor pop-up', () => { it('Should redirect to the supplier summary from summary pop-up from the supplier descriptor pop-up', () => {
cy.get(selectors.firstRowSupplier).should('be.visible').click(); cy.get(selectors.firstRowSupplier)
cy.containContent(selectors.descriptorTitle, data.supplier); .click()
cy.get(selectors.descriptorOpenSummaryBtn).should('be.visible').click(); .invoke('text')
cy.containContent(selectors.summaryTitle, data.supplier); .then((supplierName) => {
cy.get(selectors.SummaryGoToSummaryBtn).should('be.visible').click(); supplierName = supplierName.trim();
cy.url().should('include', '/supplier/1/summary'); cy.get(selectors.descriptorOpenSummaryBtn)
cy.containContent(selectors.summaryTitle, data.supplier); .should('be.visible')
.click();
cy.get(selectors.summaryGoToSummaryBtn).should('be.visible').click();
cy.url().should('match', supplierSummaryUrlRegex);
cy.containContent(selectors.descriptorSupplierTitle, supplierName);
});
}); });
}); });
describe('Invoice pop-ups', () => { describe('Invoice pop-ups', () => {
it('Should redirect to the invoiceIn summary from the invoice descriptor pop-up', () => { it('Should redirect to the invoiceIn summary from the invoice descriptor pop-up', () => {
cy.get(selectors.firstRowInvoice).should('be.visible').click(); cy.get(selectors.firstRowInvoice)
cy.containContent(selectors.descriptorTitle, data.invoice); .click()
cy.get(selectors.descriptorGoToSummaryBtn).should('be.visible').click(); .invoke('text')
cy.url().should('include', '/invoice-in/1/summary'); .then((invoice) => {
cy.containContent(selectors.summaryTitle, data.supplier); invoice = invoice.trim();
cy.get(selectors.descriptorGoToSummaryBtn).click();
cy.url().should('match', invoiceInSummaryUrlRegex);
cy.containContent(selectors.descriptorInvoiceInTitle, invoice);
});
}); });
it('Should redirect to the invoiceIn summary from summary pop-up from the invoice descriptor pop-up', () => { it('Should redirect to the invoiceIn summary from summary pop-up from the invoice descriptor pop-up', () => {
cy.get(selectors.firstRowInvoice).should('be.visible').click(); cy.get(selectors.firstRowInvoice)
cy.containContent(selectors.descriptorTitle, data.invoice); .click()
cy.get(selectors.descriptorOpenSummaryBtn).should('be.visible').click(); .invoke('text')
cy.containContent(selectors.summaryTitle, data.supplier); .then((invoice) => {
cy.get(selectors.SummaryGoToSummaryBtn).should('be.visible').click(); invoice = invoice.trim();
cy.url().should('include', '/invoice-in/1/summary'); cy.get(selectors.descriptorOpenSummaryBtn).click();
cy.containContent(selectors.summaryTitle, data.supplier); cy.get(selectors.summaryGoToSummaryBtn).click();
cy.url().should('match', invoiceInSummaryUrlRegex);
cy.containContent(selectors.descriptorInvoiceInTitle, invoice);
});
}); });
}); });
}); });

View File

@ -1,9 +1,9 @@
describe('Vehicle list', () => { describe('Vehicle list', () => {
const selectors = { const selectors = {
saveFormBtn: 'FormModelPopup_save', saveFormBtn: 'FormModelPopup_save',
descriptorTitle: '[data-cy="vnDescriptor_title"]',
summaryPopupBtn: 'tr:last-child > .q-table--col-auto-width > .q-btn', summaryPopupBtn: 'tr:last-child > .q-table--col-auto-width > .q-btn',
summaryGoToSummaryBtn: '.header > .q-icon', summaryGoToSummaryBtn: '.summaryHeader [data-cy="goToSummaryBtn"]',
summaryHeader: '.summaryHeader > div',
numberPlate: 'tr:last-child > [data-col-field="numberPlate"] > .no-padding', numberPlate: 'tr:last-child > [data-col-field="numberPlate"] > .no-padding',
}; };
@ -18,7 +18,7 @@ describe('Vehicle list', () => {
}; };
const expected = data['Nº Plate'].val; const expected = data['Nº Plate'].val;
const summaryUrl = '/summary'; const summaryUrlRegex = /vehicle\/\d+\/summary/;
beforeEach(() => { beforeEach(() => {
cy.viewport(1920, 1080); cy.viewport(1920, 1080);
@ -37,23 +37,33 @@ describe('Vehicle list', () => {
it('Should add new vehicle', () => { it('Should add new vehicle', () => {
cy.addBtnClick(); cy.addBtnClick();
cy.fillInForm(data); cy.fillInForm(data);
cy.dataCy(selectors.saveFormBtn).should('be.visible').click(); cy.dataCy(selectors.saveFormBtn).click();
cy.checkNotification('Data created'); cy.checkNotification('Data created');
cy.url().should('include', summaryUrl); cy.url().should('match', summaryUrlRegex);
cy.get(selectors.summaryHeader).should('contain', expected); cy.containContent(selectors.descriptorTitle, expected);
}); });
it('should open summary by clicking a vehicle', () => { it('should open summary by clicking a vehicle', () => {
cy.get(selectors.numberPlate).click(); cy.get(selectors.numberPlate)
cy.get(selectors.summaryHeader).should('contain', expected); .click()
cy.url().should('include', summaryUrl); .invoke('text')
.then((numberPlate) => {
numberPlate = numberPlate.trim();
cy.url().should('match', summaryUrlRegex);
cy.containContent(selectors.descriptorTitle, numberPlate);
});
}); });
it('should redirect to vehicle summary when click summary icon on summary pop-up', () => { it('should redirect to vehicle summary when click summary icon on summary pop-up', () => {
cy.get(selectors.summaryPopupBtn).click(); cy.get(selectors.numberPlate)
cy.get(selectors.summaryHeader).should('contain', expected); .invoke('text')
cy.get(selectors.summaryGoToSummaryBtn).click(); .then((numberPlate) => {
cy.url().should('include', summaryUrl); numberPlate = numberPlate.trim();
cy.get(selectors.summaryPopupBtn).click();
cy.get(selectors.summaryGoToSummaryBtn).click();
cy.url().should('match', summaryUrlRegex);
cy.containContent(selectors.descriptorTitle, numberPlate);
});
}); });
}); });

View File

@ -1,37 +1,29 @@
describe('Vehicle summary', () => { describe('Vehicle summary', () => {
const selectors = { const selectors = {
summaryTitle: '.summaryHeader', summaryTitle: '.summaryHeader',
summaryPopUpTitle: '.q-card > .summaryHeader',
descriptorTitle: '.q-item__label--header > .title > span', descriptorTitle: '.q-item__label--header > .title > span',
descriptorPopupTitle: '.q-menu > .descriptor .title',
descriptorOptions: 'descriptor-more-opts',
delete: 'delete',
basicDataSupplierLink: ':nth-child(4) > .value > .link',
summaryAssignedInvoicesLink: '.vn-max > .q-pb-lg > .header-link > .link', summaryAssignedInvoicesLink: '.vn-max > .q-pb-lg > .header-link > .link',
summaryBasicDataLink: '[dense=""] > .q-pb-lg > .header-link > .link', summaryBasicDataLink: '[dense=""] > .q-pb-lg > .header-link > .link',
basicDataSupplierLink: ':nth-child(4) > .value > .link',
assignedInvoicesSupplierLink: 'tbody > :nth-child(1) > :nth-child(2) > .link', assignedInvoicesSupplierLink: 'tbody > :nth-child(1) > :nth-child(2) > .link',
assignedInvoicesInvoiceLink: ':nth-child(1) > :nth-child(3) > .link', assignedInvoicesInvoiceLink: ':nth-child(1) > :nth-child(3) > .link',
supplierDescriptorGoToSummary: descriptorOpenSummaryBtn: '.q-menu > .descriptor [data-cy="openSummaryBtn"]',
'[href="#/supplier/1/summary"] > .q-btn > .q-btn__content > .q-icon', descriptorGoToSummaryBtn: '.q-menu > .descriptor [data-cy="goToSummaryBtn"]',
invoiceDescriptorGoToSummary: summaryGoToSummaryBtn: '.summaryHeader [data-cy="goToSummaryBtn"]',
'[href="#/invoice-in/1/summary"] > .q-btn > .q-btn__content > .q-icon',
descriptorSummaryPopup: '.header > :nth-child(2) > .q-btn__content > .q-icon',
summaryPopupGoToSummary: '.header > .q-icon',
}; };
const data = { const vehiclePlate = '3333-BAT';
vehiclePlate: '3333-BAT', const supplierSummaryUrlRegex = /supplier\/\d+\/summary/;
supplierName: 'PLANTS SL', const invoiceInSummaryUrlRegex = /invoice-in\/\d+\/summary/;
invoice: '1234',
};
beforeEach(() => { beforeEach(() => {
cy.viewport(1920, 1080); cy.viewport(1920, 1080);
cy.login('deliveryAssistant'); cy.login('deliveryAssistant');
cy.visit(`/#/route/vehicle/1/summary`); cy.visit(`/#/route/vehicle/1/summary`);
}); });
it('Should load summary', () => { it('Should load summary', () => {
cy.containContent(selectors.summaryTitle, data.vehiclePlate); cy.containContent(selectors.summaryTitle, vehiclePlate);
cy.containContent(selectors.descriptorTitle, data.vehiclePlate); cy.containContent(selectors.descriptorTitle, vehiclePlate);
}); });
it('Should redirect to vehicle basic-data', () => { it('Should redirect to vehicle basic-data', () => {
@ -46,61 +38,82 @@ describe('Vehicle summary', () => {
describe('Supplier basic data pop-ups', () => { describe('Supplier basic data pop-ups', () => {
it('Should redirect to the supplier summary from the supplier descriptor pop-up', () => { it('Should redirect to the supplier summary from the supplier descriptor pop-up', () => {
cy.get(selectors.basicDataSupplierLink).click(); cy.get(selectors.basicDataSupplierLink)
cy.containContent(selectors.descriptorPopupTitle, data.supplierName); .click()
cy.get(selectors.supplierDescriptorGoToSummary).click(); .invoke('text')
cy.url().should('include', '/supplier/1/summary'); .then((supplierName) => {
cy.containContent(selectors.summaryTitle, data.supplierName); supplierName = supplierName.trim();
cy.get(selectors.descriptorGoToSummaryBtn).click();
cy.url().should('match', supplierSummaryUrlRegex);
cy.containContent(selectors.descriptorTitle, supplierName);
});
}); });
it('Should redirect to the supplier summary from summary pop-up from the supplier descriptor pop-up', () => { it('Should redirect to the supplier summary from summary pop-up from the supplier descriptor pop-up', () => {
cy.get(selectors.basicDataSupplierLink).click(); cy.get(selectors.basicDataSupplierLink)
cy.containContent(selectors.descriptorPopupTitle, data.supplierName); .click()
cy.get(selectors.descriptorSummaryPopup).click(); .invoke('text')
cy.containContent(selectors.summaryPopUpTitle, data.supplierName); .then((supplierName) => {
cy.get(selectors.summaryPopupGoToSummary).click(); supplierName = supplierName.trim();
cy.url().should('include', '/supplier/1/summary'); cy.get(selectors.descriptorOpenSummaryBtn).click();
cy.containContent(selectors.summaryTitle, data.supplierName); cy.get(selectors.summaryGoToSummaryBtn).click();
cy.url().should('match', supplierSummaryUrlRegex);
cy.containContent(selectors.descriptorTitle, supplierName);
});
}); });
}); });
describe('Supplier assigned invoices pop-ups', () => { describe('Supplier assigned invoices pop-ups', () => {
it('Should redirect to the supplier summary from the invoice descriptor pop-up', () => { it('Should redirect to the supplier summary from the invoice descriptor pop-up', () => {
cy.get(selectors.assignedInvoicesSupplierLink).click(); cy.get(selectors.assignedInvoicesSupplierLink)
cy.containContent(selectors.descriptorPopupTitle, data.supplierName); .click()
cy.get(selectors.supplierDescriptorGoToSummary).click(); .invoke('text')
cy.url().should('include', '/supplier/1/summary'); .then((supplierName) => {
cy.containContent(selectors.summaryTitle, data.supplierName); supplierName = supplierName.trim();
cy.get(selectors.descriptorGoToSummaryBtn).click();
cy.url().should('match', supplierSummaryUrlRegex);
cy.containContent(selectors.descriptorTitle, supplierName);
});
}); });
it('Should redirect to the supplier summary from summary pop-up from the supplier descriptor pop-up', () => { it('Should redirect to the supplier summary from summary pop-up from the supplier descriptor pop-up', () => {
cy.get(selectors.assignedInvoicesSupplierLink).click(); cy.get(selectors.assignedInvoicesSupplierLink)
cy.containContent(selectors.descriptorPopupTitle, data.supplierName); .click()
cy.get(selectors.descriptorSummaryPopup).click(); .invoke('text')
cy.containContent(selectors.summaryPopUpTitle, data.supplierName); .then((supplierName) => {
cy.get(selectors.summaryPopupGoToSummary).click(); supplierName = supplierName.trim();
cy.url().should('include', '/supplier/1/summary'); cy.get(selectors.descriptorOpenSummaryBtn).click();
cy.containContent(selectors.summaryTitle, data.supplierName); cy.get(selectors.summaryGoToSummaryBtn).click();
cy.url().should('match', supplierSummaryUrlRegex);
cy.containContent(selectors.descriptorTitle, supplierName);
});
}); });
}); });
describe('Invoice pop-ups', () => { describe('Invoice pop-ups', () => {
it('Should redirect to the invoiceIn summary from the invoice descriptor pop-up', () => { it('Should redirect to the invoiceIn summary from the invoice descriptor pop-up', () => {
cy.get(selectors.assignedInvoicesInvoiceLink).click(); cy.get(selectors.assignedInvoicesInvoiceLink)
cy.containContent(selectors.descriptorPopupTitle, data.invoice); .click()
cy.get(selectors.invoiceDescriptorGoToSummary).click(); .invoke('text')
cy.url().should('include', '/invoice-in/1/summary'); .then((invoice) => {
cy.containContent(selectors.summaryTitle, data.supplierName); invoice = invoice.trim();
cy.get(selectors.descriptorGoToSummaryBtn).click();
cy.url().should('match', invoiceInSummaryUrlRegex);
cy.containContent(selectors.descriptorTitle, invoice);
});
}); });
it('Should redirect to the invoiceIn summary from summary pop-up from the invoice descriptor pop-up', () => { it('Should redirect to the invoiceIn summary from summary pop-up from the invoice descriptor pop-up', () => {
cy.get(selectors.assignedInvoicesInvoiceLink).click(); cy.get(selectors.assignedInvoicesInvoiceLink)
cy.containContent(selectors.descriptorPopupTitle, data.invoice); .click()
cy.get(selectors.descriptorSummaryPopup).click(); .invoke('text')
cy.containContent(selectors.summaryPopUpTitle, data.supplierName); .then((invoice) => {
cy.get(selectors.summaryPopupGoToSummary).click(); invoice = invoice.trim();
cy.url().should('include', '/invoice-in/1/summary'); cy.get(selectors.descriptorOpenSummaryBtn).click();
cy.containContent(selectors.summaryTitle, data.supplierName); cy.get(selectors.summaryGoToSummaryBtn).click();
cy.url().should('match', invoiceInSummaryUrlRegex);
cy.containContent(selectors.descriptorTitle, invoice);
});
}); });
}); });
}); });