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 <martin.renvoize@openfifth.co.uk>
This commit is contained in:
parent
278aa32c03
commit
bda5afd49c
|
|
@ -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", () => {
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
);
|
||||
|
|
|
|||
Loading…
Reference in New Issue