*** Settings ***
Documentation     Integration smoke test for agents init --yes (bug #522).
...               These tests are TDD-style and expected to FAIL until the
...               bug fix is applied.
Resource          ${CURDIR}/common.resource
Library           Process
Library           OperatingSystem
Library           String
Suite Setup       Setup Test Environment
Suite Teardown    Cleanup Test Environment

*** Test Cases ***
Init Yes Flag Exits Without Error
    [Documentation]    agents init --yes should complete with exit code 0
    [Tags]    wip
    ${tmpdir}=    Evaluate    __import__('tempfile').mkdtemp(prefix='init_yes_')
    ${result}=    Run Process    ${PYTHON}    -m    cleveragents    init    --yes
    ...    timeout=120s    on_timeout=kill    cwd=${tmpdir}
    Should Be Equal As Integers    ${result.rc}    0
    ...    msg=Expected exit code 0 but got ${result.rc}. stderr: ${result.stderr}
    [Teardown]    Remove Directory    ${tmpdir}    recursive=True

Init Yes Flag Produces Summary Output
    [Documentation]    agents init --yes should produce the initialization summary
    ...                with all spec-required output fields.
    [Tags]    wip
    ${tmpdir}=    Evaluate    __import__('tempfile').mkdtemp(prefix='init_yes_out_')
    ${result}=    Run Process    ${PYTHON}    -m    cleveragents    init    --yes
    ...    timeout=120s    on_timeout=kill    cwd=${tmpdir}
    Should Be Equal As Integers    ${result.rc}    0
    ...    msg=Expected exit code 0 but got ${result.rc}. stderr: ${result.stderr}
    Should Contain    ${result.stdout}    Initialized (non-interactive)
    ...    msg=Output should contain non-interactive initialization message per spec
    Should Contain    ${result.stdout}    Data Dir:
    ...    msg=Output should contain Data Dir field per spec
    Should Contain    ${result.stdout}    Config:
    ...    msg=Output should contain Config field per spec
    Should Contain    ${result.stdout}    Database:
    ...    msg=Output should contain Database field per spec
    Should Contain    ${result.stdout}    Directories:
    ...    msg=Output should contain Directories field per spec
    [Teardown]    Remove Directory    ${tmpdir}    recursive=True

Init Short Y Flag Exits Without Error
    [Documentation]    agents init -y should complete with exit code 0 (short-form alias)
    [Tags]    wip
    ${tmpdir}=    Evaluate    __import__('tempfile').mkdtemp(prefix='init_y_')
    ${result}=    Run Process    ${PYTHON}    -m    cleveragents    init    -y
    ...    timeout=120s    on_timeout=kill    cwd=${tmpdir}
    Should Be Equal As Integers    ${result.rc}    0
    ...    msg=Expected exit code 0 but got ${result.rc}. stderr: ${result.stderr}
    [Teardown]    Remove Directory    ${tmpdir}    recursive=True
