salix-front/test/cypress/integration/property/propertyList.spec.js

103 lines
3.9 KiB
JavaScript

describe('Property list', () => {
const selectors = {
firstRow: 'tr:first-child > [data-col-field="name"]',
firstRowNotaryLink: 'tr:first-child > [data-col-field="notary"] > .no-padding > .link',
descriptorTitle: '[data-cy="vnDescriptor_title"]',
notaryDescriptorTitle: '[data-cy="vnDescriptor_description"]',
descriptorOpenSummaryBtn: '.q-menu > .descriptor [data-cy="openSummaryBtn"]',
descriptorGoToSummaryBtn: '.q-menu > .descriptor [data-cy="goToSummaryBtn"]',
summaryGoToSummaryBtn: '.summaryHeader [data-cy="goToSummaryBtn"]',
};
const summaryUrlRegex = /property\/\d+\/summary/;
const notarySummaryUrlRegex = /supplier\/\d+\/summary/;
const data = {
Name: { val: 'Palacio de Asgard' },
Notary: { val: 'VNL', type: 'select' },
'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(() => {
cy.viewport(1920, 1080);
cy.login('developer');
cy.visit('/#/property/list');
cy.typeSearchbar('{enter}');
});
it('Should list properties', () => {
cy.get('.q-table')
.children()
.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()
.invoke('text')
.then((name) => {
name = name.trim();
cy.location().should('match', summaryUrlRegex);
cy.containContent(selectors.descriptorTitle, name);
});
});
it('Should create new property', () => {
cy.addBtnClick();
cy.fillInForm(data);
cy.dataCy('FormModelPopup_save').should('be.visible').click();
cy.checkNotification('Data created');
cy.location().should('match', summaryUrlRegex);
cy.containContent(selectors.descriptorTitle, data.Name.val);
});
describe('Notary pop-ups', () => {
it('Should redirect to the notary summary from notary descriptor pop-up', () => {
cy.get(selectors.firstRowNotaryLink)
.should('be.visible')
.click()
.invoke('text')
.then((notaryName) => {
notaryName = notaryName.trim();
cy.get(selectors.descriptorGoToSummaryBtn).click();
cy.location().should('match', notarySummaryUrlRegex);
cy.containContent(selectors.notaryDescriptorTitle, notaryName);
});
});
it('Should redirect to the notary summary from summary pop-up from the notary descriptor pop-up', () => {
cy.get(selectors.firstRowNotaryLink)
.should('be.visible')
.click()
.invoke('text')
.then((notaryName) => {
notaryName = notaryName.trim();
cy.get(selectors.descriptorOpenSummaryBtn).click();
cy.get(selectors.summaryGoToSummaryBtn).click();
cy.location().should('match', notarySummaryUrlRegex);
cy.containContent(selectors.notaryDescriptorTitle, notaryName);
});
});
});
});