[Bug 41719] New: Add rendering test coverage for Labels and Patroncards
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=41719 Bug ID: 41719 Summary: Add rendering test coverage for Labels and Patroncards Initiative type: --- Sponsorship --- status: Product: Koha Version: Main Hardware: All OS: All Status: NEW Severity: enhancement Priority: P5 - low Component: Test Suite Assignee: chris@bigballofwax.co.nz Reporter: chris.nighswonger@veritassuperaitsolutions.com QA Contact: testopia@bugs.koha-community.org The label and patron card rendering code paths in C4::Labels::Label and C4::Patroncards::Patroncard lack test coverage for their core drawing methods. This patch adds: - t/db_dependent/Labels/t_Label.t - Extends existing tests with subtests for: - draw_label_text() - text positioning and formatting - draw_guide_box() - guide box rendering - barcode() - all supported barcode types (CODE39, COOP2OF5, INDUSTRIAL2OF5, EAN13) - create_label() - printing type orchestration (BIB, BAR, BIBBAR, BARBIB) - t/db_dependent/Patroncards/t_Patroncard.t - New test file covering: - draw_guide_box() and draw_guide_grid() - draw_text() with patron data substitution - draw_barcode() with multiple barcode types - draw_image() with generated test image - End-to-end PDF output validation Tests use t::lib::TestBuilder fixtures and transaction rollback for isolation. AI Disclosure: This contribution was developed with AI assistance (Claude Opus 4.5, Anthropic). See commit message for full disclosure per https://wiki.koha-community.org/wiki/Coding_Guidelines#.5BDRAFT.5D_AI_and_LL.... -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=41719 --- Comment #1 from Chris Nighswonger <chris.nighswonger@veritassuperaitsolutions.com> --- Created attachment 192076 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=192076&action=edit Bug 41719: Add rendering test coverage for Labels and Patroncards Extends t/db_dependent/Labels/t_Label.t with subtests for: - draw_label_text() structure validation - draw_guide_box() PDF stream output - All supported barcode types (CODE39, CODE39MOD, CODE39MOD10, COOP2OF5, INDUSTRIAL2OF5, EAN13) - create_label() printing type orchestration (BIB/BAR/BIBBAR/BARBIB) Creates t/db_dependent/Patroncards/t_Patroncard.t with subtests for: - draw_guide_box(), draw_guide_grid(), draw_text() - draw_barcode(), draw_image() - End-to-end PDF output AI Assistance: Claude Opus 4.5 drafted test code and debugged a PDF::Reuse issue (GitHub cnighswonger/PDF-Reuse#24, fixed in 0.43). Human author directed the approach, rejected initial implementation that merely exercised PDF::Reuse rather than Koha code, reviewed all changes, and verified tests pass. Assisted-by: Claude Opus 4.5 (Anthropic) -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=41719 Chris Nighswonger <chris.nighswonger@veritassuperaitsolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |Needs Signoff -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=41719 David Cook <dcook@prosentient.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |dcook@prosentient.com.au -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=41719 Owen Leonard <oleonard@myacpl.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|chris@bigballofwax.co.nz |chris.nighswonger@veritassu | |peraitsolutions.com -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=41719 Owen Leonard <oleonard@myacpl.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |Failed QA --- Comment #2 from Owen Leonard <oleonard@myacpl.org> ---
prove t/db_dependent/Labels/t_Label.t
t/db_dependent/Labels/t_Label.t .. 4/11 # Failed test 'PDF with barcodes has content' # at t/db_dependent/Labels/t_Label.t line 258. # Looks like you failed 1 test of 7. # Failed test 'barcode() generates all supported barcode types' # at t/db_dependent/Labels/t_Label.t line 259. # Looks like you failed 1 test of 11. Is there a reason why this problem might be on my end? -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=41719 Chris Nighswonger <chris.nighswonger@veritassuperaitsolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Depends on| |41717 --- Comment #3 from Chris Nighswonger <chris.nighswonger@veritassuperaitsolutions.com> --- (In reply to Owen Leonard from comment #2)
prove t/db_dependent/Labels/t_Label.t
t/db_dependent/Labels/t_Label.t .. 4/11 # Failed test 'PDF with barcodes has content' # at t/db_dependent/Labels/t_Label.t line 258. # Looks like you failed 1 test of 7.
# Failed test 'barcode() generates all supported barcode types' # at t/db_dependent/Labels/t_Label.t line 259. # Looks like you failed 1 test of 11.
Is there a reason why this problem might be on my end?
Hey Owen, Could you confirm your system's version of PDF::Reuse? perl -MPDF::Reuse -e 'print $PDF::Reuse::VERSION, "\n" Bug 41717 needs to be applied first (or you need to cpanm PDF::Reuse@0.43 in your test container). I apologize, but I should have made this bug depend on 41717. Doing that now. Thanks! Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=41717 [Bug 41717] Update PDF::Reuse and PDF::Reuse::Barcode to the latest version -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=41719 Chris Nighswonger <chris.nighswonger@veritassuperaitsolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Depends on| |43095 Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43095 [Bug 43095] Patron card creator dies on CODE39MOD and CODE39MOD10 barcode types (missing Algorithm::CheckDigits import) -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=41719 Chris Nighswonger <chris.nighswonger@veritassuperaitsolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #192076|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=41719 --- Comment #4 from Chris Nighswonger <chris.nighswonger@veritassuperaitsolutions.com> --- Created attachment 202134 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=202134&action=edit Bug 41719: Add rendering test coverage for Labels and Patroncards Extends t/db_dependent/Labels/t_Label.t with subtests for: - draw_label_text() layout math (text_llx/text_lly pinned to the _BIB geometry contract, downward text flow) - draw_guide_box() PDF stream output - All supported barcode types (CODE39, CODE39MOD, CODE39MOD10, COOP2OF5, INDUSTRIAL2OF5, EAN13), asserting no barcode-generation warning fires per type (Label.pm converts generation failures to warns, so absence-of-death alone cannot detect breakage) - create_label() printing type orchestration (BIB/BAR/BIBBAR/BARBIB), including the geometric contract distinguishing BIBBAR from BARBIB Creates t/db_dependent/Patroncards/t_Patroncard.t with subtests for: - draw_guide_box(), draw_guide_grid(), draw_text() - draw_barcode() across all five dispatched types; the CODE39MOD and CODE39MOD10 rows fail until Bug 43095 lands (missing Algorithm::CheckDigits import in Patroncard.pm, surfaced by this coverage work) - draw_image() - End-to-end PDF output, asserting Koha-originated content (text blocks at layout-computed coordinates, guide-box rectangle) rather than only the PDF header PDF::Reuse emits unconditionally Both files skip cleanly with a clear message when PDF::Reuse < 0.43 is installed (Bug 41717), instead of failing with opaque internals. A shared capture_pdf_end() helper centralises the End() output capture and dies on End() failure instead of swallowing it. Known Bug 41718 and PDF::Reuse prJpeg warnings are filtered against their exact observed text; unexpected warnings are forwarded to Test::NoWarnings. Test plan: 1) Apply Bug 41717 (or cpanm PDF::Reuse@0.43 PDF::Reuse::Barcode@0.09) 2) prove t/db_dependent/Labels/t_Label.t -- all tests pass 3) prove t/db_dependent/Patroncards/t_Patroncard.t -- draw_barcode() subtest fails on CODE39MOD/CODE39MOD10 with "Undefined subroutine ... CheckDigits", demonstrating Bug 43095 4) Apply Bug 43095 and re-run step 3 -- all tests pass AI Assistance: Claude Opus 4.5 drafted the original test code and debugged a PDF::Reuse issue (GitHub cnighswonger/PDF-Reuse#24, fixed in 0.43). Claude Fable 5 (Anthropic) reviewed the first revision, identified tautological assertions, unexercised checksum paths, and the latent Bug 43095 crash, and drafted the revised tests. OpenAI Codex reviewed the revision (helper error propagation, warning-filter precision). Human author directed the approach, rejected an initial implementation that merely exercised PDF::Reuse rather than Koha code, chose to surface rather than skip the Bug 43095 failure, reviewed all changes, and verified test behavior. Assisted-by: Claude Opus 4.5 (Anthropic) Assisted-by: Claude Fable 5 (Anthropic) Assisted-by: Codex (OpenAI) -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=41719 --- Comment #5 from Chris Nighswonger <chris.nighswonger@veritassuperaitsolutions.com> --- (In reply to Owen Leonard from comment #2) Owen: the failure you hit was PDF::Reuse 0.39 — its prEnd() crashes on the TTFont lifecycle (fixed in 0.43, Bug 41717), and the old test swallowed that crash, leaving an empty file and a confusing downstream failure. The revised patch fixes the experience directly: both test files now skip_all with a clear message when PDF::Reuse < 0.43 is installed, so you get "PDF::Reuse >= 0.43 required (see Bug 41717)" instead of a mystery. Revision 2 notes (replaces obsoleted attachment 192076): - The end-to-end and barcode assertions in revision 1 could pass even when the Koha rendering code did nothing (file-size / %PDF-header checks are produced by PDF::Reuse unconditionally; Label.pm converts barcode-generation failures to warns). Revision 2 asserts on Koha-originated output: per-type absence of the barcode-generation warning, text blocks at layout-computed coordinates, and the guide-box rectangle at its exact geometry. - Extending patroncard barcode coverage to all five dispatched types exposed a real crash: CODE39MOD / CODE39MOD10 die with "Undefined subroutine CheckDigits" because C4::Patroncards::Patroncard never imports Algorithm::CheckDigits (C4::Labels::Label does). Filed as Bug 43095 (one-line fix, patch attached there); this bug now depends on it. The two test rows fail by design until 43095 is applied — see the test plan. - Warning filters are scoped to the exact known Bug 41718 / PDF::Reuse warning text and forward anything unexpected to Test::NoWarnings, instead of the blanket suppression in revision 1. Test plan is in the commit message. Verified in koha-testing-docker: Labels 11/11; Patroncards all pass with 43095 applied, and fails only the two designed rows without it. AI Disclosure: revision 2 was developed with AI assistance (Claude Fable 5 reviewed revision 1 and drafted the revision; OpenAI Codex reviewed the result). Human author directed the approach, chose to surface rather than skip the Bug 43095 failure, reviewed all changes, and verified test behavior. Full disclosure in the commit message per the draft AI guideline. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=41719 Chris Nighswonger <chris.nighswonger@veritassuperaitsolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Failed QA |Needs Signoff -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=41719 Bug 41719 depends on bug 43095, which changed state. Bug 43095 Summary: Patron card creator dies on CODE39MOD and CODE39MOD10 barcode types (missing Algorithm::CheckDigits import) https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43095 What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |RESOLVED Resolution|--- |DUPLICATE -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=41719 Chris Nighswonger <chris.nighswonger@veritassuperaitsolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Depends on|43095 |21123 Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=21123 [Bug 21123] Patron card creator doesn't print barcodes with Code39 + Modulo https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43095 [Bug 43095] Patron card creator dies on CODE39MOD and CODE39MOD10 barcode types (missing Algorithm::CheckDigits import) -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=41719 --- Comment #6 from Chris Nighswonger <chris.nighswonger@veritassuperaitsolutions.com> --- For the QA audit trail: the attached patch was staged and reviewed internally at https://github.com/cnighswonger/koha-wip/pull/1 (review discussion, verification detail, and revision history). -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=41719 Chris Nighswonger <chris.nighswonger@veritassuperaitsolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks| |41718 Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=41718 [Bug 41718] draw_guide_grid() passes incorrect arguments to PDF methods, causing warnings. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=41719 --- Comment #7 from Chris Nighswonger <chris.nighswonger@veritassuperaitsolutions.com> --- Created attachment 205665 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=205665&action=edit Bug 41719: Add rendering test coverage for Labels and Patroncards Pre-signoff revision. Two changes from the previous attachment (202134): **1. CODE39MOD/CODE39MOD10 rows wrapped in TODO { }.** Those two rows die on `Undefined subroutine Algorithm::CheckDigits` until Bug 43095 lands (surfaced by the coverage work in the first place). Previously the file was intentionally red on those two lines and disclosed as such; a reviewer running `prove` first sees red and can Failed-QA before reaching the disclosure. Wrapping in TODO with the blocking bug named in `$TODO` returns the file to a green overall PASS while still exercising the code path. When Bug 43095 lands, the rows unexpectedly-succeed and the TODO wrapper is removed. **2. `chmod +x` on the new `t/db_dependent/Patroncards/t_Patroncard.t`.** The prior attachment was `100644`; `koha-qa.pl` flags this as `file_permissions: File must have the exec flag`. Now `100755`, matching its sibling `t/db_dependent/Labels/t_Label.t` and every other Koha test file. Test plan step 3 updated to describe the TODO output shape. Step 4 updated to note that removing the TODO wrapper is the follow-up when Bug 43095 lands (else Test::More reports "TODO unexpectedly succeeded"). `koha-qa.pl -c 1` PASS on both files. `prove t/db_dependent/Labels/t_Label.t t/db_dependent/Patroncards/t_Patroncard.t` PASS. AI review disclosure per Coding_Guidelines §1.8 §4: this rework was authored by Claude Opus 4.7 (Anthropic) under human direction and reviewed by OpenAI Codex GPT-5.5 (OpenAI) as an independent cross-vendor second reviewer. Codex ran isolated `Test::More` probes to verify the TODO semantics on three edge cases (TODO-wrapped fail, TODO-wrapped unexpected-pass, unwrapped `die` still aborting) and confirmed correctness against the diff; no blocker or should-fix findings. Previous review chain intact in commit trailers: Claude Opus 4.5 authored the tests; Claude Fable 5 and OpenAI Codex GPT-5.5 reviewed prior revisions. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=41719 Chris Nighswonger <chris.nighswonger@veritassuperaitsolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #202134|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org