*** Settings ***
Documentation    Smoke tests for plan use with invariants, automation profiles, and actor validation
Resource         ${CURDIR}/common.resource
Suite Setup      Setup Test Environment
Suite Teardown   Cleanup Test Environment

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

*** Test Cases ***
Plan Use With Invariants
    [Documentation]    Verify that ``plan use --invariant`` passes invariants correctly
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    plan-use-invariants    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    cli-ext-plan-use-invariants-ok

Plan Use With Automation Profile
    [Documentation]    Verify that ``plan use --automation-profile`` works
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    plan-use-profile    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    cli-ext-plan-use-profile-ok

Plan Use Actor Validation Valid
    [Documentation]    Verify valid namespaced actor format is accepted
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    actor-valid    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    cli-ext-actor-valid-ok

Plan Use Actor Validation Invalid
    [Documentation]    Verify invalid actor format is rejected
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    actor-invalid    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    cli-ext-actor-invalid-ok

Plan Use Combined Profile And Invariants
    [Documentation]    Verify plan use with both profile and invariants
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    plan-combined    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    cli-ext-plan-combined-ok

Action Show With Optional Actors And Invariants
    [Documentation]    Verify action show includes optional actors, invariants, and inputs_schema when set
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    action-show-extended    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    cli-ext-action-show-extended-ok

Action Show JSON With Optional Fields
    [Documentation]    Verify action show JSON output includes optional fields
    [Tags]    tdd_issue    tdd_issue_4205    tdd_expected_fail
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    action-show-json    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    cli-ext-action-show-json-ok

Invariant Ordering Preserved
    [Documentation]    Verify that multiple invariant flags preserve insertion order
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    invariant-ordering    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    cli-ext-invariant-ordering-ok

Profile Resolution All Builtins
    [Documentation]    Verify that all builtin profiles resolve correctly
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    profile-resolution    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    cli-ext-profile-resolution-ok
