Compare commits

...

1 Commits

Author SHA1 Message Date
Alex Moreno 5ebdf55a07 test: refs #8767 try invoiceInDescriptor download 2025-04-08 12:57:41 +02:00
4 changed files with 152 additions and 131 deletions

View File

@ -3,16 +3,17 @@ import { defineConfig } from 'cypress';
let urlHost, reporter, reporterOptions, timeouts; let urlHost, reporter, reporterOptions, timeouts;
if (process.env.CI) { if (process.env.CI) {
console.log('Running in CI environment');
urlHost = 'front'; urlHost = 'front';
reporter = 'junit'; reporter = 'junit';
reporterOptions = { reporterOptions = {
mochaFile: 'junit/e2e-[hash].xml', mochaFile: 'junit/e2e-[hash].xml',
}; };
timeouts = { timeouts = {
defaultCommandTimeout: 30000, defaultCommandTimeout: 3000,
requestTimeout: 30000, requestTimeout: 3000,
responseTimeout: 60000, responseTimeout: 6000,
pageLoadTimeout: 60000, pageLoadTimeout: 6000,
}; };
} else { } else {
urlHost = 'localhost'; urlHost = 'localhost';

View File

@ -1,20 +1,8 @@
#!/bin/bash #!/bin/bash
echo $2
if [ -z "$2" ]; then
TEST_DIRS=$(find 'test/cypress/integration' -mindepth 1 -maxdepth 1 -type d)
else
TEST_DIRS=$2
fi
echo $TEST_DIRS x$1
echo "$TEST_DIRS" | xargs -P "$1" -I {} sh -c '
echo "🔷 {}" &&
xvfb-run -a cypress run \ xvfb-run -a cypress run \
--headless \ --headless \
--spec "{}" \ --spec "test/cypress/integration/invoiceIn/invoiceInDescriptor.spec.js"
--quiet \
> /dev/null
'
wait wait

View File

@ -2,124 +2,127 @@ describe('InvoiceInDescriptor', () => {
beforeEach(() => cy.login('administrative')); beforeEach(() => cy.login('administrative'));
describe('more options', () => { describe('more options', () => {
it('should booking and unbooking the invoice properly', () => { // it('should booking and unbooking the invoice properly', () => {
const checkbox = '[data-cy="vnLvIs booked"] > .q-checkbox'; // const checkbox = '[data-cy="vnLvIs booked"] > .q-checkbox';
cy.visit('/#/invoice-in/2/summary'); // cy.visit('/#/invoice-in/2/summary');
cy.selectDescriptorOption(); // cy.selectDescriptorOption();
cy.dataCy('VnConfirm_confirm').click(); // cy.dataCy('VnConfirm_confirm').click();
cy.validateCheckbox(checkbox); // cy.validateCheckbox(checkbox);
cy.selectDescriptorOption(); // cy.selectDescriptorOption();
cy.dataCy('VnConfirm_confirm').click(); // cy.dataCy('VnConfirm_confirm').click();
cy.validateCheckbox(checkbox, false); // cy.validateCheckbox(checkbox, false);
}); // });
it('should delete the invoice properly', () => { // it('should delete the invoice properly', () => {
cy.visit('/#/invoice-in/2/summary'); // cy.visit('/#/invoice-in/2/summary');
cy.selectDescriptorOption(2); // cy.selectDescriptorOption(2);
cy.clickConfirm(); // cy.clickConfirm();
cy.checkNotification('invoice deleted'); // cy.checkNotification('invoice deleted');
}); // });
it('should clone the invoice properly', () => { // it('should clone the invoice properly', () => {
cy.visit('/#/invoice-in/3/summary'); // cy.visit('/#/invoice-in/3/summary');
cy.selectDescriptorOption(3); // cy.selectDescriptorOption(3);
cy.clickConfirm(); // cy.clickConfirm();
cy.checkNotification('Invoice cloned'); // cy.checkNotification('Invoice cloned');
}); // });
it('should show the agricultural PDF properly', () => { // it('should show the agricultural PDF properly', () => {
cy.visit('/#/invoice-in/6/summary'); // cy.visit('/#/invoice-in/6/summary');
cy.validatePdfDownload( // cy.validatePdfDownload(
/api\/InvoiceIns\/6\/invoice-in-pdf\?access_token=.*/, // /api\/InvoiceIns\/6\/invoice-in-pdf\?access_token=.*/,
() => cy.selectDescriptorOption(4), // () => cy.selectDescriptorOption(4),
); // );
}); // });
it('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.intercept('POST', 'api/InvoiceIns/6/invoice-in-email').as('sendEmail');
cy.visit('/#/invoice-in/6/summary'); // cy.visit('/#/invoice-in/6/summary');
cy.selectDescriptorOption(5); // cy.selectDescriptorOption(5);
cy.dataCy('SendEmailNotificationDialogInput_input').type( // cy.dataCy('SendEmailNotificationDialogInput_input').type(
'{selectall}jorgito@gmail.mx', // '{selectall}jorgito@gmail.mx',
); // );
cy.clickConfirm(); // cy.clickConfirm();
cy.checkNotification('Notification sent'); // cy.checkNotification('Notification sent');
cy.wait('@sendEmail').then(({ request, response }) => { // cy.wait('@sendEmail').then(({ request, response }) => {
expect(request.body).to.deep.equal({ // expect(request.body).to.deep.equal({
recipientId: 2, // recipientId: 2,
recipient: 'jorgito@gmail.mx', // recipient: 'jorgito@gmail.mx',
}); // });
expect(response.statusCode).to.equal(200); // expect(response.statusCode).to.equal(200);
}); // });
}); // });
// https://redmine.verdnatura.es/issues/8767 it('should download the file properly', () => {
it.skip('should download the file properly', () => {
cy.visit('/#/invoice-in/1/summary'); cy.visit('/#/invoice-in/1/summary');
cy.validateDownload(() => cy.selectDescriptorOption(5)); cy.validateDownload(() => cy.selectDescriptorOption(5));
}); });
}); it('should download the file properly 2', () => {
describe('buttons', () => {
beforeEach(() => cy.visit('/#/invoice-in/1/summary'));
it('should navigate to the supplier summary', () => {
cy.clicDescriptorAction(1);
cy.url().should('to.match', /supplier\/\d+\/summary/);
});
it('should navigate to the entry summary', () => {
cy.clicDescriptorAction(2);
cy.url().should('to.match', /entry\/\d+\/summary/);
});
it('should navigate to the invoiceIn list', () => {
cy.clicDescriptorAction(3);
cy.url().should('to.match', /invoice-in\/list\?table=\{.*supplierFk.+\}/);
});
});
describe('corrective', () => {
const originalId = 4;
beforeEach(() => cy.visit(`/#/invoice-in/${originalId}/summary`));
it('should create a correcting invoice and redirect to original invoice', () => {
createCorrective();
redirect(originalId);
});
it('should create a correcting invoice and navigate to list filtered by corrective', () => {
createCorrective();
redirect(originalId);
cy.clicDescriptorAction(4);
cy.validateVnTableRows({
cols: [
{
name: 'supplierRef',
val: '1237',
operation: 'include',
},
],
});
});
});
describe('link', () => {
it('should open the supplier descriptor popup', () => {
cy.visit('/#/invoice-in/1/summary'); cy.visit('/#/invoice-in/1/summary');
cy.intercept('GET', /Suppliers\/\d+/).as('getSupplier'); cy.validateDownloadDos(() => cy.selectDescriptorOption(5));
cy.dataCy('invoiceInDescriptor_supplier').then(($el) => {
const alias = $el.text().trim();
$el.click();
cy.wait('@getSupplier').then(() =>
cy.validateDescriptor({ listbox: { 1: alias }, popup: true }),
);
});
}); });
}); });
// describe('buttons', () => {
// beforeEach(() => cy.visit('/#/invoice-in/1/summary'));
// it('should navigate to the supplier summary', () => {
// cy.clicDescriptorAction(1);
// cy.url().should('to.match', /supplier\/\d+\/summary/);
// });
// it('should navigate to the entry summary', () => {
// cy.clicDescriptorAction(2);
// cy.url().should('to.match', /entry\/\d+\/summary/);
// });
// it('should navigate to the invoiceIn list', () => {
// cy.clicDescriptorAction(3);
// cy.url().should('to.match', /invoice-in\/list\?table=\{.*supplierFk.+\}/);
// });
// });
// describe('corrective', () => {
// const originalId = 4;
// beforeEach(() => cy.visit(`/#/invoice-in/${originalId}/summary`));
// it('should create a correcting invoice and redirect to original invoice', () => {
// createCorrective();
// redirect(originalId);
// });
// it('should create a correcting invoice and navigate to list filtered by corrective', () => {
// createCorrective();
// redirect(originalId);
// cy.clicDescriptorAction(4);
// cy.validateVnTableRows({
// cols: [
// {
// name: 'supplierRef',
// val: '1237',
// operation: 'include',
// },
// ],
// });
// });
// });
// describe('link', () => {
// it('should open the supplier descriptor popup', () => {
// cy.visit('/#/invoice-in/1/summary');
// cy.intercept('GET', /Suppliers\/\d+/).as('getSupplier');
// cy.dataCy('invoiceInDescriptor_supplier').then(($el) => {
// const alias = $el.text().trim();
// $el.click();
// cy.wait('@getSupplier').then(() =>
// cy.validateDescriptor({ listbox: { 1: alias }, popup: true }),
// );
// });
// });
// });
}); });
function createCorrective() { function createCorrective() {

View File

@ -556,14 +556,43 @@ Cypress.Commands.add('validateDownload', (trigger, opts = {}) => {
types = ['text/plain', 'image/jpeg'], types = ['text/plain', 'image/jpeg'],
alias = 'download', alias = 'download',
} = opts; } = opts;
cy.log(url);
cy.intercept('GET', url).as(alias); cy.intercept('GET', url).as(alias);
trigger().then(() => { trigger().then(() => {
cy.wait(`@${alias}`).then(({ response }) => { // cy.wait(`@prueba`).then((interception) => {
expect(response.statusCode).to.equal(200); // cy.log(JSON.stringify(interception.request));
const isValidType = types.some((type) => cy.wait(`@${alias}`).then((interception) => {
response.headers['content-type'].includes(type), // cy.log(JSON.stringify(interception.request));
); const parsed = new URL(interception.request.url);
expect(isValidType).to.be.true; const pathAndQuery = parsed.pathname + parsed.search;
cy.log(pathAndQuery);
cy.request('GET', pathAndQuery).then(({ response }) => {
// expect(response.status).to.equal(expectedStatus);
// console.log('response: ', response);
// expect(response.headers['content-type']).to.be.oneOf(expectedTypes);
});
});
});
});
Cypress.Commands.add('validateDownloadDos', (trigger, opts = {}) => {
const {
url = /api\/dms\/\d+\/downloadFile\?access_token=.+/,
types = ['text/plain', 'image/jpeg'],
alias = 'download',
} = opts;
cy.log(url);
cy.intercept('GET', url).as(alias);
trigger().then(() => {
// cy.wait(`@prueba`).then((interception) => {
// cy.log(JSON.stringify(interception.request));
cy.wait(`@${alias}`).then((interception) => {
cy.request('GET', interception.request.url).then(({ response }) => {
// expect(response.status).to.equal(expectedStatus);
// console.log('response: ', response);
// expect(response.headers['content-type']).to.be.oneOf(expectedTypes);
});
}); });
}); });
}); });