Files
cleveragents-core/features/action_model.feature
T

172 lines
7.0 KiB
Gherkin

Feature: Action Domain Model
As a developer
I want an action domain model that defines reusable plan templates
So that I can create actions via CLI and use them on projects
# Action Argument Parsing Tests
Scenario: Parse required string argument
When I parse the action argument "name:str:required:User name"
Then the argument name should be "name"
And the argument type should be "str"
And the argument should be required
And the argument description should be "User name"
Scenario: Parse optional integer argument
When I parse the action argument "count:int:optional:Number of items"
Then the argument name should be "count"
And the argument type should be "int"
And the argument should be optional
Scenario: Parse argument without description
When I parse the action argument "flag:bool:required"
Then the argument name should be "flag"
And the argument type should be "bool"
And the argument description should be empty
Scenario: Invalid argument format raises error
When I try to parse the action argument "invalid"
Then an argument parse error should be raised
Scenario: Invalid argument type raises error
When I try to parse the action argument "name:badtype:required:desc"
Then an argument parse error should be raised
Scenario: Invalid argument requirement raises error
When I try to parse the action argument "name:str:sometimes:desc"
Then an argument parse error should be raised
Scenario: Invalid argument name raises error
When I try to create an action argument with invalid name "1invalid"
Then a validation error should be raised
And the error should mention "Argument name must be a valid Python identifier"
Scenario: Invalid argument name with hyphen raises error
When I try to create an action argument with invalid name "invalid-name"
Then a validation error should be raised
And the error should mention "Argument name must be a valid Python identifier"
Scenario: Stringify action argument definition
When I parse the action argument "limit:int:required:Limit value"
And I stringify the action argument
Then the argument definition string should be "limit:int:required:Limit value"
Scenario: Stringify optional list argument definition
When I parse the action argument "targets:list:optional:Targets to check"
And I stringify the action argument
Then the argument definition string should be "targets:list:optional:Targets to check"
# Action Creation Tests
Scenario: Create minimal action
When I create an action with name "local/test-action" and definition of done "Tests pass"
Then the action should be created
And the action namespace should be "local"
And the action name should be "test-action"
And the action state should be "draft"
Scenario: Create action with arguments
Given I have action arguments
| name | type | requirement | description |
| coverage | int | required | Target coverage percent |
| framework | str | optional | Test framework to use |
When I create an action with these arguments
Then the action should have 2 arguments
And the action should have 1 required argument
And the action should have 1 optional argument
Scenario: Validate arguments - all required provided
Given I have an action with required argument "target:int:required:Target value"
When I validate arguments with target 85
Then the validation should pass
Scenario: Validate arguments - missing required
Given I have an action with required argument "target:int:required:Target value"
When I validate arguments without target
Then the validation should fail with "Missing required argument: target"
Scenario: Validate arguments - unknown argument
Given I have an action with required argument "target:int:required:Target value"
When I validate arguments with target 85 and extra "foo"
Then the validation should fail with "Unknown argument: extra"
Scenario: Validate arguments - wrong type
Given I have an action with required argument "target:int:required:Target value"
When I validate arguments with target as string "not-a-number"
Then the validation should fail with "must be an integer"
Scenario: Validate arguments - integer below minimum
Given I have an action with bounded integer argument "priority" min 1 max 5
When I validate arguments with "priority" set to 0
Then the validation should fail with "Argument priority must be >= 1"
Scenario: Validate arguments - integer above maximum
Given I have an action with bounded integer argument "priority" min 1 max 5
When I validate arguments with "priority" set to 6
Then the validation should fail with "Argument priority must be <= 5"
Scenario: Validate arguments - float expects numeric
Given I have an action with argument "threshold" of type "float"
When I validate arguments with "threshold" set to "high"
Then the validation should fail with "Argument threshold must be a number"
Scenario: Validate arguments - boolean expects boolean
Given I have an action with argument "dry_run" of type "bool"
When I validate arguments with "dry_run" set to "yes"
Then the validation should fail with "Argument dry_run must be a boolean"
Scenario: Validate arguments - list expects list
Given I have an action with argument "targets" of type "list"
When I validate arguments with "targets" set to "api,cli"
Then the validation should fail with "Argument targets must be a list"
# Action State Tests
Scenario: New action starts in draft state
When I create a new action
Then the action state should be "draft"
Scenario: Action can be made available
Given I have a draft action
When I set the action state to available
Then the action state should be "available"
Scenario: Action can be archived
Given I have an available action
When I set the action state to archived
Then the action state should be "archived"
# Actor Configuration Tests
Scenario: Action requires strategy and execution actors
When I try to create an action without strategy actor
Then a validation error should be raised
Scenario: Action can have optional review actor
When I create an action with review actor "local/code-reviewer"
Then the action should have a review actor
Scenario: Action can have optional estimation actor
When I create an action with estimation actor "local/cost-estimator"
Then the action should have an estimation actor
# Reusability Tests
Scenario: Actions are reusable by default
When I create a new action
Then the action should be reusable
Scenario: Action can be non-reusable
When I create a non-reusable action
Then the action should not be reusable
# Read-only Tests
Scenario: Actions are not read-only by default
When I create a new action
Then the action should not be read-only
Scenario: Action can be marked read-only
When I create a read-only action
Then the action should be read-only