188 lines
7.8 KiB
JavaScript
188 lines
7.8 KiB
JavaScript
describe('RouteAutonomous', () => {
|
|
const getLinkSelector = (colField, link = true) =>
|
|
`tr:first-child > [data-col-field="${colField}"] > .no-padding${link ? ' > .link' : ''}`;
|
|
|
|
const selectors = {
|
|
total: '.value > .text-h6',
|
|
routeId: getLinkSelector('routeFk', false),
|
|
agencyRoute: getLinkSelector('agencyModeName'),
|
|
agencyAgreement: getLinkSelector('agencyAgreement'),
|
|
received: getLinkSelector('invoiceInFk'),
|
|
autonomous: getLinkSelector('supplierName'),
|
|
firstRowCheckbox: '.q-virtual-scroll__content tr:first-child .q-checkbox__bg',
|
|
secondRowCheckbox: '.q-virtual-scroll__content tr:nth-child(2) .q-checkbox__bg',
|
|
createInvoiceBtn: '.q-card > .q-btn',
|
|
saveFormBtn: 'FormModelPopup_save',
|
|
summaryIcon: 'tableAction-0',
|
|
descriptorRouteSubtitle: '[data-cy="vnDescriptor_subtitle"]',
|
|
descriptorAgencyAndSupplierTitle: '[data-cy="vnDescriptor_description"]',
|
|
descriptorInvoiceInTitle: '[data-cy="vnDescriptor_title"]',
|
|
descriptorOpenSummaryBtn: '.q-menu > .descriptor [data-cy="openSummaryBtn"]',
|
|
descriptorGoToSummaryBtn: '.q-menu > .descriptor [data-cy="goToSummaryBtn"]',
|
|
summaryGoToSummaryBtn: '.summaryHeader [data-cy="goToSummaryBtn"]',
|
|
};
|
|
|
|
const newInvoice = {
|
|
Reference: { val: 'Test invoice' },
|
|
Company: { val: 'VNL', type: 'select' },
|
|
Warehouse: { val: 'Warehouse One', type: 'select' },
|
|
Type: { val: 'Vehiculos', type: 'select' },
|
|
Description: { val: 'Test description' },
|
|
};
|
|
|
|
const total = '€206.40';
|
|
|
|
const urls = {
|
|
summaryAgencyUrlRegex: /agency\/\d+\/summary/,
|
|
summaryInvoiceInUrlRegex: /invoice-in\/\d+\/summary/,
|
|
summarySupplierUrlRegex: /supplier\/\d+\/summary/,
|
|
summaryRouteUrlRegex: /route\/\d+\/summary/,
|
|
};
|
|
const dataSaved = 'Data saved';
|
|
|
|
beforeEach(() => {
|
|
cy.login('developer');
|
|
cy.visit(`/#/route/agency-term`);
|
|
cy.typeSearchbar('{enter}');
|
|
});
|
|
|
|
it('Should list autonomous routes', () => {
|
|
cy.get('.q-table')
|
|
.children()
|
|
.should('be.visible')
|
|
.should('have.length.greaterThan', 0);
|
|
});
|
|
|
|
it.skip('Should create invoice in to selected route', () => {
|
|
cy.get(selectors.firstRowCheckbox).click();
|
|
cy.get(selectors.createInvoiceBtn).click();
|
|
cy.fillInForm(newInvoice);
|
|
cy.dataCy('attachFile').click();
|
|
cy.get('.q-file').selectFile('test/cypress/fixtures/image.jpg', {
|
|
force: true,
|
|
});
|
|
cy.dataCy(selectors.saveFormBtn).should('be.visible').click();
|
|
cy.checkNotification(dataSaved);
|
|
});
|
|
|
|
it('Should display the total price of the selected rows', () => {
|
|
cy.get(selectors.firstRowCheckbox).click();
|
|
cy.get(selectors.secondRowCheckbox).click();
|
|
cy.validateContent(selectors.total, total);
|
|
});
|
|
|
|
it('Should redirect to the summary when clicking a route', () => {
|
|
cy.checkRedirectionFromPopUp({
|
|
selectorToClick: selectors.routeId,
|
|
expectedUrlRegex: urls.summaryRouteUrlRegex,
|
|
expectedTextSelector: selectors.descriptorRouteSubtitle,
|
|
});
|
|
});
|
|
|
|
describe('Agency route pop-ups', () => {
|
|
it('Should redirect to the agency route summary from the agency route descriptor pop-up', () => {
|
|
cy.checkRedirectionFromPopUp({
|
|
selectorToClick: selectors.agencyRoute,
|
|
steps: [selectors.descriptorGoToSummaryBtn],
|
|
expectedUrlRegex: urls.summaryAgencyUrlRegex,
|
|
expectedTextSelector: selectors.descriptorAgencyAndSupplierTitle,
|
|
});
|
|
});
|
|
|
|
it('Should redirect to the agency route summary from summary pop-up from the agency route descriptor pop-up', () => {
|
|
cy.checkRedirectionFromPopUp({
|
|
selectorToClick: selectors.agencyRoute,
|
|
steps: [
|
|
selectors.descriptorOpenSummaryBtn,
|
|
selectors.summaryGoToSummaryBtn,
|
|
],
|
|
expectedUrlRegex: urls.summaryAgencyUrlRegex,
|
|
expectedTextSelector: selectors.descriptorAgencyAndSupplierTitle,
|
|
});
|
|
});
|
|
});
|
|
|
|
describe('Agency route pop-ups', () => {
|
|
it('Should redirect to the agency agreement summary from the agency agreement descriptor pop-up', () => {
|
|
cy.checkRedirectionFromPopUp({
|
|
selectorToClick: selectors.agencyAgreement,
|
|
steps: [selectors.descriptorGoToSummaryBtn],
|
|
expectedUrlRegex: urls.summaryAgencyUrlRegex,
|
|
expectedTextSelector: selectors.descriptorAgencyAndSupplierTitle,
|
|
});
|
|
});
|
|
|
|
it('Should redirect to the agency agreement summary from summary pop-up from the agency agreement descriptor pop-up', () => {
|
|
cy.checkRedirectionFromPopUp({
|
|
selectorToClick: selectors.agencyAgreement,
|
|
steps: [
|
|
selectors.descriptorOpenSummaryBtn,
|
|
selectors.summaryGoToSummaryBtn,
|
|
],
|
|
expectedUrlRegex: urls.summaryAgencyUrlRegex,
|
|
expectedTextSelector: selectors.descriptorAgencyAndSupplierTitle,
|
|
});
|
|
});
|
|
});
|
|
|
|
describe('Received pop-ups', () => {
|
|
it('Should redirect to the invoice in summary from the received descriptor pop-up', () => {
|
|
cy.checkRedirectionFromPopUp({
|
|
selectorToClick: selectors.received,
|
|
steps: [selectors.descriptorGoToSummaryBtn],
|
|
expectedUrlRegex: urls.summaryInvoiceInUrlRegex,
|
|
expectedTextSelector: selectors.descriptorInvoiceInTitle,
|
|
});
|
|
});
|
|
|
|
it('Should redirect to the invoiceIn summary from summary pop-up from the received descriptor pop-up', () => {
|
|
cy.checkRedirectionFromPopUp({
|
|
selectorToClick: selectors.received,
|
|
steps: [
|
|
selectors.descriptorOpenSummaryBtn,
|
|
selectors.summaryGoToSummaryBtn,
|
|
],
|
|
expectedUrlRegex: urls.summaryInvoiceInUrlRegex,
|
|
expectedTextSelector: selectors.descriptorInvoiceInTitle,
|
|
});
|
|
});
|
|
});
|
|
|
|
describe('Autonomous pop-ups', () => {
|
|
it('Should redirect to the supplier summary from the received descriptor pop-up', () => {
|
|
cy.checkRedirectionFromPopUp({
|
|
selectorToClick: selectors.autonomous,
|
|
steps: [selectors.descriptorGoToSummaryBtn],
|
|
expectedUrlRegex: urls.summarySupplierUrlRegex,
|
|
expectedTextSelector: selectors.descriptorAgencyAndSupplierTitle,
|
|
});
|
|
});
|
|
|
|
it('Should redirect to the supplier summary from summary pop-up from the autonomous descriptor pop-up', () => {
|
|
cy.checkRedirectionFromPopUp({
|
|
selectorToClick: selectors.autonomous,
|
|
steps: [
|
|
selectors.descriptorOpenSummaryBtn,
|
|
selectors.summaryGoToSummaryBtn,
|
|
],
|
|
expectedUrlRegex: urls.summarySupplierUrlRegex,
|
|
expectedTextSelector: selectors.descriptorAgencyAndSupplierTitle,
|
|
});
|
|
});
|
|
});
|
|
|
|
describe('Route pop-ups', () => {
|
|
it('Should redirect to the summary from the route summary pop-up', () => {
|
|
cy.get(selectors.routeId)
|
|
.invoke('text')
|
|
.then((routeId) => {
|
|
routeId = routeId.trim();
|
|
cy.dataCy(selectors.summaryIcon).first().click();
|
|
cy.get(selectors.summaryGoToSummaryBtn).click();
|
|
cy.url().should('match', urls.summaryRouteUrlRegex);
|
|
cy.containContent(selectors.descriptorRouteSubtitle, routeId);
|
|
});
|
|
});
|
|
});
|
|
});
|