test: refs #8581 enhance command functions
gitea/salix-front/pipeline/pr-dev This commit is unstable Details

This commit is contained in:
Jorge Penadés 2025-03-05 08:47:54 +01:00
parent 527c17a0e3
commit fd810db535
2 changed files with 64 additions and 50 deletions

View File

@ -2,7 +2,7 @@ describe('InvoiceInDescriptor', () => {
describe('more options', () => {
beforeEach(() => cy.login('administrative'));
it.skip('should booking and unbooking the invoice properly', () => {
it('should booking and unbooking the invoice properly', () => {
const checkbox = '[data-cy="vnLvIs booked"] > .q-checkbox';
cy.visit('/#/invoice-in/1/summary');
cy.selectDescriptorOption();
@ -13,21 +13,21 @@ describe('InvoiceInDescriptor', () => {
cy.validateCheckbox(checkbox, false);
});
it.skip('should delete the invoice properly', () => {
it('should delete the invoice properly', () => {
cy.visit('/#/invoice-in/2/summary');
cy.selectDescriptorOption(2);
cy.clickConfirm();
cy.checkNotification('invoice deleted');
});
it.skip('should clone the invoice properly', () => {
it('should clone the invoice properly', () => {
cy.visit('/#/invoice-in/3/summary');
cy.selectDescriptorOption(3);
cy.clickConfirm();
cy.checkNotification('Invoice cloned');
});
it.skip('should show the agricultural PDF properly', () => {
it('should show the agricultural PDF properly', () => {
cy.visit('/#/invoice-in/6/summary');
cy.validatePdfDownload(
/api\/InvoiceIns\/6\/invoice-in-pdf\?access_token=.*/,
@ -35,7 +35,7 @@ describe('InvoiceInDescriptor', () => {
);
});
it.skip('should send the agricultural PDF properly', () => {
it('should send the agricultural PDF properly', () => {
cy.intercept('POST', 'api/InvoiceIns/6/invoice-in-email').as('sendEmail');
cy.visit('/#/invoice-in/6/summary');
cy.selectDescriptorOption(5);
@ -54,7 +54,7 @@ describe('InvoiceInDescriptor', () => {
});
});
it.skip('should download the file properly', () => {
it('should download the file properly', () => {
cy.visit('/#/invoice-in/1/summary');
cy.validateDownload(() => cy.selectDescriptorOption(5));
});
@ -66,17 +66,17 @@ describe('InvoiceInDescriptor', () => {
cy.visit('/#/invoice-in/1/summary');
});
it.skip('should navigate to the supplier summary', () => {
it('should navigate to the supplier summary', () => {
cy.clicDescriptorAction(1);
cy.url().should('to.match', /supplier\/\d+\/summary/);
});
it.skip('should navigate to the entry summary', () => {
it('should navigate to the entry summary', () => {
cy.clicDescriptorAction(2);
cy.url().should('to.match', /entry\/\d+\/summary/);
});
it.skip('should navigate to the invoiceIn list', () => {
it('should navigate to the invoiceIn list', () => {
cy.intercept('GET', /api\/InvoiceIns\/1/).as('getCard');
cy.clicDescriptorAction(3);
cy.wait('@getCard');
@ -84,46 +84,63 @@ describe('InvoiceInDescriptor', () => {
});
});
describe('corrective', () => {
describe.only('corrective', () => {
beforeEach(() => {
cy.login('administrative');
cy.visit('/#/invoice-in/1/summary');
});
it('should create two correcting invoice', () => {
cy.visit(`/#/invoice-in/1/summary`);
corrective();
});
// it('should navigate to the corrected or correcting invoice page', () => {
// cy.visit('/#/invoice-in/1/summary');
// cy.clicDescriptorAction(4);
// cy.url().should('include', '/invoice-in');
// });
it('should create a correcting invoice and redirect to original invoice', () => {
const originalId = 1;
cy.visit(`/#/invoice-in/${originalId}/summary`);
cy.intercept('POST', '/api/InvoiceIns/corrective').as('corrective');
// it('should navigate to invoice-in list filtered by the corrected invoice', () => {
// cy.visit('')
// });
const regex = new RegExp(`InvoiceIns/${originalId}\\?filter=.*`);
cy.intercept('GET', regex).as('getOriginal');
createCorrective({ class: 'R5', type: 'sustitución', reason: 'VAT' });
cy.wait('@corrective').then(({ response }) => {
const correctingId = response.body;
cy.url().should('include', `/invoice-in/${correctingId}/summary`);
cy.visit(`/#/invoice-in/${correctingId}/corrective`);
cy.dataCy('invoiceInCorrective_class').should('contain.value', 'R');
cy.dataCy('invoiceInCorrective_type').should('contain.value', type);
cy.dataCy('invoiceInCorrective_reason').should('contain.value', reason);
});
redirect(originalId);
});
it('should create a correcting invoice and navigate to list filtered by corrective', () => {
const originalId = 1;
cy.visit(`/#/invoice-in/${originalId}/summary`);
const regex = new RegExp(`InvoiceIns/${originalId}\\?filter=.*`);
cy.intercept('GET', regex).as('getOriginal');
createCorrective({ class: 'R3', type: 'diferencias', reason: 'customer' });
redirect(originalId);
cy.clicDescriptorAction(4);
cy.url().should('to.match', /invoice-in\/list\?table=\{.*correctedFk*\}/);
cy.validateVnTableRows({
cols: [
{
name: 'supplierRef',
val: '1234',
operation: 'include',
},
],
});
});
});
});
function corrective() {
cy.intercept('POST', '/api/InvoiceIns/corrective').as('corrective');
function createCorrective(opts = {}) {
const { type, reason, class: classVal } = opts;
cy.selectDescriptorOption(4);
cy.selectOption('[data-cy="invoiceInDescriptorMenu_class"]', 'R5');
cy.selectOption('[data-cy="invoiceInDescriptorMenu_type"]', 'sustitución');
cy.selectOption('[data-cy="invoiceInDescriptorMenu_reason"]', 'VAT');
cy.selectOption('[data-cy="invoiceInDescriptorMenu_class"]', classVal);
cy.selectOption('[data-cy="invoiceInDescriptorMenu_type"]', type);
cy.selectOption('[data-cy="invoiceInDescriptorMenu_reason"]', reason);
cy.dataCy('saveCorrectiveInvoice').click();
cy.wait('@corrective').then(({ response }) => {
const correctingId = response.body;
cy.url().should('include', `/invoice-in/${correctingId}/summary`);
cy.visit(`/#/invoice-in/${correctingId}/corrective`);
cy.dataCy('invoiceInCorrective_type')
.invoke('val')
.then((val) => expect(val).includes('sustitución'));
cy.dataCy('invoiceInCorrective_reason')
.invoke('val')
.then((val) => expect(val).includes('VAT'));
cy.dataCy('invoiceInCorrective_class')
.invoke('val')
.then((val) => expect(val).includes('R5'));
});
}
function redirect(subtitle) {
cy.clicDescriptorAction(4);
cy.wait('@getOriginal');
cy.validateDescriptor({ subtitle });
}

View File

@ -358,12 +358,6 @@ Cypress.Commands.add('openActionsDescriptor', () => {
cy.get('[data-cy="cardDescriptor"] [data-cy="descriptor-more-opts"]').click();
});
Cypress.Commands.add('clickButtonDescriptor', (id) => {
cy.get(`.actions > .q-card__actions> .q-btn:nth-child(${id})`)
.invoke('removeAttr', 'target')
.click();
});
Cypress.Commands.add('openUserPanel', () => {
cy.dataCy('userPanel_btn').click();
});
@ -453,9 +447,10 @@ Cypress.Commands.add('waitRequest', (alias, cb) => {
});
Cypress.Commands.add('validateDescriptor', (toCheck = {}) => {
const { title, listbox = {} } = toCheck;
const { title, subtitle, listbox = {} } = toCheck;
if (title) cy.dataCy('cardDescriptor_title').contains(title);
if (subtitle) cy.dataCy('cardDescriptor_subtitle').contains(subtitle);
for (const index in listbox)
cy.get('[data-cy="cardDescriptor_listbox"] > *')
@ -477,7 +472,9 @@ Cypress.Commands.add('validateVnTableRows', (opts = {}) => {
.invoke('text')
.then((text) => {
if (type === 'string')
expect(text.trim().toLowerCase()).to.equal(val.toLowerCase());
expect(text.trim().toLowerCase()).to[operation](
val.toLowerCase(),
);
if (type === 'number') cy.checkNumber(text, val, operation);
if (type === 'date') cy.checkDate(text, val, operation);
});