From adf0b82d8da246a57e2de7ab5c74a7416a723ab8 Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Mon, 2 Mar 2026 10:56:30 +0000 Subject: [PATCH] Bug 41178: Add cypress test Run: cypress run --spec t/cypress/integration/SIP2/Institutions.ts Test plan: 1) Create a SIP institution, visit: http://localhost:8081/cgi-bin/koha/sip2/institutions/add 2) Create a SIP account linked to the institution from 1): http://localhost:8081/cgi-bin/koha/sip2/accounts/add 3) Go back to institutions: http://localhost:8081/cgi-bin/koha/sip2/institutions 4) Click 'delete'. Confirm the delete confirmation message contains: 'It has 1 associated accounts...' 5) Confirm that, notice the institution (and linked account) were deleted as expected and alerted 6) Repeat the test plan for the 'view' page instead of 'list' page: http://localhost:8081/cgi-bin/koha/sip2/institutions/ 7) Repeat the test plan but using an institution without any linked accounts. Confirm the 'regular' delete message is shown, which contains only the institution name in the modal body. Signed-off-by: David Nind --- t/cypress/integration/SIP2/Institutions.ts | 44 ++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/t/cypress/integration/SIP2/Institutions.ts b/t/cypress/integration/SIP2/Institutions.ts index f1c4dd3fdc..dddf8ec93a 100644 --- a/t/cypress/integration/SIP2/Institutions.ts +++ b/t/cypress/integration/SIP2/Institutions.ts @@ -282,4 +282,48 @@ describe("Institutions", () => { //Make sure we return to list after deleting from show cy.get("#institutions_list table tbody tr:first"); }); + + it("Delete institution with accounts linked", () => { + let institution = cy.getSIP2Institution(); + let institutions = [institution]; + + // Delete from list + // Click the 'Delete' button from the list + cy.intercept("GET", "/api/v1/sip2/institutions*", { + statusCode: 200, + body: institutions, + headers: { + "X-Base-Total-Count": "1", + "X-Total-Count": "1", + }, + }); + cy.intercept("GET", "/api/v1/sip2/institutions/*", institution); + cy.visit("/cgi-bin/koha/sip2/institutions"); + + let linked_account_loginid = "my_login"; + cy.intercept("GET", "/api/v1/sip2/accounts**", [ + { login_id: linked_account_loginid }, + ]); + + cy.intercept("DELETE", "/api/v1/sip2/institutions/*", { + statusCode: 204, + body: null, + }); + + cy.get("#institutions_list table tbody tr:first") + .contains("Delete") + .click(); + cy.get(".confirmation.modal.show .modal-body").contains( + "It has 1 associated accounts" + ); + cy.contains(linked_account_loginid); + + cy.get(".alert-warning.confirmation h1").contains( + "remove this institution" + ); + cy.contains("Yes, delete").click(); + cy.get("main div[class='alert alert-info']") + .contains("Institution") + .contains("deleted"); + }); }); -- 2.39.5