Skip to content

Bugfix Issue 2101 Test Strategy Report Authored Sections PDF

github-actions[bot] edited this page Nov 29, 2026 · 1 revision

Bugfix — Issue #2101: authored Test Strategy sections in the report and PDF export

Authored Test Strategy sections and Export PDF

Symptom

Issue #2101 asked for per-section input areas for the Test Strategy, aggregation of those texts into the Test Strategy report, and export of the resulting strategy to PDF. Investigation on a freshly imported 2.0.1 database showed that the nine section textareas already existed (gui/templates/strategy/strategyDoc.html:176-184, backed by api/strategydoc/index.php), but the generated report (api/strategyreport/index.php) never read testproject_strategy_docs and the report toolbar had no PDF action. A document with a filled Exit Criteria round-tripped through the strategy-document API yet its text never appeared anywhere in the report.

Root cause

The authoring half (#1943) and the generated report half (#1925) were implemented separately and never wired together:

  • api/strategyreport/index.php assembled only context, scope, types, levels, environments, tooling, team, related, signals — measured GET action=init response had no authored key at all.
  • gui/templates/results/strategyReport.html exported Markdown and HTML and offered a generic Print action (window.print()), but no PDF-labelled action.
  • The report's published 10 panels ended with assumptions; there was nowhere for project-authored text to render.
  • The 18 static ISTQB chapter pages are read-only reference material; converting all of them into editable forms would be an architecture-sized change, beyond a minimal fix for the already-existing editor.

Approach chosen

  1. Aggregate in the BFF, not in the browser. api/strategyreport/index.php now reads testproject_strategy_docs for the addressed project, decodes the JSON section blob into the same nine canonical keys used by the authoring API, and returns an additive authored[] array with metadata (id, name, status, version, author, updated). The read is gated by mgt_view_tc OR mgt_modify_tc on that project — the same right as the strategy-document reader — so report viewers without that right receive an empty array instead of leaked content. A SHOW TABLES LIKE probe keeps freshly imported databases working when the lazily-created table does not exist yet. Author logins are resolved in one batched WHERE id IN (...) query (code-review finding).
  2. Render and export from one source of truth. The screen adds panel 10, 10. Authored Test Strategy sections, reusing the existing sdoc.sec_* heading keys and escaping every dynamic value with esc(). buildMarkdown() appends the same documents and sections after the assumptions section, so the Markdown and HTML exports both carry the authored Exit Criteria.
  3. PDF via the established print path. The teal Export PDF button calls window.print(), which in Chrome opens the print dialog where Save as PDF produces the file; the existing @media print rules hide the toolbar, header and footer and give each panel a printed border. This avoids a server-side PDF library and matches existing repo screens (reportPrint.html, printTestDoc.html).

Alternatives rejected

  • A server-side PDF generator (TCPDF/Dompdf) would add a dependency and a new write path for a capability the browser already provides.
  • Making all 18 static strategy chapter pages editable would require a new schema and a second persistence workflow; the issue's concrete example (Exit Criteria) is already editable in the authored document.
  • Reusing testplan_metrics alone to expose authored text would widen strategy-document read rights and break the parity with api/strategydoc/index.php.

Files changed

  • api/strategyreport/index.php — authored payload, rights gate, batched author lookup.
  • gui/templates/results/strategyReport.html — panel 10, Markdown block, PDF button.
  • gui/templates/i18n/{de,en,es,fr,it,ja,pt,ro,ru,zh}.json — strat.exportPdf, strat.secAuthored, strat.authoredEmpty in every bundle.
  • tmp/TLU_Test_Cases.md — regression suite Regression — Issue #2101.
  • docs/screenshots/issue-2101-authored-sections.png — post-fix browser screenshot.

Verification

  • Repro before: HTTP 200 with no authored key, no panel, no PDF action.
  • After: authored[0].sections.exit_criteria returned and rendered; the patched window.print() counter incremented once on clicking Export PDF; empty project 2 showed the localized empty state; Markdown export carried all three section texts.
  • Gates: php -l clean, extracted JS node --check clean, 10 bundles json.tool clean, bash ai/verify_i18n_coverage.sh 9/9 PASS, suite gate 34 PASS / 0 FAIL.
  • Console: 0 Error/Warning entries; Event Viewer: only AUDIT log_level 16 rows after the fixture and test run.
  • Review caveat: the negative-permission case was verified against the rights gate code and API shape, not with a separate limited-rights browser login; it is a REVIEW rather than an executed PASS. The code-review hardening also added an exact table-name check to the lazy-table probe and collapsed newlines in Markdown document metadata.

Clone this wiki locally