*** Settings ***
Documentation    Smoke tests for the validation pipeline service
Library          Process
Library          OperatingSystem
Resource         ${CURDIR}/common.resource
Suite Setup      Setup Test Environment
Suite Teardown   Cleanup Test Environment

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

*** Test Cases ***
Validation Pipeline Models Are Valid
    [Documentation]    Verify ValidationCommand, ValidationResult, ValidationSummary Pydantic models
    ${result}=    Run Process    ${PYTHON}    ${HELPER_SCRIPT}    models    cwd=${WORKSPACE}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    models-ok

Validation Pipeline Empty Pipeline Returns Passing Summary
    [Documentation]    Empty command list produces a zero-total passing summary
    ${result}=    Run Process    ${PYTHON}    ${HELPER_SCRIPT}    empty_pipeline    cwd=${WORKSPACE}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    empty-pipeline-ok

Validation Pipeline Passing Validations
    [Documentation]    Pipeline with passing required and informational validations
    ${result}=    Run Process    ${PYTHON}    ${HELPER_SCRIPT}    passing_pipeline    cwd=${WORKSPACE}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    passing-pipeline-ok

Validation Pipeline Failing Required Blocks
    [Documentation]    A failing required validation sets all_required_passed to False
    ${result}=    Run Process    ${PYTHON}    ${HELPER_SCRIPT}    failing_required    cwd=${WORKSPACE}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    failing-required-ok

Validation Pipeline Run For Plan Integration
    [Documentation]    run_for_plan stores validation_summary in plan metadata dict
    ${result}=    Run Process    ${PYTHON}    ${HELPER_SCRIPT}    run_for_plan    cwd=${WORKSPACE}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    run-for-plan-ok

Validation Pipeline Unknown Command Returns Error
    [Documentation]    Running with unknown command exits with code 1
    ${result}=    Run Process    ${PYTHON}    ${HELPER_SCRIPT}    nonexistent_cmd    cwd=${WORKSPACE}
    Should Be Equal As Integers    ${result.rc}    1
    Should Contain    ${result.stderr}    Unknown command
