*** Settings ***
Documentation    TDD Issue #969 — plan correct should accept plan_id as first positional
...              argument.  Integration test verifying that ``plan correct <plan_id>``
...              resolves the plan_id to the root decision and applies the correction
...              successfully.  The underlying bug has been fixed: the command now
...              correctly resolves a plan_id to its root decision_id before applying
...              the correction.
...
...              Bug: https://git.cleverthis.com/cleveragents/cleveragents-core/issues/969
...              TDD: https://git.cleverthis.com/cleveragents/cleveragents-core/issues/979
Resource         ${CURDIR}/common.resource
Suite Setup      Setup Test Environment
Suite Teardown   Cleanup Test Environment

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

*** Test Cases ***
TDD Plan Correct Accepts Plan ID As Positional Argument Revert Mode
    [Documentation]    Verify that plan correct resolves a plan_id to the root
    ...                decision when the plan_id is passed as the first positional
    ...                argument with --mode revert.  Bug #969: the code currently
    ...                uses the plan_id as target_decision_id directly.
    [Tags]  tdd_issue    tdd_issue_969    tdd_issue_4178
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    plan-correct-with-plan-id    cwd=${WORKSPACE}    timeout=120s    on_timeout=kill
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    tdd-plan-correct-plan-id-ok

TDD Plan Correct Accepts Plan ID As Positional Argument Append Mode
    [Documentation]    Verify that plan correct resolves a plan_id to the root
    ...                decision when the plan_id is passed as the first positional
    ...                argument with --mode append.  Bug #969 affects
    ...                target_decision_id resolution before mode branching, so both
    ...                revert and append modes are affected.
    [Tags]  tdd_issue    tdd_issue_969    tdd_issue_4178
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    plan-correct-append-with-plan-id    cwd=${WORKSPACE}    timeout=120s    on_timeout=kill
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    tdd-plan-correct-plan-id-append-ok
