test: refs #8422 add test for vehicleDms
gitea/salix-front/pipeline/pr-dev There was a failure building this commit Details

This commit is contained in:
Jose Antonio Tubau 2025-03-05 11:14:20 +01:00
parent c5284e54c7
commit b259988f90
2 changed files with 104 additions and 1 deletions

View File

@ -0,0 +1,103 @@
describe('Vehicle DMS', () => {
const getSelector = (btnPosition) =>
`tr:last-child > .text-right > .no-wrap > :nth-child(${btnPosition}) > .q-btn > .q-btn__content > .q-icon`;
const selectors = {
lastRowDownloadBtn: getSelector(1),
lastRowEditBtn: getSelector(2),
lastRowDeleteBtn: getSelector(3),
lastRowReference: 'tr:last-child > :nth-child(5) > .q-tr > :nth-child(1) > span',
firstRowReference:
'tr:first-child > :nth-child(5) > .q-tr > :nth-child(1) > span',
referenceInput: 'Reference_input',
companySelect: 'Company_select',
warehouseSelect: 'Warehouse_select',
typeSelect: 'Type_select',
fileInput: 'VnDms_inputFile',
importBtn: 'importBtn',
addBtn: 'addDmsBtn',
saveFormBtn: 'FormModelPopup_save',
};
const data = {
Reference: { val: 'Vehicle:1234-ABC' },
Company: { val: 'VNL', type: 'select' },
Warehouse: { val: 'Warehouse One', type: 'select' },
Type: { val: 'Vehiculos', type: 'select' },
};
const updateData = {
Reference: { val: 'Vehicle:5678-DEF' },
Company: { val: 'CCs', type: 'select' },
Warehouse: { val: 'Warehouse Two', type: 'select' },
Type: { val: 'Facturas Recibidas', type: 'select' },
};
beforeEach(() => {
cy.viewport(1920, 1080);
cy.login('developer');
cy.visit(`/#/route/vehicle/1/dms`);
});
it('should display vehicle DMS', () => {
cy.get('.q-table')
.children()
.should('be.visible')
.should('have.length.greaterThan', 0);
});
xit('Should create new DMS', () => {
const filePath = '11.jpg';
cy.dataCy(selectors.addBtn).click();
cy.dataCy(selectors.referenceInput).type(data.Reference.val);
cy.dataCy(selectors.fileInput).type(filePath);
cy.dataCy(selectors.saveFormBtn).click();
});
it('Should import DMS', () => {
const data = {
Document: { val: '1', type: 'select' },
};
cy.dataCy(selectors.importBtn).click();
cy.fillInForm(data);
cy.dataCy(selectors.saveFormBtn).click();
cy.validateContent(selectors.lastRowReference, 'Ticket:11');
});
it('Should edit DMS', () => {
cy.get(selectors.lastRowEditBtn).click();
cy.fillInForm(updateData);
cy.dataCy(selectors.saveFormBtn).click();
cy.validateContent(selectors.lastRowReference, updateData.Reference.val);
});
it('Should download DMS', () => {
const downloadsFolder = Cypress.config('downloadsFolder');
cy.get(selectors.lastRowDownloadBtn).click();
cy.wait(3000);
const fileName = '1.txt';
cy.readFile(`${downloadsFolder}/${fileName}`).should('exist');
});
it('Should delete DMS', () => {
cy.get(selectors.lastRowDeleteBtn).click();
cy.clickConfirm();
cy.validateContent(selectors.firstRowReference, 'Vehicle:3333-BAT');
});
it('Should redirect to worker summary from worker descriptor pop-up', () => {
cy.get(':nth-child(1) > :nth-child(8) > .q-tr > .link').click();
cy.get(
'.q-menu > .descriptor > .body > .q-list > .q-item__label--header > .title > span',
).should('have.text', 'administrativeNick');
cy.get(
'[href="#/worker/5/summary"] > .q-btn > .q-btn__content > .q-icon',
).click();
cy.get('.summaryHeader > div').should(
'have.text',
'5 - administrative administrative',
);
});
});

View File

@ -172,7 +172,7 @@ Cypress.Commands.add('fillInForm', (obj, form = '.q-form > .q-card') => {
cy.get('.q-time .q-time__link').contains(val.x).click();
break;
default:
cy.wrap(el).type(val);
cy.wrap(el).clear().type(val);
break;
}
});