"""Step definitions for TDD Issue #570 — session create DI regression tests.

These steps exercise the *real* DI path in ``_get_session_service()``.
Bug #570 has been fixed (same root cause as #554): the DI container
now provides a ``session_service`` provider that builds the service
correctly.
"""

from __future__ import annotations

from behave import when
from behave.runner import Context

from cleveragents.cli.commands.session import app as session_app

# The "Given a CLI runner using the real session DI path" step and the
# parameterised exit/JSON assertion steps live in tdd_session_shared_steps.py
# (Behave loads all steps globally).


@when("I invoke the session create command")
def step_invoke_create(context: Context) -> None:
    """Invoke ``session create`` through the real CLI app."""
    context.result = context.runner.invoke(session_app, ["create"])


@when('I invoke the session create command with actor "{actor}"')
def step_invoke_create_with_actor(context: Context, actor: str) -> None:
    """Invoke ``session create --actor`` through the real CLI app."""
    context.result = context.runner.invoke(session_app, ["create", "--actor", actor])


@when("I invoke the session create command with format json")
def step_invoke_create_json(context: Context) -> None:
    """Invoke ``session create --format json`` through the real CLI app."""
    context.result = context.runner.invoke(session_app, ["create", "--format", "json"])
