From 57e80040fa7af563cac40c90a4940f771369bbe2 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Sun, 16 Mar 2025 12:36:22 +0100 Subject: [PATCH] test: check params from and to --- .../integration/monitor/monitorTicket.spec.js | 81 ++++++++++--------- 1 file changed, 43 insertions(+), 38 deletions(-) diff --git a/test/cypress/integration/monitor/monitorTicket.spec.js b/test/cypress/integration/monitor/monitorTicket.spec.js index 766dfddda..a3920ff65 100644 --- a/test/cypress/integration/monitor/monitorTicket.spec.js +++ b/test/cypress/integration/monitor/monitorTicket.spec.js @@ -139,57 +139,62 @@ describe('Monitor Tickets Table', () => { cy.url().should('include', 'packing'); countRows('eq', 5); }); -}); -it('Cols', () => { - cy.get(firstRow('totalProblems')); - cy.get(firstRow('id')).find('span').should('have.class', 'link').click(); - cy.dataCy('TicketDescriptor').should('exist'); + it('Cols', () => { + cy.get(firstRow('totalProblems')); - cy.get(firstRow('zoneFk')).find('span').should('have.class', 'link').click(); - cy.dataCy('ZoneDescriptor').should('exist'); + cy.get(firstRow('id')).find('span').should('have.class', 'link').click(); + cy.dataCy('TicketDescriptor').should('exist'); - cy.get(firstRow('clientFk')).find('span').should('have.class', 'link').click(); - cy.dataCy('CustomerDescriptor').should('exist'); + cy.get(firstRow('zoneFk')).find('span').should('have.class', 'link').click(); + cy.dataCy('ZoneDescriptor').should('exist'); - cy.get(firstRow('departmentFk')).find('span').should('have.class', 'link').click(); - cy.dataCy('DepartmentDescriptor').should('exist'); - cy.get(firstRow('shippedDate')).find('.q-badge'); - cy.get( - ':nth-child(1) > .q-table--col-auto-width > [data-cy="tableAction-0"] > .q-btn__content > .q-icon', - ).click({ ctrlKey: true }); - cy.get( - ':nth-child(1) > .q-table--col-auto-width > [data-cy="tableAction-1"] > .q-btn__content > .q-icon', - ).click(); - cy.get('.summaryHeader').should('exist'); + cy.get(firstRow('clientFk')).find('span').should('have.class', 'link').click(); + cy.dataCy('CustomerDescriptor').should('exist'); + + cy.get(firstRow('departmentFk')) + .find('span') + .should('have.class', 'link') + .click(); + cy.dataCy('DepartmentDescriptor').should('exist'); + cy.get(firstRow('shippedDate')).find('.q-badge'); + cy.get( + ':nth-child(1) > .q-table--col-auto-width > [data-cy="tableAction-0"] > .q-btn__content > .q-icon', + ).click({ ctrlKey: true }); + cy.get( + ':nth-child(1) > .q-table--col-auto-width > [data-cy="tableAction-1"] > .q-btn__content > .q-icon', + ).click(); + cy.get('.summaryHeader').should('exist'); + }); + + it.only('clear scopeDays', function () { + cy.get('[data-cy="Days onward_input"]').clear().type('2'); + cy.searchInFilterPanel(); + cy.get('.q-chip__content > span').should('have.text', '"2"'); + cy.waitSpinner(); + checkScopeDays(2); + cy.get('[data-cy="Days onward_input"]').clear(); + cy.searchInFilterPanel(); + cy.get('.q-chip__content > span').should('have.text', '"0"'); + cy.waitSpinner(); + checkScopeDays(0); + }); }); -it('clear scopeDays', function () { - cy.get('[data-cy="Days onward_input"]').clear().type('2'); - cy.searchInFilterPanel(); - cy.get('.q-chip__content > span').should('have.text', '"2"'); - cy.waitSpinner(); - // Verify URL contains correct scopeDays value +function checkScopeDays(scopeDays) { cy.url().then((url) => { const urlParams = new URLSearchParams(url.split('?')[1]); const saleMonitorTickets = JSON.parse( decodeURIComponent(urlParams.get('saleMonitorTickets')), ); - expect(saleMonitorTickets.scopeDays).to.equal(2); - }); - cy.get('[data-cy="Days onward_input"]').clear(); - cy.searchInFilterPanel(); - cy.get('.q-chip__content > span').should('have.text', '"0"'); - cy.waitSpinner(); - // Verify URL after clearing - cy.url().then((url) => { - const urlParams = new URLSearchParams(url.split('?')[1]); - const saleMonitorTickets = JSON.parse( - decodeURIComponent(urlParams.get('saleMonitorTickets')), + expect(saleMonitorTickets.scopeDays).to.equal(scopeDays); + const fromDate = new Date(saleMonitorTickets.from); + const toDate = new Date(saleMonitorTickets.to); + expect(toDate.getDate() - fromDate.getDate()).to.equal( + saleMonitorTickets.scopeDays, ); - expect(saleMonitorTickets.scopeDays).to.equal(0); }); -}); +} function requestParams(key, value, options = { inWhere: false, like: false }) { cy.wait('@filterRequest').then((interception) => { if (!key) return;