Files
HAL9000 f1ad838270
CI / lint (pull_request) Successful in 42s
CI / build (pull_request) Successful in 1m8s
CI / quality (pull_request) Successful in 1m11s
CI / helm (pull_request) Successful in 56s
CI / security (pull_request) Successful in 1m30s
CI / typecheck (pull_request) Successful in 2m6s
CI / push-validation (pull_request) Successful in 25s
CI / unit_tests (pull_request) Successful in 5m52s
CI / docker (pull_request) Successful in 1m44s
CI / integration_tests (pull_request) Successful in 10m13s
CI / coverage (pull_request) Successful in 10m14s
CI / status-check (pull_request) Successful in 4s
fix(coverage): delete stale output.py and add BDD coverage for all format branches
The stale `src/cleveragents/cli/output.py` file (391 lines) was added by
this PR alongside the existing `output/` package. Python silently uses the
package, leaving output.py permanently unreachable and at 0% coverage,
which dragged the project total below the 96.5% threshold.

Additionally, the json/yaml/plain format branches in
`_cli_output_manager.py` had no BDD test coverage. The existing table
scenarios also set the output format after calling display_table(), so
the non-rich branches were never exercised.

Fixes:
- Delete src/cleveragents/cli/output.py (unreachable stale module)
- Add 18 BDD scenarios covering json/yaml/plain format branches for all
  display functions: success, warning, info, error panel, success panel,
  table, handle_exception
- Add step defs for CLIOutputManager instance method calls
- Fix scenario ordering: output format set before display calls

ISSUES CLOSED: #10655
2026-06-06 00:56:05 -04:00

182 lines
7.0 KiB
Gherkin

Feature: Unified CLI Error Handling and User Feedback
As a CLI user
I want consistent error messages and user feedback across all commands
So that I have a predictable and professional experience
Background:
Given the CLI output manager is initialized
And the output format is set to "rich"
Scenario: Display success message
When I display a success message "Operation completed successfully"
Then the message should be displayed in green
And the message should contain a checkmark symbol
Scenario: Display warning message
When I display a warning message "This action may have side effects"
Then the message should be displayed in yellow
And the message should contain a warning indicator
Scenario: Display error message without debug
When I display an error with label "Validation Error" and message "Invalid input"
And debug mode is disabled
Then the error should be displayed in red
And no stack trace should be shown
Scenario: Display error message with debug
When I display an error with label "Validation Error" and message "Invalid input"
And debug mode is enabled
Then the error should be displayed in red
And the stack trace should be shown
Scenario: Display success panel
When I display a success panel with title "Success" and content "All operations completed"
Then a green panel should be displayed
And the panel should contain the title "Success"
Scenario: Display error panel
When I display an error panel with title "Error" and content "Operation failed"
Then a red panel should be displayed
And the panel should contain the title "Error"
Scenario: Display table with rich format
When I display a table with columns "Name, Status, Created"
And the table contains 2 rows of data
And the output format is "rich"
Then a formatted table should be displayed
And the table should have 3 columns
Scenario: Display table with JSON format
When I display a table with columns "Name, Status, Created"
And the table contains 2 rows of data
And the output format is "json"
Then JSON output should be displayed
And the CLI output should be valid JSON
Scenario: Display table with YAML format
When I display a table with columns "Name, Status, Created"
And the table contains 2 rows of data
And the output format is "yaml"
Then YAML output should be displayed
And the CLI output should be valid YAML
Scenario: Handle CleverAgentsError exception
When a CleverAgentsError is raised with message "Resource not found"
And the error is handled by the CLI output manager
Then a user-friendly error message should be displayed
And the application should exit with code 1
Scenario: Handle unexpected exception
When an unexpected exception is raised with message "Something went wrong"
And the error is handled by the CLI output manager
Then a generic error message should be displayed
And the application should exit with code 1
Scenario: Display info message
When I display an info message "Processing started"
Then the message should be displayed
And the message should be readable
Scenario: Error output goes to stderr
When an error is displayed
Then the error should be written to stderr
And not to stdout
Scenario: Success output goes to stdout
When a success message is displayed
Then the message should be written to stdout
And not to stderr
Scenario: Display success message with JSON format
When the output format is "json"
And I display a success message "JSON success message"
Then JSON output should be displayed
And the CLI output should be valid JSON
Scenario: Display success message with plain format
When the output format is "plain"
And I display a success message "Plain success message"
Then the message should contain a checkmark symbol
Scenario: Display warning message with JSON format
When the output format is "json"
And I display a warning message "JSON warning message"
Then JSON output should be displayed
Scenario: Display warning message with plain format
When the output format is "plain"
And I display a warning message "Plain warning message"
Then the message should contain a warning indicator
Scenario: Display info message with JSON format
When the output format is "json"
And I display an info message "JSON info message"
Then JSON output should be displayed
Scenario: Display info message with plain format
When the output format is "plain"
And I display an info message "Plain info message"
Then the message should be displayed
Scenario: Display error panel with JSON format
When the output format is "json"
And I display an error panel with title "JSON Error" and content "Error details"
Then the error should be written to stderr
Scenario: Display error panel with plain format
When the output format is "plain"
And I display an error panel with title "Plain Error" and content "Error details"
Then the error should be written to stderr
Scenario: Display success panel with JSON format
When the output format is "json"
And I display a success panel with title "JSON Done" and content "All good"
Then JSON output should be displayed
Scenario: Display success panel with plain format
When the output format is "plain"
And I display a success panel with title "Plain Done" and content "All good"
Then the message should be written to stdout
Scenario: Display table with JSON format using correct step order
When the output format is "json"
And I display a table with columns "Name, Status"
And the table contains 2 rows of data
Then JSON output should be displayed
And the CLI output should be valid JSON
Scenario: Display table with YAML format using correct step order
When the output format is "yaml"
And I display a table with columns "Name, Status"
And the table contains 2 rows of data
Then YAML output should be displayed
Scenario: Display table with plain format
When the output format is "plain"
And I display a table with columns "Name, Status"
And the table contains 2 rows of data
Then a formatted table should be displayed
Scenario: Handle exception with JSON format
When the output format is "json"
And an error is displayed
Then the error should be written to stderr
Scenario: Handle exception with plain format
When the output format is "plain"
And an error is displayed
Then the error should be written to stderr
Scenario: Display error with debug mode enabled before display
Given debug mode is enabled
When an error is displayed
Then the error should be written to stderr
Scenario: Display success via manager instance method
When I display success via the manager method "Manager success"
Then the message should be written to stdout
Scenario: Display warning via manager instance method
When I display warning via the manager method "Manager warning"
Then the message should be written to stdout