*** Settings ***
Resource          flow_zmx.resource
Resource          res_zmx.resource
Library           DateTime

*** Variables ***
${path}           /api/v1/plan/add_trigger

*** Test Cases ***
正例-正常添加计划触发器
    [Tags]    F
    create session    URI    ${URL}
    ${current_time}    Get Current Date
    ${future_time}    Add Time To Date    ${current_time}    30 seconds
    ${formatted_time}    Convert Date    ${future_time}    result_format=%Y-%m-%dT%H:%M:%S
    ${content}    POST请求结果    ${path}    {"plan_id":"${plan_id}","trigger":{"type":"定时触发器","trigger_type":"date","expression":"${formatted_time}","is_active":true}}    200    ${token}
    log    ${content}
    Should Be Equal As Strings    ${content["code"]}    200
    Set Global Variable    ${trigger_id}    ${content["data"]}

反例-不传入token
    [Tags]    E
    create session    URI    ${URL}
    ${content}    POST请求结果    ${path}    {"plan_id":"${plan_id}","trigger":{"type":"定时触发器","trigger_type":"date","expression":"2025-09-05T16:23:45","is_active":true}}    401    ${EMPTY}
    log    ${content}
    Should Be Equal As Strings    ${content["code"]}    401

反例-传入空白token
    [Tags]    E
    create session    URI    ${URL}
    ${content}    POST请求结果    ${path}    {"plan_id":"${plan_id}","trigger":{"type":"定时触发器","trigger_type":"date","expression":"2025-09-05T16:23:45","is_active":true}}    401    {}
    log    ${content}
    Should Be Equal As Strings    ${content["code"]}    401

反例-不传入plan_id参数
    [Tags]    E
    create session    URI    ${URL}
    ${content}    POST请求结果    ${path}    {"trigger":{"type":"定时触发器","trigger_type":"date","expression":"2025-09-05T16:23:45","is_active":true}}    422    ${token}
    log    ${content}
    Should Be Equal As Strings    ${content["detail"][0]["type"]}    missing

反例-不传入trigger参数
    [Tags]    E
    create session    URI    ${URL}
    ${content}    POST请求结果    ${path}    {"plan_id":"${plan_id}"}    422    ${token}
    log    ${content}
    Should Be Equal As Strings    ${content["detail"][0]["type"]}    missing
