feat: refs #8581 add checkQueryParams command to validate URL query parameters
gitea/salix-front/pipeline/pr-dev There was a failure building this commit
Details
gitea/salix-front/pipeline/pr-dev There was a failure building this commit
Details
This commit is contained in:
parent
7b4b5c892a
commit
9b04fc3bc8
|
@ -84,39 +84,33 @@ describe('InvoiceInDescriptor', () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe.only('corrective', () => {
|
||||
describe('corrective', () => {
|
||||
const originalId = 1;
|
||||
|
||||
beforeEach(() => {
|
||||
cy.login('administrative');
|
||||
});
|
||||
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');
|
||||
});
|
||||
|
||||
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);
|
||||
it('should create a correcting invoice and redirect to original invoice', () => {
|
||||
createCorrective(originalId, {
|
||||
class: 'R5',
|
||||
type: 'sustitución',
|
||||
reason: 'VAT',
|
||||
});
|
||||
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' });
|
||||
|
||||
createCorrective(originalId, {
|
||||
class: 'R3',
|
||||
type: 'diferencias',
|
||||
reason: 'customer',
|
||||
});
|
||||
redirect(originalId);
|
||||
|
||||
cy.clicDescriptorAction(4);
|
||||
cy.url().should('to.match', /invoice-in\/list\?table=\{.*correctedFk*\}/);
|
||||
cy.checkQueryParams({ table: { subkey: 'correctedFk', val: originalId } });
|
||||
cy.validateVnTableRows({
|
||||
cols: [
|
||||
{
|
||||
|
@ -130,13 +124,26 @@ describe('InvoiceInDescriptor', () => {
|
|||
});
|
||||
});
|
||||
|
||||
function createCorrective(opts = {}) {
|
||||
function createCorrective(originalId, opts = {}) {
|
||||
const regex = new RegExp(`InvoiceIns/${originalId}\\?filter=.*`);
|
||||
cy.intercept('POST', '/api/InvoiceIns/corrective').as('corrective');
|
||||
cy.intercept('GET', regex).as('getOriginal');
|
||||
const { type, reason, class: classVal } = opts;
|
||||
|
||||
cy.selectDescriptorOption(4);
|
||||
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_class').should('contain.value', classVal);
|
||||
cy.dataCy('invoiceInCorrective_type').should('contain.value', type);
|
||||
cy.dataCy('invoiceInCorrective_reason').should('contain.value', reason);
|
||||
});
|
||||
}
|
||||
|
||||
function redirect(subtitle) {
|
||||
|
|
|
@ -563,3 +563,19 @@ Cypress.Commands.add('validatePdfDownload', (match, trigger) => {
|
|||
Cypress.Commands.add('clicDescriptorAction', (index = 1) => {
|
||||
cy.get(`[data-cy="descriptor_actions"] .q-btn:nth-of-type(${index})`).click();
|
||||
});
|
||||
|
||||
Cypress.Commands.add('checkQueryParams', (expectedParams = {}) => {
|
||||
cy.url().then((url) => {
|
||||
const urlParams = new URLSearchParams(url.split('?')[1]);
|
||||
|
||||
for (const key in expectedParams) {
|
||||
const expected = expectedParams[key];
|
||||
const param = JSON.parse(decodeURIComponent(urlParams.get(key)));
|
||||
|
||||
if (typeof expected === 'object') {
|
||||
const { subkey, val } = expected;
|
||||
expect(param[subkey]).to.equal(val);
|
||||
} else expect(param).to.equal(expected);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue