1 import { mount } from "@cypress/vue";
3 function get_attributes() {
6 processing_attribute_id: 1,
9 type: "authorised_value",
10 option_source: "COUNTRY",
13 processing_attribute_id: 1,
17 option_source: "biblio.title",
20 processing_attribute_id: 1,
28 function get_processing() {
30 name: "test processing",
32 attributes: get_attributes(),
35 describe("Processings", () => {
38 cy.title().should("eq", "Koha staff interface");
41 "/cgi-bin/koha/svc/config/systempreferences/?pref=PreservationModule",
46 "/cgi-bin/koha/svc/config/systempreferences/?pref=PreservationNotForLoanWaitingListIn",
51 "/cgi-bin/koha/svc/config/systempreferences/?pref=PreservationNotForLoanDefaultTrainIn",
56 "/api/v1/authorised_value_categories/NOT_LOAN/authorised_values",
59 category_name: "NOT_LOAN",
60 description: "Ordered",
64 category_name: "NOT_LOAN",
65 description: "Not for loan",
69 category_name: "NOT_LOAN",
70 description: "Staff collection",
74 category_name: "NOT_LOAN",
75 description: "Added to bundle",
79 category_name: "NOT_LOAN",
80 description: "In preservation",
84 category_name: "NOT_LOAN",
85 description: "In preservation external",
92 it("Settings", () => {
93 cy.visit("/cgi-bin/koha/preservation/home.pl");
94 cy.get("#navmenulist").contains("Settings").click();
95 cy.get("#not_for_loan_waiting_list_in .vs__selected").contains(
98 cy.get("#not_for_loan_default_train_in .vs__selected").contains(
99 "In preservation external"
102 it("List processing", () => {
103 cy.intercept("GET", "/api/v1/preservation/processings*", []);
104 cy.visit("/cgi-bin/koha/preservation/settings");
105 cy.get("#processing_0").should("not.exist");
106 cy.intercept("GET", "/api/v1/preservation/processings*", [
109 cy.visit("/cgi-bin/koha/preservation/settings");
110 cy.get("#processing_0").should("exist");
113 it("Add processing", () => {
114 cy.intercept("GET", "/api/v1/preservation/processings*", []);
115 cy.visit("/cgi-bin/koha/preservation/settings");
116 let processing = get_processing();
117 cy.contains("Add new processing").click();
118 cy.get("#processing_name").type(processing.name);
119 cy.contains("Add new attribute").click();
120 let attribute = processing.attributes[0];
121 cy.get("#attribute_name_0").type(attribute.name);
122 cy.get("#attribute_type_0 .vs__search").type("Authorized{enter}", {
125 cy.get("#attribute_option_0 .vs__search").type(
126 attribute.option_source + "{enter}",
129 cy.contains("Add new attribute").click();
130 attribute = processing.attributes[1];
131 cy.get("#attribute_name_1").type(attribute.name);
132 cy.get("#attribute_type_1 .vs__search").type("Database{enter}", {
135 cy.get("#attribute_option_1 .vs__search").type(
136 attribute.option_source + "{enter}",
139 cy.contains("Add new attribute").click();
140 attribute = processing.attributes[2];
141 cy.get("#attribute_name_2").type(attribute.name);
142 cy.get("#attribute_type_2 .vs__search").type("Free{enter}", {
146 // Submit the form, get 500
147 cy.intercept("POST", "/api/v1/preservation/processings", {
149 error: "Something went wrong",
151 cy.get("#processings_add").contains("Submit").click();
152 cy.get("main div[class='dialog alert']").contains(
153 "Something went wrong: Error: Internal Server Error"
156 // Submit the form, success!
157 cy.intercept("POST", "/api/v1/preservation/processings", {
161 cy.intercept("GET", "/api/v1/preservation/processings*", {
165 cy.get("#processings_add").contains("Submit").click();
166 cy.get("main div[class='dialog message']").contains(
169 cy.get("#processing_0").contains(processing.name);
172 it("Edit processing", () => {
173 let processing = get_processing();
174 cy.intercept("GET", "/api/v1/preservation/processings/*", {
178 cy.intercept("GET", "/api/v1/preservation/processings*", {
182 cy.visit("/cgi-bin/koha/preservation/settings");
183 cy.get("#processing_0").contains(processing.name);
184 cy.get("#processing_0").contains("Edit this processing").click();
185 cy.get("#processing_name").should("have.value", processing.name);
186 let attribute = processing.attributes[0];
187 cy.get("#attribute_name_0").should("have.value", attribute.name);
188 cy.get("#attribute_type_0 .vs__selected").contains("Authorized value");
189 cy.get("#attribute_option_0 .vs__selected").contains(
190 attribute.option_source
192 attribute = processing.attributes[1];
193 cy.get("#attribute_name_1").should("have.value", attribute.name);
194 cy.get("#attribute_type_1 .vs__selected").contains("Database column");
195 cy.get("#attribute_option_1 .vs__selected").contains(
196 attribute.option_source
198 attribute = processing.attributes[2];
199 cy.get("#attribute_name_2").should("have.value", attribute.name);
200 cy.get("#attribute_type_2 .vs__selected").contains("Free text");
201 cy.get("#attribute_option_2").should("not.exist");
203 // Submit the form, get 500
204 cy.intercept("PUT", "/api/v1/preservation/processings/*", {
206 error: "Something went wrong",
208 cy.get("#processings_add").contains("Submit").click();
209 cy.get("main div[class='dialog alert']").contains(
210 "Something went wrong: Error: Internal Server Error"
213 // Submit the form, success!
214 cy.intercept("PUT", "/api/v1/preservation/processings/*", {
218 cy.get("#processings_add").contains("Submit").click();
219 cy.get("main div[class='dialog message']").contains(
224 it("Delete processing", () => {
225 let processing = get_processing();
226 cy.intercept("GET", "/api/v1/preservation/processings*", {
231 // Submit the form, get 500
232 cy.intercept("DELETE", "/api/v1/preservation/processings/*", {
234 error: "Something went wrong",
236 cy.visit("/cgi-bin/koha/preservation/settings");
237 cy.get("#processing_0").contains("Remove this processing").click();
238 cy.contains("Yes, delete").click();
239 cy.get("main div[class='dialog alert']").contains(
240 "Something went wrong: Error: Internal Server Error"
243 // Submit the form, success!
244 cy.intercept("DELETE", "/api/v1/preservation/processings/*", {
248 cy.get("#processing_0").contains("Remove this processing").click();
249 cy.contains("Yes, delete").click();
250 cy.get("main div[class='dialog message']").contains(
251 `Processing ${processing.name} deleted`