*** Settings ***
Resource          flow_zmx.resource
Resource          res_zmx.resource

*** Variables ***
${path}           /api/chat/history/save

*** Test Cases ***
正例-正常新增历史记录
    [Tags]    F
    ${secs1}    Get Time    epoch
    create session    URI    ${URL}
    ${content}    POST请求结果    ${path}    {"sessionId":"${sessionId}","content":"[{\\"id\\":\\"testhistory\\",\\"role\\":\\"user\\",\\"content\\":\\"你好\\",\\"contentType\\":\\"text\\",\\"timestamp\\":${secs1},\\"status\\":\\"ok\\",\\"messageSegmentIndex\\":0,\\"visible\\":true,\\"attachments\\":[]}]","title":"简洁问候语","type":"normal"}    200    ${token}
    log    ${content}
    Should Be Equal As Strings    ${content["code"]}    200
    Set Global Variable    ${secs}    ${secs1}

正例-正常更新历史记录
    [Tags]    F
    ${secs1}    Get Time    epoch
    create session    URI    ${URL}
    ${content}    POST请求结果    ${path}    {"sessionId":"${sessionId}","content":"[{\\"id\\":\\"testhistory\\",\\"role\\":\\"user\\",\\"content\\":\\"你好\\",\\"contentType\\":\\"text\\",\\"timestamp\\":${secs},\\"status\\":\\"ok\\",\\"messageSegmentIndex\\":0,\\"visible\\":true,\\"attachments\\":[]},{\\"id\\":\\"testhistoryres\\",\\"role\\":\\"robot\\",\\"content\\":\\"你好！今天有什么我可以帮助你的吗？\\",\\"contentType\\":\\"text\\",\\"timestamp\\":${secs1},\\"status\\":\\"ok\\",\\"messageSegmentIndex\\":0,\\"visible\\":true,\\"sessionId\\":\\"${sessionId}\\",\\"loading\\":false,\\"showImmediately\\":false,\\"references\\":[],\\"tip\\":\\"\\",\\"streamId\\":\\"${text_streamId}\\"}]","title":"简洁问候语","type":"normal"}    200    ${token}
    log    ${content}
    Should Be Equal As Strings    ${content["code"]}    200

反例-传入错误token
    [Tags]    E
    ${secs1}    Get Time    epoch
    create session    URI    ${URL}
    ${content}    POST请求结果    ${path}    {"sessionId":"${sessionId}","content":"[{\\"id\\":\\"testhistory\\",\\"role\\":\\"user\\",\\"content\\":\\"你好\\",\\"contentType\\":\\"text\\",\\"timestamp\\":${secs},\\"status\\":\\"ok\\",\\"messageSegmentIndex\\":0,\\"visible\\":true,\\"attachments\\":[]},{\\"id\\":\\"testhistoryres\\",\\"role\\":\\"robot\\",\\"content\\":\\"你好！今天有什么我可以帮助你的吗？\\",\\"contentType\\":\\"text\\",\\"timestamp\\":${secs1},\\"status\\":\\"ok\\",\\"messageSegmentIndex\\":0,\\"visible\\":true,\\"sessionId\\":\\"${sessionId}\\",\\"loading\\":false,\\"showImmediately\\":false,\\"references\\":[],\\"tip\\":\\"\\",\\"streamId\\":\\"${text_streamId}\\"}]","title":"简洁问候语","type":"normal"}    401    {}
    log    ${content}
    Should Be Equal As Strings    ${content["code"]}    401

反例-传入空白token
    [Tags]    E
    ${secs1}    Get Time    epoch
    create session    URI    ${URL}
    ${content}    POST请求结果    ${path}    {"sessionId":"${sessionId}","content":"[{\\"id\\":\\"testhistory\\",\\"role\\":\\"user\\",\\"content\\":\\"你好\\",\\"contentType\\":\\"text\\",\\"timestamp\\":${secs},\\"status\\":\\"ok\\",\\"messageSegmentIndex\\":0,\\"visible\\":true,\\"attachments\\":[]},{\\"id\\":\\"testhistoryres\\",\\"role\\":\\"robot\\",\\"content\\":\\"你好！今天有什么我可以帮助你的吗？\\",\\"contentType\\":\\"text\\",\\"timestamp\\":${secs1},\\"status\\":\\"ok\\",\\"messageSegmentIndex\\":0,\\"visible\\":true,\\"sessionId\\":\\"${sessionId}\\",\\"loading\\":false,\\"showImmediately\\":false,\\"references\\":[],\\"tip\\":\\"\\",\\"streamId\\":\\"${text_streamId}\\"}]","title":"简洁问候语","type":"normal"}    401    ${EMPTY}
    log    ${content}
    Should Be Equal As Strings    ${content["code"]}    401
