Lines 1-7
Link Here
|
1 |
const RESTdefaultPageSize = "20"; // FIXME Mock this |
1 |
const RESTdefaultPageSize = "20"; // FIXME Mock this |
2 |
const baseTotalCount = "42"; |
2 |
const baseTotalCount = "42"; |
3 |
|
3 |
|
4 |
describe("catalogue/detail/holdings_table", () => { |
4 |
describe("catalogue/detail/holdings_table with items", () => { |
5 |
const table_id = "holdings_table"; |
5 |
const table_id = "holdings_table"; |
6 |
beforeEach(() => { |
6 |
beforeEach(() => { |
7 |
cy.login(); |
7 |
cy.login(); |
Lines 409-411
describe("catalogue/detail/holdings_table", () => {
Link Here
|
409 |
}); |
409 |
}); |
410 |
}); |
410 |
}); |
411 |
}); |
411 |
}); |
412 |
- |
412 |
|
|
|
413 |
describe("catalogue/detail/holdings_table without items", () => { |
414 |
const table_id = "holdings_table"; |
415 |
beforeEach(() => { |
416 |
cy.login(); |
417 |
cy.title().should("eq", "Koha staff interface"); |
418 |
cy.window().then(win => { |
419 |
win.localStorage.clear(); |
420 |
}); |
421 |
|
422 |
// FIXME All the following code should not be reused as it |
423 |
// It must be moved to a Cypress command or task "buildSampleBiblio" or even "insertSampleBiblio" |
424 |
let generated_objects = {}; |
425 |
const objects = [{ object: "library" }, { object: "item_type" }]; |
426 |
cy.wrap(Promise.resolve()) |
427 |
.then(() => { |
428 |
return objects.reduce((chain, { object }) => { |
429 |
return chain.then(() => { |
430 |
return cy |
431 |
.task("buildSampleObject", { object }) |
432 |
.then(attributes => { |
433 |
generated_objects[object] = attributes; |
434 |
}); |
435 |
}); |
436 |
}, Promise.resolve()); |
437 |
}) |
438 |
.then(() => { |
439 |
const item_type = generated_objects["item_type"]; |
440 |
const queries = [ |
441 |
{ |
442 |
query: "INSERT INTO itemtypes(itemtype, description) VALUES (?, ?)", |
443 |
values: [item_type.item_type_id, item_type.description], |
444 |
}, |
445 |
]; |
446 |
cy.wrap(Promise.resolve()) |
447 |
.then(() => { |
448 |
return queries.reduce((chain, { query, values }) => { |
449 |
return chain.then(() => cy.query(query, values)); |
450 |
}, Promise.resolve()); |
451 |
}) |
452 |
.then(() => { |
453 |
let biblio = { |
454 |
leader: " nam a22 7a 4500", |
455 |
fields: [ |
456 |
{ "005": "20250120101920.0" }, |
457 |
{ |
458 |
"245": { |
459 |
ind1: "", |
460 |
ind2: "", |
461 |
subfields: [{ a: "Some boring read" }], |
462 |
}, |
463 |
}, |
464 |
{ |
465 |
"100": { |
466 |
ind1: "", |
467 |
ind2: "", |
468 |
subfields: [ |
469 |
{ c: "Some boring author" }, |
470 |
], |
471 |
}, |
472 |
}, |
473 |
{ |
474 |
"942": { |
475 |
ind1: "", |
476 |
ind2: "", |
477 |
subfields: [ |
478 |
{ c: item_type.item_type_id }, |
479 |
], |
480 |
}, |
481 |
}, |
482 |
], |
483 |
}; |
484 |
cy.request({ |
485 |
method: "POST", |
486 |
url: "/api/v1/biblios", |
487 |
headers: { |
488 |
"Content-Type": "application/marc-in-json", |
489 |
"x-confirm-not-duplicate": 1, |
490 |
}, |
491 |
body: biblio, |
492 |
}).then(response => { |
493 |
const biblio_id = response.body.id; |
494 |
cy.wrap(biblio_id).as("biblio_id"); |
495 |
}); |
496 |
}); |
497 |
}); |
498 |
cy.query( |
499 |
"SELECT value FROM systempreferences WHERE variable='AlwaysShowHoldingsTableFilters'" |
500 |
).then(value => { |
501 |
cy.wrap(value).as("syspref_AlwaysShowHoldingsTableFilters"); |
502 |
}); |
503 |
}); |
504 |
|
505 |
afterEach( |
506 |
() => |
507 |
function () { |
508 |
cleanup(); |
509 |
cy.set_syspref( |
510 |
"AlwaysShowHoldingsTableFilters", |
511 |
this.syspref_AlwaysShowHoldingsTableFilters |
512 |
); |
513 |
} |
514 |
); |
515 |
|
516 |
it.only("Do not display the table", function () { |
517 |
// Do not use `() => {` or this.biblio_id won't be retrieved |
518 |
const biblio_id = this.biblio_id; |
519 |
|
520 |
cy.visit("/cgi-bin/koha/catalogue/detail.pl?biblionumber=" + biblio_id); |
521 |
|
522 |
cy.get(`#${table_id}_wrapper`).should("not.exist"); |
523 |
}); |
524 |
}); |