From f151895e08c2b81c9129ef6994c07c42f17d1e66 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 31 Oct 2023 15:27:25 +0100 Subject: [PATCH] Bug 35201: (bug 30708 follow-up) Fix Preservation tests We didn't mock the config given the last changes Signed-off-by: Tomas Cohen Arazi --- .../prog/js/vue/routes/preservation.js | 2 +- t/cypress/integration/Preservation/Trains.ts | 28 +++++++-------- .../integration/Preservation/WaitingList.ts | 34 +++++++++---------- 3 files changed, 30 insertions(+), 34 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/routes/preservation.js b/koha-tmpl/intranet-tmpl/prog/js/vue/routes/preservation.js index cb75d07ce1..ac9df94e8f 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/vue/routes/preservation.js +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/routes/preservation.js @@ -97,7 +97,7 @@ export const routes = [ }, { path: "/cgi-bin/koha/preservation/waiting-list", - title: $__("Waiting List"), + title: $__("Waiting list"), icon: "fa fa-recycle", is_end_node: true, children: [ diff --git a/t/cypress/integration/Preservation/Trains.ts b/t/cypress/integration/Preservation/Trains.ts index 7c2a440fb7..6dda1f78a3 100644 --- a/t/cypress/integration/Preservation/Trains.ts +++ b/t/cypress/integration/Preservation/Trains.ts @@ -208,19 +208,10 @@ describe("Trains", () => { cy.title().should("eq", "Koha staff interface"); cy.intercept( "GET", - "/cgi-bin/koha/svc/config/systempreferences/?pref=PreservationModule", - '{"value":"1"}' - ); - cy.intercept( - "GET", - "/cgi-bin/koha/svc/config/systempreferences/?pref=PreservationNotForLoanWaitingListIn", - '{"value":"24"}' - ); - cy.intercept( - "GET", - "/cgi-bin/koha/svc/config/systempreferences/?pref=PreservationNotForLoanDefaultTrainIn", - '{"value":"42"}' + "/api/v1/preservation/config", + '{"permissions":{"manage_sysprefs":"1"},"settings":{"enabled":"1","not_for_loan_default_train_in":"42","not_for_loan_waiting_list_in": "24"}}' ); + cy.intercept( "GET", "/api/v1/authorised_value_categories/NOT_LOAN/authorised_values", @@ -277,7 +268,7 @@ describe("Trains", () => { ); // GET trains returns empty list - cy.intercept("GET", "/api/v1/*", []); + cy.intercept("GET", "/api/v1/preservation/trains*", []); cy.visit("/cgi-bin/koha/preservation/trains"); cy.get("#trains_list").contains("There are no trains defined"); @@ -345,7 +336,15 @@ describe("Trains", () => { let train = get_train(); let processings = get_processings(); cy.intercept("GET", "/api/v1/preservation/trains/*", train); - cy.intercept("GET", "/api/v1/preservation/trains", [train]); + cy.intercept("GET", "/api/v1/preservation/trains*", { + statusCode: 200, + body: [train], + headers: { + "X-Base-Total-Count": "1", + "X-Total-Count": "1", + }, + }); + cy.intercept("GET", "/api/v1/preservation/processings*", processings); cy.visit("/cgi-bin/koha/preservation/trains"); cy.get("#trains_list table tbody tr:first").contains("Edit").click(); @@ -361,7 +360,6 @@ describe("Trains", () => { // Submit the form, get 500 cy.intercept("PUT", "/api/v1/preservation/trains/*", { statusCode: 500, - error: "Something went wrong", }); cy.get("#trains_add").contains("Submit").click(); cy.get("main div[class='dialog alert']").contains( diff --git a/t/cypress/integration/Preservation/WaitingList.ts b/t/cypress/integration/Preservation/WaitingList.ts index e5c956198f..3c12003b37 100644 --- a/t/cypress/integration/Preservation/WaitingList.ts +++ b/t/cypress/integration/Preservation/WaitingList.ts @@ -21,32 +21,31 @@ function get_items() { }, ]; } +let config = { + permissions: { manage_sysprefs: "1" }, + settings: { + enabled: "1", + not_for_loan_default_train_in: "42", + not_for_loan_waiting_list_in: "24", + }, +}; describe("WaitingList", () => { beforeEach(() => { cy.login(); cy.title().should("eq", "Koha staff interface"); cy.intercept( "GET", - "/cgi-bin/koha/svc/config/systempreferences/?pref=PreservationModule", - '{"value":"1"}' - ); - cy.intercept( - "GET", - "/cgi-bin/koha/svc/config/systempreferences/?pref=PreservationNotForLoanWaitingListIn", - '{"value":"24"}' - ); - cy.intercept( - "GET", - "/cgi-bin/koha/svc/config/systempreferences/?pref=PreservationNotForLoanDefaultTrainIn", - '{"value":"42"}' + "/api/v1/preservation/config", + JSON.stringify(config) ); }); it("List", () => { + config.settings.not_for_loan_waiting_list_in = ""; cy.intercept( "GET", - "/cgi-bin/koha/svc/config/systempreferences/?pref=PreservationNotForLoanWaitingListIn", - '{"value":""}' + "/api/v1/preservation/config", + JSON.stringify(config) ); cy.visit("/cgi-bin/koha/preservation/home.pl"); cy.intercept("GET", "/api/v1/preservation/waiting-list/items*", []); @@ -55,10 +54,11 @@ describe("WaitingList", () => { "You need to configure this module first." ); + config.settings.not_for_loan_waiting_list_in = "42"; cy.intercept( "GET", - "/cgi-bin/koha/svc/config/systempreferences/?pref=PreservationNotForLoanWaitingListIn", - '{"value":"42"}' + "/api/v1/preservation/config", + JSON.stringify(config) ); cy.visit("/cgi-bin/koha/preservation/home.pl"); cy.intercept("GET", "/api/v1/preservation/waiting-list/items*", []); @@ -73,7 +73,6 @@ describe("WaitingList", () => { cy.visit("/cgi-bin/koha/preservation/waiting-list"); cy.intercept("POST", "/api/v1/preservation/waiting-list/items", { statusCode: 500, - error: "Something went wrong", }); cy.get("#waiting-list").contains("Add to waiting list").click(); cy.get("#barcode_list").type("bc_1\nbc_2\nbc_3"); @@ -117,7 +116,6 @@ describe("WaitingList", () => { // Submit the form, get 500 cy.intercept("DELETE", "/api/v1/preservation/waiting-list/items/*", { statusCode: 500, - error: "Something went wrong", }); cy.get("#waiting-list table tbody tr:first").contains("Remove").click(); cy.contains("Yes, remove").click(); -- 2.39.5