Repository navigation
Print Test Specification Modernized
Modernization of the Print Test Specification screen (the legacy
lib/results/printDocOptions.php?type=testspec document generator) — GitHub
issue #982.
The standalone Dashio navigator (gui/templates/testcases/printTestSpec.html)
lets you print the whole test specification document of a test project or a
single test suite, with the exact same document-option checkboxes as the legacy
screen (table of contents, header numbering, test case header, summary, steps,
author, keywords, custom fields, requirements) and the HTML / MS Word output
format. The generated document opens in its own tab
(gui/templates/testcases/printTestDoc.html) so you can preview, print or
download it.
Screen: gui/templates/testcases/printTestSpec.html (navigator) +
gui/templates/testcases/printTestDoc.html (document popup)
BFF API: api/testcasesprint/index.php
(GET ?action=init, GET ?action=tree, GET ?action=print,
GET ?action=download)
Rights: testplan_metrics on the target test project — 403 without it.
ASIDE entry: Test Case Design → Test Specification Document (gated the
same way).



Screenshots: docs/screenshots/pts_navigator.png, pts_doc_wholeproject.png,
pts_doc_suite.png.
-
Navigator (
printTestSpec.html):- header "Print Test Specification in test project ", with a locale
switcher (the printed document itself uses the chosen document language,
exactly like the legacy
document_languageselector). - info box (i) explaining the node-click behavior, (i) "Select a test suite" hint, and the tree listed with per-suite test-case counts and a "whole project document" row under the project node, plus a Refresh tree button.
- clicking the project node or a suite node opens the document popup for the whole project / that suite in a new tab.
- Document print options card: Output format (HTML / MS Word), then the legacy checkboxes split into DOCUMENT STRUCTURE — Table of contents, Header numbering — and TEST SPECIFICATION CONTENT — Test case header (id, title, status), Test case summary (default on), Test case steps, Author, Keywords, Custom fields, Requirements.
- Print whole project document button.
- footer: "
Ntest suites ·Mtest cases" plus "TestLink 2.0.1 - Print Test Specification".
- header "Print Test Specification in test project ", with a locale
switcher (the printed document itself uses the chosen document language,
exactly like the legacy
-
Document popup (
printTestDoc.html):- loads
GET ?action=print&level=<testproject|testsuite>&id=<id>&tproject_id=<n>with the chosen options asformat,toc,headerNumbering,header,summary,body,author,keyword,cfields,requirementflags and renders the extracted legacy HTML document inside an iframe. - toolbar: title (
<title>of the generated document), Print (window print of the iframe), Refresh, Back (returns to the navigator), and for MS Word format a client-side.docBlob download button. - HTML output is shown in a bordered preview; MS Word output is downloaded as
TestSpecification_<project-name>.doc(the legacy filename).
- loads
Authenticated (session cookie); BFF runs at top-level script scope so the
legacy printDocument.php include resolves project-level $tlCfg.
| Method & path | Rights | Description |
|---|---|---|
GET ?action=init&tproject_id=<n> |
view | Project name + option defaults (matching the legacy getPrintOptions() defaults: summary on, rest off) + output formats |
GET ?action=tree&tproject_id=<n> |
view | Nested suite tree with recursion-aware tcTotal counts (project root excluded from its own path) |
GET ?action=print&level=<testproject|testsuite>&id=<id>&tproject_id=<n>&format=…&…options… |
testplan_metrics |
Rendered document title + HTML body; whole-project (level=testproject, id=<tproject_id>) or suite (level=testsuite, id=<suite_id>) |
GET ?action=download&… (same params) |
testplan_metrics |
MS Word: streams the legacy document with attachment headers |
Errors: 400 invalid level, 403 missing right, 404 missing project / unknown suite / suite not belonging to the project.
- The entire legacy pipeline is reused:
lib/functions/printDocument.phpat top-level include scope,spec_header/spec_footer, the per-suite recursive document builder (print_testsuite),get_tarefa_array()step reconstruction and the keywords/CF/requirement sections. Nothing is re-implemented, so output stays byte-identical to 1.9.20. -
FORMAT_HTML = 0,FORMAT_MSWORD = 4,DOC_TEST_SPEC = 'testspec'. - Toc (table of contents) and header-numbering state are kept across the
legacy object (
report_debug/optionsinprintDocumentSpecMakeSpec()). - Suite membership is verified with
get_subtree_list(...,'array')overget_path()(which excludes the root node, so aget_path()membership test alone would wrongly reject suites). - Document title extraction prefers the
<title>tag, then the TOC<h1>. - The MS-Word legacy generator commits its
Content-Type: application/vnd.ms-wordheaders during the include (headers_sent()is already true on return), so the BFF cannot un-commit them; the front-end therefore forces jQuerydataType:'json'for theprintrequest so the JSON response is never re-sniffed as text.
- The legacy click-through flow (checkbox list + "Print document" submit within the same page) becomes a navigator + separate doc-popup tab; selection state is kept in the popup's query string instead of a server-side form.
- The legacy locale dropdown written into the document header is preserved as
the navigator's locale switcher (same
ls_*locale codes). -
format=HTMLdocuments are previewed in the popup (an iframe) and can be browser-printed; no download is forced, matching the legacy "display / save" choice.
New keys in ALL 10 locale bundles (gui/templates/i18n/{en,de,es,fr,it,ja,pt,ro,ru,zh}.json):
footers.printTestSpec, footers.printTestDoc, the pts.* navigator set
(status header, tree labels, option-group headers, each of the 9 document
option captions, format labels, message strings) and the ptdoc.* popup set
(toolbar buttons, download label, preview helpers). Reused existing common.*
keys for buttons and table chrome.
- Same-origin guard (
bffSameOriginGuard()) on every route. -
testplan_metricson the owning test project gatesprint/download(verified against the legacyhas_right()check inprintDocOptions.php);init/treeanswer withcanGenerate:false(and hide the print controls) when the user lacks it — legacy lets the user see the form but fails on submit, the screen reflects the grant up-front. -
levelis whitelisted;id/tproject_idareintval-cast and every id is cross-checked against the session's test projects.
Exercised via browser (navigator, whole-project & suite documents, MS Word
preview/download, locale switch, ASIDE wiring) and direct BFF curl probes
(401 unauth, 400 invalid level, 403 no-rights, 404 missing project/suite,
404 unknown action). Regression suite PTS-982 (16/16 PASS) appended to
tmp/TLU_Test_Cases.md; Event Viewer check confirmed no Error/Warning rows
from the modernized screen.