*** Settings ***
Documentation     Integration tests for the estimation actor type.
...               Covers EstimationResult model, EstimationStubActor,
...               Plan estimation_result field, ActorRole.ESTIMATOR,
...               and estimation invocation during plan lifecycle.
...               Issue #890.
Resource          ${CURDIR}/common.resource
Suite Setup       Setup Test Environment
Suite Teardown    Cleanup Test Environment

*** Variables ***
${HELPER_SCRIPT}    robot/helper_estimation_actor.py

*** Test Cases ***
EstimationResult Domain Model
    [Documentation]    Verify EstimationResult creation, defaults, serialization, and immutability
    [Tags]    estimation    model    critical
    ${result}=    Run Process    ${PYTHON}    ${HELPER_SCRIPT}    estimation-result-model    cwd=${WORKSPACE}    on_timeout=kill    timeout=30s
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    estimation-result-model-ok

EstimationStubActor Placeholder Output
    [Documentation]    Verify stub actor returns placeholder estimation with correct summary
    [Tags]    estimation    stub    critical
    ${result}=    Run Process    ${PYTHON}    ${HELPER_SCRIPT}    estimation-stub-actor    cwd=${WORKSPACE}    on_timeout=kill    timeout=30s
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    estimation-stub-actor-ok

ActorRole ESTIMATOR Enum Value
    [Documentation]    Verify ActorRole enum includes ESTIMATOR with value "estimator"
    [Tags]    estimation    enum
    ${result}=    Run Process    ${PYTHON}    ${HELPER_SCRIPT}    actor-role-estimator    cwd=${WORKSPACE}    on_timeout=kill    timeout=30s
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    actor-role-estimator-ok

Plan Model Estimation Result Field
    [Documentation]    Verify Plan model accepts estimation_result and includes it in CLI dict
    [Tags]    estimation    plan    model
    ${result}=    Run Process    ${PYTHON}    ${HELPER_SCRIPT}    plan-estimation-field    cwd=${WORKSPACE}    on_timeout=kill    timeout=30s
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    plan-estimation-field-ok

Estimation Runs During Strategize To Execute Transition
    [Documentation]    Verify estimation actor is invoked when transitioning from Strategize to Execute
    [Tags]    estimation    lifecycle    critical
    ${result}=    Run Process    ${PYTHON}    ${HELPER_SCRIPT}    estimation-lifecycle-integration    cwd=${WORKSPACE}    on_timeout=kill    timeout=30s
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    estimation-lifecycle-integration-ok

Estimation Skipped When No Actor Configured
    [Documentation]    Verify estimation is skipped when no estimation_actor is set on the plan
    [Tags]    estimation    lifecycle
    ${result}=    Run Process    ${PYTHON}    ${HELPER_SCRIPT}    no-estimation-lifecycle    cwd=${WORKSPACE}    on_timeout=kill    timeout=30s
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    no-estimation-lifecycle-ok
