diff --git a/test/cypress/integration/zone/zoneDeliveryDays.spec.js b/test/cypress/integration/zone/zoneDeliveryDays.spec.js index 1e1fc8ff5..f42274d8f 100644 --- a/test/cypress/integration/zone/zoneDeliveryDays.spec.js +++ b/test/cypress/integration/zone/zoneDeliveryDays.spec.js @@ -1,15 +1,56 @@ describe('ZoneDeliveryDays', () => { + const postcode = '46680'; + const agency = 'Gotham247Expensive'; + const submitForm = '.q-form > .q-btn > .q-btn__content'; beforeEach(() => { cy.login('developer'); cy.viewport(1920, 1080); cy.visit(`/#/zone/delivery-days`); }); - it('should query for the day', () => { + it('should return no data when querying without params', () => { cy.get('.q-form > .q-btn > .q-btn__content').click(); cy.get('.q-notification__message').should( 'have.text', - 'No service for the specified zone' + 'No service for the specified zone', ); }); + + it('should query for delivery', () => { + cy.intercept('GET', /\/api\/Zones\/getEvents/).as('events'); + + cy.selectOption('[data-cy="ZoneDeliveryDaysPostcodeSelect"]', postcode); + + cy.dataCy('ZoneDeliveryDaysPostcodeSelect').type(postcode); + cy.get('.q-menu .q-item').contains(postcode).click(); + cy.get('.q-menu').then(($menu) => { + if ($menu.is(':visible')) { + cy.get('[data-cy="ZoneDeliveryDaysPostcodeSelect"]') + .as('focusedElement') + .focus(); + cy.get('@focusedElement').blur(); + } + }); + cy.get('.q-menu').should('not.exist'); + + cy.dataCy('ZoneDeliveryDaysAgencySelect').type(agency); + cy.get('.q-menu .q-item').contains(agency).click(); + cy.get('.q-menu').then(($menu) => { + if ($menu.is(':visible')) { + cy.get('[data-cy="ZoneDeliveryDaysAgencySelect"]') + .as('focusedElement') + .focus(); + cy.get('@focusedElement').blur(); + } + }); + cy.get('.q-menu').should('not.exist'); + + cy.get(submitForm).click(); + cy.wait('@events').then((interception) => { + cy.log('interception: ', interception); + //TODO: interceptar llamada y comprobar que el objeto de los eventos no está vacío + // const data = interception.response.body; + // expect(data.hasComponentLack).to.equal(1); + }); + }); }); diff --git a/test/cypress/integration/zone/zoneUpcomingDeliveries.spec.js b/test/cypress/integration/zone/zoneUpcomingDeliveries.spec.js index 28e2222d4..576b2ea70 100644 --- a/test/cypress/integration/zone/zoneUpcomingDeliveries.spec.js +++ b/test/cypress/integration/zone/zoneUpcomingDeliveries.spec.js @@ -1,9 +1,17 @@ describe('ZoneUpcomingDeliveries', () => { + const tableFields = (opt) => + `:nth-child(1) > .q-table__container > .q-table__middle > .q-table > thead > tr > :nth-child(${opt})`; + beforeEach(() => { cy.login('developer'); cy.viewport(1920, 1080); cy.visit(`/#/zone/upcoming-deliveries`); }); - it('should show the page', () => {}); + it('should show the page', () => { + cy.get('.q-card').should('be.visible'); + cy.get(tableFields(1)).should('be.visible').should('have.text', 'Province'); + cy.get(tableFields(2)).should('be.visible').should('have.text', 'Closing'); + cy.get(tableFields(3)).should('be.visible').should('have.text', 'Id'); + }); });