*** Settings ***
Documentation    Smoke tests for built-in file tools
Resource         ${CURDIR}/common.resource
Suite Setup      Setup Test Environment
Suite Teardown   Cleanup Test Environment

*** Variables ***
${HELPER_SCRIPT}    robot/helper_tool_builtins.py

*** Test Cases ***
File Read Tool
    [Documentation]    Read a file using builtin/file-read
    ${result}=    Run Process    ${PYTHON}    ${HELPER_SCRIPT}    read    cwd=${WORKSPACE}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    file-read-ok

File Write Tool
    [Documentation]    Write a file using builtin/file-write
    ${result}=    Run Process    ${PYTHON}    ${HELPER_SCRIPT}    write    cwd=${WORKSPACE}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    file-write-ok

File Edit Tool
    [Documentation]    Edit a file using builtin/file-edit
    ${result}=    Run Process    ${PYTHON}    ${HELPER_SCRIPT}    edit    cwd=${WORKSPACE}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    file-edit-ok

File Delete Tool
    [Documentation]    Delete a file using builtin/file-delete
    ${result}=    Run Process    ${PYTHON}    ${HELPER_SCRIPT}    delete    cwd=${WORKSPACE}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    file-delete-ok

File List Tool
    [Documentation]    List directory using builtin/file-list
    ${result}=    Run Process    ${PYTHON}    ${HELPER_SCRIPT}    list    cwd=${WORKSPACE}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    file-list-ok

File Search Tool
    [Documentation]    Search files using builtin/file-search
    ${result}=    Run Process    ${PYTHON}    ${HELPER_SCRIPT}    search    cwd=${WORKSPACE}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    file-search-ok

Path Traversal Prevention
    [Documentation]    Path traversal should be blocked
    ${result}=    Run Process    ${PYTHON}    ${HELPER_SCRIPT}    traversal    cwd=${WORKSPACE}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    traversal-ok
