Commit 999ac4c9 authored by zhanhuasheng's avatar zhanhuasheng

新增livechat测试用例

parent 3ff7481c
import pytest
from Utils import yaml_handler
from Utils import req_handler
from TestData.inbox.livechat_test_data import livechatData
class TestLivechat:
yaml_path = r'inbox\livechat.yaml'
yaml_data = yaml_handler.yaml_handler.get_case(yaml_path)
@pytest.mark.parametrize('case',yaml_data)
def test_livechat(self,case):
req_handler.ReqHandler.send_requests(case=case,var_class=livechatData)
print(case)
\ No newline at end of file
from Utils.global_variate import Global
class livechatData(Global):
text = "{\"contentList\":\"this is a test message<br>\",\"attachmentList\":[]}" #测试文本
emoji = "{\"contentList\":\"<b contenteditable=\\\"false\\\" style=\\\"font-family: &quot;Segoe UI Emoji&quot;; font-style: normal; font-size: 20px;\\\">😀</b>\",\"attachmentList\":[]}" #emoji表情
img = "{\"contentList\":\"<div data-type=\\\"willdesk-image\\\" class=\\\"willdesk-chat-image\\\" contenteditable=\\\"false\\\"><img src=\\\"https://img.willdesk.com/test/chat/6052/2024/03/08/b48ed17d47f87145d397409a32fa8213/png图片_1024×1024.png\\\" data-width=\\\"1024\\\" data-height=\\\"1024\\\" data-size=\\\"219148\\\" data-chattagtype=\\\"wd-img\\\" style=\\\"max-height: 200px; max-width: 200px; vertical-align: bottom; margin: 2px 0px; border-radius: 4px; width: 200px; height: 200px;\\\"></div> <br>\",\"attachmentList\":[]}" #图片
file = "{\"contentList\":\"\",\"attachmentList\":[{\"src\":\"https://img.willdesk.com/test/chat/6052/2024/03/08/6708797241bf6d9e1e83f0cad4d5becf/新建_文本文档.txt\",\"blobSrc\":\"https://img.willdesk.com/test/chat/6052/2024/03/08/6708797241bf6d9e1e83f0cad4d5becf/新建_文本文档.txt\",\"name\":\"新建 文本文档.txt\",\"size\":0,\"type\":\"text/plain\"}]}" #文件
link = "{\"contentList\":\"<a class=\\\"wd-chat-link\\\" data-type=\\\"willdesk-link\\\" href=\\\"https://www.baidu.com\\\" contenteditable=\\\"false\\\" target=\\\"_blank\\\">测试链接文本</a>\",\"attachmentList\":[]}"
faq = "{\"contentList\":\"<div data-type=\\\"willdesk-faq\\\" style=\\\"background: rgb(255, 255, 255); border-radius: 8px; min-width: 230px; max-width: 100%; width: 300px; box-sizing: border-box; position: relative; border: 0.5px solid rgb(229, 229, 235);\\\"><div style=\\\"padding: 12px 16px 0px; color: rgb(18, 17, 39); font-size: 16px; font-weight: 600; line-height: 24px; overflow: hidden; display: -webkit-box; text-overflow: ellipsis; -webkit-box-orient: vertical; -webkit-line-clamp: 2;\\\">The product I want is out-of-stock, when will it be available?</div><div style=\\\"padding: 4px 16px 12px; color: rgb(108, 107, 128); font-size: 14px; max-height: 48px; font-weight: 400; line-height: 24px; overflow: hidden; display: -webkit-box; text-overflow: ellipsis; -webkit-box-orient: vertical; -webkit-line-clamp: 2;\\\"><p>We strive to maintain our stock levels in line with demand. However, from time to time we may become out of stock of a certain product. If one of our products is out of stock, please feel free to send us a message and well make sure to let you know when you will be able to order it again.&nbsp;</p></div><a href=\\\"https://zhs-test.myshopify.com/a/self-faq?helpPath=/&amp;cat_id=24862&amp;article_id=63090\\\" title=\\\"https://zhs-test.myshopify.com/a/self-faq?helpPath=/&amp;cat_id=24862&amp;article_id=63090\\\" target=\\\"_blank\\\" style=\\\"box-sizing: border-box; margin-top: 8px; text-decoration: none; padding: 8px 16px; background: rgb(243, 243, 246); color: rgb(44, 35, 229); font-size: 14px; font-family: Inter; line-height: 22px; width: 100%; border-radius: 0px 0px 8px 8px; display: inline-block;\\\">View all →</a></div>\",\"attachmentList\":[]}"
rate = "[&*{\"reviewContent\":\"<p>Would you mind sharing your feedback on your experience so fa222r?</p>\",\"thumbsReviews\":{\"good\":\"\",\"bad\":\"FeedbackURL\"},\"startReviews\":{\"one_start\":\"FeedbackURL\",\"two_start\":\"FeedbackURL\",\"three_start\":\"FeedbackURL\",\"four_start\":\"\",\"five_start\":\"www.baidu.com\"},\"reviewTitle\":\"How was your chat with {AgentName}222?\",\"reviewChoose\":\"thumbs\",\"askSendReview\":\"true\",\"autoSendReview\":\"false\",\"primaryColor\":\"#2C23E5\"}]"
product = "{\"contentList\":\"<a href=\\\"https://zhs-test.myshopify.com/products/selling-plans-ski-wax\\\" title=\\\"https://zhs-test.myshopify.com/products/selling-plans-ski-wax\\\" data-type=\\\"willdesk-product\\\" target=\\\"_blank\\\" style=\\\"display: flex; background: rgb(255, 255, 255); border-radius: 8px; min-height: 80px; max-height: 150px; min-width: 100px; max-width: 100%; width: 300px; box-sizing: border-box; position: relative; text-decoration: none; padding: 12px 16px; border: 1px solid rgb(231, 233, 236);\\\"><img src=\\\"https://cdn.shopify.com/s/files/1/0690/4551/8586/products/snowboard_wax.png?v=1708331992\\\" style=\\\"width: 110px; height: 110px; max-height: 150px; object-fit: cover; border-radius: 8px; margin-right: 4%; flex-shrink: 0; border: 0.5px solid rgb(231, 233, 236);\\\"><div style=\\\"width: calc(100% - 118px); display: flex; flex-direction: column; position: relative; justify-content: center;\\\"><div style=\\\"width: 100%; max-height: 48px; line-height: 24px; color: rgb(18, 17, 39); font-size: 14px; font-weight: bold; overflow: hidden; display: -webkit-box; text-overflow: ellipsis; -webkit-box-orient: vertical; -webkit-line-clamp: 2;\\\">Selling Plans Ski Wax</div></div></a>\",\"attachmentList\":[]}"
coupon = "{\"contentList\":\"<a class=\\\"wd-chat-link\\\" data-type=\\\"willdesk-link\\\" href=\\\"https://zhs-test.myshopify.com/discount/KP7ZYSNMS9ES\\\" contenteditable=\\\"false\\\" style=\\\"margin-right: 8px\\\" target=\\\"_blank\\\">KP7ZYSNMS9ES</a>\",\"attachmentList\":[]}"
api1:
title: c端主动发起会话 - text
ws: customer
action: sendmsg
data:
type: text
api2:
title: b端获取房间号
url: /api/v1/chat/local/roomList
method: post
data: {"uid":"${userId}","uType":2,"platform":1,"siteIds":["${shopId}"],"status":1,"page":1,"pageSize":20,"sortName":"all","keyword":"","v":"${v}"}
set_value: {"roomId": "$.data.list[?(@.fromID == '${customerId}')].roomId"}
expected:
- eq: {"$.code" : 0}
- like: {"$.data.list[?(@.fromID == '${customerId}')].firstSendUid" : "${customerId}"}
api3:
title: c端主动发起会话 - emoji
ws: customer
action: sendmsg
data:
type: emoji
api4:
title: c端主动发起会话 - img
ws: customer
action: sendmsg
data:
type: img
api5:
title: c端主动发起会话 - file
ws: customer
action: sendmsg
data:
type: file
api6:
title: b端接收会话信息 - 检查
url: /api/v1/chatRecord/list
method: post
data: {"uid":"${userId}","uType":2,"platform":1,"roomId":"${roomId}","roomType":1,"firstSendUid":"${customerId}","firstSendUuidType":1,"brandId":"${brandId}","sendTime":0,"page":1,"pageSize":20,"v":"${v}"}
expected:
- eq: {"$.code": 0}
- eq: {"$.data.list[0].content": "${file}"}
- like: {"$.data.list[0].senderUid": "${customerId}"}
- eq: { "$.data.list[1].content": "${img}" }
- like: { "$.data.list[1].senderUid": "${customerId}" }
- eq: { "$.data.list[2].content": "${emoji}" }
- like: { "$.data.list[2].senderUid": "${customerId}" }
- eq: { "$.data.list[3].content": "${text}" }
- like: { "$.data.list[3].senderUid": "${customerId}" }
api7:
title: b端主动发起会话 - img
ws: willdesk
action: sendmsg
data:
type: img
roomId: "${roomId}"
api8:
title: b端主动发起会话 - file
ws: willdesk
action: sendmsg
data:
type: file
roomId: "${roomId}"
api9:
title: b端主动发起会话 - link
ws: willdesk
action: sendmsg
data:
type: link
roomId: "${roomId}"
api10:
title: b端主动发起会话 - faq
ws: willdesk
action: sendmsg
data:
type: faq
roomId: "${roomId}"
api11:
title: b端主动发起会话 - rate
ws: willdesk
action: sendmsg
data:
type: rate
roomId: "${roomId}"
api12:
title: b端主动发起会话 - product
ws: willdesk
action: sendmsg
data:
type: product
roomId: "${roomId}"
api13:
title: b端主动发起会话 - coupon
ws: willdesk
action: sendmsg
data:
type: coupon
roomId: "${roomId}"
api14:
title: b端主动发起会话 - text
ws: willdesk
action: sendmsg
data:
type: text
roomId: "${roomId}"
api15:
title: b端主动发起会话 - emoji
ws: willdesk
action: sendmsg
data:
type: emoji
roomId: "${roomId}"
api16:
title: c端接收会话消息 - 检查
url: /api/v1/chatRecord/customerList
method: post
data: {"uid":"${customerId}","uType":1,"platform":1,"siteId":"${shopId}","sendTime":0,"pageSize":20,"v":"${customer_v}"}
expected:
- eq: { "$.code": 0 }
- eq: { "$.data.list[0].content": "${emoji}" }
- like: { "$.data.list[0].senderUid": "${userId}" }
- eq: { "$.data.list[1].content": "${text}" }
- like: { "$.data.list[1].senderUid": "${userId}" }
- eq: { "$.data.list[2].content": "${coupon}" }
- like: { "$.data.list[2].senderUid": "${userId}" }
- eq: { "$.data.list[3].content": "${product}" }
- like: { "$.data.list[3].senderUid": "${userId}" }
- eq: { "$.data.list[4].content": "${rate}" }
- like: { "$.data.list[4].senderUid": "${userId}" }
- eq: { "$.data.list[5].content": "${faq}" }
- like: { "$.data.list[5].senderUid": "${userId}" }
- eq: { "$.data.list[6].content": "${link}" }
- like: { "$.data.list[6].senderUid": "${userId}" }
- eq: { "$.data.list[7].content": "${file}" }
- like: { "$.data.list[7].senderUid": "${userId}" }
- eq: { "$.data.list[8].content": "${img}" }
- like: { "$.data.list[8].senderUid": "${userId}" }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment