summaryrefslogtreecommitdiff
path: root/addons/website_livechat/static/tests
diff options
context:
space:
mode:
authorDavid Beguin <dbe@odoo.com>2019-11-06 16:27:36 +0000
committerDavid Beguin <dbe@odoo.com>2020-03-17 12:21:48 +0000
commit190dab8144b5dd46bb2492093d0d8d3abafb19b4 (patch)
tree9c1b6cbeb5d54ba170ab50042d1be967303ff3a6 /addons/website_livechat/static/tests
parent69b1e1a05228f05b4cd5f2934167260e51101dce (diff)
[IMP] website_livechat : add various tests on livechat and visitors
Adds Python tests and javascripts tours on livechat (website and visitor integration). Because breaking livechat every two days in rush periods (or even not) is getting quite annoying. Those tests are testing : - The client side flow (open livechat, send messages, send rating and close the livechat session) - The channel and message author naming, visitor page view history - Chat request flow (complete chat request flow, open empty operator's chat request and cancel due to visitor's new chat session) Task ID : 2079087 PR #40052 Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
Diffstat (limited to 'addons/website_livechat/static/tests')
-rw-r--r--addons/website_livechat/static/tests/tours/website_livechat_common.js165
-rw-r--r--addons/website_livechat/static/tests/tours/website_livechat_rating.js38
-rw-r--r--addons/website_livechat/static/tests/tours/website_livechat_request.js46
3 files changed, 249 insertions, 0 deletions
diff --git a/addons/website_livechat/static/tests/tours/website_livechat_common.js b/addons/website_livechat/static/tests/tours/website_livechat_common.js
new file mode 100644
index 00000000000..446b1fa8fc9
--- /dev/null
+++ b/addons/website_livechat/static/tests/tours/website_livechat_common.js
@@ -0,0 +1,165 @@
+odoo.define('website_livechat.tour_common', function(require) {
+'use strict';
+
+var session = require('web.session');
+var LivechatButton = require('im_livechat.im_livechat').LivechatButton;
+
+/**
+ * Alter this method for test purposes.
+ *
+ * Fake the notification after sending message
+ * As bus is not available, it's necessary to add the message in the chatter + in livechat.messages
+ *
+ * Add a class to the chatter window after sendFeedback is done
+ * to force the test to wait until feedback is really done
+ * (to check afterwards if the livechat session is set to inactive)
+ *
+ * Note : this asset is loaded for tests only (rpc call done only during tests)
+ */
+LivechatButton.include({
+ _sendMessage: function (message) {
+ var self = this;
+ return this._super.apply(this, arguments).then(function () {
+ if (message.isFeedback) {
+ $('div.o_thread_window_header').addClass('feedback_sent');
+ }
+ else {
+ session.rpc('/bus/test_mode_activated', {}).then(function (in_test_mode) {
+ if (in_test_mode) {
+ var notification = [
+ self._livechat.getUUID(),
+ {
+ 'id': -1,
+ 'author_id': [0, 'Website Visitor Test'],
+ 'email_from': 'Website Visitor Test',
+ 'body': '<p>' + message.content + '</p>',
+ 'is_discussion': true,
+ 'subtype_id': [1, "Discussions"],
+ 'date': moment().format('YYYY-MM-DD HH:mm:ss'),
+ }
+ ]
+ self._handleNotification(notification);
+ }
+ });
+ }
+ });
+ },
+});
+
+/*******************************
+* Common Steps
+*******************************/
+
+var startStep = [{
+ content: "click on livechat widget",
+ trigger: "div.o_livechat_button"
+}, {
+ content: "Say hello!",
+ trigger: "input.o_composer_text_field",
+ run: "text Hello Sir!"
+}, {
+ content: "Send the message",
+ trigger: "input.o_composer_text_field",
+ run: function() {
+ $('input.o_composer_text_field').trigger($.Event('keydown', {which: $.ui.keyCode.ENTER}));
+ }
+}, {
+ content: "Verify your message has been typed",
+ trigger: "div.o_thread_message_content>p:contains('Hello Sir!')"
+}, {
+ content: "Verify there is no duplicates",
+ trigger: "body",
+ run: function () {
+ if ($("div.o_thread_message_content p:contains('Hello Sir!')").length === 1) {
+ $('body').addClass('no_duplicated_message');
+ }
+ }
+}, {
+ content: "Is your message correctly sent ?",
+ trigger: 'body.no_duplicated_message'
+}];
+
+var endDiscussionStep = [{
+ content: "Close the chatter",
+ trigger: "a.o_thread_window_close",
+ run: function() {
+ $('a.o_thread_window_close').click();
+ }
+}];
+
+var feedbackStep = [{
+ content: "Type a feedback",
+ trigger: "div.o_livechat_rating_reason > textarea",
+ run: "text ;-) This was really helpful. Thanks ;-)!"
+}, {
+ content: "Send the feedback",
+ trigger: "input[type='button'].o_rating_submit_button",
+}, {
+ content: "Check if feedback has been sent",
+ trigger: "div.o_thread_window_header.feedback_sent",
+}, {
+ content: "Thanks for your feedback",
+ trigger: "div.o_livechat_rating_box:has(div:contains('Thank you for your feedback'))",
+}];
+
+var transcriptStep = [{
+ content: "Type your email",
+ trigger: "input[id='o_email']",
+ run: "text deboul@onner.com"
+}, {
+ content: "Send the conversation to your email address",
+ trigger: "button.o_email_chat_button",
+}, {
+ content: "Type your email",
+ trigger: "div.o_livechat_email:has(strong:contains('Conversation Sent'))",
+}];
+
+var closeStep = [{
+ content: "Close the conversation with the x button",
+ trigger: "a.o_thread_window_close",
+}, {
+ content: "Check that the chat window is closed",
+ trigger: 'body',
+ run: function () {
+ if ($('div.o_livechat_button').length === 1 && !$('div.o_livechat_button').is(':visible')) {
+ $('body').addClass('tour_success');
+ }
+ }
+}, {
+ content: "Is the Test succeded ?",
+ trigger: 'body.tour_success'
+}];
+
+var goodRatingStep = [{
+ content: "Send Good Rating",
+ trigger: "div.o_livechat_rating_choices > img[data-value=10]",
+}, {
+ content: "Check if feedback has been sent",
+ trigger: "div.o_thread_window_header.feedback_sent",
+}, {
+ content: "Thanks for your feedback",
+ trigger: "div.o_livechat_rating_box:has(div:contains('Thank you for your feedback'))"
+}];
+
+var okRatingStep = [{
+ content: "Send ok Rating",
+ trigger: "div.o_livechat_rating_choices > img[data-value=5]",
+}];
+
+var sadRatingStep = [{
+ content: "Send bad Rating",
+ trigger: "div.o_livechat_rating_choices > img[data-value=1]",
+}];
+
+return {
+ 'startStep': startStep,
+ 'endDiscussionStep': endDiscussionStep,
+ 'transcriptStep': transcriptStep,
+ 'feedbackStep': feedbackStep,
+ 'closeStep': closeStep,
+ 'goodRatingStep': goodRatingStep,
+ 'okRatingStep': okRatingStep,
+ 'sadRatingStep': sadRatingStep,
+};
+
+});
diff --git a/addons/website_livechat/static/tests/tours/website_livechat_rating.js b/addons/website_livechat/static/tests/tours/website_livechat_rating.js
new file mode 100644
index 00000000000..d3339f2b02b
--- /dev/null
+++ b/addons/website_livechat/static/tests/tours/website_livechat_rating.js
@@ -0,0 +1,38 @@
+odoo.define('website_livechat.tour', function(require) {
+'use strict';
+
+var commonSteps = require("website_livechat.tour_common");
+var tour = require("web_tour.tour");
+
+tour.register('website_livechat_complete_flow_tour', {
+ test: true,
+ url: '/',
+}, [].concat(commonSteps.startStep, commonSteps.endDiscussionStep, commonSteps.okRatingStep, commonSteps.feedbackStep, commonSteps.transcriptStep, commonSteps.closeStep));
+
+tour.register('website_livechat_happy_rating_tour', {
+ test: true,
+ url: '/',
+}, [].concat(commonSteps.startStep, commonSteps.endDiscussionStep, commonSteps.goodRatingStep));
+
+tour.register('website_livechat_ok_rating_tour', {
+ test: true,
+ url: '/',
+}, [].concat(commonSteps.startStep, commonSteps.endDiscussionStep, commonSteps.okRatingStep, commonSteps.feedbackStep));
+
+tour.register('website_livechat_sad_rating_tour', {
+ test: true,
+ url: '/',
+}, [].concat(commonSteps.startStep, commonSteps.endDiscussionStep, commonSteps.sadRatingStep, commonSteps.feedbackStep));
+
+tour.register('website_livechat_no_rating_tour', {
+ test: true,
+ url: '/',
+}, [].concat(commonSteps.startStep, commonSteps.endDiscussionStep, commonSteps.transcriptStep, commonSteps.closeStep));
+
+tour.register('website_livechat_no_rating_no_close_tour', {
+ test: true,
+ url: '/',
+}, [].concat(commonSteps.startStep));
+
+return {};
+});
diff --git a/addons/website_livechat/static/tests/tours/website_livechat_request.js b/addons/website_livechat/static/tests/tours/website_livechat_request.js
new file mode 100644
index 00000000000..8c4042e3821
--- /dev/null
+++ b/addons/website_livechat/static/tests/tours/website_livechat_request.js
@@ -0,0 +1,46 @@
+odoo.define('website_livechat.chat_request_tour', function(require) {
+'use strict';
+
+var commonSteps = require("website_livechat.tour_common");
+var tour = require("web_tour.tour");
+
+
+var stepWithChatRequestStep = [{
+ content: "Answer the chat request!",
+ trigger: "input.o_composer_text_field",
+ run: "text Hi ! What a coincidence! I need your help indeed."
+}, {
+ content: "Send the message",
+ trigger: "input.o_composer_text_field",
+ run: function() {
+ $('input.o_composer_text_field').trigger($.Event('keydown', {which: $.ui.keyCode.ENTER}));
+ }
+}, {
+ content: "Verify your message has been typed",
+ trigger: "div.o_thread_message_content>p:contains('Hi ! What a coincidence! I need your help indeed.')"
+}, {
+ content: "Verify there is no duplicates",
+ trigger: "body",
+ run: function () {
+ if ($("div.o_thread_message_content p:contains('Hi ! What a coincidence! I need your help indeed.')").length === 1) {
+ $('body').addClass('no_duplicated_message');
+ }
+ }
+}, {
+ content: "Is your message correctly sent ?",
+ trigger: 'body.no_duplicated_message'
+}];
+
+
+tour.register('website_livechat_chat_request_part_1_no_close_tour', {
+ test: true,
+ url: '/',
+}, [].concat(stepWithChatRequestStep));
+
+tour.register('website_livechat_chat_request_part_2_end_session_tour', {
+ test: true,
+ url: '/',
+}, [].concat(commonSteps.endDiscussionStep, commonSteps.okRatingStep, commonSteps.feedbackStep, commonSteps.transcriptStep, commonSteps.closeStep));
+
+return {};
+});