From 3751379f1e9a4c215fb6eb898b4ccc67659b9ace Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Tue, 10 May 2022 21:51:50 +0700 Subject: initial commit 2 --- .../tests/test_livechat_request.py | 79 ++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 addons/website_livechat/tests/test_livechat_request.py (limited to 'addons/website_livechat/tests/test_livechat_request.py') diff --git a/addons/website_livechat/tests/test_livechat_request.py b/addons/website_livechat/tests/test_livechat_request.py new file mode 100644 index 00000000..f50780da --- /dev/null +++ b/addons/website_livechat/tests/test_livechat_request.py @@ -0,0 +1,79 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from odoo import tests +from odoo.addons.website_livechat.tests.common import TestLivechatCommon + + +@tests.tagged('post_install', '-at_install') +class TestLivechatRequestHttpCase(tests.HttpCase, TestLivechatCommon): + def test_livechat_request_complete_flow(self): + self._clean_livechat_sessions() + + # Send first chat request - Open chat from operator side + channel_1 = self._common_chat_request_flow() + # Visitor Rates the conversation (Good) + self._send_rating(channel_1, self.visitor, 5) + + # Operator Re-Send a chat request + channel_2 = self._common_chat_request_flow() + # Visitor Rates the conversation (Bad) + self._send_rating(channel_2, self.visitor, 1, "Stop bothering me! I hate you %s has left the conversation.

" % self.visitor.display_name) + self.assertEqual(channel.livechat_active, False, "The livechat session must be inactive as the visitor sent his feedback.") + + return channel + + def _clean_livechat_sessions(self): + # clean every possible mail channel linked to the visitor + active_channels = self.env['mail.channel'].search([('livechat_visitor_id', '=', self.visitor.id), ('livechat_active', '=', True)]) + for active_channel in active_channels: + active_channel._close_livechat_session() -- cgit v1.2.3