Bugzilla – Attachment 170468 Details for
Bug 37620
Fix randomly failing tests for cypress/integration/InfiniteScrollSelect_spec.ts
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 37620: Improve cypress test to reduce random failures
Bug-37620-Improve-cypress-test-to-reduce-random-fa.patch (text/plain), 7.66 KB, created by
Matt Blenkinsop
on 2024-08-19 13:20:59 UTC
(
hide
)
Description:
Bug 37620: Improve cypress test to reduce random failures
Filename:
MIME Type:
Creator:
Matt Blenkinsop
Created:
2024-08-19 13:20:59 UTC
Size:
7.66 KB
patch
obsolete
>From 174af293e8523c192251aa6b1097284af53a26d0 Mon Sep 17 00:00:00 2001 >From: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com> >Date: Mon, 19 Aug 2024 13:16:00 +0000 >Subject: [PATCH] Bug 37620: Improve cypress test to reduce random failures > >This patch makes some improvements to the Infinite Scroll cypress test to try and prevent random test failures > >- Fixes X-Base-Count and X-Total-Count for intercepted requests >- Makes element selection more precise >- Adds an intercepted request returning the requrired result for the filtered search >- Awaits this request before selecting an element from the dropdown >- Awaits all 10 requests triggered by typing "License 50" rather than just the first one >- Ensures that the select dropdown is closed between operations by clicking into another field to remove focus from the select dropdown > >Test plan: >1) yarn cypress run --spec t/cypress/integration/InfiniteScrollSelect_spec.ts >or >1) yarn cypress open and select the InfiniteScrollSelect test from the Cypress GUI >--- > .../integration/InfiniteScrollSelect_spec.ts | 110 +++++++++++++++--- > 1 file changed, 93 insertions(+), 17 deletions(-) > >diff --git a/t/cypress/integration/InfiniteScrollSelect_spec.ts b/t/cypress/integration/InfiniteScrollSelect_spec.ts >index b2c6fa3d361..bc928cfffd0 100644 >--- a/t/cypress/integration/InfiniteScrollSelect_spec.ts >+++ b/t/cypress/integration/InfiniteScrollSelect_spec.ts >@@ -81,8 +81,8 @@ describe("Infinite scroll", () => { > statusCode: 200, > body: pageTwo, > headers: { >- "X-Base-Total-Count": "20", >- "X-Total-Count": "20", >+ "X-Base-Total-Count": "40", >+ "X-Total-Count": "40", > }, > }).as("getPageTwo"); > // Scroll the dropdown >@@ -94,8 +94,8 @@ describe("Infinite scroll", () => { > statusCode: 200, > body: pageThree, > headers: { >- "X-Base-Total-Count": "20", >- "X-Total-Count": "20", >+ "X-Base-Total-Count": "60", >+ "X-Total-Count": "60", > }, > }).as("getPageThree"); > // Scroll the dropdown again >@@ -193,7 +193,7 @@ describe("Infinite scroll", () => { > "X-Base-Total-Count": "20", > "X-Total-Count": "20", > }, >- }); >+ }).as("getPageOne"); > > // Click the button in the toolbar > cy.visit("/cgi-bin/koha/erm/agreements"); >@@ -201,41 +201,80 @@ describe("Infinite scroll", () => { > > cy.get("#agreement_licenses").contains("Add new license").click(); > cy.get("#license_id_0 .vs__open-indicator").click(); >+ cy.wait("@getPageOne"); > cy.get("#license_id_0").find("li").as("options"); > cy.get("@options").should("have.length", 20); >- > cy.intercept("GET", "/api/v1/erm/licenses*", { > statusCode: 200, > body: pageTwo, > headers: { >- "X-Base-Total-Count": "20", >- "X-Total-Count": "20", >+ "X-Base-Total-Count": "40", >+ "X-Total-Count": "40", > }, > }).as("getPageTwo"); > // Scroll the dropdown >- cy.get(".vs__dropdown-menu").scrollTo("bottom"); >+ cy.get( >+ "#agreement_license_0 #license_id_0 .vs__dropdown-menu" >+ ).scrollTo("bottom"); > cy.wait("@getPageTwo"); >- > cy.intercept("GET", "/api/v1/erm/licenses*", { > statusCode: 200, > body: pageThree, > headers: { >- "X-Base-Total-Count": "20", >- "X-Total-Count": "20", >+ "X-Base-Total-Count": "60", >+ "X-Total-Count": "60", > }, > }).as("finalPage"); > // Scroll the dropdown again >- cy.get(".vs__dropdown-menu").scrollTo("bottom"); >+ cy.get( >+ "#agreement_license_0 #license_id_0 .vs__dropdown-menu" >+ ).scrollTo("bottom"); > cy.wait("@finalPage"); >- >+ cy.intercept("GET", "/api/v1/erm/licenses*", { >+ statusCode: 200, >+ body: [ >+ { >+ license_id: 50, >+ name: "License " + 50, >+ description: "A test license", >+ type: "local", >+ status: "active", >+ started_on: dates["today_iso"], >+ ended_on: dates["tomorrow_iso"], >+ user_roles: [], >+ }, >+ ], >+ headers: { >+ "X-Base-Total-Count": "20", >+ "X-Total-Count": "20", >+ }, >+ }).as("searchFilter"); > // Select a license that is not in the first page of results > cy.get("#agreement_license_0 #license_id_0 .vs__search").type( >- "License 50{enter}", >+ "License 50", >+ { force: true } >+ ); >+ cy.wait([ >+ "@searchFilter", >+ "@searchFilter", >+ "@searchFilter", >+ "@searchFilter", >+ "@searchFilter", >+ "@searchFilter", >+ "@searchFilter", >+ "@searchFilter", >+ "@searchFilter", >+ "@searchFilter", >+ ]); >+ cy.get("#agreement_license_0 #license_id_0 .vs__search").type( >+ "{enter}", > { force: true } > ); > cy.get("#agreement_license_0").contains("License 50"); > > // Re-open the dropdown, License 50 will no longer be in the dataset but the label should still show >+ // First we will click into the notes field to ensure the dropdown is closed >+ cy.get("#license_notes_0").click(); > cy.intercept("GET", "/api/v1/erm/licenses*", { > statusCode: 200, > body: pageOne, >@@ -246,13 +285,50 @@ describe("Infinite scroll", () => { > }).as("resetDropdown"); > cy.get("#license_id_0 .vs__open-indicator").click(); > cy.wait("@resetDropdown"); >- cy.get("#agreement_licenses").click(); >+ // Close the dropdown >+ cy.get("#license_id_0 .vs__open-indicator").click(); >+ cy.get("#license_notes_0").click(); > cy.get("#agreement_license_0").contains("License 50"); > > // Select a different license >+ cy.intercept("GET", "/api/v1/erm/licenses*", { >+ statusCode: 200, >+ body: [ >+ { >+ license_id: 10, >+ name: "License " + 10, >+ description: "A test license", >+ type: "local", >+ status: "active", >+ started_on: dates["today_iso"], >+ ended_on: dates["tomorrow_iso"], >+ user_roles: [], >+ }, >+ ], >+ headers: { >+ "X-Base-Total-Count": "20", >+ "X-Total-Count": "20", >+ }, >+ }).as("secondSearchFilter"); > cy.get("#license_id_0 .vs__open-indicator").click(); > cy.get("#agreement_license_0 #license_id_0 .vs__search").type( >- "License 10{enter}", >+ "License 10", >+ { force: true } >+ ); >+ cy.wait([ >+ "@secondSearchFilter", >+ "@secondSearchFilter", >+ "@secondSearchFilter", >+ "@secondSearchFilter", >+ "@secondSearchFilter", >+ "@secondSearchFilter", >+ "@secondSearchFilter", >+ "@secondSearchFilter", >+ "@secondSearchFilter", >+ "@secondSearchFilter", >+ ]); >+ cy.get("#agreement_license_0 #license_id_0 .vs__search").type( >+ "{enter}", > { force: true } > ); > cy.get("#agreement_license_0").contains("License 10"); >-- >2.39.3 (Apple Git-146)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 37620
:
170468
|
170749
|
170750
|
170752