*** Settings ***
Documentation    Smoke tests for Plan CLI spec alignment (use/list/status flags)
Resource         ${CURDIR}/common.resource
Suite Setup      Setup Test Environment
Suite Teardown   Cleanup Test Environment

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

*** Test Cases ***
Plan Use Accepts Positional Projects
    [Documentation]    Verify that ``plan use`` accepts multiple positional projects
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    use-positional-projects    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    plan-cli-use-positional-ok

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

Plan Use Accepts Invariant Flag
    [Documentation]    Verify that ``plan use --invariant`` is accepted (repeatable)
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    use-invariant    cwd=${WORKSPACE}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    plan-cli-use-invariant-ok

Plan Use Accepts Actor Override Flags
    [Documentation]    Verify that plan use accepts actor override flags
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    use-actor-overrides    cwd=${WORKSPACE}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    plan-cli-use-actors-ok

Plan Lifecycle List Accepts Filter Flags
    [Documentation]    Verify that ``plan list`` accepts --phase, --state, --project, --action
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    list-filters    cwd=${WORKSPACE}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    plan-cli-list-filters-ok

Plan Lifecycle List Accepts Regex Positional Argument
    [Documentation]    Verify that ``plan list <REGEX>`` filters plans by name regex
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    list-regex    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    plan-cli-list-regex-ok

Plan Status Renders Required Fields
    [Documentation]    Verify that ``plan status`` renders action_name, phase, state, projects, args, timestamps
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    status-fields    cwd=${WORKSPACE}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    plan-cli-status-fields-ok

Plan Cancel Accepts Reason Flag
    [Documentation]    Verify that ``plan cancel --reason`` is accepted
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    cancel-reason    cwd=${WORKSPACE}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    plan-cli-cancel-reason-ok

Plan List Rich Output Includes Required Columns
    [Documentation]    Verify that ``plan list`` rich output includes Name, Updated, and Invariants columns
    [Tags]    tdd_issue    tdd_issue_4311    tdd_expected_fail

    ${result}=    Run Process    ${PYTHON}    ${HELPER}    list-columns    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    plan-cli-list-columns-ok
