*** Settings ***
Documentation    Smoke tests for diff review artifact building,
...              rename detection, serialization, and truncation.
Resource         ${CURDIR}/common.resource
Suite Setup      Setup Test Environment
Suite Teardown   Cleanup Test Environment

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

*** Test Cases ***
Build Empty Changeset Artifact
    [Documentation]    Build a ReviewArtifact from an empty SpecChangeSet
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    build-empty    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    build-empty-ok

Build Create Change Artifact
    [Documentation]    Build a ReviewArtifact with a single CREATE change entry
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    build-create    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    build-create-ok

Detect Rename From Delete And Create
    [Documentation]    Detect renames by matching content hashes across DELETE/CREATE pairs
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    build-rename    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    build-rename-ok

Serialize Artifact To All Formats
    [Documentation]    Serialize a ReviewArtifact to plain text, JSON, and rich format
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    serialize-all    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    serialize-all-ok

Truncate Large Diff
    [Documentation]    Verify diff truncation when content exceeds max_diff_size
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    truncation    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    truncation-ok
