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

View File

@ -1,9 +1,9 @@
describe('Vehicle list', () => {
const selectors = {
saveFormBtn: 'FormModelPopup_save',
descriptorTitle: '[data-cy="vnDescriptor_title"]',
summaryPopupBtn: 'tr:last-child > .q-table--col-auto-width > .q-btn',
summaryGoToSummaryBtn: '.header > .q-icon',
summaryHeader: '.summaryHeader > div',
summaryGoToSummaryBtn: '.summaryHeader [data-cy="goToSummaryBtn"]',
numberPlate: 'tr:last-child > [data-col-field="numberPlate"] > .no-padding',
};
@ -18,7 +18,7 @@ describe('Vehicle list', () => {
};
const expected = data['Nº Plate'].val;
const summaryUrl = '/summary';
const summaryUrlRegex = /vehicle\/\d+\/summary/;
beforeEach(() => {
cy.viewport(1920, 1080);
@ -37,23 +37,33 @@ describe('Vehicle list', () => {
it('Should add new vehicle', () => {
cy.addBtnClick();
cy.fillInForm(data);
cy.dataCy(selectors.saveFormBtn).should('be.visible').click();
cy.dataCy(selectors.saveFormBtn).click();
cy.checkNotification('Data created');
cy.url().should('include', summaryUrl);
cy.get(selectors.summaryHeader).should('contain', expected);
cy.url().should('match', summaryUrlRegex);
cy.containContent(selectors.descriptorTitle, expected);
});
it('should open summary by clicking a vehicle', () => {
cy.get(selectors.numberPlate).click();
cy.get(selectors.summaryHeader).should('contain', expected);
cy.url().should('include', summaryUrl);
cy.get(selectors.numberPlate)
.click()
.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', () => {
cy.get(selectors.summaryPopupBtn).click();
cy.get(selectors.summaryHeader).should('contain', expected);
cy.get(selectors.summaryGoToSummaryBtn).click();
cy.url().should('include', summaryUrl);
cy.get(selectors.numberPlate)
.invoke('text')
.then((numberPlate) => {
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', () => {
const selectors = {
summaryTitle: '.summaryHeader',
summaryPopUpTitle: '.q-card > .summaryHeader',
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',
summaryBasicDataLink: '[dense=""] > .q-pb-lg > .header-link > .link',
basicDataSupplierLink: ':nth-child(4) > .value > .link',
assignedInvoicesSupplierLink: 'tbody > :nth-child(1) > :nth-child(2) > .link',
assignedInvoicesInvoiceLink: ':nth-child(1) > :nth-child(3) > .link',
supplierDescriptorGoToSummary:
'[href="#/supplier/1/summary"] > .q-btn > .q-btn__content > .q-icon',
invoiceDescriptorGoToSummary:
'[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',
descriptorOpenSummaryBtn: '.q-menu > .descriptor [data-cy="openSummaryBtn"]',
descriptorGoToSummaryBtn: '.q-menu > .descriptor [data-cy="goToSummaryBtn"]',
summaryGoToSummaryBtn: '.summaryHeader [data-cy="goToSummaryBtn"]',
};
const data = {
vehiclePlate: '3333-BAT',
supplierName: 'PLANTS SL',
invoice: '1234',
};
const vehiclePlate = '3333-BAT';
const supplierSummaryUrlRegex = /supplier\/\d+\/summary/;
const invoiceInSummaryUrlRegex = /invoice-in\/\d+\/summary/;
beforeEach(() => {
cy.viewport(1920, 1080);
cy.login('deliveryAssistant');
cy.visit(`/#/route/vehicle/1/summary`);
});
it('Should load summary', () => {
cy.containContent(selectors.summaryTitle, data.vehiclePlate);
cy.containContent(selectors.descriptorTitle, data.vehiclePlate);
cy.containContent(selectors.summaryTitle, vehiclePlate);
cy.containContent(selectors.descriptorTitle, vehiclePlate);
});
it('Should redirect to vehicle basic-data', () => {
@ -46,61 +38,82 @@ describe('Vehicle summary', () => {
describe('Supplier basic data pop-ups', () => {
it('Should redirect to the supplier summary from the supplier descriptor pop-up', () => {
cy.get(selectors.basicDataSupplierLink).click();
cy.containContent(selectors.descriptorPopupTitle, data.supplierName);
cy.get(selectors.supplierDescriptorGoToSummary).click();
cy.url().should('include', '/supplier/1/summary');
cy.containContent(selectors.summaryTitle, data.supplierName);
cy.get(selectors.basicDataSupplierLink)
.click()
.invoke('text')
.then((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', () => {
cy.get(selectors.basicDataSupplierLink).click();
cy.containContent(selectors.descriptorPopupTitle, data.supplierName);
cy.get(selectors.descriptorSummaryPopup).click();
cy.containContent(selectors.summaryPopUpTitle, data.supplierName);
cy.get(selectors.summaryPopupGoToSummary).click();
cy.url().should('include', '/supplier/1/summary');
cy.containContent(selectors.summaryTitle, data.supplierName);
cy.get(selectors.basicDataSupplierLink)
.click()
.invoke('text')
.then((supplierName) => {
supplierName = supplierName.trim();
cy.get(selectors.descriptorOpenSummaryBtn).click();
cy.get(selectors.summaryGoToSummaryBtn).click();
cy.url().should('match', supplierSummaryUrlRegex);
cy.containContent(selectors.descriptorTitle, supplierName);
});
});
});
describe('Supplier assigned invoices pop-ups', () => {
it('Should redirect to the supplier summary from the invoice descriptor pop-up', () => {
cy.get(selectors.assignedInvoicesSupplierLink).click();
cy.containContent(selectors.descriptorPopupTitle, data.supplierName);
cy.get(selectors.supplierDescriptorGoToSummary).click();
cy.url().should('include', '/supplier/1/summary');
cy.containContent(selectors.summaryTitle, data.supplierName);
cy.get(selectors.assignedInvoicesSupplierLink)
.click()
.invoke('text')
.then((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', () => {
cy.get(selectors.assignedInvoicesSupplierLink).click();
cy.containContent(selectors.descriptorPopupTitle, data.supplierName);
cy.get(selectors.descriptorSummaryPopup).click();
cy.containContent(selectors.summaryPopUpTitle, data.supplierName);
cy.get(selectors.summaryPopupGoToSummary).click();
cy.url().should('include', '/supplier/1/summary');
cy.containContent(selectors.summaryTitle, data.supplierName);
cy.get(selectors.assignedInvoicesSupplierLink)
.click()
.invoke('text')
.then((supplierName) => {
supplierName = supplierName.trim();
cy.get(selectors.descriptorOpenSummaryBtn).click();
cy.get(selectors.summaryGoToSummaryBtn).click();
cy.url().should('match', supplierSummaryUrlRegex);
cy.containContent(selectors.descriptorTitle, supplierName);
});
});
});
describe('Invoice pop-ups', () => {
it('Should redirect to the invoiceIn summary from the invoice descriptor pop-up', () => {
cy.get(selectors.assignedInvoicesInvoiceLink).click();
cy.containContent(selectors.descriptorPopupTitle, data.invoice);
cy.get(selectors.invoiceDescriptorGoToSummary).click();
cy.url().should('include', '/invoice-in/1/summary');
cy.containContent(selectors.summaryTitle, data.supplierName);
cy.get(selectors.assignedInvoicesInvoiceLink)
.click()
.invoke('text')
.then((invoice) => {
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', () => {
cy.get(selectors.assignedInvoicesInvoiceLink).click();
cy.containContent(selectors.descriptorPopupTitle, data.invoice);
cy.get(selectors.descriptorSummaryPopup).click();
cy.containContent(selectors.summaryPopUpTitle, data.supplierName);
cy.get(selectors.summaryPopupGoToSummary).click();
cy.url().should('include', '/invoice-in/1/summary');
cy.containContent(selectors.summaryTitle, data.supplierName);
cy.get(selectors.assignedInvoicesInvoiceLink)
.click()
.invoke('text')
.then((invoice) => {
invoice = invoice.trim();
cy.get(selectors.descriptorOpenSummaryBtn).click();
cy.get(selectors.summaryGoToSummaryBtn).click();
cy.url().should('match', invoiceInSummaryUrlRegex);
cy.containContent(selectors.descriptorTitle, invoice);
});
});
});
});