*** Settings ***
Documentation    E2E workflow tests for A2A local facade session and plan lifecycle
...
...    Tests the A2A local facade operations including:
...    - Session initialization and lifecycle
...    - Plan listing and status
...    - Output format validation against specification
...
...    These tests run against the real CLI without mocking.
Resource         common_e2e.resource
Suite Setup      E2E Suite Setup
Suite Teardown   E2E Suite Teardown

*** Test Cases ***
A2A Local Facade Session Initialization
    [Documentation]    Verify A2A local facade can initialize a session
    ...
    ...    This test validates that:
    ...    - Session creation succeeds
    ...    - Session ID is returned in expected format
    ...    - Session state is properly initialized
    [Tags]    E2E    A2A    Session
    ${result}=    Run CleverAgents Command    session    create    --format    json
    Should Be Equal As Integers    ${result.rc}    0
    Should Not Be Empty    ${result.stdout}
    Output Should Contain    ${result}    session_id

A2A Local Facade Session Listing
    [Documentation]    Verify A2A local facade can list sessions
    ...
    ...    This test validates that:
    ...    - Session listing succeeds
    ...    - Output format matches specification
    ...    - Sessions are properly enumerated
    [Tags]    E2E    A2A    Session
    ${result}=    Run CleverAgents Command    session    list    --format    json
    Should Be Equal As Integers    ${result.rc}    0
    Should Not Be Empty    ${result.stdout}
    Output Should Contain    ${result}    total

A2A Local Facade Plan Listing
    [Documentation]    Verify A2A local facade can list plans
    ...
    ...    This test validates that:
    ...    - Plan listing succeeds
    ...    - Output format matches specification
    ...    - Plans are properly enumerated
    [Tags]    E2E    A2A    Plan
    ${result}=    Run CleverAgents Command    plan    list    --format    json
    Should Be Equal As Integers    ${result.rc}    0
    Should Not Be Empty    ${result.stdout}

A2A Local Facade Session Deletion
    [Documentation]    Verify A2A local facade can delete a session
    ...
    ...    This test validates that:
    ...    - Session creation succeeds
    ...    - Session deletion succeeds
    ...    - Session is no longer listed after deletion
    [Tags]    E2E    A2A    Session
    ${create_result}=    Run CleverAgents Command    session    create    --format    json
    Should Be Equal As Integers    ${create_result.rc}    0
    ${session_id}=    Safe Parse Json Field    ${create_result.stdout}    session_id
    Should Not Be Empty    ${session_id}
    ${delete_result}=    Run CleverAgents Command    session    delete    ${session_id}    --yes
    Should Be Equal As Integers    ${delete_result.rc}    0

A2A Local Facade Session Create And List Workflow
    [Documentation]    Verify A2A local facade supports complete session workflow
    ...
    ...    This test validates that:
    ...    - Session can be created
    ...    - Session appears in list after creation
    ...    - Session count increases after creation
    [Tags]    E2E    A2A    Workflow
    ${list_before}=    Run CleverAgents Command    session    list    --format    json
    Should Be Equal As Integers    ${list_before.rc}    0
    ${count_before}=    Safe Parse Json Field    ${list_before.stdout}    total
    Run CleverAgents Command    session    create    --format    plain
    ${list_after}=    Run CleverAgents Command    session    list    --format    json
    Should Be Equal As Integers    ${list_after.rc}    0
    ${count_after}=    Safe Parse Json Field    ${list_after.stdout}    total
    Should Be True    ${count_after} > ${count_before}

A2A Local Facade Plan List Output Format
    [Documentation]    Verify A2A local facade plan list output format
    ...
    ...    This test validates that:
    ...    - Plan list output is valid JSON
    ...    - Output contains expected fields
    [Tags]    E2E    A2A    Plan
    ${result}=    Run CleverAgents Command    plan    list    --format    json
    Should Be Equal As Integers    ${result.rc}    0
    Should Not Be Empty    ${result.stdout}

*** Keywords ***
Output Should Contain
    [Documentation]    Verify output contains expected text
    [Arguments]    ${result}    ${expected_text}
    Should Contain    ${result.stdout}    ${expected_text}
