From 85b9d00472834326a2e725886704d12b7e63dfd1 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 10 Jan 2024 16:45:24 +0100 Subject: [PATCH] Bug 35329: Add cypress tests Signed-off-by: Owen Leonard Signed-off-by: Martin Renvoize --- t/cypress/integration/ERM/UserRoles_spec.ts | 79 +++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 t/cypress/integration/ERM/UserRoles_spec.ts diff --git a/t/cypress/integration/ERM/UserRoles_spec.ts b/t/cypress/integration/ERM/UserRoles_spec.ts new file mode 100644 index 00000000000..7bc3cd410b8 --- /dev/null +++ b/t/cypress/integration/ERM/UserRoles_spec.ts @@ -0,0 +1,79 @@ +import { mount } from "@cypress/vue"; + +describe("Add/search user", () => { + beforeEach(() => { + cy.login(); + cy.title().should("eq", "Koha staff interface"); + cy.intercept( + "GET", + "/api/v1/erm/config", + '{"settings":{"ERMModule":"1","ERMProviders":["local"]}}' + ); + }); + + it("Add agreement", () => { + let vendors = cy.get_vendors_to_relate(); + // No agreement, no license yet + cy.intercept("GET", "/api/v1/erm/agreements*", { + statusCode: 200, + body: [], + }); + cy.intercept("GET", "/api/v1/erm/licenses*", { + statusCode: 200, + body: [], + }); + + //Intercept patrons request + cy.intercept("GET", "/api/v1/patrons*", { + statusCode: 200, + body: [ + { + patron_id: 1, + firstname: "foo", + surname: "bar", + category_id: "S", + library_id: "CPL", + }, + { + patron_id: 2, + firstname: "foofoo", + surname: "barbar", + category_id: "S", + library_id: "CPL", + }, + ], + headers: { + "X-Base-Total-Count": "2", + "X-Total-Count": "2", + }, + }); + + cy.intercept("GET", "/api/v1/patrons/1", { + statusCode: 200, + body: { + patron_id: 1, + firstname: "foo", + surname: "bar", + category_id: "S", + library_id: "CPL", + }, + }); + + // Click the button in the toolbar + cy.visit("/cgi-bin/koha/erm/agreements"); + cy.contains("New agreement").click(); + cy.get("#agreements_add h2").contains("New agreement"); + cy.left_menu_active_item_is("Agreements"); + + cy.contains("Add new user").click(); + cy.contains("Select user").click(); + cy.get("#patron_search_modal fieldset.action") + .contains("Search") + .click(); + + cy.get("#patron_search_modal table").contains("bar, foo"); + cy.get("#patron_search_modal td").contains("Select").click(); + + cy.get("#user_roles li:first span.user").contains("foo bar"); + }); +}); -- 2.43.0