From 23b00bdc06d28e012724a37ed5052bf056026302 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Fri, 13 Sep 2024 10:49:29 -0300 Subject: [PATCH] Bug 37917: Add some wait time to RecordSources_spec.ts for the intercepted request responses This patch introduces the `cy.wait(500)` we use in several other Cypress tests when an (intercepted) API request is made. This is very important when tables are being rendered as DataTables is particularly bulky and prone to take longer to finish loading the components if the CPU load is a bit high. I wasn't able to reproduce the problem very often, but you can test yourself: 1. Run: $ ktd --shell k$ run_cypress --spec t/cypress/integration/Admin/RecordSources_spec.ts 2. Run it many times => FAIL: At some point it fails, you can overload your computer to try 3. Apply the patch 4. Repeat 2 => SUCCESS: No failures :-D 5. Sign off :-D Signed-off-by: Tomas Cohen Arazi Signed-off-by: Katrin Fischer --- t/cypress/integration/Admin/RecordSources_spec.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/t/cypress/integration/Admin/RecordSources_spec.ts b/t/cypress/integration/Admin/RecordSources_spec.ts index 90f13afc8e..09c2c40525 100644 --- a/t/cypress/integration/Admin/RecordSources_spec.ts +++ b/t/cypress/integration/Admin/RecordSources_spec.ts @@ -31,6 +31,7 @@ describe("Record sources CRUD tests", () => { it("Add", () => { cy.visit("/cgi-bin/koha/admin/admin-home.pl"); + cy.wait(500); cy.contains("Record sources").click(); cy.contains("New record source").click(); cy.get("#name").type("Poop"); @@ -57,6 +58,7 @@ describe("Record sources CRUD tests", () => { }, }); cy.visit("/cgi-bin/koha/admin/record_sources"); + cy.wait(500); cy.get("#record_sources_list").contains( "There are no record sources defined" ); @@ -89,6 +91,7 @@ describe("Record sources CRUD tests", () => { }, }); cy.visit("/cgi-bin/koha/admin/record_sources"); + cy.wait(500); cy.get("#record_sources_list").contains("Showing 1 to 3 of 3 entries"); cy.get(".dataTable > tbody > tr:first-child").within(() => { @@ -151,6 +154,7 @@ describe("Record sources CRUD tests", () => { can_be_edited: true, }, }); + cy.wait(500); cy.get("#record_sources_list table tbody tr:first") .contains("Edit") .click(); @@ -166,6 +170,7 @@ describe("Record sources CRUD tests", () => { }, }); cy.visit("/cgi-bin/koha/admin/record_sources/edit/1"); + cy.wait(500); cy.get("#name").should("have.value", "Source 1"); cy.get("#can_be_edited").should("not.be.checked"); @@ -210,6 +215,7 @@ describe("Record sources CRUD tests", () => { }, }); cy.visit("/cgi-bin/koha/admin/record_sources"); + cy.wait(500); cy.intercept("DELETE", "/api/v1/record_sources/2", { statusCode: 204, body: {}, -- 2.39.5