# Helpdesk Smoke Test

Use `helpdesk_smoke_test.py` to verify that the LAN Redmine copy, Mailpit, and
redMCP work together on real Helpdesk issues.

The test creates one inbound Helpdesk email for `fud-helpdesk`, triggers
Helpdesk mail import, fetches the created issue through
`RedMCP\RedmineClient::issueWithHelpdesk()`, performs a non-Helpdesk CRUD
control in `fud-nohelpdesk`, sends a Helpdesk reply with
`updateIssue(..., ['send_helpdesk_email' => true])`, verifies the outbound
message arrives in Mailpit, verifies a default `updateIssue()` does not send
mail, and closes the Helpdesk issue.

## Run

```sh
./helpdesk_smoke_test.py
```

Defaults:

- Redmine: `http://192.168.50.170`
- Mailpit: `192.168.1.105`, SMTP `1025`, HTTP `8025`
- Helpdesk project: `fud-helpdesk`
- CRUD control project: `fud-nohelpdesk`
- API key source: `REDMINE_API_KEY`, `REDMNINE_API_KEY`, or `redMCP/.env`

The script runs `./validate_test_instance.py` first. To skip that preflight
while debugging:

```sh
./helpdesk_smoke_test.py --skip-preflight
```

## Expected Result

The final output should include:

```text
[OK] redMCP issueWithHelpdesk returned Helpdesk ticket context
[OK] redMCP default issue update did not send Helpdesk email
[OK] redMCP non-Helpdesk CRUD control passed
[OK] Mailpit received outbound Helpdesk/Redmine mail containing the reply token
[OK] redMCP issueWithHelpdesk returned post-reply journal message context
[OK] Closed smoke-test Helpdesk issue
Smoke test passed.
```

Closed smoke-test tickets are intentionally retained in `fud-helpdesk` as audit
evidence. Their subjects start with `[redMCP-smoke ...]`.

For outbox and worker coverage, run `./validate_helpdesk_outbox_worker.py`.
That script reuses this same live smoke path, then checks the matching
`event_outbox_events` rows and dry-runs worker enrichment.
