*** Settings ***
Documentation    Smoke tests for the validation-gated apply pipeline,
...              including pass/fail gating, idempotent re-apply, and
...              empty changeset guard.
Resource         ${CURDIR}/common.resource
Suite Setup      Setup Test Environment
Suite Teardown   Cleanup Test Environment

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

*** Test Cases ***
Apply Passes When All Validations Pass
    [Documentation]    Verify apply succeeds when required validations all pass
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    apply-passes    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    apply-passes-ok

Apply Blocked When Required Validations Fail
    [Documentation]    Verify apply is blocked with constrained outcome on validation failure
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    apply-blocked    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    apply-blocked-ok

Re-Apply On Already Applied Plan Returns Already Applied
    [Documentation]    Verify idempotent re-apply blocking on terminal applied state
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    already-applied    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    already-applied-ok

Apply Blocked On Empty Changeset
    [Documentation]    Verify apply is blocked when changeset has no entries
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    empty-changeset    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    empty-changeset-ok

Apply Pipeline Model Checks
    [Documentation]    Verify ApplyOutcome enum and ApplyResult model construction
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    model-checks    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    model-checks-ok
