From 30a5b94ae8ae48dc3dc7b8d6073ffaa51ec20b92 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/ --- 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 8dd209ee8d5..b9319278583 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 9f39eaa2125..dc85f035d24 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 88791518282..78d1390c029 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 f5f6be5c4ed..647c30d19eb 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 90061e600db..06724aa4d8c 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.25.1