From 999ac4c9134c48870aac91091a96cae0301fa4dd Mon Sep 17 00:00:00 2001 From: zhanhuasheng Date: Fri, 8 Mar 2024 16:59:08 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9Elivechat=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TestCase/inbox/test_livechat_01.py | 13 +++ TestData/inbox/livechat_test_data.py | 13 +++ YamlCase/inbox/livechat.yaml | 160 +++++++++++++++++++++++++++ 3 files changed, 186 insertions(+) create mode 100644 TestCase/inbox/test_livechat_01.py create mode 100644 TestData/inbox/livechat_test_data.py create mode 100644 YamlCase/inbox/livechat.yaml diff --git a/TestCase/inbox/test_livechat_01.py b/TestCase/inbox/test_livechat_01.py new file mode 100644 index 0000000..af16f9f --- /dev/null +++ b/TestCase/inbox/test_livechat_01.py @@ -0,0 +1,13 @@ +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 diff --git a/TestData/inbox/livechat_test_data.py b/TestData/inbox/livechat_test_data.py new file mode 100644 index 0000000..463f986 --- /dev/null +++ b/TestData/inbox/livechat_test_data.py @@ -0,0 +1,13 @@ +from Utils.global_variate import Global + +class livechatData(Global): + text = "{\"contentList\":\"this is a test message
\",\"attachmentList\":[]}" #测试文本 + emoji = "{\"contentList\":\"😀\",\"attachmentList\":[]}" #emoji表情 + img = "{\"contentList\":\"

\",\"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\":\"测试链接文本\",\"attachmentList\":[]}" + faq = "{\"contentList\":\"
The product I want is out-of-stock, when will it be available?

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. 

View all →
\",\"attachmentList\":[]}" + rate = "[&*{\"reviewContent\":\"

Would you mind sharing your feedback on your experience so fa222r?

\",\"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\":\"
Selling Plans Ski Wax
\",\"attachmentList\":[]}" + coupon = "{\"contentList\":\"KP7ZYSNMS9ES\",\"attachmentList\":[]}" + diff --git a/YamlCase/inbox/livechat.yaml b/YamlCase/inbox/livechat.yaml new file mode 100644 index 0000000..cded230 --- /dev/null +++ b/YamlCase/inbox/livechat.yaml @@ -0,0 +1,160 @@ +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}" } + -- GitLab