*** Settings ***
Documentation    TDD regression tests for issue #1429: actor compiler reads
...              actor_ref from NodeDefinition.actor_ref field, not from the
...              raw node.config dict.
...
...              Two compiler functions are covered:
...                _map_node()     -- sets NodeConfig.subgraph
...                compile_actor() -- populates metadata.subgraph_refs
Resource         ${CURDIR}/common.resource
Suite Setup      Setup Test Environment
Suite Teardown   Cleanup Test Environment

*** Variables ***
${HELPER}    ${CURDIR}/helper_tdd_actor_compiler_actor_ref_1429.py

*** Test Cases ***
NodeConfig subgraph Set From actor_ref Field In _map_node
    [Documentation]    Verify _map_node() reads actor_ref from NodeDefinition.actor_ref
    ...    so that NodeConfig.subgraph is populated for SUBGRAPH nodes.
    ...    Before the fix for #1429 this always returned None because the compiler
    ...    used config.get("actor_ref") on a dict that never contained the key.
    [Tags]    slow
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    subgraph-field    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    tdd-1429-subgraph-field-ok

Metadata subgraph_refs Populated From actor_ref Field In compile_actor
    [Documentation]    Verify compile_actor() reads actor_ref from NodeDefinition.actor_ref
    ...    so that metadata.subgraph_refs maps SUBGRAPH node IDs to referenced actor names.
    ...    Before the fix for #1429 subgraph_refs was always empty because the compiler
    ...    used node_def.config.get("actor_ref", "") on a dict that never contained the key.
    [Tags]    slow
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    subgraph-refs    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    tdd-1429-subgraph-refs-ok
