test: refs #6683 add Cypress integration tests for property DMS, list, and notes
gitea/salix-front/pipeline/pr-dev This commit is unstable Details

This commit is contained in:
Jose Antonio Tubau 2025-04-02 14:14:07 +02:00
parent 5690ab7ce1
commit 46826b6b95
3 changed files with 174 additions and 1 deletions

View File

@ -0,0 +1,108 @@
describe('Property DMS', () => {
const getBtnSelector = (btnPosition) =>
`tr:last-child > .text-right > .no-wrap > :nth-child(${btnPosition}) > .q-btn > .q-btn__content > .q-icon`;
const selectors = {
lastRowDownloadBtn: getBtnSelector(1),
lastRowEditBtn: getBtnSelector(2),
lastRowDeleteBtn: getBtnSelector(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',
firstRowId: 'tr:first-child > :nth-child(2) > .q-tr > :nth-child(1) > span',
lastRowWorkerLink: 'tr:last-child > :nth-child(8) > .q-tr > .link',
descriptorTitle: '.descriptor .title',
descriptorGoToSummaryBtn: '.q-menu .descriptor [data-cy="goToSummaryBtn"]',
summaryTitle: '.summaryHeader',
referenceInput: 'Reference_input',
companySelect: 'Company_select',
warehouseSelect: 'Warehouse_select',
typeSelect: 'Type_select',
fileInput: 'VnDms_inputFile',
importBtn: 'importBtn',
addBtn: 'addButton',
saveFormBtn: 'FormModelPopup_save',
};
const data = {
Reference: { val: 'Property:Peter Parker' },
Company: { val: 'VNL', type: 'select' },
Warehouse: { val: 'Warehouse One', type: 'select' },
Type: { val: 'Copia simple', type: 'select' },
};
const updateData = {
Reference: { val: 'Property:Peter Parker House' },
Company: { val: 'CCs', type: 'select' },
Warehouse: { val: 'Warehouse Two', type: 'select' },
Type: { val: 'Escritura original', type: 'select' },
};
beforeEach(() => {
cy.viewport(1920, 1080);
cy.login('developer');
cy.visit(`/#/property/1/dms`);
});
it('should display vehicle DMS', () => {
cy.get('.q-table')
.children()
.should('be.visible')
.should('have.length.greaterThan', 0);
});
it('Should create new DMS', () => {
const uploadFolder = Cypress.config('tmpUploadFolder');
cy.dataCy(selectors.addBtn).click();
cy.fillInForm(data);
cy.dataCy(selectors.fileInput).selectFile('test/cypress/fixtures/image.jpg', {
force: true,
});
cy.dataCy(selectors.saveFormBtn).click();
const fileName = 'image.jpg';
cy.readFile(`${uploadFolder}/${fileName}`).should('exist');
cy.checkNotification('Data saved');
});
it('Should import DMS', () => {
const data = {
Document: { val: '10', type: 'select' },
};
cy.dataCy(selectors.importBtn).click();
cy.fillInForm(data);
cy.dataCy(selectors.saveFormBtn).click();
cy.checkNotification('Data saved');
cy.validateContent(selectors.lastRowReference, '1');
});
it('Should edit DMS', () => {
cy.get(selectors.lastRowEditBtn).click();
cy.fillInForm(updateData);
cy.dataCy(selectors.saveFormBtn).click();
cy.checkNotification('Data saved');
cy.validateContent(selectors.lastRowReference, updateData.Reference.val);
});
it('Should delete DMS', () => {
cy.get(selectors.lastRowDeleteBtn).click();
cy.clickConfirm();
cy.checkNotification('Data deleted');
cy.validateContent(selectors.lastRowReference, data.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 redirect to worker summary from worker descriptor pop-up', () => {
cy.get(selectors.lastRowWorkerLink).click();
cy.get(selectors.descriptorTitle).should('contain', 'administrative');
cy.get(selectors.descriptorGoToSummaryBtn).click();
cy.containContent(selectors.summaryTitle, 'administrative');
});
});

View File

@ -1,6 +1,30 @@
describe('Property list', () => {
const selectors = {
table: 'propertyListTable',
firstRow: 'tr:first-child > [data-col-field="name"]',
summaryTitle: '.summaryHeader',
};
const data = {
Name: { val: 'Palacio de Asgard' },
'Notarial protocol': { val: '1291/2025' },
Owner: { val: 'VNL', type: 'select' },
Group: { val: 'Cotes', type: 'select' },
Map: { val: 'http://www.google.com' },
Value: { val: 150000 },
'Purchase date': { val: '01-01-2001', type: 'date' },
'Booked date': { val: '01-01-2002', type: 'date' },
Cadaster: { val: 'REF-123-456' },
'Small holding': { val: 195 },
Area: { val: 3 },
Allocation: { val: 'COTES' },
Town: { val: 'Alzira', type: 'select' },
m2: { val: 120000 },
Registry: { val: 'Asgard' },
Tome: { val: 1 },
Book: { val: 1 },
Page: { val: 1 },
Farm: { val: 1 },
Registration: { val: 2 },
};
beforeEach(() => {
@ -16,4 +40,19 @@ describe('Property list', () => {
.should('be.visible')
.should('have.length.greaterThan', 0);
});
it('Should redirect to the property summary when clicking the row', () => {
cy.get(selectors.firstRow).should('be.visible').click();
cy.url().should('match', /property\/\d+\/summary/);
cy.containContent(selectors.summaryTitle, 'Stark Tower');
});
it('Should create new property', () => {
cy.addBtnClick();
cy.fillInForm(data);
cy.dataCy('FormModelPopup_save').should('be.visible').click();
cy.checkNotification('Data created');
cy.url().should('match', /property\/\d+\/summary/);
cy.containContent(selectors.summaryTitle, data.Name.val);
});
});

View File

@ -0,0 +1,26 @@
describe('Property notes', () => {
const selectors = {
addNoteInput: 'Add note here..._input',
saveNoteBtn: 'saveNote',
noteCard: '.column.full-width > :nth-child(1) > .q-card__section--vert',
};
const newNoteText = 'Cristal ventana salon roto';
beforeEach(() => {
cy.viewport(1280, 720);
cy.login('developer');
cy.visit('#/property/1/notes');
});
it('Should show the property notes', () => {
cy.get(selectors.noteCard)
.first()
.should('contain', 'Golpe en la puerta de entrada');
});
it('Should add a new note', () => {
cy.dataCy(selectors.addNoteInput).should('be.visible').type(newNoteText);
cy.dataCy(selectors.saveNoteBtn).click();
cy.get(selectors.noteCard).last().should('contain', newNoteText);
});
});