Files
cleveragents-core/features/plan_lifecycle_commands_coverage.feature

235 lines
11 KiB
Gherkin

Feature: Plan V3 Lifecycle Commands and Streaming Coverage
As a developer
I want to test V3 lifecycle commands and streaming in plan.py
So that previously uncovered lines/branches have test coverage
# ===================================================================
# V3 Lifecycle - use_action command
# ===================================================================
Scenario: Use action creates a plan from an available action with string arguments
Given I have a temporary test directory
When I invoke use_action with string argument "target_coverage=80"
Then the use_action CLI should succeed
And the lifecycle plan panel should be printed
Scenario: Use action parses integer and float argument values correctly
Given I have a temporary test directory
When I invoke use_action with args "count=42" and "ratio=3.14"
Then the use_action CLI should succeed
And the parsed arguments should contain integer 42 and float 3.14
Scenario: Use action parses boolean argument values correctly
Given I have a temporary test directory
When I invoke use_action with args "verbose=true" and "dry_run=false"
Then the use_action CLI should succeed
And the parsed arguments should contain booleans true and false
Scenario: Use action rejects invalid argument format without equals sign
Given I have a temporary test directory
When I invoke use_action with malformed argument "badarg"
Then the use_action CLI should abort
And the output should mention invalid argument format
Scenario: Use action falls back to action name lookup when ID not found
Given I have a temporary test directory
When I invoke use_action where get_action raises NotFoundError
Then the use_action CLI should succeed via name fallback
Scenario: Use action parses custom automation profile
Given I have a temporary test directory
When I invoke use_action with automation profile "full-auto"
Then the use_action CLI should succeed
And the lifecycle service should receive full-auto profile
Scenario: Use action rejects invalid automation profile
Given I have a temporary test directory
When I invoke use_action with automation profile "super_auto"
Then the use_action CLI should abort
And the output should mention invalid automation profile
Scenario: Use action reports error when action is not available
Given I have a temporary test directory
When I invoke use_action and ActionNotAvailableError is raised
Then the use_action CLI should abort
And the output should mention action not available
Scenario: Use action handles validation errors gracefully
Given I have a temporary test directory
When I invoke use_action and ValidationError is raised
Then the use_action CLI should abort with lifecycle validation error
Scenario: Use action handles general CleverAgents errors
Given I have a temporary test directory
When I invoke use_action and CleverAgentsError is raised
Then the use_action CLI should abort with lifecycle general error
# ===================================================================
# V3 Lifecycle - execute_plan command
# ===================================================================
Scenario: Execute plan transitions a strategize-complete plan to execute phase
Given I have a temporary test directory
When I invoke execute_plan with a valid plan ID
Then the execute_plan CLI should succeed
And the execute phase panel should be printed
Scenario: Execute plan auto-selects the only strategize-complete plan when no ID given
Given I have a temporary test directory
When I invoke execute_plan without ID and one strategize-complete plan exists
Then the execute_plan CLI should succeed
Scenario: Execute plan aborts when no plans are ready for execution
Given I have a temporary test directory
When I invoke execute_plan without ID and no strategize-complete plans exist
Then the execute_plan CLI should abort
And the output should mention no plans ready for execution
Scenario: Execute plan aborts when multiple plans are ready and no ID given
Given I have a temporary test directory
When I invoke execute_plan without ID and multiple strategize-complete plans exist
Then the execute_plan CLI should abort
And the output should mention multiple plans ready
Scenario: Execute plan reports invalid phase transition error
Given I have a temporary test directory
When I invoke execute_plan and InvalidPhaseTransitionError is raised
Then the execute_plan CLI should abort
And the output should mention invalid transition
Scenario: Execute plan reports plan not ready error
Given I have a temporary test directory
When I invoke execute_plan and PlanNotReadyError is raised
Then the execute_plan CLI should abort
And the output should mention plan not ready
# ===================================================================
# V3 Lifecycle - lifecycle_apply_plan command
# ===================================================================
Scenario: Lifecycle apply transitions an execute-complete plan to apply phase
Given I have a temporary test directory
When I invoke lifecycle-apply with a valid plan ID
Then the lifecycle-apply CLI should succeed
And the apply phase panel should be printed
Scenario: Lifecycle apply auto-selects the only execute-complete plan
Given I have a temporary test directory
When I invoke lifecycle-apply without ID and one execute-complete plan exists
Then the lifecycle-apply CLI should succeed
Scenario: Lifecycle apply aborts when no plans are ready for apply
Given I have a temporary test directory
When I invoke lifecycle-apply without ID and no execute-complete plans exist
Then the lifecycle-apply CLI should abort
And the output should mention no plans ready for apply
Scenario: Lifecycle apply aborts when multiple plans are ready and no ID given
Given I have a temporary test directory
When I invoke lifecycle-apply without ID and multiple execute-complete plans exist
Then the lifecycle-apply CLI should abort
And the output should mention multiple plans ready for apply
# ===================================================================
# V3 Lifecycle - plan_status command
# ===================================================================
Scenario: Plan status shows details for a specific plan ID
Given I have a temporary test directory
When I invoke plan status with a specific plan ID
Then the plan status CLI should succeed
And the plan status panel should be displayed
Scenario: Plan status lists all active plans when no ID given
Given I have a temporary test directory
When I invoke plan status without ID and active plans exist
Then the plan status CLI should succeed
And the active plans table should be displayed
Scenario: Plan status shows no plans message when empty
Given I have a temporary test directory
When I invoke plan status without ID and no plans exist
Then the plan status CLI should succeed with no plans message
# ===================================================================
# V3 Lifecycle - lifecycle_list_plans command
# ===================================================================
Scenario: Lifecycle list shows all plans without filters
Given I have a temporary test directory
When I invoke lifecycle-list without filters
Then the lifecycle-list CLI should succeed
And the lifecycle plans table should be displayed
Scenario: Lifecycle list filters plans by phase
Given I have a temporary test directory
When I invoke lifecycle-list with phase filter "strategize"
Then the lifecycle-list CLI should succeed
Scenario: Lifecycle list rejects invalid phase filter
Given I have a temporary test directory
When I invoke lifecycle-list with phase filter "bogus_phase"
Then the lifecycle-list CLI should abort
And the output should mention invalid phase
Scenario: Lifecycle list shows no plans message when empty
Given I have a temporary test directory
When I invoke lifecycle-list and no plans match
Then the lifecycle-list CLI should succeed with empty list message
# ===================================================================
# V3 Lifecycle - cancel_plan command
# ===================================================================
Scenario: Cancel plan cancels a plan with a reason
Given I have a temporary test directory
When I invoke cancel with a reason "no longer needed"
Then the cancel CLI should succeed
And the output should show cancellation with reason
Scenario: Cancel plan cancels a plan without a reason
Given I have a temporary test directory
When I invoke cancel without a reason
Then the cancel CLI should succeed
And the output should show cancellation without reason text
Scenario: Cancel plan handles plan errors
Given I have a temporary test directory
When I invoke cancel and PlanError is raised
Then the cancel CLI should abort
And the output should mention cannot cancel
# ===================================================================
# Streaming (_tell_streaming)
# ===================================================================
Scenario: Tell streaming displays real-time progress for plan generation nodes
Given I have a temporary test directory
When I run _tell_streaming with a successful async event stream
Then _tell_streaming should complete without error
And the streaming output should include completion panel
Scenario: Tell streaming handles errors during streaming generation
Given I have a temporary test directory
When I run _tell_streaming with an error during streaming
Then _tell_streaming should raise the streaming error
# ===================================================================
# _print_lifecycle_plan
# ===================================================================
Scenario: Print lifecycle plan displays details for a real LifecyclePlan
Given I have a temporary test directory
When I call _print_lifecycle_plan with a LifecyclePlan instance
Then the lifecycle plan panel should be rendered with plan details
Scenario: Print lifecycle plan falls back for a non-LifecyclePlan object
Given I have a temporary test directory
When I call _print_lifecycle_plan with a non-LifecyclePlan object
Then the fallback plan panel should be rendered
Scenario: Print lifecycle plan shows error message when present
Given I have a temporary test directory
When I call _print_lifecycle_plan with a LifecyclePlan that has an error
Then the lifecycle plan panel should include the error message