# Channels - Test run block (Xray Test Execution of a UI scenario run)

Contract for the "Test Koşumu (Xray)" content option of `/multi-agent:channels`. The block names the Xray Test Execution of the task's UI scenario run, so the reader of the Jira comment or the PR description gets from the dev task to the run that verifies it.

**Source.** A flow runner records every scenario run in `<RUN_ROOT>/history.jsonl` (`RUN_ROOT` is `~/FlowRuns` unless the runner is configured otherwise; pass `--run-root <dir>` then): a `run` line with per-scenario results (`id`, `domain`, `status`, `testKey`, plus `commit` / `branch` when recorded), and, once the run is delivered, a `delivery` line with the same `runId` whose `executions` maps each domain to the Test Execution it created. The runner's deliver hook writes both; channels only reads them.

**Read-only.** The block is rendered by `$HOME/.claude/scripts/render-flow-run.mjs`. It never calls Xray, never creates or updates an execution, never edits the issue description, and starts no process but `git`. A key that is not in a delivery line is not printed, never synthesised. The block adds no external write: it goes into the same Step 6 preview and approval as every other section, and skips the humanizer as code does, because a reworded key or link is a wrong one.

```bash
# An argv array, because zsh does not split an unquoted ${VAR:+...} expansion.
args=(--state "$STATE_FILE" --json --lang "$OUTPUT_LANGUAGE" --heading-level 2)
[ -n "${FLOW_RUNS:-}" ] && args+=(--flow-run "$FLOW_RUNS")
[ -n "${RUN_ROOT:-}" ] && args+=(--run-root "$RUN_ROOT")
node "$HOME/.claude/scripts/render-flow-run.mjs" "${args[@]}"
```

`--json` returns `{available, reason, source, suggestion, runIds, missing, candidates, markdown}`.

## Which runs

First hit wins:

1. `--flow-run <runId>[,<runId>...]`.
2. `state.evidence.flowRuns[]`, read from the state file (the Phase 5 bundle's `flowRuns` is the same list). A step that drives a flow runner for the task records the run id there; no pipeline step does so yet, so a run started outside the pipeline is found by discovery or named with `--flow-run` (`FLOW_RUNS` above is that flag only).
3. Discovery: runs whose recorded commit is in `baseBranch..branch`, or whose results carry `ticket` equal to the Jira key. Discovery is a suggestion: `suggestion: true` comes back with `candidates[]`, and the Step 6 preview lists each candidate run. To drop one, the user answers Edit, and the block is rendered again with `--flow-run <the ids kept>`. Autopilot, which skips Step 6, drops the block when the JSON has `suggestion: true`: a discovery nobody confirmed is never posted.

A `--flow-run` id that is not in the history comes back in `missing[]` and is named in the preview.

## Picker

- **Greyed** when the renderer reports `available: false`; the greyed reason is its `reason` verbatim (no history file, or no run for this task). Forced with `--content test-run`, the section is omitted and the Step 8 summary names the reason.
- **Ticked** by default when the run came from `--flow-run` or `state.evidence.flowRuns[]`; otherwise `prefs.global.reportContent.testRun` decides.
- **Label** follows `outputLanguage`: `Test Koşumu (Xray)` / `Test Run (Xray)`.

## What the block says

- **Delivery.** The latest delivery line for each runId. A domain with an execution key is linked. A domain in `skipped` shows that reason. A domain the delivery line does not mention shows that no execution was created, with the run's lane. A run with no delivery line shows its summary, says it was not delivered to Xray, and prints the deliver command to run.
- **Links.** `jiraBase` is the runner's own setting: `JIRA_BASE`, else `deliver.jiraBase` in `scenario.config.yaml`. Without it, keys print without links; a host is never guessed. Test Set / Plan keys come from the domain's xray settings (`setKey` / `planKey`) when configured.
- **Results.** Counted the way Xray records them: `PASS`, `FAIL`, `ABORTED` always, `TODO` when present.
- **Scenarios.** One row per scenario, never filtered. A scenario with no `testKey` is listed as having no Xray test yet (`xray-sync` creates it).

## Per channel

| Channel | Placement |
|---|---|
| Jira comment | `test_run` section right after `test_scenarios`, rendered with `--heading-level 2` (`channels/jira.md`) |
| PR description | `test_run` section right after `test_scenarios`, rendered with `--heading-level 2` (`channels/pr.md`) |
| Confluence | only when the user ticks it |

## Out of scope

Editing the Jira issue description, and linking the Test Execution to the dev task from the deliver hook. The second belongs to the flow runner's own repository.
