From 86d99a561335ff1abd63a384b543cd144ef24519 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 4 Apr 2023 17:02:12 +0200 Subject: [PATCH] Bug 33408: Mock ERM sysprefs from cypress tests Sponsored-by: BULAC - http://www.bulac.fr/ Signed-off-by: Pedro Amorim Signed-off-by: Martin Renvoize Signed-off-by: Tomas Cohen Arazi (cherry picked from commit 2579b95db9d0477060c91610e54b44d96cc8ea20) Signed-off-by: Matt Blenkinsop --- t/cypress/integration/ERM/Agreements_spec.ts | 8 ++------ t/cypress/integration/ERM/Dialog_spec.ts | 8 ++------ t/cypress/integration/ERM/Licenses_spec.ts | 8 ++------ t/cypress/integration/ERM/Packages_spec.ts | 8 ++------ t/cypress/integration/ERM/Titles_spec.ts | 8 ++------ 5 files changed, 10 insertions(+), 30 deletions(-) diff --git a/t/cypress/integration/ERM/Agreements_spec.ts b/t/cypress/integration/ERM/Agreements_spec.ts index 8dd209ee8d..b931927858 100644 --- a/t/cypress/integration/ERM/Agreements_spec.ts +++ b/t/cypress/integration/ERM/Agreements_spec.ts @@ -118,8 +118,8 @@ function get_licenses_to_relate() { describe("Agreement CRUD operations", () => { before(() => { - cy.fetch_initial_ERM_sys_pref_value(); - cy.set_ERM_sys_pref_value(true); + cy.intercept("GET", "/cgi-bin/koha/svc/config/systempreferences/?pref=ERMModule", '{"value":"1"}'); + cy.intercept("GET", "/cgi-bin/koha/svc/config/systempreferences/?pref=ERMProviders", '{"value":"local"}'); }); beforeEach(() => { @@ -127,10 +127,6 @@ describe("Agreement CRUD operations", () => { cy.title().should("eq", "Koha staff interface"); }); - after(() => { - cy.reset_initial_ERM_sys_pref_value(); - }); - it("List agreements", () => { // GET agreements returns 500 cy.intercept("GET", "/api/v1/erm/agreements*", { diff --git a/t/cypress/integration/ERM/Dialog_spec.ts b/t/cypress/integration/ERM/Dialog_spec.ts index 9f39eaa212..dc85f035d2 100644 --- a/t/cypress/integration/ERM/Dialog_spec.ts +++ b/t/cypress/integration/ERM/Dialog_spec.ts @@ -23,8 +23,8 @@ function get_package() { describe("Dialog operations", () => { before(() => { - cy.fetch_initial_ERM_sys_pref_value(); - cy.set_ERM_sys_pref_value(true); + cy.intercept("GET", "/cgi-bin/koha/svc/config/systempreferences/?pref=ERMModule", '{"value":"1"}'); + cy.intercept("GET", "/cgi-bin/koha/svc/config/systempreferences/?pref=ERMProviders", '{"value":"local"}'); }); beforeEach(() => { @@ -32,10 +32,6 @@ describe("Dialog operations", () => { cy.title().should("eq", "Koha staff interface"); }); - after(() => { - cy.reset_initial_ERM_sys_pref_value(); - }); - it("There are no ... defined", () => { // GET packages returns empty list cy.intercept("GET", "/api/v1/erm/eholdings/local/packages*", { diff --git a/t/cypress/integration/ERM/Licenses_spec.ts b/t/cypress/integration/ERM/Licenses_spec.ts index 8879151828..78d1390c02 100644 --- a/t/cypress/integration/ERM/Licenses_spec.ts +++ b/t/cypress/integration/ERM/Licenses_spec.ts @@ -34,8 +34,8 @@ function get_license() { describe("License CRUD operations", () => { before(() => { - cy.fetch_initial_ERM_sys_pref_value(); - cy.set_ERM_sys_pref_value(true); + cy.intercept("GET", "/cgi-bin/koha/svc/config/systempreferences/?pref=ERMModule", '{"value":"1"}'); + cy.intercept("GET", "/cgi-bin/koha/svc/config/systempreferences/?pref=ERMProviders", '{"value":"local"}'); }); beforeEach(() => { @@ -43,10 +43,6 @@ describe("License CRUD operations", () => { cy.title().should("eq", "Koha staff interface"); }); - after(() => { - cy.reset_initial_ERM_sys_pref_value(); - }); - it("List license", () => { // GET license returns 500 cy.intercept("GET", "/api/v1/erm/licenses*", { diff --git a/t/cypress/integration/ERM/Packages_spec.ts b/t/cypress/integration/ERM/Packages_spec.ts index f44cedf96d..5a52fc231c 100644 --- a/t/cypress/integration/ERM/Packages_spec.ts +++ b/t/cypress/integration/ERM/Packages_spec.ts @@ -25,8 +25,8 @@ function get_package() { describe("Package CRUD operations", () => { before(() => { - cy.fetch_initial_ERM_sys_pref_value(); - cy.set_ERM_sys_pref_value(true); + cy.intercept("GET", "/cgi-bin/koha/svc/config/systempreferences/?pref=ERMModule", '{"value":"1"}'); + cy.intercept("GET", "/cgi-bin/koha/svc/config/systempreferences/?pref=ERMProviders", '{"value":"local"}'); }); beforeEach(() => { @@ -34,10 +34,6 @@ describe("Package CRUD operations", () => { cy.title().should("eq", "Koha staff interface"); }); - after(() => { - cy.reset_initial_ERM_sys_pref_value(); - }); - it("List package", () => { // GET package returns 500 cy.intercept("GET", "/api/v1/erm/eholdings/local/packages*", { diff --git a/t/cypress/integration/ERM/Titles_spec.ts b/t/cypress/integration/ERM/Titles_spec.ts index 90061e600d..06724aa4d8 100644 --- a/t/cypress/integration/ERM/Titles_spec.ts +++ b/t/cypress/integration/ERM/Titles_spec.ts @@ -19,8 +19,8 @@ function get_packages_to_relate() { describe("Title CRUD operations", () => { before(() => { - cy.fetch_initial_ERM_sys_pref_value(); - cy.set_ERM_sys_pref_value(true); + cy.intercept("GET", "/cgi-bin/koha/svc/config/systempreferences/?pref=ERMModule", '{"value":"1"}'); + cy.intercept("GET", "/cgi-bin/koha/svc/config/systempreferences/?pref=ERMProviders", '{"value":"local"}'); }); beforeEach(() => { @@ -28,10 +28,6 @@ describe("Title CRUD operations", () => { cy.title().should("eq", "Koha staff interface"); }); - after(() => { - cy.reset_initial_ERM_sys_pref_value(); - }); - it("Import titles", () => { let erm_title = cy.get_title(); let resource = erm_title.resources[0]; -- 2.39.5