|
Lines 491-496
describe("Agreement CRUD operations", () => {
Link Here
|
| 491 |
let agreement = get_agreement(); |
491 |
let agreement = get_agreement(); |
| 492 |
let agreements = [agreement]; |
492 |
let agreements = [agreement]; |
| 493 |
|
493 |
|
|
|
494 |
// Delete from list |
| 494 |
// Click the 'Delete' button from the list |
495 |
// Click the 'Delete' button from the list |
| 495 |
cy.intercept("GET", "/api/v1/erm/agreements*", { |
496 |
cy.intercept("GET", "/api/v1/erm/agreements*", { |
| 496 |
statusCode: 200, |
497 |
statusCode: 200, |
|
Lines 506-532
describe("Agreement CRUD operations", () => {
Link Here
|
| 506 |
cy.get("#agreements_list table tbody tr:first") |
507 |
cy.get("#agreements_list table tbody tr:first") |
| 507 |
.contains("Delete") |
508 |
.contains("Delete") |
| 508 |
.click(); |
509 |
.click(); |
| 509 |
cy.get("#agreements_confirm_delete h2").contains("Delete agreement"); |
510 |
cy.get(".dialog.alert.confirmation h1").contains("remove this agreement"); |
| 510 |
cy.contains("Agreement name: " + agreement.name); |
511 |
cy.contains(agreement.name); |
| 511 |
|
512 |
|
| 512 |
// Submit the form, get 500 |
513 |
// Accept the confirmation dialog, get 500 |
| 513 |
cy.intercept("DELETE", "/api/v1/erm/agreements/*", { |
514 |
cy.intercept("DELETE", "/api/v1/erm/agreements/*", { |
| 514 |
statusCode: 500, |
515 |
statusCode: 500, |
| 515 |
error: "Something went wrong", |
516 |
error: "Something went wrong", |
| 516 |
}); |
517 |
}); |
| 517 |
cy.contains("Yes, delete").click(); |
518 |
cy.contains("Accept").click(); |
| 518 |
cy.get("main div[class='dialog alert']").contains( |
519 |
cy.get("main div[class='dialog alert']").contains( |
| 519 |
"Something went wrong: Error: Internal Server Error" |
520 |
"Something went wrong: Error: Internal Server Error" |
| 520 |
); |
521 |
); |
| 521 |
|
522 |
|
| 522 |
// Submit the form, success! |
523 |
// Accept the confirmation dialog, success! |
| 523 |
cy.intercept("DELETE", "/api/v1/erm/agreements/*", { |
524 |
cy.intercept("DELETE", "/api/v1/erm/agreements/*", { |
| 524 |
statusCode: 204, |
525 |
statusCode: 204, |
| 525 |
body: null, |
526 |
body: null, |
| 526 |
}); |
527 |
}); |
|
|
528 |
cy.get("#agreements_list table tbody tr:first") |
| 529 |
.contains("Delete") |
| 530 |
.click(); |
| 531 |
cy.get(".dialog.alert.confirmation h1").contains("remove this agreement"); |
| 527 |
cy.contains("Yes, delete").click(); |
532 |
cy.contains("Yes, delete").click(); |
| 528 |
cy.get("main div[class='dialog message']").contains( |
533 |
cy.get("main div[class='dialog message']").contains("Agreement").contains("deleted"); |
| 529 |
"Agreement deleted" |
534 |
|
|
|
535 |
// Delete from show |
| 536 |
// Click the "name" link from the list |
| 537 |
cy.intercept("GET", "/api/v1/erm/agreements*", { |
| 538 |
statusCode: 200, |
| 539 |
body: agreements, |
| 540 |
headers: { |
| 541 |
"X-Base-Total-Count": "1", |
| 542 |
"X-Total-Count": "1", |
| 543 |
}, |
| 544 |
}); |
| 545 |
cy.intercept("GET", "/api/v1/erm/agreements/*", agreement).as( |
| 546 |
"get-agreement" |
| 530 |
); |
547 |
); |
|
|
548 |
cy.visit("/cgi-bin/koha/erm/agreements"); |
| 549 |
let name_link = cy.get( |
| 550 |
"#agreements_list table tbody tr:first td:first a" |
| 551 |
); |
| 552 |
name_link.should( |
| 553 |
"have.text", |
| 554 |
agreement.name + " (#" + agreement.agreement_id + ")" |
| 555 |
); |
| 556 |
name_link.click(); |
| 557 |
cy.wait("@get-agreement"); |
| 558 |
cy.wait(500); // Cypress is too fast! Vue hasn't populated the form yet! |
| 559 |
cy.get("#agreements_show h2").contains( |
| 560 |
"Agreement #" + agreement.agreement_id |
| 561 |
); |
| 562 |
|
| 563 |
cy.get('#agreements_show .action_links .fa-trash').click(); |
| 564 |
cy.get(".dialog.alert.confirmation h1").contains("remove this agreement"); |
| 565 |
cy.contains("Yes, delete").click(); |
| 566 |
cy.get("main div[class='dialog message']").contains("Agreement").contains("deleted"); |
| 567 |
|
| 568 |
//Make sure we return to list after deleting from show |
| 569 |
cy.get("#agreements_list table tbody tr:first") |
| 531 |
}); |
570 |
}); |
| 532 |
}); |
571 |
}); |