*** Settings ***
Documentation    Smoke tests for LSP Registry and Runtime stubs
Resource         ${CURDIR}/common.resource
Suite Setup      Setup Test Environment
Suite Teardown   Cleanup Test Environment

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

*** Test Cases ***
Register And Retrieve An LSP Server
    [Documentation]    Register an LSP server and retrieve it by name
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    register-and-get    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    lsp-registry-ok

List LSP Servers With Namespace Filter
    [Documentation]    Register servers and list with namespace filter
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    list-filter    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    lsp-list-ok

Remove An LSP Server
    [Documentation]    Register and remove an LSP server
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    remove-server    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    lsp-remove-ok

Runtime Stub Raises In Local Mode
    [Documentation]    Verify runtime operations raise LspNotAvailableError
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    runtime-stub    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    lsp-runtime-stub-ok

Tool Adapter Generates Specs
    [Documentation]    Verify tool adapter generates tool specs from capabilities
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    tool-adapter    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    lsp-tool-adapter-ok
