From f54810d82bce1c31acc98ea4002dba7e894f4d13 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 16 Jun 2025 16:06:57 +0200 Subject: [PATCH] Bug 40168: Restore afterEach in KohaTable Cypress tests We defined an anonymous function inside an arrow function, and Cypress does not call it. Test plan: Set AlwaysShowHoldingsTableFilters to "Do not" Run t/cypress/integration/KohaTable/Holdings_spec.ts: yarn cypress run --spec t/cypress/integration/KohaTable/Holdings_spec.ts When done, have a look at the value of AlwaysShowHoldingsTableFilters => without this patch it has been modified (not restored) and is set to "Do" => With this patch applied the original value is restored at the end of the tests (actually the end of each test) Signed-off-by: David Nind Signed-off-by: Pedro Amorim Signed-off-by: Lucas Gass (cherry picked from commit b83df697de67261e83c0aa6ae3a13a3df2770010) Signed-off-by: Paul Derscheid (cherry picked from commit 98ca5b0800297c4150ead372743d7c1414171466) Signed-off-by: Fridolin Somers --- .../integration/KohaTable/Holdings_spec.ts | 14 ++++---------- .../integration/KohaTable/PatronSearch_spec.ts | 17 +++++++---------- 2 files changed, 11 insertions(+), 20 deletions(-) diff --git a/t/cypress/integration/KohaTable/Holdings_spec.ts b/t/cypress/integration/KohaTable/Holdings_spec.ts index 043a3468bc..2b39c127b7 100644 --- a/t/cypress/integration/KohaTable/Holdings_spec.ts +++ b/t/cypress/integration/KohaTable/Holdings_spec.ts @@ -109,16 +109,13 @@ describe("catalogue/detail/holdings_table with items", () => { }); }); - afterEach( - () => - function () { + afterEach(function () { cleanup(); cy.set_syspref( "AlwaysShowHoldingsTableFilters", this.syspref_AlwaysShowHoldingsTableFilters ); - } - ); + }); it("Correctly init the table", function () { // Do not use `() => {` or this.biblio_id won't be retrieved @@ -458,16 +455,13 @@ describe("catalogue/detail/holdings_table without items", () => { }); }); - afterEach( - () => - function () { + afterEach(function () { cleanup(); cy.set_syspref( "AlwaysShowHoldingsTableFilters", this.syspref_AlwaysShowHoldingsTableFilters ); - } - ); + }); it("Do not display the table", function () { // Do not use `() => {` or this.biblio_id won't be retrieved diff --git a/t/cypress/integration/KohaTable/PatronSearch_spec.ts b/t/cypress/integration/KohaTable/PatronSearch_spec.ts index b706f1eb80..a9cc064f40 100644 --- a/t/cypress/integration/KohaTable/PatronSearch_spec.ts +++ b/t/cypress/integration/KohaTable/PatronSearch_spec.ts @@ -26,16 +26,13 @@ describe("ExtendedPatronAttributes", () => { }); }); - afterEach( - () => - function () { - cleanup(); - cy.set_syspref( - "ExtendedPatronAttributes", - this.syspref_ExtendedPatronAttributes - ); - } - ); + afterEach(function () { + cleanup(); + cy.set_syspref( + "ExtendedPatronAttributes", + this.syspref_ExtendedPatronAttributes + ); + }); const table_id = "memberresultst";