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

*** Variables ***
${path}           /api/ability

*** Test Cases ***
正例-保存能力
    [Tags]    F
    ${random_string}    Generate Random String    12    [LOWER]
    log    ${random_string}
    create session    URI    ${URL}
    ${content}    POST请求结果    ${path}    {"exploreSessionId":"${EXPsessionId}","filteredStepIndices":[0],"draft":{"name":"${random_string}","description":"自动化测试","parameters":[],"outputs":[],"extensions":{"skipError":false,"useIncognito":false,"closePage":false,"stepInterval":1000,"autoFocus":false},"startPageUrl":"https://www.baidu.com/","stepIndices":[0]}}    200    ${token}
    log    ${content}
    Set Global Variable    ${ability_name}    ${random_string}
    Should Be Equal As Strings    ${content["code"]}    200
    Set Global Variable    ${bid}    ${content["data"]}

反例-不传入token
    [Tags]    E
    create session    URI    ${URL}
    ${content}    POST请求结果    ${path}    {"exploreSessionId":"${EXPsessionId}","filteredStepIndices":[0],"draft":{"name":"test666","description":"自动化测试","parameters":[],"outputs":[],"extensions":{"skipError":false,"useIncognito":false,"closePage":false,"stepInterval":1000,"autoFocus":false},"startPageUrl":"https://www.baidu.com/","stepIndices":[0]}}    401    {}
    log    ${content}
    Should Be Equal As Strings    ${content["code"]}    401

反例-传入错误参数
    [Tags]    E
    create session    URI    ${URL}
    ${content}    POST请求结果    ${path}    {"workerId":"a68ad587830d41aebf418a919006353e"}    422    ${token}
    log    ${content}
    Should Be Equal As Strings    ${content["detail"][0]["msg"]}    Field required

反例-传入空参数
    [Tags]    E
    create session    URI    ${URL}
    ${content}    POST请求结果    ${path}    {}    422    ${token}
    log    ${content}
    Should Be Equal As Strings    ${content["detail"][0]["msg"]}    Field required

反例-能力名已存在
    [Tags]    F
    create session    URI    ${URL}
    ${content}    POST请求结果    ${path}    {"exploreSessionId":"${EXPsessionId}","filteredStepIndices":[0],"draft":{"name":"${ability_name}","description":"自动化测试","parameters":[],"outputs":[],"extensions":{"skipError":false,"useIncognito":false,"closePage":false,"stepInterval":1000,"autoFocus":false},"startPageUrl":"https://www.baidu.com/","stepIndices":[0]}}    200    ${token}
    log    ${content}
    Should Be Equal As Strings    ${content["code"]}    BAE0008
    Should Be Equal As Strings    ${content["message"]}    此能力名已存在
