|
Lines 125-154
const parse_to_ill_response = {
Link Here
|
| 125 |
}; |
125 |
}; |
| 126 |
|
126 |
|
| 127 |
const batchstatuses = [ |
127 |
const batchstatuses = [ |
| 128 |
{ |
128 |
{ |
| 129 |
"code": "NEW", |
129 |
code: "NEW", |
| 130 |
"id": 1, |
130 |
id: 1, |
| 131 |
"is_system": true, |
131 |
is_system: true, |
| 132 |
"name": "New" |
132 |
name: "New", |
| 133 |
}, |
133 |
}, |
| 134 |
{ |
134 |
{ |
| 135 |
"code": "IN_PROGRESS", |
135 |
code: "IN_PROGRESS", |
| 136 |
"id": 2, |
136 |
id: 2, |
| 137 |
"is_system": true, |
137 |
is_system: true, |
| 138 |
"name": "In progress" |
138 |
name: "In progress", |
| 139 |
}, |
139 |
}, |
| 140 |
{ |
140 |
{ |
| 141 |
"code": "COMPLETED", |
141 |
code: "COMPLETED", |
| 142 |
"id": 3, |
142 |
id: 3, |
| 143 |
"is_system": true, |
143 |
is_system: true, |
| 144 |
"name": "Completed" |
144 |
name: "Completed", |
| 145 |
}, |
145 |
}, |
| 146 |
{ |
146 |
{ |
| 147 |
"code": "UNKNOWN", |
147 |
code: "UNKNOWN", |
| 148 |
"id": 4, |
148 |
id: 4, |
| 149 |
"is_system": true, |
149 |
is_system: true, |
| 150 |
"name": "Unknown" |
150 |
name: "Unknown", |
| 151 |
} |
151 |
}, |
| 152 |
]; |
152 |
]; |
| 153 |
|
153 |
|
| 154 |
describe("ILL Batches", () => { |
154 |
describe("ILL Batches", () => { |
|
Lines 188-196
describe("ILL Batches", () => {
Link Here
|
| 188 |
|
188 |
|
| 189 |
cy.intercept("GET", "/api/v1/ill/batchstatuses", { |
189 |
cy.intercept("GET", "/api/v1/ill/batchstatuses", { |
| 190 |
statusCode: 200, |
190 |
statusCode: 200, |
| 191 |
body: batchstatuses |
191 |
body: batchstatuses, |
| 192 |
}).as("get-batchstatuses"); |
192 |
}).as("get-batchstatuses"); |
| 193 |
|
|
|
| 194 |
}); |
193 |
}); |
| 195 |
afterEach(function () { |
194 |
afterEach(function () { |
| 196 |
//Restore ILLModule sys pref original value |
195 |
//Restore ILLModule sys pref original value |
|
Lines 296-298
describe("ILL Batches", () => {
Link Here
|
| 296 |
cy.get("#identifier-table_wrapper").should("not.be.visible"); |
295 |
cy.get("#identifier-table_wrapper").should("not.be.visible"); |
| 297 |
}); |
296 |
}); |
| 298 |
}); |
297 |
}); |
| 299 |
- |
298 |
|
|
|
299 |
describe("AutoILLBackendPriority syspref", () => { |
| 300 |
let original_plugin_restricted; |
| 301 |
let kohaconf = "/etc/koha/sites/kohadev/koha-conf.xml"; |
| 302 |
beforeEach(() => { |
| 303 |
cy.login(); |
| 304 |
cy.task("query", { |
| 305 |
sql: "SELECT value FROM systempreferences WHERE variable='ILLModule'", |
| 306 |
}).then(rows => { |
| 307 |
cy.wrap(rows[0].value).as("syspref_ILLModule"); |
| 308 |
}); |
| 309 |
cy.set_syspref("ILLModule", 1); |
| 310 |
cy.task("query", { |
| 311 |
sql: "SELECT value FROM systempreferences WHERE variable='AutoILLBackendPriority'", |
| 312 |
}).then(rows => { |
| 313 |
cy.wrap(rows[0].value).as("syspref_AutoILLBackendPriority"); |
| 314 |
}); |
| 315 |
cy.set_syspref("AutoILLBackendPriority", "PluginBackend"); |
| 316 |
cy.task("readXmlElementValue", { |
| 317 |
filePath: kohaconf, |
| 318 |
element: "plugins_restricted", |
| 319 |
}).then(value => { |
| 320 |
original_plugin_restricted = value; |
| 321 |
if (value == "1") { |
| 322 |
cy.task("modifyXmlElement", { |
| 323 |
filePath: kohaconf, |
| 324 |
element: "plugins_restricted", |
| 325 |
value: "0", |
| 326 |
}); |
| 327 |
} |
| 328 |
}); |
| 329 |
cy.title().should("eq", "Koha staff interface"); |
| 330 |
cy.get("a.icon_administration").contains("Koha administration").click(); |
| 331 |
cy.get("a").contains("Manage plugins").click(); |
| 332 |
cy.get("a#upload_plugin").contains("Upload plugin").click(); |
| 333 |
|
| 334 |
cy.get("#uploadfile").click(); |
| 335 |
cy.get("#uploadfile").selectFile( |
| 336 |
"t/cypress/fixtures/koha-plugin-ill-metadata-enrichment.kpz" |
| 337 |
); |
| 338 |
cy.get("input").contains("Upload").click(); |
| 339 |
|
| 340 |
// Install dummy backend plugin compatibly with AutoILLBackendPriority and ILL batches |
| 341 |
cy.visit("/cgi-bin/koha/plugins/plugins-home.pl"); |
| 342 |
cy.get("a#upload_plugin").contains("Upload plugin").click(); |
| 343 |
cy.get("#uploadfile").click(); |
| 344 |
cy.get("#uploadfile").selectFile( |
| 345 |
"t/cypress/fixtures/koha-plugin-ill-backend.kpz" |
| 346 |
); |
| 347 |
cy.get("input").contains("Upload").click(); |
| 348 |
|
| 349 |
cy.intercept("GET", "/api/v1/ill/batchstatuses", { |
| 350 |
statusCode: 200, |
| 351 |
body: batchstatuses, |
| 352 |
}).as("get-batchstatuses"); |
| 353 |
}); |
| 354 |
afterEach(function () { |
| 355 |
//Restore ILLModule sys pref original value |
| 356 |
cy.set_syspref("ILLModule", this.syspref_ILLModule); |
| 357 |
// Restore AutoILLBackendPriority original value |
| 358 |
cy.set_syspref( |
| 359 |
"AutoILLBackendPriority", |
| 360 |
this.syspref_AutoILLBackendPriority |
| 361 |
); |
| 362 |
//Restore plugins_restricted original value |
| 363 |
cy.task("modifyXmlElement", { |
| 364 |
filePath: kohaconf, |
| 365 |
element: "plugins_restricted", |
| 366 |
value: original_plugin_restricted, |
| 367 |
}); |
| 368 |
//Clean-up created test batches |
| 369 |
cy.task("query", { |
| 370 |
sql: "DELETE from illbatches", |
| 371 |
}); |
| 372 |
//Clean-up installed plugin(s) |
| 373 |
cy.task("query", { |
| 374 |
sql: "DELETE from plugin_data", |
| 375 |
}); |
| 376 |
cy.task("query", { |
| 377 |
sql: "DELETE from plugin_methods", |
| 378 |
}); |
| 379 |
}); |
| 380 |
|
| 381 |
it("AutoILLBackendPriority: Backend error", function () { |
| 382 |
// ILL toolbar |
| 383 |
cy.visit("/cgi-bin/koha/ill/ill-requests.pl"); |
| 384 |
cy.get("#ill-batch-backend-dropdown").should("not.exist"); |
| 385 |
cy.get(".ill-toolbar a.btn-default") |
| 386 |
.contains("New ILL requests batch") |
| 387 |
.click(); |
| 388 |
cy.wait("@get-batchstatuses"); |
| 389 |
|
| 390 |
// Modal |
| 391 |
cy.get("#ill-batch-modal").should("be.visible"); |
| 392 |
cy.get("#ill-batch-modal #button_create_batch") |
| 393 |
.should("exist") |
| 394 |
.and("be.disabled"); |
| 395 |
|
| 396 |
// Create a batch |
| 397 |
cy.get("#ill-batch-modal #name").type("second test batch"); |
| 398 |
cy.get("#ill-batch-modal #batchcardnumber").type("42"); |
| 399 |
cy.get("#ill-batch-modal #branchcode").select("Centerville"); |
| 400 |
cy.get("#ill-batch-modal #button_create_batch") |
| 401 |
.should("exist") |
| 402 |
.and("not.be.disabled"); |
| 403 |
cy.get("#ill-batch-modal #button_create_batch").click(); |
| 404 |
cy.get("#ill-batch-modal #add_batch_items").should("be.visible"); |
| 405 |
|
| 406 |
// Add identifiers + Mock plugin (pubmedid) API responses |
| 407 |
let pubmedid = "123"; |
| 408 |
cy.intercept( |
| 409 |
"GET", |
| 410 |
"/api/v1/contrib/pubmed/esummary?pmid=" + pubmedid, |
| 411 |
{ |
| 412 |
statusCode: 200, |
| 413 |
body: pubmedid_metadata_response, |
| 414 |
} |
| 415 |
).as("get-pubmedid-metadata"); |
| 416 |
cy.intercept("POST", "/api/v1/contrib/pubmed/parse_to_ill", { |
| 417 |
statusCode: 200, |
| 418 |
body: parse_to_ill_response, |
| 419 |
}).as("get-parse_to_ill"); |
| 420 |
cy.intercept( |
| 421 |
"GET", |
| 422 |
"/api/v1/contrib/pluginbackend/ill_backend_availability_pluginbackend*", |
| 423 |
{ |
| 424 |
statusCode: 404, |
| 425 |
body: { |
| 426 |
error: "Provided ISBN is not available in PluginBackend", |
| 427 |
}, |
| 428 |
} |
| 429 |
).as("get-backend_availability_response"); |
| 430 |
|
| 431 |
cy.get("#ill-batch-modal #identifiers_input").type(pubmedid); |
| 432 |
cy.get("#ill-batch-modal #process-button") |
| 433 |
.contains("Process identifiers") |
| 434 |
.click(); |
| 435 |
cy.wait("@get-pubmedid-metadata"); |
| 436 |
cy.wait("@get-parse_to_ill"); |
| 437 |
cy.wait("@get-backend_availability_response"); |
| 438 |
cy.get("#identifier-table .dt-column-title") |
| 439 |
.contains("Auto backend") |
| 440 |
.should("exist"); |
| 441 |
cy.get("#ill-batch-modal #create-requests-button").should("exist"); |
| 442 |
|
| 443 |
//Plugin backend came back with error, Standard should be checked |
| 444 |
cy.get("input[name='auto_backend_0']").first().should("not.be.checked"); |
| 445 |
cy.get("input[name='auto_backend_0']").eq(1).should("be.checked"); |
| 446 |
}); |
| 447 |
|
| 448 |
it("AutoILLBackendPriority: Backend warning", function () { |
| 449 |
// ILL toolbar |
| 450 |
cy.visit("/cgi-bin/koha/ill/ill-requests.pl"); |
| 451 |
cy.get("#ill-batch-backend-dropdown").should("not.exist"); |
| 452 |
cy.get(".ill-toolbar a.btn-default") |
| 453 |
.contains("New ILL requests batch") |
| 454 |
.click(); |
| 455 |
cy.wait("@get-batchstatuses"); |
| 456 |
|
| 457 |
// Modal |
| 458 |
cy.get("#ill-batch-modal").should("be.visible"); |
| 459 |
cy.get("#ill-batch-modal #button_create_batch") |
| 460 |
.should("exist") |
| 461 |
.and("be.disabled"); |
| 462 |
|
| 463 |
// Create a batch |
| 464 |
cy.get("#ill-batch-modal #name").type("second test batch"); |
| 465 |
cy.get("#ill-batch-modal #batchcardnumber").type("42"); |
| 466 |
cy.get("#ill-batch-modal #branchcode").select("Centerville"); |
| 467 |
cy.get("#ill-batch-modal #button_create_batch") |
| 468 |
.should("exist") |
| 469 |
.and("not.be.disabled"); |
| 470 |
cy.get("#ill-batch-modal #button_create_batch").click(); |
| 471 |
cy.get("#ill-batch-modal #add_batch_items").should("be.visible"); |
| 472 |
|
| 473 |
// Add identifiers + Mock plugin (pubmedid) API responses |
| 474 |
let pubmedid = "123"; |
| 475 |
cy.intercept( |
| 476 |
"GET", |
| 477 |
"/api/v1/contrib/pubmed/esummary?pmid=" + pubmedid, |
| 478 |
{ |
| 479 |
statusCode: 200, |
| 480 |
body: pubmedid_metadata_response, |
| 481 |
} |
| 482 |
).as("get-pubmedid-metadata"); |
| 483 |
cy.intercept("POST", "/api/v1/contrib/pubmed/parse_to_ill", { |
| 484 |
statusCode: 200, |
| 485 |
body: parse_to_ill_response, |
| 486 |
}).as("get-parse_to_ill"); |
| 487 |
cy.intercept( |
| 488 |
"GET", |
| 489 |
"/api/v1/contrib/pluginbackend/ill_backend_availability_pluginbackend*", |
| 490 |
{ |
| 491 |
statusCode: 200, |
| 492 |
body: { |
| 493 |
warning: |
| 494 |
"May be placed but will have to go through human verification", |
| 495 |
}, |
| 496 |
} |
| 497 |
).as("get-backend_availability_response"); |
| 498 |
|
| 499 |
cy.get("#ill-batch-modal #identifiers_input").type(pubmedid); |
| 500 |
cy.get("#ill-batch-modal #process-button") |
| 501 |
.contains("Process identifiers") |
| 502 |
.click(); |
| 503 |
cy.wait("@get-pubmedid-metadata"); |
| 504 |
cy.wait("@get-parse_to_ill"); |
| 505 |
cy.wait("@get-backend_availability_response"); |
| 506 |
cy.get("#identifier-table .dt-column-title") |
| 507 |
.contains("Auto backend") |
| 508 |
.should("exist"); |
| 509 |
cy.get("#ill-batch-modal #create-requests-button").should("exist"); |
| 510 |
|
| 511 |
//Plugin backend came back with warning, Standard should be checked |
| 512 |
cy.get("input[name='auto_backend_0']").first().should("not.be.checked"); |
| 513 |
cy.get("input[name='auto_backend_0']").eq(1).should("be.checked"); |
| 514 |
}); |
| 515 |
|
| 516 |
it("AutoILLBackendPriority: Backend success", function () { |
| 517 |
// ILL toolbar |
| 518 |
cy.visit("/cgi-bin/koha/ill/ill-requests.pl"); |
| 519 |
cy.get("#ill-batch-backend-dropdown").should("not.exist"); |
| 520 |
cy.get(".ill-toolbar a.btn-default") |
| 521 |
.contains("New ILL requests batch") |
| 522 |
.click(); |
| 523 |
cy.wait("@get-batchstatuses"); |
| 524 |
|
| 525 |
// Modal |
| 526 |
cy.get("#ill-batch-modal").should("be.visible"); |
| 527 |
cy.get("#ill-batch-modal #button_create_batch") |
| 528 |
.should("exist") |
| 529 |
.and("be.disabled"); |
| 530 |
|
| 531 |
// Create a batch |
| 532 |
cy.get("#ill-batch-modal #name").type("second test batch"); |
| 533 |
cy.get("#ill-batch-modal #batchcardnumber").type("42"); |
| 534 |
cy.get("#ill-batch-modal #branchcode").select("Centerville"); |
| 535 |
cy.get("#ill-batch-modal #button_create_batch") |
| 536 |
.should("exist") |
| 537 |
.and("not.be.disabled"); |
| 538 |
cy.get("#ill-batch-modal #button_create_batch").click(); |
| 539 |
cy.get("#ill-batch-modal #add_batch_items").should("be.visible"); |
| 540 |
|
| 541 |
// Add identifiers + Mock plugin (pubmedid) API responses |
| 542 |
let pubmedid = "123"; |
| 543 |
cy.intercept( |
| 544 |
"GET", |
| 545 |
"/api/v1/contrib/pubmed/esummary?pmid=" + pubmedid, |
| 546 |
{ |
| 547 |
statusCode: 200, |
| 548 |
body: pubmedid_metadata_response, |
| 549 |
} |
| 550 |
).as("get-pubmedid-metadata"); |
| 551 |
cy.intercept("POST", "/api/v1/contrib/pubmed/parse_to_ill", { |
| 552 |
statusCode: 200, |
| 553 |
body: parse_to_ill_response, |
| 554 |
}).as("get-parse_to_ill"); |
| 555 |
cy.intercept( |
| 556 |
"GET", |
| 557 |
"/api/v1/contrib/pluginbackend/ill_backend_availability_pluginbackend*", |
| 558 |
{ |
| 559 |
statusCode: 200, |
| 560 |
body: { success: "" }, |
| 561 |
} |
| 562 |
).as("get-backend_availability_response"); |
| 563 |
|
| 564 |
cy.get("#ill-batch-modal #identifiers_input").type(pubmedid); |
| 565 |
cy.get("#ill-batch-modal #process-button") |
| 566 |
.contains("Process identifiers") |
| 567 |
.click(); |
| 568 |
cy.wait("@get-pubmedid-metadata"); |
| 569 |
cy.wait("@get-parse_to_ill"); |
| 570 |
cy.wait("@get-backend_availability_response"); |
| 571 |
cy.get("#identifier-table .dt-column-title") |
| 572 |
.contains("Auto backend") |
| 573 |
.should("exist"); |
| 574 |
cy.get("#ill-batch-modal #create-requests-button").should("exist"); |
| 575 |
|
| 576 |
//Plugin backend came back with success, PluginBackend should be checked |
| 577 |
cy.get("input[name='auto_backend_0']").first().should("be.checked"); |
| 578 |
cy.get("input[name='auto_backend_0']").eq(1).should("not.be.checked"); |
| 579 |
}); |
| 580 |
}); |