1 import { mount } from "@cypress/vue";
3 function get_package() {
7 package_type: "complete",
13 description: "agreement description",
14 name: "agreement name",
24 describe("Dialog operations", () => {
27 cy.title().should("eq", "Koha staff interface");
30 "/cgi-bin/koha/svc/config/systempreferences/?pref=ERMModule",
35 "/cgi-bin/koha/svc/config/systempreferences/?pref=ERMProviders",
40 it("There are no ... defined", () => {
41 // GET packages returns empty list
42 cy.intercept("GET", "/api/v1/erm/eholdings/local/packages*", {
46 "X-Base-Total-Count": "0",
50 cy.visit("/cgi-bin/koha/erm/eholdings/local/packages");
51 cy.get("#packages_list").contains("There are no packages defined");
54 it("Something went wrong - 500", () => {
55 // GET package returns 500
56 cy.intercept("GET", "/api/v1/erm/eholdings/local/packages*", {
59 error: "This is a specific error message",
62 cy.visit("/cgi-bin/koha/erm/erm.pl");
63 cy.get("#navmenulist").contains("Packages").click();
64 cy.get("main div[class='dialog alert']").contains(
65 "Something went wrong: Error: This is a specific error message"
68 cy.intercept("GET", "/api/v1/erm/eholdings/local/packages*", {
69 statusCode: 500, // No body, in case of Internal Server Error, we get statusText
71 cy.visit("/cgi-bin/koha/erm/erm.pl");
72 cy.get("#navmenulist").contains("Packages").click();
73 cy.get("main div[class='dialog alert']").contains(
74 "Something went wrong: Error: Internal Server Error"
77 cy.intercept("GET", "/api/v1/erm/agreements*", []);
78 cy.get("#navmenulist").contains("Agreements").click();
79 // Info messages should be cleared when view is changed
80 cy.get("main div[class='dialog message']").contains(
81 "There are no agreements defined"
83 cy.get("main div[class='dialog message']").should("have.length", 1);
86 it("...created!", () => {
87 let erm_package = get_package();
88 cy.intercept("GET", "/api/v1/erm/agreements*", []);
90 cy.visit("/cgi-bin/koha/erm/eholdings/local/packages/add");
91 cy.get("#package_name").type(erm_package.name);
92 cy.get("#package_type .vs__search").type(
93 erm_package.package_type + "{enter}",
97 cy.intercept("POST", "/api/v1/erm/eholdings/local/packages", {
101 cy.get("#packages_add").contains("Submit").click();
102 cy.get("main div[class='dialog message']").contains("Package created");
103 cy.get("main div[class='dialog message']").should("have.length", 1);
105 cy.intercept("GET", "/api/v1/erm/eholdings/local/titles*", {
107 body: [cy.get_title()],
109 "X-Base-Total-Count": "1",
110 "X-Total-Count": "1",
113 cy.get("#navmenulist").contains("Titles").click();
114 // Info messages should be cleared when view is changed
115 cy.get("main div[class='dialog message']").should("not.exist");
118 it("Confirmation messages", () => {
119 let erm_package = get_package();
120 let packages = [erm_package];
122 // Click the 'Delete' button from the list
123 cy.intercept("GET", "/api/v1/erm/eholdings/local/packages*", {
127 "X-Base-Total-Count": "1",
128 "X-Total-Count": "1",
131 cy.intercept("PUT", "/api/v1/erm/eholdings/local/packages/*", {
137 "/api/v1/erm/eholdings/local/packages/*",
140 cy.visit("/cgi-bin/koha/erm/eholdings/local/packages");
142 cy.get("#packages_list table tbody tr:first").contains("Edit").click();
143 cy.get("#packages_add").contains("Submit").click();
144 cy.get("main div[class='dialog message']").contains("Package updated");
145 cy.get("main div[class='dialog message']").should("have.length", 1);
147 cy.get("#packages_list table tbody tr:first")
150 cy.contains("No, do not delete").click();
151 cy.get(".dialog.alert.confirmation h1").should("not.exist");
152 cy.get("main div[class='dialog message']").contains("Package updated");
153 cy.get("main div[class='dialog message']").should("have.length", 1);
155 cy.intercept("DELETE", "/api/v1/erm/eholdings/local/packages/*", {
159 cy.get("#packages_list table tbody tr:first")
162 cy.get(".dialog.alert.confirmation h1").contains("remove this package");
163 cy.contains("Yes, delete").click();
164 cy.get("main div[class='dialog message']")
165 .contains("Local package")
166 .contains("deleted");
167 cy.get("main div[class='dialog message']").should("have.length", 1);