cli/session: add failing test for session delete --format json missing envelope #10457

Open
opened 2026-04-18 09:50:05 +00:00 by HAL9000 · 0 comments
Owner

Metadata

  • Commit message: test(cli/session): add failing test for session delete --format json missing envelope
  • Branch name: test/cli-session-delete-format-json-missing-envelope

Background and Context

The agents session delete --format json command currently outputs Rich markup text instead of a spec-compliant JSON envelope. This TDD issue captures the failing test that verifies the correct behavior, driving the subsequent bug fix.

Expected Behavior

A test exists that:

  • Invokes agents session delete <id> --yes --format json
  • Asserts the output is a valid JSON envelope (not Rich markup)
  • Fails on the current codebase (confirming the bug exists)
  • Passes after the corresponding bug fix is applied

Summary

Add a failing BDD/unit test that verifies agents session delete --format json emits a spec-compliant JSON envelope instead of Rich markup text.

Test Specification

# tests/cli/test_session_delete_json.py
def test_session_delete_format_json_emits_envelope(runner, mock_session_service):
    """agents session delete --format json must emit JSON envelope, not Rich markup."""
    result = runner.invoke(app, ["session", "delete", "01HXYZ", "--yes", "--format", "json"])
    assert result.exit_code == 0
    output = json.loads(result.output)
    assert output["command"] == "agents session delete 01HXYZ"
    assert output["status"] == "ok"
    assert output["exit_code"] == 0
    assert "data" in output
    assert "timing" in output
    assert "messages" in output
    # Must NOT contain Rich markup
    assert "[green]" not in result.output
    assert "✓ OK" not in result.output

Tags

  • @tdd_issue
  • @tdd_issue_1
  • @tdd_expected_fail

Expected Failure

The test currently fails because session delete in src/cleveragents/cli/commands/session.py (line ~342) calls console.print(f"[green]✓ OK[/green] Session {session_id} deleted") for non-rich formats instead of calling format_output().

Acceptance Criteria

  • Test file tests/cli/test_session_delete_json.py is created with the above test case
  • Test is tagged with @tdd_issue, @tdd_issue_1, @tdd_expected_fail
  • Running the test on the current codebase produces a failure (exit code != 0 or JSON parse error)
  • The test passes after the corresponding bug fix (Issue: cli/session: session delete --format json outputs Rich markup instead of JSON envelope) is applied

Subtasks

  • Create tests/cli/test_session_delete_json.py with the test function above
  • Add required pytest markers/tags (@tdd_issue, @tdd_issue_1, @tdd_expected_fail)
  • Add any necessary fixtures (runner, mock_session_service) if not already present
  • Verify the test fails on the current codebase
  • Document the expected failure reason in the test docstring

Definition of Done

This issue should be closed when:

  • The test file exists and is committed to the branch
  • The test is confirmed to fail on the current (unfixed) codebase
  • The test is confirmed to pass after the bug fix in the corresponding bug issue is applied
  • CI/CD pipeline runs the test as part of the test suite

Automated by CleverAgents Bot
Supervisor: Bug Hunt Pool | Agent: bug-hunt-pool-supervisor

## Metadata - **Commit message:** `test(cli/session): add failing test for session delete --format json missing envelope` - **Branch name:** `test/cli-session-delete-format-json-missing-envelope` ## Background and Context The `agents session delete --format json` command currently outputs Rich markup text instead of a spec-compliant JSON envelope. This TDD issue captures the failing test that verifies the correct behavior, driving the subsequent bug fix. ## Expected Behavior A test exists that: - Invokes `agents session delete <id> --yes --format json` - Asserts the output is a valid JSON envelope (not Rich markup) - Fails on the current codebase (confirming the bug exists) - Passes after the corresponding bug fix is applied ## Summary Add a failing BDD/unit test that verifies `agents session delete --format json` emits a spec-compliant JSON envelope instead of Rich markup text. ## Test Specification ```python # tests/cli/test_session_delete_json.py def test_session_delete_format_json_emits_envelope(runner, mock_session_service): """agents session delete --format json must emit JSON envelope, not Rich markup.""" result = runner.invoke(app, ["session", "delete", "01HXYZ", "--yes", "--format", "json"]) assert result.exit_code == 0 output = json.loads(result.output) assert output["command"] == "agents session delete 01HXYZ" assert output["status"] == "ok" assert output["exit_code"] == 0 assert "data" in output assert "timing" in output assert "messages" in output # Must NOT contain Rich markup assert "[green]" not in result.output assert "✓ OK" not in result.output ``` ## Tags - @tdd_issue - @tdd_issue_1 - @tdd_expected_fail ## Expected Failure The test currently fails because `session delete` in `src/cleveragents/cli/commands/session.py` (line ~342) calls `console.print(f"[green]✓ OK[/green] Session {session_id} deleted")` for non-rich formats instead of calling `format_output()`. ## Acceptance Criteria - [ ] Test file `tests/cli/test_session_delete_json.py` is created with the above test case - [ ] Test is tagged with `@tdd_issue`, `@tdd_issue_1`, `@tdd_expected_fail` - [ ] Running the test on the current codebase produces a failure (exit code != 0 or JSON parse error) - [ ] The test passes after the corresponding bug fix (Issue: `cli/session`: `session delete --format json` outputs Rich markup instead of JSON envelope) is applied ## Subtasks - [ ] Create `tests/cli/test_session_delete_json.py` with the test function above - [ ] Add required pytest markers/tags (`@tdd_issue`, `@tdd_issue_1`, `@tdd_expected_fail`) - [ ] Add any necessary fixtures (`runner`, `mock_session_service`) if not already present - [ ] Verify the test fails on the current codebase - [ ] Document the expected failure reason in the test docstring ## Definition of Done This issue should be closed when: - The test file exists and is committed to the branch - The test is confirmed to fail on the current (unfixed) codebase - The test is confirmed to pass after the bug fix in the corresponding bug issue is applied - CI/CD pipeline runs the test as part of the test suite --- **Automated by CleverAgents Bot** Supervisor: Bug Hunt Pool | Agent: bug-hunt-pool-supervisor
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
cleveragents/cleveragents-core#10457
No description provided.