Skip to content

Task Issue 916 TestSpec Add To Test Plan

opencode-agent edited this page Sep 16, 2026 · 1 revision

Task 916 — Add to Test Plan action in the Test Specification editor

Issue: #916 Status: IMPLEMENTED (2026-09-16)

The gap

Legacy Test Cases (lib/testcases/tcEdit.php:80 doAction=doAdd2testplan → lib/testcases/testcaseCommands.class.php:476 doAdd2testplan, plus the tcAssign2Tplan.php popup) let a user add a test case version to a Test Plan directly from the test-case editor, choosing the target test plan; the TC then appears in that plan's tree.

The modern testSpec.html editor dropped this capability: no add-to-test-plan action and the modern BFF (api/testcases/index.php) had no such endpoint (confirmed via git history — both landed in commit 8ff73e50c, 01:22Z).

Legacy behavior (port source)

  • doAdd2testplan reads request['add2tplanid'] = tplan_id → array(platform_id), builds item2link (tcversion, platform, items) and calls testplan::link_tcversions(tplan_id, item2link, user_id) per checked (plan, platform) pair.
  • Button visible only with testplan_planning right + project having test plans.
  • Already-linked (plan, platform) pairs are read-only in the grid.

Modern implementation

Backend api/testcases/index.php

  • GET ?action=add_plan_options (line 1598) — owning-project resolution, testplan_planning gate, tcversion identity, plan×platform grid via addToplanGrid() (line 1138, legacy decision logic port).
  • POST ?action=add_to_plan (line 1921) — testplan_planning gate, tcversion-belonging validation, (plan, tcversion, platform) dedup, testplan::link_tcversions per checked pair.

Frontend gui/templates/testcases/testSpec.html

  • Add to Test Plan action in the TC view panel (line 858), gated by grants['testplan_planning'] && ctx.hasTestPlans.
  • Modal #addToPlanModal (line 260): Ver. / Test Plans / Platform grid, per-pair checkboxes, already-linked rows checked+disabled with "(Already linked)", submit disabled until a free pair is picked.
  • JS openAddToPlan / renderAddToPlanModal / submitAddToPlan (lines 458–539).
  • i18n tspec.* keys in all 10 locale bundles.

Screenshots

Add to Test Plan button in the TC view panel:

Add to Test Plan modal with the (plan, platform) grid:

Verification (fresh DB, this run)

Fixtures via modern UI: project TP916, platforms Linux/Windows, plans Release 1.0/Release 2.0 (both platforms assigned), suite Login Suite, TC TC Login Valid (tcase 5, tcversion 6).

  1. Button visible on the TC panel.
  2. Modal lists 4 (plan, platform) pairs + identity TP916-1:TC Login Valid.
  3. Add Release 1.0 × Linux + Release 2.0 × Windows → toast "Test case added to test plan(s) (2)"; testplan_tcversions rows (2,6,1) and (3,6,2); audit audit_tc_added_to_testplan for both plans.
  4. Reopen: linked pairs checked + disabled + "(Already linked)".
  5. Dedup proven: re-adding (3,1) + (2,1) → added:1 (duplicate skipped).
  6. Plan tree: planUpdateTC.html for Release 1.0 shows suite → TC; plan management Test Cases: 1 for both plans.
  7. Error paths 400/404 correct; no console errors; no new Event Viewer Error/Warning entries.

Test suite: Task — Issue #916 in tmp/TLU_Test_Cases.md.

Clone this wiki locally