*** Settings ***
Library    Browser
Library    RequestsLibrary
Library    Process

*** Variables ***
${FRONTEND_URL}    http://localhost:5173
${BACKEND_URL}     http://localhost:8000

*** Keywords ***
Wait For Backend Health
    [Arguments]    ${timeout}=120    ${interval}=5
    ${deadline}=    Evaluate    time.time() + ${timeout}
    WHILE    True
        ${now}=    Evaluate    time.time()
        IF    ${now} >= ${deadline}    FAIL    Backend did not become healthy within ${timeout} seconds
        ${response}=    GET    ${BACKEND_URL}/api/v1/health    expected_status=200
        IF    ${response.status} == 200    BREAK
        Sleep    ${interval}
    END
    Log    Backend is healthy.