Koha Solutions knowledge base: run log of a live check Article https://kohasolutions.com/knowledge-base/koha-holds-workflow Check scripts/kb/live/koha-holds-workflow.mjs (SHA-256 2d907630869175b988e5c94cd91dc218241b46b66fb656d52c9546439e8a5d93) Ran 2026-11-05T14:29:11Z (UTC), 26 s Koha 26.05.02 (Koha::version 26.05.02.002, database version 26.0600002) Source https://git.koha-community.org/Koha-community/Koha/src/commit/d3fc229bc5eaea25dfe88f86149386408fe5d32d System Debian GNU/Linux 13 (trixie) Result PASS: all 9 claims held Each claim is something the article says. "seen" is what the check read back when it is not just a yes/no. Changes the check made to the test server were undone afterwards, as its header describes. == Claims == ok test record and item created seen: 2568 ok check-in shows "Hold found" with "Confirm hold", "Print slip and confirm", "Ignore" seen: Circulation | Patrons | Search | More | koha Centerville | | Check out | Check out | Renew | Search catalog | Home | Circulation | Check in | Help | Hold found | Kbverify hold test | (KBVERIFYH1 ok nothing ticked for Hold filled → "Patron is not notified." ok Confirm hold → the hold is waiting (found = W) seen: W ok …and no HOLD notice is queued at all seen: none ok Hold filled by email → "Patron notification: Email." seen: Patron notification: Email. | Hold at Centerville ok …Confirm hold queues the HOLD notice by email seen: HOLD/email ok email ticked but no address → a printed HOLD notice is queued instead seen: HOLD/print ok Holds awaiting pickup lists the waiting hold == The check that produced this log (scripts/kb/live/koha-holds-workflow.mjs) == /** * Live check for prisma/ks-kb/48-koha-holds-workflow.ts. Creates a throwaway record "Kbverify hold test" with one * item (barcode KBVERIFYH1, CPL) and places holds on it for the fixture patron; changes the fixture patron's * "Hold filled" messaging preference and email. All undone: holds, the record and item, queued messages, the * preference rows and the email are put back. */ export const meta = { koha: '26.05.02', passed: '2026-11-05' } const BARCODE = 'KBVERIFYH1' export default async function run(ctx) { const I = ctx.INSTANCE const pid = ctx.patron() const perl = (code) => { ctx.sh(`cat > /tmp/kbv-h.pl <<'PL'\n${code}\nPL\nchmod 644 /tmp/kbv-h.pl`) const r = ctx.sh(`koha-shell ${I} -c "perl /tmp/kbv-h.pl"; rm -f /tmp/kbv-h.pl`) return r.out.split('\n').pop() } const firstMsg = Number(ctx.sqlValue('SELECT COALESCE(MAX(message_id), 0) FROM message_queue')) const attr = ctx.sqlValue("SELECT message_attribute_id FROM message_attributes WHERE message_name = 'Hold_Filled'") const email = ctx.sqlValue(`SELECT email FROM borrowers WHERE borrowernumber = ${pid}`) const prefs = ctx.sql(`SELECT p.borrower_message_preference_id, IFNULL(GROUP_CONCAT(t.message_transport_type), '') FROM borrower_message_preferences p LEFT JOIN borrower_message_transport_preferences t USING (borrower_message_preference_id) WHERE p.borrowernumber = ${pid} AND p.message_attribute_id = ${attr} GROUP BY p.borrower_message_preference_id`) const before = prefs[0]?.[1] ?? null const setHoldFilled = (transports) => { ctx.sql(`DELETE FROM borrower_message_preferences WHERE borrowernumber = ${pid} AND message_attribute_id = ${attr}`) if (transports === null) return ctx.sql(`INSERT INTO borrower_message_preferences (borrowernumber, message_attribute_id, days_in_advance, wants_digest) VALUES (${pid}, ${attr}, 0, 0)`) const id = ctx.sqlValue(`SELECT borrower_message_preference_id FROM borrower_message_preferences WHERE borrowernumber = ${pid} AND message_attribute_id = ${attr}`) for (const t of transports.split(',').filter(Boolean)) ctx.sql(`INSERT INTO borrower_message_transport_preferences VALUES (${id}, ${ctx.q(t)})`) } const bn = Number(perl(`use C4::Biblio qw(AddBiblio); use MARC::Record; my $r = MARC::Record->new; $r->leader(' nam a22 7a 4500'); $r->append_fields(MARC::Field->new('245','1','0','a'=>'Kbverify hold test')); my ($bn) = AddBiblio($r, ''); Koha::Item->new({ biblionumber => $bn, homebranch => 'CPL', holdingbranch => 'CPL', barcode => '${BARCODE}', itype => 'BK' })->store; print "$bn\\n";`)) ctx.restore('remove the Kbverify record, its holds and this run\'s messages; put the patron back', () => { ctx.sql(`DELETE FROM reserves WHERE biblionumber = ${bn}`) ctx.sql(`DELETE FROM old_reserves WHERE biblionumber = ${bn}`) ctx.sql(`DELETE FROM message_queue WHERE borrowernumber = ${pid} AND message_id > ${firstMsg}`) perl(`use C4::Biblio qw(DelBiblio); my $b = Koha::Biblios->find(${bn}); $_->delete for $b ? $b->items->as_list : (); DelBiblio(${bn});`) setHoldFilled(before) ctx.sql(`UPDATE borrowers SET email = ${email === null ? 'NULL' : ctx.q(email)} WHERE borrowernumber = ${pid}`) }) ctx.check('test record and item created', bn > 0 && ctx.sqlValue(`SELECT COUNT(*) FROM items WHERE barcode = '${BARCODE}'`) === '1', bn) const staff = await ctx.newPage() await ctx.staffLogin(staff) const holdAndCheckIn = async () => { ctx.sql(`DELETE FROM reserves WHERE biblionumber = ${bn}`) perl(`use C4::Reserves qw(AddReserve); AddReserve({ branchcode => 'CPL', borrowernumber => ${pid}, biblionumber => ${bn}, priority => 1 }); print "ok\\n";`) await staff.goto(`${ctx.STAFF}/cgi-bin/koha/circ/returns.pl`) await staff.fill('#barcode', BARCODE) await staff.locator('#barcode').press('Enter') await staff.waitForLoadState() await staff.waitForTimeout(1000) const text = await ctx.pageText(staff) const confirm = staff.locator('button', { hasText: /^\s*Confirm hold/ }).first() if (await confirm.count()) { await confirm.click(); await staff.waitForLoadState() } const msg = ctx.sql(`SELECT letter_code, message_transport_type FROM message_queue WHERE borrowernumber = ${pid} AND message_id > ${firstMsg} AND letter_code = 'HOLD' ORDER BY message_id DESC LIMIT 1`)[0] const waiting = ctx.sqlValue(`SELECT found FROM reserves WHERE biblionumber = ${bn}`) ctx.sql(`DELETE FROM message_queue WHERE borrowernumber = ${pid} AND message_id > ${firstMsg}`) return { text, msg: msg ? msg.join('/') : 'none', waiting } } // 1. No transport ticked for Hold filled. setHoldFilled(null) const a = await holdAndCheckIn() ctx.check('check-in shows "Hold found" with "Confirm hold", "Print slip and confirm", "Ignore"', ['Hold found', 'Confirm hold', 'Print slip and confirm', 'Ignore'].every((t) => a.text.includes(t)), a.text.slice(0, 200)) ctx.check('nothing ticked for Hold filled → "Patron is not notified."', a.text.includes('Patron is not notified.')) ctx.check('Confirm hold → the hold is waiting (found = W)', a.waiting === 'W', a.waiting) ctx.check('…and no HOLD notice is queued at all', a.msg === 'none', a.msg) // 2. Email ticked, patron has an email address. setHoldFilled('email') const b = await holdAndCheckIn() ctx.check('Hold filled by email → "Patron notification: Email."', /Patron notification:[\s|]*Email\./.test(b.text), (b.text.match(/Patron notification.{0,30}/) ?? [''])[0]) ctx.check('…Confirm hold queues the HOLD notice by email', b.msg === 'HOLD/email', b.msg) // 3. Email ticked, no email address: a print notice instead. ctx.sql(`UPDATE borrowers SET email = NULL WHERE borrowernumber = ${pid}`) const c = await holdAndCheckIn() ctx.check('email ticked but no address → a printed HOLD notice is queued instead', c.msg === 'HOLD/print', c.msg) // Holds awaiting pickup lists it. await staff.goto(`${ctx.STAFF}/cgi-bin/koha/circ/waitingreserves.pl`) await staff.waitForTimeout(1500) ctx.check('Holds awaiting pickup lists the waiting hold', (await ctx.pageText(staff)).includes('Kbverify hold test')) }