From afb0e912d69edd914a4b5e0d5ca68d475baf5bc6 Mon Sep 17 00:00:00 2001 From: Jon Date: Wed, 12 Mar 2025 09:46:02 +0100 Subject: [PATCH] test: fix selectOption wait to ariaControl is visible --- test/cypress/integration/client/clientBalance.spec.js | 3 ++- test/cypress/support/commands.js | 10 ++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/test/cypress/integration/client/clientBalance.spec.js b/test/cypress/integration/client/clientBalance.spec.js index 56ce01692..0228d71bc 100644 --- a/test/cypress/integration/client/clientBalance.spec.js +++ b/test/cypress/integration/client/clientBalance.spec.js @@ -6,9 +6,10 @@ describe('Client balance', () => { cy.visit('#/customer/1101/balance'); }); it('Should create a mandate', () => { + cy.waitSpinner(); cy.get('.q-page-sticky > div > .q-btn').click(); cy.selectOption('[data-cy="paymentBank"]', 2); - cy.dataCy('paymentAmount_input').type('100'); + cy.dataCy('paymentAmount_input').clear().type('100'); cy.saveCard(); }); }); diff --git a/test/cypress/support/commands.js b/test/cypress/support/commands.js index dfec341cd..c2dd1579f 100755 --- a/test/cypress/support/commands.js +++ b/test/cypress/support/commands.js @@ -92,6 +92,14 @@ Cypress.Commands.add('getValue', (selector) => { }); }); +Cypress.Commands.add('waitSpinner', () => { + cy.get('body').then(($body) => { + if ($body.find('[data-cy="loading-spinner"]').length) { + cy.get('[data-cy="loading-spinner"]').should('not.be.visible'); + } + }); +}); + // Fill Inputs Cypress.Commands.add('selectOption', (selector, option, timeout = 2500) => { cy.waitForElement(selector, timeout); @@ -109,6 +117,7 @@ Cypress.Commands.add('selectOption', (selector, option, timeout = 2500) => { function selectItem(selector, option, ariaControl, hasWrite = true) { if (!hasWrite) cy.wait(100); + cy.waitSpinner(); getItems(ariaControl).then((items) => { const matchingItem = items @@ -128,6 +137,7 @@ function getItems(ariaControl, startTime = Cypress._.now(), timeout = 2500) { .should('exist') .find('.q-item') .should('exist') + .should('be.visible') .then(($items) => { if (!$items?.length || $items.first().text().trim() === '') { if (Cypress._.now() - startTime > timeout) {