*** Settings ***
Documentation    End-to-end smoke tests for Session CLI commands
Resource         ${CURDIR}/common.resource
Suite Setup      Setup Test Environment
Suite Teardown   Cleanup Test Environment

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

*** Test Cases ***
Session Create Default
    [Documentation]    Verify that ``session create`` succeeds with defaults
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    create-default    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    session-cli-create-default-ok

Session Create With Actor
    [Documentation]    Verify that ``session create --actor`` binds an actor
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    create-actor    cwd=${WORKSPACE}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    session-cli-create-actor-ok

Session List Empty
    [Documentation]    Verify that ``session list`` handles empty state
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    list-empty    cwd=${WORKSPACE}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    session-cli-list-empty-ok

Session List Populated
    [Documentation]    Verify that ``session list`` shows sessions
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    list-populated    cwd=${WORKSPACE}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    session-cli-list-populated-ok

Session Show Valid
    [Documentation]    Verify that ``session show`` displays details
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    show-valid    cwd=${WORKSPACE}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    session-cli-show-valid-ok

Session Show Not Found
    [Documentation]    Verify that ``session show`` reports missing session
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    show-not-found    cwd=${WORKSPACE}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    session-cli-show-not-found-ok

Session Delete With Yes
    [Documentation]    Verify that ``session delete --yes`` works
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    delete-yes    cwd=${WORKSPACE}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    session-cli-delete-yes-ok

Session Export Import Roundtrip
    [Documentation]    Verify export/import round-trip
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    export-import-roundtrip    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    session-cli-export-import-roundtrip-ok

Session Import Rich Output Panels
    [Documentation]    Verify that ``session import`` renders Session Import, Validation, and Merge panels
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    import-rich-panels    cwd=${WORKSPACE}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    session-cli-import-rich-panels-ok

Session Export Rich Panels
    [Documentation]    Verify that ``session export`` renders Session Export, Contents, and Integrity panels
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    export-rich-panels    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    session-cli-export-rich-panels-ok

Session Export Stdout Rich Panels
    [Documentation]    Verify that ``session export`` to stdout also renders Rich panels
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    export-stdout-rich-panels    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    session-cli-export-stdout-rich-panels-ok

Session Tell Appends Message
    [Documentation]    Verify that ``session tell`` appends a message
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    tell-message    cwd=${WORKSPACE}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    session-cli-tell-message-ok
