Koha Solutions knowledge base: run log of a live check Article https://kohasolutions.com/knowledge-base/koha-opac-customization-guide Check scripts/kb/live/koha-opac-customization-guide.mjs (SHA-256 fa0d8ae1f2e2f22328ede6914ac2517f989c23a31438e3cbe5ca4856947a1869) Ran 2026-11-05T15:41:49Z (UTC), 118 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 47 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 the OPAC preferences named exist: LibraryName, OpacPublic, OpacMaintenance, opacthemes, OPACFallback, OPACUserCSS, OPACUserJS, OpacAdditionalStylesheet, opaclayoutstylesheet, OpacFavicon, OPACXSLTDetailsDisplay, OPACXSLTResultsDisplay, OPACXSLTListsDisplay ok the OPAC tab of System preferences has 10 sections (Appearance, Features, … Authentication) seen: 10 ok LibraryName "Kbverify Library" is the text of the header link (#logo a) seen: Kbverify Library ok …and the logo you see is a CSS background on #logo (koha-green-logo.svg), so it is changed with CSS seen: url("http://localhost:8080/opac-tmpl/bootstrap/images/koha-green-logo.svg") ok Tools lists "News", "HTML customizations", "Pages" and "Record display customizations" ok an HTML customization in OpacMainUserBlock shows on the OPAC home page ok a Pages entry (OPAC only) is its own page at /cgi-bin/koha/opac-page.pl?page_id=63 ok …set to staff only, the OPAC link redirects to the 404 page seen: http://localhost:8080/cgi-bin/koha/errors/404.pl ok a Record display customization at OPACDetailPage is added to the record's page, with [% record.title %] filled in seen: E Street shuffle : the glory days of Bruce Springsteen & the E Street Band / Clinton Heylin. | title: E Street shuffle : ok …and not to search results (that is OPACResultsPage) ok OPACXSLTDetailsDisplay is "default" (the shipped stylesheet) seen: default ok a plain copy in another folder fails: plack-opac-error.log "xsl:import : unable to load /var/lib/koha/kohadev/MARC21slimUtils.xsl" seen: [2026/11/05 15:42:05] [WARN] XSLT::Base: I/O warning : failed to load external entity "/var/lib/koha/kohadev/MARC21slimUtils.xsl" compilation error: file /var/lib/koha/kohadev/kbv-detail-1793893309532.xsl element import xsl:import : unable to load /var/lib/koha/kohadev/MARC21slimUtils.xsl at /kohad ok …and the record page shows none of the copy (no record description at all) ok with the xsl:import changed to the full path of MARC21slimUtils.xsl, the record page uses the copy ok a folder kbvtheme/en in the OPAC template directory appears as a choice for opacthemes seen: bootstrap , kbvtheme ok opacthemes = the new theme: its own opac-main.tt is used ok …every page it does not contain comes from the fallback (bootstrap): search still works ok …but its home page links no opac.css: CSS is looked up in the theme folder only, so a theme without css/ is unstyled ok …plack-opac-error.log: "File not found : css/opac.css at …/Koha/Template/Plugin/Asset.pm" (and js/basket.js, js/Gettext.js…) seen: [2026/11/05 15:42:11] [WARN] File not found : css/opac.css at /kohadevbox/koha/Koha/Template/Plugin/Asset.pm line 107. [2026/11/05 15:42:11] [WARN] File not found : css/print.css at /kohadevbox/koha/Koha/Template/Plugin/Asset.pm line 107. [2026/11/05 15:42:11] [WARN] File not found : js/Gettext.js at /kohadevbox/koha/Koha/Template/Plugin/Asset.pm line 84. [2026/11/05 15:42:11] [WARN] File not foun ok with css, js and images linked to bootstrap's (ln -s ../bootstrap/css css …), the theme's page loads opac-tmpl/kbvtheme/css/opac_….css seen: opac-tmpl/kbvtheme/css/opac_26.0502002.css ok OpacPublic Disable: the OPAC home page asks to log in ("Log in to your account") ok OpacMaintenance Show: every OPAC page shows "System maintenance" instead ok logo: an OPACUserCSS rule on #logo replaces the Koha logo with your image seen: url("https://cdn.example.org/our-logo.png") 200px ok header: an opacheader HTML customization shows on every page (search results too), just under the top bar seen: after-nav ok links: an OpacMoreSearches entry adds a link to the row under the search box (#moresearches), on every page ok links: an OpacNavBottom entry shows in the left column of the home page ok QuoteOfTheDay is empty on a new Koha (no quote shown anywhere) ok QuoteOfTheDay = OPAC: the home page shows "Quote of the day" with a quote seen: At the end of the day, we can endure much more than we think we can. ok …the same quote all day: a second visit shows the same one seen: At the end of the day, we can endure much more than we think we can. / At the end of the day, we can endure much more than we think we can. ok …because showing it stamps that quote's Last display with today ok …and the next day (no quote stamped today) Koha picks a new one at random by itself, no cron job seen: We have ...drawn a line in the sand. ok the public report at /cgi-bin/koha/svc/report?id=…&annotated=1 returns the newest items as JSON (biblionumber, title, author, added) seen: {"title":"Kbverify new arrival one","biblionumber":2594,"added":"2026-11-05","author":null} ok …20 rows: the report's own LIMIT 20 decides how many seen: 20 ok …without a LIMIT the service returns only 10 (SvcMaxReportRows, default 10) seen: 10 ok STUCK: a book added after the first request does not appear (the JSON is cached for the report's 300 seconds) seen: Kbverify new arrival one | The God of Small Things ok OLD BOOKS: a deleted book is still in the slider until the cache expires seen: Kbverify new arrival one | The God of Small Things ok fix: with the cache cleared (or expired), the deleted book is gone and the new one is first seen: Kbverify new arrival two | The God of Small Things ok fix: with the report's cache expiry set low, a newly added book appears on its own within that time seen: Kbverify new arrival three | Kbverify new arrival two ok a withdrawn copy is left out by the report (withdrawn = 0) ok the slider: the OPACUserJS code fills #new-arrivals with one link per book, newest first, in a scrolling row seen: 20 cards, first "Kbverify new arrival three", flex auto ok …each card links to the book's page seen: /cgi-bin/koha/opac-detail.pl?biblionumber=2596 ok the OPAC includes call KohaPlugins.get_plugins_opac_head and get_plugins_opac_js seen: 2 ok package install: bootstrap templates and the default XSLT belong to koha-common (an upgrade overwrites them) seen: koha-common: /usr/share/koha/opac/htdocs/opac-tmpl/bootstrap/en/modules/opac-main.tt koha-common: /usr/share/koha/opac/htdocs/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACDetail.xsl dpkg-query: no path found matching pattern /usr/share/koha/opac/htdocs/opac-tmpl/mytheme Version: 26.05.05-1 ok …and a theme folder of your own belongs to no package: "dpkg-query: no path found matching pattern …/mytheme" seen: koha-common: /usr/share/koha/opac/htdocs/opac-tmpl/bootstrap/en/modules/opac-main.tt koha-common: /usr/share/koha/opac/htdocs/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACDetail.xsl dpkg-query: no path found matching pattern /usr/share/koha/opac/htdocs/opac-tmpl/mytheme Version: 26.05.05-1 ok …on koha-common 26.05.05 seen: koha-common: /usr/share/koha/opac/htdocs/opac-tmpl/bootstrap/en/modules/opac-main.tt koha-common: /usr/share/koha/opac/htdocs/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACDetail.xsl dpkg-query: no path found matching pattern /usr/share/koha/opac/htdocs/opac-tmpl/mytheme Version: 26.05.05-1 ok the article's theme commands, on a package install: the folder holds one template and three links to bootstrap seen: total 4 lrwxrwxrwx 1 root root 16 Nov 5 15:43 css -> ../bootstrap/css drwxr-xr-x 3 root root 4096 Nov 5 15:43 en lrwxrwxrwx 1 root root 19 Nov 5 15:43 images -> ../bootstrap/images lrwxrwxrwx 1 root root 15 Nov 5 15:43 js -> ../bootstrap/js /usr/share/koha/opac/htdocs/opac-tmpl/mytheme/en/modules/opac-main.tt --- 10: ok the article's XSLT commands: the copy now imports MARC21slimUtils.xsl by its full path seen: total 4 lrwxrwxrwx 1 root root 16 Nov 5 15:43 css -> ../bootstrap/css drwxr-xr-x 3 root root 4096 Nov 5 15:43 en lrwxrwxrwx 1 root root 19 Nov 5 15:43 images -> ../bootstrap/images lrwxrwxrwx 1 root root 15 Nov 5 15:43 js -> ../bootstrap/js /usr/share/koha/opac/htdocs/opac-tmpl/mytheme/en/modules/opac-main.tt --- 10: == The check that produced this log (scripts/kb/live/koha-opac-customization-guide.mjs) == /** * Live check for prisma/ks-kb/99-koha-opac-customization-guide.ts (the OPAC customization pillar). On live Koha: * the OPAC preferences the article names exist; LibraryName is the header's text over the Koha logo; the four Tools * entries (News, HTML customizations, Pages, Record display customizations); a Pages entry served by * opac-page.pl?page_id= (and a 404 when it is staff-only); a Record display customization appended to the record's * page with Template Toolkit ([% record.title %]); a custom XSLT file named in OPACXSLTDetailsDisplay; a custom theme * folder holding one template, falling back to bootstrap for the rest, and its missing CSS; OpacPublic and * OpacMaintenance. The upgrade claims (which paths the koha-common package owns) run in a throwaway * kbv-koha-ubuntu:24.04 box (koha-common 26.05.05). Undone: prefs, rows, files and the theme folder. */ import { spawnSync } from 'node:child_process' // The article shows these four exactly; the check runs them as they are. export const NEW_ARRIVALS_SQL = `SELECT b.biblionumber, b.title, b.author, MAX(i.dateaccessioned) AS added FROM items i JOIN biblio b ON b.biblionumber = i.biblionumber WHERE i.withdrawn = 0 AND i.itemlost = 0 AND i.dateaccessioned IS NOT NULL GROUP BY b.biblionumber, b.title, b.author ORDER BY added DESC, b.biblionumber DESC LIMIT 20` export const SLIDER_HTML = '

New arrivals

\n
' export const SLIDER_CSS = '.new-arrivals { display: flex; gap: 1rem; overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: .5rem; }\n.new-arrivals a { flex: 0 0 10rem; scroll-snap-align: start; border: 1px solid #ddd; border-radius: 6px; padding: .75rem; }' export const SLIDER_JS = `$(function () { var box = $("#new-arrivals"); if (!box.length) return; $.getJSON("/cgi-bin/koha/svc/report?id=REPORT_ID&annotated=1", function (rows) { $.each(rows, function (i, r) { $("").attr("href", "/cgi-bin/koha/opac-detail.pl?biblionumber=" + r.biblionumber) .text(r.title + (r.author ? " / " + r.author : "")).appendTo(box); }); }); });` export const THEME_CMDS = `cd /usr/share/koha/opac/htdocs/opac-tmpl sudo mkdir -p mytheme/en/modules sudo cp bootstrap/en/modules/opac-main.tt mytheme/en/modules/ cd mytheme sudo ln -s ../bootstrap/css css sudo ln -s ../bootstrap/js js sudo ln -s ../bootstrap/images images ls -l find /usr/share/koha/opac/htdocs/opac-tmpl/mytheme -name '*.tt'` export const XSLT_CMDS = `sudo mkdir -p /usr/local/share/koha-custom sudo cp /usr/share/koha/opac/htdocs/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACDetail.xsl /usr/local/share/koha-custom/ sudo sed -i 's#"MARC21slimUtils.xsl"#"/usr/share/koha/opac/htdocs/opac-tmpl/bootstrap/en/xslt/MARC21slimUtils.xsl"#' /usr/local/share/koha-custom/MARC21slim2OPACDetail.xsl grep -n 'xsl:import' /usr/local/share/koha-custom/MARC21slim2OPACDetail.xsl` export const meta = { koha: '26.05.02', passed: '2026-11-05' } const IMG = 'kbv-koha-ubuntu:24.04' const HT = '/kohadevbox/koha/koha-tmpl/opac-tmpl' const THEME = 'kbvtheme' // a new name each run: Koha::XSLT::Base caches a stylesheet by file name in each Plack worker const XSL = `/var/lib/koha/kohadev/kbv-detail-${Date.now()}.xsl` export default async function run(ctx) { const opac = (path) => ctx.sh(`curl -s -L '${ctx.OPAC}${path}'`).out const bib = ctx.sqlValue('SELECT MIN(biblionumber) FROM biblio') const ids = [] ctx.restore("delete this run's additional_contents rows", () => { if (!ids.length) return ctx.sql(`DELETE FROM additional_contents_localizations WHERE additional_content_id IN (${ids.join(',')})`) ctx.sql(`DELETE FROM additional_contents WHERE id IN (${ids.join(',')})`) ctx.flushCaches() }) const add = (category, location, code, content) => { ctx.sql(`INSERT INTO additional_contents (category, code, location, branchcode, published_on) VALUES ('${category}', '${code}', '${location}', NULL, CURDATE() - INTERVAL 1 DAY)`) const id = ctx.sqlValue(`SELECT MAX(id) FROM additional_contents WHERE code = '${code}'`) ids.push(id) ctx.sql(`INSERT INTO additional_contents_localizations (additional_content_id, title, content, lang) VALUES (${id}, 'Kbverify ${code}', ${ctx.q(content)}, 'default')`) ctx.flushCaches() return id } // 1. The preferences the article names. const names = ['LibraryName', 'OpacPublic', 'OpacMaintenance', 'opacthemes', 'OPACFallback', 'OPACUserCSS', 'OPACUserJS', 'OpacAdditionalStylesheet', 'opaclayoutstylesheet', 'OpacFavicon', 'OPACXSLTDetailsDisplay', 'OPACXSLTResultsDisplay', 'OPACXSLTListsDisplay'] const have = ctx.sql(`SELECT variable FROM systempreferences WHERE variable IN (${names.map((n) => `'${n}'`).join(',')})`).map((r) => r[0]) ctx.check(`the OPAC preferences named exist: ${names.join(', ')}`, names.every((n) => have.includes(n)), names.filter((n) => !have.includes(n)).join(', ')) const pref = ctx.sh('grep -c "^ [A-Z][A-Za-z ]*:$" /kohadevbox/koha/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref').out ctx.check('the OPAC tab of System preferences has 10 sections (Appearance, Features, … Authentication)', pref === '10', pref) // 2. LibraryName is the header's text; the Koha logo is a CSS background. ctx.setPref('LibraryName', 'Kbverify Library') const b = await ctx.newPage() await b.goto(`${ctx.OPAC}/cgi-bin/koha/opac-main.pl`) const brand = (await b.locator('#logo a').innerText().catch(() => '')).trim() const bg = await b.evaluate(() => getComputedStyle(document.querySelector('#logo')).backgroundImage) ctx.check('LibraryName "Kbverify Library" is the text of the header link (#logo a)', brand === 'Kbverify Library', brand) ctx.check('…and the logo you see is a CSS background on #logo (koha-green-logo.svg), so it is changed with CSS', /koha-green-logo/.test(bg), bg) // 3. Tools → the four content tools. const staff = await ctx.newPage() await ctx.staffLogin(staff) await staff.goto(`${ctx.STAFF}/cgi-bin/koha/tools/tools-home.pl`) const tools = await ctx.pageText(staff) const four = ['News', 'HTML customizations', 'Pages', 'Record display customizations'] ctx.check('Tools lists "News", "HTML customizations", "Pages" and "Record display customizations"', four.every((x) => tools.includes(x)), four.filter((x) => !tools.includes(x)).join(', ')) // 4. HTML customization: one block on the home page. add('html_customizations', 'OpacMainUserBlock', 'KBV_MAIN', '

Kbverify main block

') ctx.check('an HTML customization in OpacMainUserBlock shows on the OPAC home page', opac('/cgi-bin/koha/opac-main.pl').includes('Kbverify main block')) // 5. Pages. const page = add('pages', 'opac_only', 'KBV_PAGE', '

Kbverify opening hours page

') ctx.check(`a Pages entry (OPAC only) is its own page at /cgi-bin/koha/opac-page.pl?page_id=${page}`, opac(`/cgi-bin/koha/opac-page.pl?page_id=${page}`).includes('Kbverify opening hours page')) ctx.sql(`UPDATE additional_contents SET location = 'staff_only' WHERE id = ${page}`) ctx.flushCaches() const code = ctx.sh(`curl -s -o /dev/null -w '%{redirect_url}' '${ctx.OPAC}/cgi-bin/koha/opac-page.pl?page_id=${page}'`).out ctx.check('…set to staff only, the OPAC link redirects to the 404 page', /errors\/404\.pl/.test(code), code) // 6. Record display customization. add('record_display', 'OPACDetailPage', 'KBV_REC', '

Kbverify note for [% record.title %]

') const title = ctx.sqlValue(`SELECT title FROM biblio WHERE biblionumber = ${bib}`) const det = opac(`/cgi-bin/koha/opac-detail.pl?biblionumber=${bib}`) const shown = (det.match(/Kbverify note for ([^<]*)/s//Kbverify custom XSLT<\\/span>/' ${XSL} && chmod 644 ${XSL}`) ctx.restore('remove the custom XSLT file', () => ctx.sh(`rm -f ${XSL}`)) ctx.setPref('OPACXSLTDetailsDisplay', XSL) const logMark = Number(ctx.sh('wc -l < /var/log/koha/kohadev/plack-opac-error.log').out) let d = opac(`/cgi-bin/koha/opac-detail.pl?biblionumber=${bib}`) const err = ctx.sh(`tail -n +${logMark + 1} /var/log/koha/kohadev/plack-opac-error.log`).out ctx.check(`a plain copy in another folder fails: plack-opac-error.log "xsl:import : unable to load ${XSL.replace(/kbv-detail-[0-9]+\.xsl$/, 'MARC21slimUtils.xsl')}"`, err.includes(`xsl:import : unable to load ${XSL.replace(/kbv-detail-[0-9]+\.xsl$/, 'MARC21slimUtils.xsl')}`), err.slice(0, 300)) ctx.check('…and the record page shows none of the copy (no record description at all)', !d.includes('Kbverify custom XSLT')) ctx.sh(`sed -i 's###' ${XSL}`) ctx.sh(`grep -n 'xsl:import' ${XSL}`) d = opac(`/cgi-bin/koha/opac-detail.pl?biblionumber=${bib}`) ctx.check('with the xsl:import changed to the full path of MARC21slimUtils.xsl, the record page uses the copy', d.includes('Kbverify custom XSLT')) ctx.setPref('OPACXSLTDetailsDisplay', 'default') // 8. A theme folder with one template. ctx.sh(`mkdir -p ${HT}/${THEME}/en/modules && cp ${HT}/bootstrap/en/modules/opac-main.tt ${HT}/${THEME}/en/modules/ && sed -i '0,/
/s//

Kbverify theme<\\/p>/' ${HT}/${THEME}/en/modules/opac-main.tt && chown -R kohadev-koha: ${HT}/${THEME}`) ctx.restore('remove the test theme folder', () => ctx.sh(`rm -rf ${HT}/${THEME}`)) await staff.goto(`${ctx.STAFF}/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=opacthemes`) const opts = await staff.locator('select[name="pref_opacthemes"] option').allInnerTexts() ctx.check(`a folder ${THEME}/en in the OPAC template directory appears as a choice for opacthemes`, opts.map((o) => o.trim()).includes(THEME), opts.join(', ')) ctx.setPref('OPACFallback', 'bootstrap') ctx.setPref('opacthemes', THEME) const themeMark = Number(ctx.sh('wc -l < /var/log/koha/kohadev/plack-opac-error.log').out) const home = opac('/cgi-bin/koha/opac-main.pl') ctx.check('opacthemes = the new theme: its own opac-main.tt is used', home.includes('id="kbv-theme"')) ctx.check('…every page it does not contain comes from the fallback (bootstrap): search still works', opac('/cgi-bin/koha/opac-search.pl?q=a').includes('id="numresults"') || opac('/cgi-bin/koha/opac-search.pl?q=a').includes('results')) ctx.check('…but its home page links no opac.css: CSS is looked up in the theme folder only, so a theme without css/ is unstyled', !/opac-tmpl\/[a-z]+\/css\/opac[_0-9]*\.css/.test(home), (home.match(/opac-tmpl\/[^"]*\.css/g) ?? []).join(' ')) const tlog = ctx.sh(`tail -n +${themeMark + 1} /var/log/koha/kohadev/plack-opac-error.log`).out ctx.check('…plack-opac-error.log: "File not found : css/opac.css at …/Koha/Template/Plugin/Asset.pm" (and js/basket.js, js/Gettext.js…)', tlog.includes('File not found : css/opac.css') && tlog.includes('File not found : js/Gettext.js'), tlog.slice(0, 400)) ctx.sh(`cd ${HT}/${THEME} && ln -s ../bootstrap/css css && ln -s ../bootstrap/js js && ln -s ../bootstrap/images images`) const fixed = opac('/cgi-bin/koha/opac-main.pl') ctx.check(`with css, js and images linked to bootstrap's (ln -s ../bootstrap/css css …), the theme's page loads opac-tmpl/${THEME}/css/opac_….css`, new RegExp(`opac-tmpl/${THEME}/css/opac_[0-9.]+\\.css`).test(fixed) && fixed.includes('id="kbv-theme"'), (fixed.match(/opac-tmpl\/[^"]*opac[^"]*\.css/g) ?? []).join(' ')) ctx.setPref('opacthemes', 'bootstrap') // 9. Private and maintenance. ctx.setPref('OpacPublic', '0') ctx.check('OpacPublic Disable: the OPAC home page asks to log in ("Log in to your account")', opac('/cgi-bin/koha/opac-main.pl').includes('Log in to your account')) ctx.setPref('OpacPublic', '1') ctx.setPref('OpacMaintenance', '1') ctx.check('OpacMaintenance Show: every OPAC page shows "System maintenance" instead', opac('/cgi-bin/koha/opac-main.pl').includes('System maintenance') && opac(`/cgi-bin/koha/opac-detail.pl?biblionumber=${bib}`).includes('System maintenance')) ctx.setPref('OpacMaintenance', '0') // 9b. Logo, header and navigation links. ctx.setPref('OPACUserCSS', '#logo { background-image: url("https://cdn.example.org/our-logo.png"); background-size: contain; width: 200px; } #logo a { width: 200px; padding-top: 50px; }') await b.goto(`${ctx.OPAC}/cgi-bin/koha/opac-main.pl`) const logo = await b.evaluate(() => { const s = getComputedStyle(document.querySelector('#logo')); return `${s.backgroundImage} ${s.width}` }) ctx.check('logo: an OPACUserCSS rule on #logo replaces the Koha logo with your image', logo.includes('https://cdn.example.org/our-logo.png') && logo.includes('200px'), logo) ctx.setPref('OPACUserCSS', '') add('html_customizations', 'opacheader', 'KBV_HEAD', '

Kbverify header strip

') await b.goto(`${ctx.OPAC}/cgi-bin/koha/opac-search.pl?q=a`) const headPos = await b.evaluate(() => { const h = document.querySelector('.kbv-head'); const n = document.querySelector('#header-region nav'); return h && n ? (n.compareDocumentPosition(h) & Node.DOCUMENT_POSITION_FOLLOWING ? 'after-nav' : 'before-nav') : 'missing' }) ctx.check('header: an opacheader HTML customization shows on every page (search results too), just under the top bar', headPos === 'after-nav', headPos) add('html_customizations', 'OpacMoreSearches', 'KBV_MORE', '
') await b.goto(`${ctx.OPAC}/cgi-bin/koha/opac-search.pl?q=a`) ctx.check('links: an OpacMoreSearches entry adds a link to the row under the search box (#moresearches), on every page', (await b.locator('#moresearches a', { hasText: 'Kbverify opening hours' }).count()) === 1) add('html_customizations', 'OpacNavBottom', 'KBV_NAVB', '') ctx.check('links: an OpacNavBottom entry shows in the left column of the home page', opac('/cgi-bin/koha/opac-main.pl').includes('Kbverify staff directory')) // 9c. Quote of the day. const qBefore = ctx.sql('SELECT id, COALESCE(timestamp, "NULL") FROM quotes') ctx.restore('quotes: remove the test quotes and put back every Last display date', () => { ctx.sql("DELETE FROM quotes WHERE source = 'Kbverify'") for (const [id, ts] of qBefore) ctx.sql(`UPDATE quotes SET timestamp = ${ts === 'NULL' ? 'NULL' : `'${ts}'`} WHERE id = ${id}`) }) ctx.sql("INSERT INTO quotes (source, text, timestamp) VALUES ('Kbverify', 'Kbverify quote one', NULL), ('Kbverify', 'Kbverify quote two', NULL)") ctx.check('QuoteOfTheDay is empty on a new Koha (no quote shown anywhere)', ctx.sh("grep -E \"^\\('QuoteOfTheDay',\" /kohadevbox/koha/installer/data/mysql/mandatory/sysprefs.sql").out.includes("('QuoteOfTheDay','')")) ctx.setPref('QuoteOfTheDay', 'opac') const q1 = opac('/cgi-bin/koha/opac-main.pl') const text1 = (q1.match(/id="daily-quote-text">([^<]*)([^<]*)([^<]*) ctx.sql(`DELETE FROM saved_sql WHERE id = ${rid}`)) const perl = (code) => { ctx.sh(`cat > /tmp/kbv-oc.pl <<'PL'\n${code}\nPL\nchmod 644 /tmp/kbv-oc.pl`); return ctx.sh(`koha-shell ${ctx.INSTANCE} -c "perl /tmp/kbv-oc.pl" 2>&1; rm -f /tmp/kbv-oc.pl`).out.trim().split('\n').pop() } const today = ctx.sqlValue('SELECT CURDATE()') const newBib = (t) => Number(perl(`use C4::Biblio qw(AddBiblio); use MARC::Record; use Koha::Item; my $r = MARC::Record->new; $r->leader(' nam a22 7a 4500'); $r->append_fields(MARC::Field->new('245','1','0','a'=>'${t}')); my ($bn) = AddBiblio($r, ''); Koha::Item->new({ biblionumber => $bn, homebranch => 'CPL', holdingbranch => 'CPL', itype => 'BK', dateaccessioned => '${today}' })->store; print "$bn\\n";`)) const delBib = (bn) => perl(`use C4::Biblio qw(DelBiblio); use Koha::Biblios; my $b = Koha::Biblios->find(${bn}); $_->safe_delete for $b ? $b->items->as_list : (); DelBiblio(${bn}); print "ok\\n";`) const made = [] ctx.restore('remove the new-arrival test records', () => { for (const bn of made) { delBib(bn); ctx.sql(`DELETE FROM deleteditems WHERE biblionumber = ${bn}`); ctx.sql(`DELETE FROM deletedbiblio_metadata WHERE biblionumber = ${bn}`); ctx.sql(`DELETE FROM deletedbiblioitems WHERE biblionumber = ${bn}`); ctx.sql(`DELETE FROM deletedbiblio WHERE biblionumber = ${bn}`) } }) const svc = () => JSON.parse(ctx.sh(`curl -s '${ctx.OPAC}/cgi-bin/koha/svc/report?id=${rid}&annotated=1'`).out || '[]') const one = newBib('Kbverify new arrival one'); made.push(one) ctx.flushCaches() let rows = svc() ctx.check('the public report at /cgi-bin/koha/svc/report?id=…&annotated=1 returns the newest items as JSON (biblionumber, title, author, added)', rows[0]?.title === 'Kbverify new arrival one' && 'biblionumber' in rows[0] && 'added' in rows[0], JSON.stringify(rows[0])) ctx.check("…20 rows: the report's own LIMIT 20 decides how many", rows.length === 20, rows.length) ctx.sql(`UPDATE saved_sql SET savedsql = ${ctx.q(REPORT_SQL.replace(/\nLIMIT 20$/, ''))} WHERE id = ${rid}`) ctx.flushCaches() const noLimit = svc().length ctx.sql(`UPDATE saved_sql SET savedsql = ${ctx.q(REPORT_SQL)} WHERE id = ${rid}`) ctx.flushCaches() rows = svc() ctx.check('…without a LIMIT the service returns only 10 (SvcMaxReportRows, default 10)', noLimit === 10, noLimit) const two = newBib('Kbverify new arrival two'); made.push(two) rows = svc() ctx.check('STUCK: a book added after the first request does not appear (the JSON is cached for the report\'s 300 seconds)', !rows.some((r) => r.title === 'Kbverify new arrival two'), rows.slice(0, 2).map((r) => r.title).join(' | ')) delBib(one) rows = svc() ctx.check('OLD BOOKS: a deleted book is still in the slider until the cache expires', rows.some((r) => r.title === 'Kbverify new arrival one'), rows.slice(0, 2).map((r) => r.title).join(' | ')) ctx.sql(`UPDATE saved_sql SET cache_expiry = 1 WHERE id = ${rid}`) ctx.flushCaches() rows = svc() ctx.check('fix: with the cache cleared (or expired), the deleted book is gone and the new one is first', rows[0]?.title === 'Kbverify new arrival two' && !rows.some((r) => r.title === 'Kbverify new arrival one'), rows.slice(0, 2).map((r) => r.title).join(' | ')) const three = newBib('Kbverify new arrival three'); made.push(three) await new Promise((r) => setTimeout(r, 2500)) rows = svc() ctx.check('fix: with the report\'s cache expiry set low, a newly added book appears on its own within that time', rows[0]?.title === 'Kbverify new arrival three', rows.slice(0, 2).map((r) => r.title).join(' | ')) ctx.check('a withdrawn copy is left out by the report (withdrawn = 0)', (() => { ctx.sql(`UPDATE items SET withdrawn = 1 WHERE biblionumber = ${three}`); ctx.flushCaches(); const r = svc(); ctx.sql(`UPDATE items SET withdrawn = 0 WHERE biblionumber = ${three}`); return !r.some((x) => x.title === 'Kbverify new arrival three') })()) ctx.flushCaches() add('html_customizations', 'OpacMainUserBlock', 'KBV_SLIDER', SLIDER_HTML) ctx.setPref('OPACUserCSS', SLIDER_CSS) ctx.setPref('OPACUserJS', SLIDER_JS.replace('REPORT_ID', rid)) await b.goto(`${ctx.OPAC}/cgi-bin/koha/opac-main.pl`) await b.waitForSelector('#new-arrivals a', { timeout: 15000 }).catch(() => {}) const cards = await b.locator('#new-arrivals a').allInnerTexts() const flex = await b.evaluate(() => { const e = document.querySelector('#new-arrivals'); return e ? `${getComputedStyle(e).display} ${getComputedStyle(e).overflowX}` : '' }) ctx.check('the slider: the OPACUserJS code fills #new-arrivals with one link per book, newest first, in a scrolling row', cards.length === 20 && cards[0].includes('Kbverify new arrival three') && flex === 'flex auto', `${cards.length} cards, first "${cards[0]}", ${flex}`) const href = await b.locator('#new-arrivals a').first().getAttribute('href') ctx.check("…each card links to the book's page", href === `/cgi-bin/koha/opac-detail.pl?biblionumber=${three}`, href) ctx.setPref('OPACUserJS', '') ctx.setPref('OPACUserCSS', '') // 10. Plugins add to every OPAC page through two hooks. const hooks = ctx.sh(`grep -rn "KohaPlugins.get_plugins_opac_head\\|KohaPlugins.get_plugins_opac_js" ${HT}/bootstrap/en/includes/ | wc -l`).out ctx.check('the OPAC includes call KohaPlugins.get_plugins_opac_head and get_plugins_opac_js', Number(hooks) >= 2, hooks) // 11. What the package owns (an upgrade replaces it), on a real package install. if (spawnSync('docker', ['image', 'inspect', IMG]).status !== 0) { ctx.check(`image ${IMG} present`, false); return } const r = spawnSync('docker', ['run', '--rm', IMG, 'bash', '-c', `{ dpkg -S /usr/share/koha/opac/htdocs/opac-tmpl/bootstrap/en/modules/opac-main.tt; dpkg -S /usr/share/koha/opac/htdocs/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACDetail.xsl; mkdir -p /usr/share/koha/opac/htdocs/opac-tmpl/mytheme/en; dpkg -S /usr/share/koha/opac/htdocs/opac-tmpl/mytheme; dpkg -s koha-common | grep ^Version; } 2>&1`], { encoding: 'utf8' }) const out = (r.stdout ?? '').trim() ctx.check('package install: bootstrap templates and the default XSLT belong to koha-common (an upgrade overwrites them)', out.includes('koha-common: /usr/share/koha/opac/htdocs/opac-tmpl/bootstrap/en/modules/opac-main.tt') && out.includes('koha-common: /usr/share/koha/opac/htdocs/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACDetail.xsl'), out) ctx.check('…and a theme folder of your own belongs to no package: "dpkg-query: no path found matching pattern …/mytheme"', out.includes('dpkg-query: no path found matching pattern /usr/share/koha/opac/htdocs/opac-tmpl/mytheme'), out) ctx.check('…on koha-common 26.05.05', /Version: 26\.05\.05/.test(out), out) const T = '/usr/share/koha/opac/htdocs/opac-tmpl' const r2 = spawnSync('docker', ['run', '--rm', IMG, 'bash', '-c', `{ ${THEME_CMDS}\necho ---; ${XSLT_CMDS}\n} 2>&1`], { encoding: 'utf8' }) const out2 = (r2.stdout ?? '').trim() ctx.check('the article\'s theme commands, on a package install: the folder holds one template and three links to bootstrap', /lrwxrwxrwx .* css -> \.\.\/bootstrap\/css/.test(out2) && /lrwxrwxrwx .* js -> \.\.\/bootstrap\/js/.test(out2) && /lrwxrwxrwx .* images -> \.\.\/bootstrap\/images/.test(out2) && out2.includes(`${T}/mytheme/en/modules/opac-main.tt`), out2) ctx.check('the article\'s XSLT commands: the copy now imports MARC21slimUtils.xsl by its full path', out2.includes(``), out2) ctx._boxOut = out2 }