From 4e5754ccb5a5d87339116d61e8389d342633147f Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Mon, 25 Nov 2024 23:49:24 +0100 Subject: [PATCH] test: perf clientList descriptor action --- .../integration/client/clientList.spec.js | 19 +++++++++++++------ test/cypress/support/commands.js | 10 ++++++++++ 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/test/cypress/integration/client/clientList.spec.js b/test/cypress/integration/client/clientList.spec.js index 93e53b9f6..a528907e2 100644 --- a/test/cypress/integration/client/clientList.spec.js +++ b/test/cypress/integration/client/clientList.spec.js @@ -6,7 +6,11 @@ describe('Client list', () => { cy.visit('/#/customer/list', { timeout: 5000, onBeforeLoad(win) { - cy.stub(win, 'open'); + cy.stub(win, 'open') + .callsFake((url) => { + return win.open.wrappedMethod.call(win, url, '_self'); + }) + .as('Open'); }, }); }); @@ -47,17 +51,20 @@ describe('Client list', () => { it('Client founded create ticket', () => { const search = 'Jessica Jones'; cy.searchByLabel('Name', search); - cy.clickButtonsDescriptor(2); + cy.openActionDescriptor('Create ticket'); cy.waitForElement('#formModel'); - cy.waitForElement('.q-form'); - cy.checkValueForm(1, search); + cy.waitForElement('.q-form', { timeout: 5000 }); + + cy.get('.grid-create >:nth-child(1)').find('input').should('have.value', search); + cy.get('.grid-create >:nth-child(2)').find('input').should('have.value', search); }); it('Client founded create order', () => { const search = 'Jessica Jones'; cy.searchByLabel('Name', search); - cy.clickButtonsDescriptor(4); + cy.openActionDescriptor('New order'); cy.waitForElement('#formModel'); cy.waitForElement('.q-form'); - cy.checkValueForm(2, search); + cy.get('.grid-create >:nth-child(2)').find('input').should('have.value', search); + cy.get('.grid-create >:nth-child(4)').find('input').should('have.value', search); }); }); diff --git a/test/cypress/support/commands.js b/test/cypress/support/commands.js index 64c159f6d..2350d1231 100755 --- a/test/cypress/support/commands.js +++ b/test/cypress/support/commands.js @@ -249,6 +249,7 @@ Cypress.Commands.add('writeSearchbar', (value) => { value ); }); + Cypress.Commands.add('validateContent', (selector, expectedValue) => { cy.get(selector).should('have.text', expectedValue); }); @@ -256,6 +257,14 @@ Cypress.Commands.add('validateContent', (selector, expectedValue) => { Cypress.Commands.add('openActionsDescriptor', () => { cy.get('.header > :nth-child(3) > .q-btn__content > .q-icon').click(); }); + +Cypress.Commands.add('openActionDescriptor', (opt) => { + cy.openActionsDescriptor(); + const listItem = '[role="menu"] .q-list .q-item'; + cy.contains(listItem, opt).click(); + 1; +}); + Cypress.Commands.add('clickButtonsDescriptor', (id) => { cy.get(`.actions > .q-card__actions> .q-btn:nth-child(${id})`) .invoke('removeAttr', 'target') @@ -267,6 +276,7 @@ Cypress.Commands.add('openUserPanel', () => { '.column > .q-avatar > .q-avatar__content > .q-img > .q-img__container > .q-img__image' ).click(); }); + Cypress.Commands.add('checkNotification', (text) => { cy.get('.q-notification') .should('be.visible')