From e49ab4dfa42a180811cace08cd082a2a84a4f0d6 Mon Sep 17 00:00:00 2001
From: jorgep <jorgep@verdnatura.es>
Date: Thu, 6 Mar 2025 17:31:51 +0100
Subject: [PATCH] fix: refs #8581 enhance filtering logic in InvoiceInList
 tests and add waitTableLoad command

---
 .../invoiceIn/invoiceInList.spec.js           | 21 +++++++++----------
 test/cypress/support/commands.js              |  2 ++
 2 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/test/cypress/integration/invoiceIn/invoiceInList.spec.js b/test/cypress/integration/invoiceIn/invoiceInList.spec.js
index 8ccccdcad..0d6c4ba04 100644
--- a/test/cypress/integration/invoiceIn/invoiceInList.spec.js
+++ b/test/cypress/integration/invoiceIn/invoiceInList.spec.js
@@ -161,21 +161,20 @@ describe('InvoiceInList', () => {
         });
 
         it('should filter by correctingFk param', () => {
-            let correctiveCount;
-            let noCorrectiveCount;
-
             cy.dataCy('vnCheckboxRectificative').click();
             cy.get('[data-cy="vnTable"] .q-virtual-scroll__content')
                 .children()
                 .its('length')
-                .then((len) => (correctiveCount = len));
-            cy.dataCy('vnCheckboxRectificative').click();
-            cy.get('[data-cy="vnTable"] .q-virtual-scroll__content')
-                .children()
-                .its('length')
-                .then((len) => (noCorrectiveCount = len));
-
-            expect(correctiveCount).to.not.equal(noCorrectiveCount);
+                .then((firstCount) => {
+                    cy.dataCy('vnCheckboxRectificative').click();
+                    cy.waitTableLoad();
+                    cy.get('[data-cy="vnTable"] .q-virtual-scroll__content')
+                        .children()
+                        .its('length')
+                        .then((secondCount) => {
+                            expect(firstCount).to.not.equal(secondCount);
+                        });
+                });
         });
     });
 });
diff --git a/test/cypress/support/commands.js b/test/cypress/support/commands.js
index e3b6d7aaa..137b61c4f 100755
--- a/test/cypress/support/commands.js
+++ b/test/cypress/support/commands.js
@@ -593,3 +593,5 @@ Cypress.Commands.add('checkQueryParams', (expectedParams = {}) => {
         }
     });
 });
+
+Cypress.Commands.add('waitTableLoad', () => cy.waitForElement('[data-q-vs-anchor]'));