From bda5afd49cc1ce77c7bb8b50aa5ec27fbf758f8b Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Mon, 13 Apr 2026 09:27:53 +0100 Subject: [PATCH] Bug 40383: (follow-up) Fix flaky Cypress EDIFACT search tests in CI Replace cy.wait(N) + bare assertion with assertion-based waits using { timeout: 10000 }, and replace .type(term, { delay: 50 }) with .invoke('val', term).trigger('input') to avoid keyboard simulation timing races against the 500ms debounce in the search component. Signed-off-by: Martin Renvoize --- .../Acquisitions/EdifactModal_spec.ts | 32 +++++++++---------- .../Acquisitions/EdifactSearch_spec.ts | 13 +++++--- 2 files changed, 23 insertions(+), 22 deletions(-) diff --git a/t/cypress/integration/Acquisitions/EdifactModal_spec.ts b/t/cypress/integration/Acquisitions/EdifactModal_spec.ts index 960e52824f..72c9e88ed2 100644 --- a/t/cypress/integration/Acquisitions/EdifactModal_spec.ts +++ b/t/cypress/integration/Acquisitions/EdifactModal_spec.ts @@ -404,11 +404,8 @@ describe("EDIFACT Modal Tests", () => { // Type a search query that should have multiple results cy.get("#EDI_modal .edi-search-input").type("UNH"); - // Wait for search to complete - cy.wait(1000); - - // Check that results are found and navigation buttons are enabled - cy.get("#EDI_modal .edi-search-count").should( + // Wait for debounce + search to complete + cy.get("#EDI_modal .edi-search-count", { timeout: 10000 }).should( "not.contain", "0 results" ); @@ -426,20 +423,21 @@ describe("EDIFACT Modal Tests", () => { // Search for something likely to exist cy.get("#EDI_modal .edi-search-input").type("UN"); - cy.wait(1000); - // If results found, navigation should be enabled - cy.get("#EDI_modal .edi-search-count").then($count => { - const countText = $count.text(); - if (!countText.includes("0 results")) { - cy.get("#EDI_modal .edi-search-prev").should( - "not.be.disabled" - ); - cy.get("#EDI_modal .edi-search-next").should( - "not.be.disabled" - ); + // Wait for debounce + search to complete + cy.get("#EDI_modal .edi-search-count", { timeout: 10000 }).then( + $count => { + const countText = $count.text(); + if (!countText.includes("0 results")) { + cy.get("#EDI_modal .edi-search-prev").should( + "not.be.disabled" + ); + cy.get("#EDI_modal .edi-search-next").should( + "not.be.disabled" + ); + } } - }); + ); }); it("should clear search when input is cleared", () => { diff --git a/t/cypress/integration/Acquisitions/EdifactSearch_spec.ts b/t/cypress/integration/Acquisitions/EdifactSearch_spec.ts index a236128069..2ae914ac22 100644 --- a/t/cypress/integration/Acquisitions/EdifactSearch_spec.ts +++ b/t/cypress/integration/Acquisitions/EdifactSearch_spec.ts @@ -9,15 +9,18 @@ describe("EDIFACT Search Functionality Tests", () => { // Clear input first to ensure clean state cy.get("#EDI_modal .edi-search-input").clear(); - // Type with delay and verify the value was entered correctly - cy.get("#EDI_modal .edi-search-input").type(searchTerm, { delay: 50 }); + // Set value directly and trigger input event to avoid keyboard simulation + // timing races with the 500ms debounce in the component + cy.get("#EDI_modal .edi-search-input") + .invoke("val", searchTerm) + .trigger("input"); - // Verify the input contains what we typed - retry if needed + // Verify the input contains what we typed cy.get("#EDI_modal .edi-search-input").should("have.value", searchTerm); if (shouldFindResults) { - // Wait for debounce + search to complete (with longer timeout for reliability) - cy.get("#EDI_modal .edi-search-count", { timeout: 3000 }).should( + // Wait for debounce + search to complete + cy.get("#EDI_modal .edi-search-count", { timeout: 10000 }).should( "not.contain", "0 results" );