155 lines
6.2 KiB
JavaScript
155 lines
6.2 KiB
JavaScript
describe('InvoiceInSummary', () => {
|
|
const url = '/#/invoice-in/1/summary';
|
|
|
|
const selectors = {
|
|
supplierLink: '[data-cy="invoiceInSummary_supplier"]',
|
|
vehicleLink: '[data-cy="invoiceInSummary_vehicle"]',
|
|
descriptorOpenSummaryBtn: '.q-menu .descriptor [data-cy="openSummaryBtn"]',
|
|
descriptorGoToSummaryBtn: '.q-menu .descriptor [data-cy="goToSummaryBtn"]',
|
|
summaryGoToSummaryBtn: '.summaryHeader [data-cy="goToSummaryBtn"]',
|
|
supplierDescriptorTitle: '[data-cy="vnDescriptor_description"]',
|
|
vehicleDescriptorTitle: '[data-cy="vnDescriptor_title"]',
|
|
};
|
|
|
|
const sectionSelectors = {
|
|
basicDataIcon: 'InvoiceInBasicData-menu-item',
|
|
vatIcon: 'InvoiceInVat-menu-item',
|
|
dueDayIcon: 'InvoiceInDueDay-menu-item',
|
|
intrastatIcon: 'InvoiceInIntrastat-menu-item',
|
|
vehicleIcon: 'InvoiceInVehicle-menu-item',
|
|
logIcon: 'InvoiceInLog-menu-item',
|
|
};
|
|
|
|
const titlesLinks = {
|
|
basicData: '[data-cy="basicDataTitleLink"].link',
|
|
vat: '[data-cy="vatTitleLink"].link',
|
|
dueDay: '[data-cy="dueDayTitleLink"].link',
|
|
intrastat: '[data-cy="intrastatTitleLink"].link',
|
|
vehicle: '[data-cy="vehicleTitleLink"].link',
|
|
};
|
|
|
|
const basePath = 'invoice-in/1/';
|
|
const sectionRegex = {
|
|
basicData: new RegExp(`${basePath}basic-data`),
|
|
vat: new RegExp(`${basePath}vat`),
|
|
dueDay: new RegExp(`${basePath}due-day`),
|
|
intrastat: new RegExp(`${basePath}intrastat`),
|
|
vehicle: new RegExp(`${basePath}vehicle`),
|
|
log: new RegExp(`${basePath}log`),
|
|
};
|
|
|
|
const supplierSummaryUrlRegex = /supplier\/\d+\/summary/;
|
|
const vehicleSummaryUrlRegex = /vehicle\/\d+\/summary/;
|
|
beforeEach(() => {
|
|
cy.login('administrative');
|
|
cy.visit(url);
|
|
});
|
|
|
|
it('Should redirect to the corresponding section when clicking on the icons in the left menu', () => {
|
|
cy.dataCy(sectionSelectors.basicDataIcon).click();
|
|
cy.location().should('match', sectionRegex.basicData);
|
|
|
|
cy.visit(url);
|
|
cy.dataCy(sectionSelectors.vatIcon).click();
|
|
cy.location().should('match', sectionRegex.vat);
|
|
|
|
cy.visit(url);
|
|
cy.dataCy(sectionSelectors.dueDayIcon).click();
|
|
cy.location().should('match', sectionRegex.dueDay);
|
|
|
|
cy.visit(url);
|
|
cy.dataCy(sectionSelectors.intrastatIcon).click();
|
|
cy.location().should('match', sectionRegex.intrastat);
|
|
|
|
cy.visit(url);
|
|
cy.dataCy(sectionSelectors.vehicleIcon).click();
|
|
cy.location().should('match', sectionRegex.vehicle);
|
|
|
|
cy.visit(url);
|
|
cy.dataCy(sectionSelectors.logIcon).click();
|
|
cy.location().should('match', sectionRegex.log);
|
|
});
|
|
|
|
describe('Title links redirections', () => {
|
|
it('Should redirect to invoiceIn basic-data when clicking on basic-data title link', () => {
|
|
cy.get(titlesLinks.basicData).click();
|
|
cy.location().should('match', sectionRegex.basicData);
|
|
});
|
|
|
|
it('Should redirect to invoiceIn vat when clicking on vat title link', () => {
|
|
cy.get(titlesLinks.vat).click();
|
|
cy.location().should('match', sectionRegex.vat);
|
|
});
|
|
|
|
it('Should redirect to invoiceIn due-day when clicking on due-day title link', () => {
|
|
cy.get(titlesLinks.dueDay).click();
|
|
cy.location().should('match', sectionRegex.dueDay);
|
|
});
|
|
|
|
it('Should redirect to invoiceIn intrastat when clicking on intrastat title link', () => {
|
|
cy.get(titlesLinks.intrastat).click();
|
|
cy.location().should('match', sectionRegex.intrastat);
|
|
});
|
|
|
|
it('Should redirect to invoiceIn vehicle when clicking on vehicle title link', () => {
|
|
cy.get(titlesLinks.vehicle).click();
|
|
cy.location().should('match', sectionRegex.vehicle);
|
|
});
|
|
});
|
|
|
|
it('should booking and unbooking the invoice properly', () => {
|
|
const checkbox = '[data-cy="vnLvIs booked"] > .q-checkbox';
|
|
cy.dataCy('invoiceInSummary_book').click();
|
|
cy.dataCy('VnConfirm_confirm').click();
|
|
cy.validateCheckbox(checkbox);
|
|
cy.selectDescriptorOption();
|
|
cy.dataCy('VnConfirm_confirm').click();
|
|
});
|
|
|
|
describe('Supplier pop-ups', () => {
|
|
it('Should redirect to the supplier summary from the supplier descriptor pop-up', () => {
|
|
cy.checkRedirectionFromPopUp({
|
|
selectorToClick: selectors.supplierLink,
|
|
steps: [selectors.descriptorGoToSummaryBtn],
|
|
expectedUrlRegex: supplierSummaryUrlRegex,
|
|
expectedTextSelector: selectors.supplierDescriptorTitle,
|
|
});
|
|
});
|
|
|
|
it('Should redirect to the supplier summary from summary pop-up from the supplier descriptor pop-up', () => {
|
|
cy.checkRedirectionFromPopUp({
|
|
selectorToClick: selectors.supplierLink,
|
|
steps: [
|
|
selectors.descriptorOpenSummaryBtn,
|
|
selectors.summaryGoToSummaryBtn,
|
|
],
|
|
expectedUrlRegex: supplierSummaryUrlRegex,
|
|
expectedTextSelector: selectors.supplierDescriptorTitle,
|
|
});
|
|
});
|
|
});
|
|
|
|
describe('Vehicle pop-ups', () => {
|
|
it('Should redirect to the vehicle summary from the vehicle descriptor pop-up', () => {
|
|
cy.checkRedirectionFromPopUp({
|
|
selectorToClick: selectors.vehicleLink,
|
|
steps: [selectors.descriptorGoToSummaryBtn],
|
|
expectedUrlRegex: vehicleSummaryUrlRegex,
|
|
expectedTextSelector: selectors.vehicleDescriptorTitle,
|
|
});
|
|
});
|
|
|
|
it('Should redirect to the vehicle summary from summary pop-up from the vehicle descriptor pop-up', () => {
|
|
cy.checkRedirectionFromPopUp({
|
|
selectorToClick: selectors.vehicleLink,
|
|
steps: [
|
|
selectors.descriptorOpenSummaryBtn,
|
|
selectors.summaryGoToSummaryBtn,
|
|
],
|
|
expectedUrlRegex: vehicleSummaryUrlRegex,
|
|
expectedTextSelector: selectors.vehicleDescriptorTitle,
|
|
});
|
|
});
|
|
});
|
|
});
|