From 351f291086fdc09879410037e119bf76bf012a69 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Mon, 24 Mar 2025 11:15:25 +0100 Subject: [PATCH] test: remove timeout --- .../integration/monitor/clientActions.spec.js | 62 ++++++++----------- .../integration/monitor/monitorTicket.spec.js | 17 +++-- .../vnComponent/vnSelect.commands.js | 3 + 3 files changed, 37 insertions(+), 45 deletions(-) create mode 100644 test/cypress/integration/vnComponent/vnSelect.commands.js diff --git a/test/cypress/integration/monitor/clientActions.spec.js b/test/cypress/integration/monitor/clientActions.spec.js index f413332f3..5208c6410 100644 --- a/test/cypress/integration/monitor/clientActions.spec.js +++ b/test/cypress/integration/monitor/clientActions.spec.js @@ -1,3 +1,5 @@ +const clientFk = `[data-cy="recentOrderActions"] [data-cy="column-filter-clientFk"]`; +const departmentFk = `[data-cy="recentOrderActions"] [data-cy="column-filter-departmentFk"]`; describe('Monitor Clients actions', () => { beforeEach(() => { cy.login('developer'); @@ -6,12 +8,19 @@ describe('Monitor Clients actions', () => { cy.intercept('GET', '**/SalesMonitors/ordersFilter*').as('ordersFilter'); cy.intercept('GET', '**/SalesMonitors/clientsFilter*').as('clientsFilter'); }); - it.only('Should load layout', () => { + it('Should load layout', () => { cy.get('.q-page').should('be.visible'); - cy.firstRow('clientFk').find('span').should('have.class', 'link').click(); + cy.dataCy('recentOrderActions').within(() => { + cy.firstRow('clientFk').find('span').should('have.class', 'link').click(); + }); cy.dataCy('CustomerDescriptor').should('exist'); - cy.firstRow('departmentFk', 2).find('span').should('have.class', 'link').click(); + cy.dataCy('recentOrderActions').within(() => { + cy.firstRow('departmentFk', 2) + .find('span') + .should('have.class', 'link') + .click(); + }); cy.dataCy('DepartmentDescriptor').should('exist'); cy.dataCy('clientsOnWebsite') @@ -22,40 +31,23 @@ describe('Monitor Clients actions', () => { .should('have.text', 'Recent order actions'); cy.get('[data-cy="From_inputDate"]').should('have.value', '01/01/2001'); cy.get('[data-cy="To_inputDate"]').should('have.value', '01/01/2001'); - cy.get('[data-cy="recentOrderActions"]') - .find('[data-cy="column-filter-clientFk"]') - .find(' [data-cy="_select"]') - .click(); - cy.get('.q-menu :nth-child(1) >.q-item__section').click(); + cy.get(`${clientFk} [data-cy="_select"]`).click(); + cy.clickOption(); cy.countTableRows('eq', 0); - cy.get('[data-cy="recentOrderActions"]') - .find( - '[data-cy="column-filter-clientFk"] .q-field .q-field__control > :nth-child(2)', - ) - .click(); - cy.get('[data-cy="recentOrderActions"]') - .find('[data-cy="column-filter-departmentFk"]') - .find(' [data-cy="_select"]') - .click(); - cy.get('[data-cy="recentOrderActions"]') - .find('[data-cy="column-filter-departmentFk"]') - .find(' [data-cy="_select"]') - .type('VIP'); - cy.wait(1000); - cy.get('.q-menu :nth-child(1) >.q-item__section').click(); - cy.countTableRows('eq', 13); + cy.get(`${clientFk} .q-field .q-field__control > :nth-child(2)`).click(); + cy.get(`${departmentFk} [data-cy="_select"]`).type('VIP').trigger('enter'); + cy.intercept('GET', '**/Departments*').as('filterDepartment'); + cy.wait('@filterDepartment').then(() => { + cy.clickOption(); + cy.countTableRows('eq', 13); + }); - cy.get('[data-cy="recentOrderActions"]') - .find('[data-cy="column-filter-clientFk"]') - .find(' [data-cy="_select"]') - .click(); - cy.get('[data-cy="recentOrderActions"]') - .find('[data-cy="column-filter-clientFk"]') - .find(' [data-cy="_select"]') - .type('bru'); - cy.wait(1000); - cy.get('.q-menu :nth-child(1) >.q-item__section').click(); - cy.countTableRows('eq', 3); + cy.get(`${clientFk} [data-cy="_select"]`).type('Bruce Banner'); + cy.intercept('GET', '**/Clients*').as('filterClient'); + cy.wait('@filterClient').then(() => { + cy.clickOption(); + cy.countTableRows('eq', 3); + }); }); }); diff --git a/test/cypress/integration/monitor/monitorTicket.spec.js b/test/cypress/integration/monitor/monitorTicket.spec.js index 0955679b1..d34561271 100644 --- a/test/cypress/integration/monitor/monitorTicket.spec.js +++ b/test/cypress/integration/monitor/monitorTicket.spec.js @@ -19,20 +19,17 @@ describe('Monitor Tickets Table', () => { cy.get(firstRow('provinceFk')).click({ ctrlKey: true }); cy.get('@windowOpen').should('be.calledWithMatch', /\/ticket\/\d+\/sale/); }); - it('should filter by column headers and update URL params', () => { + it.only('should filter by column headers and update URL params', () => { cy.intercept('GET', '**/SalesMonitors/salesFilter*').as('filterRequest'); - cy.dataCy('column-filter-id').find(' [data-cy="_input"]').type('13'); + cy.dataCy('column-filter-id').find('[data-cy="_input"]').type('13'); cy.dataCy('column-filter-id').find(' .q-icon').click(); cy.openRightMenu(); - cy.dataCy('column-filter-clientFk') - .find('[data-cy="_select"]', { timeout: 3000 }) - .type('1101', { timeout: 3000, force: true }); - cy.get('[role="listbox"]') - .find('.q-item') - .find('.q-item__label') - .contains('Bruce Wayne') - .click(); + cy.dataCy('column-filter-clientFk').find('[data-cy="_select"]').type('1101'); + cy.intercept('GET', '**/Clients*').as('filterClient'); + cy.wait('@filterClient').then(() => { + cy.clickOption(); + }); }); it('should filter by filter panel', () => { // Client id - clientFk diff --git a/test/cypress/integration/vnComponent/vnSelect.commands.js b/test/cypress/integration/vnComponent/vnSelect.commands.js new file mode 100644 index 000000000..017b6e7ea --- /dev/null +++ b/test/cypress/integration/vnComponent/vnSelect.commands.js @@ -0,0 +1,3 @@ +Cypress.Commands.add('clickOption', (index = 1) => + cy.get(`.q-menu :nth-child(${index}) >.q-item__section`).click(), +);