https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=8214

--- Comment #33 from Matt Blenkinsop <[email protected]> ---
Created attachment 203624
  -->
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=203624&action=edit
Bug 8214: Add unit tests

Test plan:

Setup

1. Apply all patches. In KTD run updatedatabase, then yarn build and
   restart_all.
2. Run the tests - all should pass:

   prove t/db_dependent/Koha/Item/BiblioLinks.t \
         t/db_dependent/Koha/Item.t \
         t/db_dependent/Koha/Biblio.t \
         t/db_dependent/api/v1/item_biblio_links.t \
         t/db_dependent/XSLT.t \
         t/db_dependent/Koha/Filter/EmbedItemsAvailability.t \
         t/db_dependent/Koha/SearchEngine/Elasticsearch.t \
         t/db_dependent/Reserves.t \
         t/db_dependent/HoldsQueue.t

Linking workflow (staff)

3. In Administration > System preferences > Cataloging, set
   EnableBoundWithItems to "Enable" and save. Using Cataloging > New
   record, create three records, A, B and C, and give only A an item
   (with a barcode and a call number).
4. Search the catalogue for A and click its title to open the record.
   On the Holdings tab the item row's Actions column has a "Bound-with
   links" button. The "Bound-with" column itself is not visible yet:
   Koha auto-hides holdings columns whose cells are all empty, the same
   as Collection or Serial enumeration on a plain item. It appears in
   step 5, once the row has links. Open the button: the modal is titled
   "Bound-with links", states the item record lives on A, and offers
   "Add links" - a search box ("Title, author, ISBN or record number").
   Type part of B's title, select B from the dropdown, then do the same
   for C - both appear as selected entries - and click "Link". The page
   reloads.
5. On A: the Bound-with column is now present and the item row shows a
   "View (2)" button. Clicking it opens a display-only modal titled
   "Bound-with records" listing B and C as links, with no Remove or
   Add-links controls and only "Close" in the footer. The Actions
   column's "Bound-with links" button still opens the full management
   modal; the two buttons must not behave the same. "Also bound in this
   volume: B; C" shows above the table.
6. On B: the shared item appears in the holdings table (visually
   identical availability data), its Bound-with column shows "View (2)"
   listing A and C, and "Also bound in this volume" lists A and C. Same
   on C. No record reads as more authoritative than another.
7. Go back to A and click the Actions column's "Bound-with links"
   button again to reopen the management modal. This step only checks
   what the "Add links" search box finds. Titles, authors and ISBNs are
   matched on "contains", so several records can match at once and the
   list shows up to 20; each entry gives the title, author and record
   number, so the right one can be picked out. Record numbers are the
   exception and are matched exactly. Type each of the following in
   turn and look at the list that drops down, but do not select
   anything and do not click "Link":
   - part of the title of any other record in the catalogue (one that
     is not A, B or C): that record is listed, along with any other
     record whose title or author contains the same text.
   - the record number of that same record, typed on its own: that
     record is listed. The number itself is matched exactly, so 10 does
     not bring back 100 or 1000; but the digits are also matched
     against titles and authors, so a record such as "Top 100 recipes"
     can appear in the list too.
   - the ISBN of a record that has one: that record is listed. (Sample
     catalogue records normally have ISBNs; hyphens may be typed or
     left out.)
   - B's title or record number: B is not offered, because it is
     already linked to this item.
   - A's title or record number: A is not offered, because the item
     already lives on A.
   - a single letter: nothing is looked up. Title and author searching
     begins at three characters, although a record number works at any
     length.
   Words are matched as typed, in order, so "hard stares" finds "Notes
   on hard stares" but "stares hard" finds nothing. Close the modal with
   "Close". No new links have been created, so A still shows "View (2)".
8. Create a fourth record, D. Open it and choose Edit > "Bound-with
   link" from the toolbar, then enter the item's barcode; the item is
   linked to D. Remove the link again from D's Holdings tab, using the
   Actions column's "Bound-with links" button -> "Remove link" (a
   confirmation view is shown first).
9. Open B, and on the Holdings tab click the item's barcode to reach the
   item details page. It shows a "Bound-with" section reading "Item
   record lives on: A" then "Bound with: C". B itself must not be listed
   as its own peer. Do the same from A (Holdings tab > barcode): that
   section lists "Bound with: B" and "Bound with: C" with no "Item
   record lives on" line, because the item lives there. On both pages
   the "No. of items" count includes the shared item (e.g. "1"), not a
   negative or zero total. Now open B and choose Edit > "Manage items":
   the item row's Actions offer "Edit item on its home record" (which
   opens the item on record A) and "Remove bound-with link" (with
   confirmation).
10. Duplicate and self links are refused: adding B again gives an error
    in the modal; adding A, the record the item lives on, gives an
    error.
11. Log in as a staff user who has "Search the catalog" but not the
    "Create and remove links between items and bibliographic records"
    permission (set on the patron's More > Set permissions page, under
    "Edit catalog"). Open A: the Actions column's "Bound-with links"
    button and the Edit > "Bound-with link" toolbar entry are both
    absent, while the Bound-with column's "View (N)" button still opens
    the display-only modal.

OPAC

12. In the OPAC, search for B and click its title. On the Holdings tab
    the shared item appears with call number, barcode and status,
    labelled "This title is bound with A; C" on its own line in the Call
    number column, each title linking to that record in the OPAC. "Also
    bound in this volume" links show above the table, and there is no
    "No physical items for this record" message. Repeat for C, then for
    A: the label is worded identically on A ("This title is bound with
    B; C"), since no record is privileged. On every record the label
    omits the record being viewed.

Search and indexing

13. Run a full reindex (koha-rebuild-zebra -b -f -v kohadev, or the
    Elasticsearch equivalent).
14. Search the catalogue by title for B, then for C, in both the staff
    interface and the OPAC, so each appears in a results list. Their
    result entries show "1 item / available" (staff) and "Items
    available for loan" (OPAC), NOT "No items available", and offer a
    Place hold link.
15. In Circulation > Check out, check the item out to any patron by
    barcode; circulation must behave exactly as normal. Reindex (or wait
    for the indexer), then confirm B's search result line and the
    records for A, B and C all show the item as checked out. Check it
    back in from Circulation > Check in.

Holds

16. Open B and click "Place hold" (or place the hold from B in the
    OPAC). On the Place hold page the shared item row is labelled
    "Bound-with item - the item record lives on A", and the "Pickup at"
    list is populated with libraries. Place the hold. It is recorded
    against B: the patron's Holds tab shows B's title, and so does B's
    own Holds tab.
17. Go to Circulation > Check in and check in the item's barcode. The
    hold-found dialog appears for B's hold, shows B's title, and carries
    the context line "Bound-with item: the hold is for this title, the
    item record itself lives on A". Choose "Confirm hold"; the hold
    becomes Waiting on the patron's Holds tab.
18. Circulation > Holds queue: with a pending hold on B, build the queue
    (enable the RealTimeHoldsQueue preference, or run
    misc/cronjobs/holds/build_holds_queue.pl). The queue offers A's item
    for B's hold. Place a second hold on A and rebuild: the single item
    is assigned to only one of the two records' holds, never both.
19. Unlink check. An "active hold" is any hold still listed on the
    record's Holds tab, whether pending or waiting:
    - A hold placed on a specific copy (item-level) on B always blocks
      unlinking.
    - A hold placed on the record as a whole (next available copy) on B
      blocks only while the link is B's only source of items. Add an
      item of B's own and the same unlink is allowed.
    In either blocking case "Remove bound-with link" is refused with a
    warning that holds would be stranded, and "Remove anyway" succeeds.
    Re-create the link afterwards if continuing.

MARC 501

20. Open A and choose Edit > "Edit record". In tab 5 add field 501
    subfield a, "Bound with: [Title B] / [Author]", and save. A's record
    page in both the staff interface and the OPAC now displays the note
    once, exactly as catalogued - the note carries its own "Bound with:"
    prefix and no extra label is added - alongside the "Also bound in
    this volume" links.

Teardown checks

21. Remove the remaining links, from either record's Holdings tab. The
    bound-with column, labels and "Also bound in this volume" links
    disappear from every record, and after a reindex B and C show no
    items again in search results.
22. Re-create the links, then delete the item from A (Holdings tab >
    Actions > Delete item). The confirmation notes that the item is
    linked to other records, but still allows the deletion. Afterwards
    the links are gone from B and C, and their pages and search results
    revert after a reindex.
23. In Administration > System preferences > Cataloging, set
    EnableBoundWithItems back to "Don't enable" and save. All
    bound-with wording and buttons then disappear with no errors, and
    search availability for B reverts at the next reindex.

Assisted-by: Sonnet 5 (Anthropic)

-- 
You are receiving this mail because:
You are watching all bug changes.
_______________________________________________
Koha-bugs mailing list -- [email protected]
To unsubscribe send an email to [email protected]
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/

Reply via email to