Lines 488-495
describe("Hit all tables", () => {
Link Here
|
488 |
|
488 |
|
489 |
describe("catalogue/detail/holdings_table", () => { |
489 |
describe("catalogue/detail/holdings_table", () => { |
490 |
const table_id = "holdings_table"; |
490 |
const table_id = "holdings_table"; |
491 |
it("correctly init", () => { |
491 |
beforeEach(() => { |
492 |
const biblio_id = 1; |
492 |
// FIXME All the following code should not be reused as it |
|
|
493 |
// It must be moved to a Cypress command or task "buildSampleBiblio" or even "insertSampleBiblio" |
494 |
let generated_objects = {}; |
495 |
const objects = [{ object: "library" }, { object: "item_type" }]; |
496 |
cy.wrap(Promise.resolve()) |
497 |
.then(() => { |
498 |
return objects.reduce((chain, { object }) => { |
499 |
return chain.then(() => { |
500 |
return cy |
501 |
.task("buildSampleObject", { object }) |
502 |
.then(attributes => { |
503 |
generated_objects[object] = attributes; |
504 |
}); |
505 |
}); |
506 |
}, Promise.resolve()); |
507 |
}) |
508 |
.then(() => { |
509 |
const library = generated_objects["library"]; |
510 |
const item_type = generated_objects["item_type"]; |
511 |
const queries = [ |
512 |
{ |
513 |
query: "INSERT INTO branches(branchcode, branchname) VALUES (?, ?)", |
514 |
values: [library.library_id, library.name], |
515 |
}, |
516 |
{ |
517 |
query: "INSERT INTO itemtypes(itemtype, description) VALUES (?, ?)", |
518 |
values: [ |
519 |
item_type.item_type_id, |
520 |
item_type.description, |
521 |
], |
522 |
}, |
523 |
]; |
524 |
cy.wrap(Promise.resolve()) |
525 |
.then(() => { |
526 |
return queries.reduce( |
527 |
(chain, { query, values }) => { |
528 |
return chain.then(() => |
529 |
cy.query(query, values) |
530 |
); |
531 |
}, |
532 |
Promise.resolve() |
533 |
); |
534 |
}) |
535 |
.then(() => { |
536 |
let biblio = { |
537 |
leader: " nam a22 7a 4500", |
538 |
fields: [ |
539 |
{ "005": "20250120101920.0" }, |
540 |
{ |
541 |
"245": { |
542 |
ind1: "", |
543 |
ind2: "", |
544 |
subfields: [ |
545 |
{ a: "Some boring read" }, |
546 |
], |
547 |
}, |
548 |
}, |
549 |
{ |
550 |
"100": { |
551 |
ind1: "", |
552 |
ind2: "", |
553 |
subfields: [ |
554 |
{ c: "Some boring author" }, |
555 |
], |
556 |
}, |
557 |
}, |
558 |
{ |
559 |
"942": { |
560 |
ind1: "", |
561 |
ind2: "", |
562 |
subfields: [ |
563 |
{ c: item_type.item_type_id }, |
564 |
], |
565 |
}, |
566 |
}, |
567 |
], |
568 |
}; |
569 |
cy.request({ |
570 |
method: "POST", |
571 |
url: "/api/v1/biblios", |
572 |
auth: { |
573 |
username: "koha", |
574 |
password: "koha", |
575 |
}, |
576 |
headers: { |
577 |
"Content-Type": "application/marc-in-json", |
578 |
"x-confirm-not-duplicate": 1, |
579 |
}, |
580 |
body: biblio, |
581 |
}).then(response => { |
582 |
const biblio_id = response.body.id; |
583 |
cy.wrap(biblio_id).as("biblio_id"); |
584 |
cy.request({ |
585 |
method: "POST", |
586 |
url: `/api/v1/biblios/${biblio_id}/items`, |
587 |
auth: { |
588 |
username: "koha", |
589 |
password: "koha", |
590 |
}, |
591 |
headers: { |
592 |
"Content-Type": "application/json", |
593 |
}, |
594 |
body: { |
595 |
home_library_id: library.library_id, |
596 |
holding_library_id: library.library_id, |
597 |
}, |
598 |
}); |
599 |
}); |
600 |
}); |
601 |
}); |
602 |
}); |
603 |
|
604 |
afterEach(() => {}); |
605 |
|
606 |
it("Correctly init the table", function () { |
607 |
// Do not use `() => {` or this.biblio_id won't be retrieved |
608 |
const biblio_id = this.biblio_id; |
493 |
cy.task("buildSampleObjects", { |
609 |
cy.task("buildSampleObjects", { |
494 |
object: "item", |
610 |
object: "item", |
495 |
count: RESTdefaultPageSize, |
611 |
count: RESTdefaultPageSize, |
Lines 537-544
describe("Hit all tables", () => {
Link Here
|
537 |
}); |
653 |
}); |
538 |
}); |
654 |
}); |
539 |
|
655 |
|
540 |
it("Show filters", () => { |
656 |
it("Show filters", function () { |
541 |
const biblio_id = 1; |
657 |
// Do not use `() => {` or this.biblio_id won't be retrieved |
|
|
658 |
const biblio_id = this.biblio_id; |
542 |
cy.task("buildSampleObjects", { |
659 |
cy.task("buildSampleObjects", { |
543 |
object: "item", |
660 |
object: "item", |
544 |
count: RESTdefaultPageSize, |
661 |
count: RESTdefaultPageSize, |
545 |
- |
|
|