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" );