*** Settings ***
Documentation     Smoke tests for decision type phase-gating at recording time
Resource          ${CURDIR}/common.resource
Suite Setup       Setup Test Environment
Suite Teardown    Cleanup Test Environment

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

*** Test Cases ***
Valid Strategize Types Accepted
    [Documentation]    Record valid strategize-phase decision types
    [Tags]    service    decision    phase-gating
    ${result}=    Run Process    ${PYTHON}    ${HELPER_SCRIPT}    valid-strategize    cwd=${WORKSPACE}    timeout=120s    on_timeout=kill
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    valid-strategize-ok
    Should Be Empty    ${result.stderr}

Valid Execute Types Accepted
    [Documentation]    Record valid execute-phase decision types
    [Tags]    service    decision    phase-gating
    ${result}=    Run Process    ${PYTHON}    ${HELPER_SCRIPT}    valid-execute    cwd=${WORKSPACE}    timeout=120s    on_timeout=kill
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    valid-execute-ok
    Should Be Empty    ${result.stderr}

Invalid Strategize Types Rejected
    [Documentation]    Reject execute-only types during strategize phase
    [Tags]    service    decision    phase-gating
    ${result}=    Run Process    ${PYTHON}    ${HELPER_SCRIPT}    invalid-strategize    cwd=${WORKSPACE}    timeout=120s    on_timeout=kill
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    invalid-strategize-ok
    Should Be Empty    ${result.stderr}

Invalid Execute Types Rejected
    [Documentation]    Reject strategize-only types during execute phase
    [Tags]    service    decision    phase-gating
    ${result}=    Run Process    ${PYTHON}    ${HELPER_SCRIPT}    invalid-execute    cwd=${WORKSPACE}    timeout=120s    on_timeout=kill
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    invalid-execute-ok
    Should Be Empty    ${result.stderr}

Phase Agnostic Types Both Phases
    [Documentation]    Phase-agnostic types accepted in both phases
    [Tags]    service    decision    phase-gating
    ${result}=    Run Process    ${PYTHON}    ${HELPER_SCRIPT}    phase-agnostic    cwd=${WORKSPACE}    timeout=120s    on_timeout=kill
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    phase-agnostic-ok
    Should Be Empty    ${result.stderr}

Error Attributes Correct
    [Documentation]    DecisionPhaseViolationError has correct attributes
    [Tags]    service    decision    phase-gating
    ${result}=    Run Process    ${PYTHON}    ${HELPER_SCRIPT}    error-attributes    cwd=${WORKSPACE}    timeout=120s    on_timeout=kill
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    error-attributes-ok
    Should Be Empty    ${result.stderr}
