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

147 lines
6.2 KiB
JavaScript

describe('Property summary', () => {
const selectors = {
summaryTitle: '.summaryHeader',
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"]',
summaryBasicDataBlock1Link: 'a.link[data-cy="titleBasicDataBlock1"]',
summaryBasicDataBlock2Link: 'a.link[data-cy="titleBasicDataBlock2"]',
summaryBasicDataBlock3Link: 'a.link[data-cy="titleBasicDataBlock3"]',
summaryDmsBlockLink: 'a.link[data-cy="titleDmsBlock"]',
summaryNotesBlockLink: 'a.link[data-cy="titleNotesBlock"]',
summaryPropertyMapLink: 'a.grafana[data-cy="propertyMapLink"]',
dmsFirstRowWorkerLink: '.summaryBody :nth-child(1) > :nth-child(7) .link',
basicDataIcon: 'PropertyBasicData-menu-item',
dmsIcon: 'PropertyDms-menu-item',
notesIcon: 'PropertyNotes-menu-item',
logIcon: 'PropertyLog-menu-item',
notaryLink: '.summaryBody [data-cy="vnLvNotary"] .link',
};
const url = '/#/property/1/summary';
const basicDataUrlRegex = /property\/1\/basic-data/;
const dmsUrlRegex = /property\/1\/dms/;
const notesUrlRegex = /property\/1\/notes/;
const logUrlRegex = /property\/1\/history/;
const workerSummaryUrlRegex = /worker\/\d+\/summary/;
const notarySummaryUrlRegex = /supplier\/\d+\/summary/;
const propertyName = 'Stark Tower';
beforeEach(() => {
cy.viewport(1920, 1080);
cy.login('developer');
cy.visit(url);
});
it('Should load summary', () => {
cy.containContent(selectors.summaryTitle, propertyName);
cy.containContent(selectors.descriptorTitle, propertyName);
});
it('Should redirect to the corresponding section when clicking on the icons in the left menu', () => {
cy.dataCy(selectors.basicDataIcon).click();
cy.location().should('match', basicDataUrlRegex);
cy.visit(url);
cy.dataCy(selectors.dmsIcon).click();
cy.location().should('match', dmsUrlRegex);
cy.visit(url);
cy.dataCy(selectors.notesIcon).click();
cy.location().should('match', notesUrlRegex);
cy.visit(url);
cy.dataCy(selectors.logIcon).click();
cy.location().should('match', logUrlRegex);
});
it('Should redirect to property basic-data when clicking on basic-data title links', () => {
cy.get(selectors.summaryBasicDataBlock1Link).click();
cy.location().should('match', basicDataUrlRegex);
cy.visit(url);
cy.get(selectors.summaryBasicDataBlock2Link).click();
cy.location().should('match', basicDataUrlRegex);
cy.visit(url);
cy.get(selectors.summaryBasicDataBlock3Link).click();
cy.location().should('match', basicDataUrlRegex);
});
it('Should redirect to property DMS when clicking on DMS title', () => {
cy.get(selectors.summaryDmsBlockLink).click();
cy.location().should('match', dmsUrlRegex);
});
it('Should redirect to property notes when clicking on notes title', () => {
cy.get(selectors.summaryNotesBlockLink).click();
cy.location().should('match', notesUrlRegex);
});
it('Should redirect to property map', () => {
cy.get(selectors.summaryPropertyMapLink).invoke('removeAttr', 'target').click();
cy.origin('https://www.marvel.com', () => {
cy.location().should('match', /marvel.com/);
});
});
describe('Notary pop-ups', () => {
it('Should redirect to the notary summary from notary descriptor pop-up', () => {
cy.get(selectors.notaryLink)
.should('be.visible')
.click()
.invoke('text')
.then((notaryName) => {
notaryName = notaryName.trim();
cy.log('Notary name: ', notaryName);
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.notaryLink)
.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);
});
});
});
describe('Worker pop-ups', () => {
it('Should redirect to the worker summary from worker descriptor pop-up', () => {
cy.get(selectors.dmsFirstRowWorkerLink)
.should('be.visible')
.click()
.invoke('text')
.then((workerName) => {
workerName = workerName.trim();
cy.get(selectors.descriptorGoToSummaryBtn).click();
cy.location().should('match', workerSummaryUrlRegex);
cy.containContent(selectors.descriptorTitle, workerName);
});
});
it('Should redirect to the worker summary from summary pop-up from the worker descriptor pop-up', () => {
cy.get(selectors.dmsFirstRowWorkerLink)
.should('be.visible')
.click()
.invoke('text')
.then((workerName) => {
workerName = workerName.trim();
cy.get(selectors.descriptorOpenSummaryBtn).click();
cy.get(selectors.summaryGoToSummaryBtn).click();
cy.location().should('match', workerSummaryUrlRegex);
cy.containContent(selectors.descriptorTitle, workerName);
});
});
});
});