[REF] website_livechat: prettify tour files

This commit prepares the ground for the refactoring of the
public livechat by prettifying the files that will be modified
in order to ease the diff.

part of task-2212347

closes odoo/odoo#123022

Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
This commit is contained in:
tsm-odoo
2023-05-31 13:08:19 +02:00
parent 9f9a0ee7dd
commit 7139a0db35
4 changed files with 447 additions and 301 deletions
@@ -12,147 +12,207 @@ import "@im_livechat/legacy/public_models/livechat_button_view";
const messagesContain = (text) => `div.o_thread_message_content:contains("${text}")`;
registry.category("web_tour.tours").add('website_livechat_chatbot_flow_tour', {
registry.category("web_tour.tours").add("website_livechat_chatbot_flow_tour", {
test: true,
steps: [{
trigger: messagesContain("Hello! I'm a bot!"),
async run() {
const { messaging } = await odoo.__DEBUG__;
/**
* Make it a bit faster than the default delay (3500ms).
* Also debounce waiting for more user inputs for only 500ms.
*/
messaging.publicLivechatGlobal.chatbot.update({ isWebsiteLivechatTourFlow: true });
},
}, {
trigger: messagesContain("I help lost visitors find their way."),
run: () => {} // check second welcome message is posted
}, {
trigger: messagesContain("How can I help you?"),
run: () => {} // check question_selection message is posted
}, {
trigger: '.o_livechat_chatbot_options li:contains("I want to buy the software")',
run: 'click'
}, {
trigger: messagesContain("I want to buy the software"),
run: () => {} // check selected option is posted
}, {
trigger: messagesContain("Can you give us your email please?"),
run: () => {} // check ask email step following selecting option A
}, {
trigger: "input.o_composer_text_field",
run: "text No, you won't get my email!"
}, {
trigger: "input.o_composer_text_field",
run: () => {
$('input.o_composer_text_field').trigger($.Event('keydown', {which: $.ui.keyCode.ENTER}));
}
}, {
trigger: messagesContain("'No, you won't get my email!' does not look like a valid email. Can you please try again?"),
run: () => {} // check invalid email detected and the bot asks for a retry
}, {
trigger: "input.o_composer_text_field",
run: "text okfine@fakeemail.com"
}, {
trigger: "input.o_composer_text_field",
run: () => {
$('input.o_composer_text_field').trigger($.Event('keydown', {which: $.ui.keyCode.ENTER}));
}
}, {
trigger: messagesContain("Your email is validated, thank you!"),
run: () => {} // check that this time the email goes through and we proceed to next step
}, {
trigger: messagesContain("Would you mind providing your website address?"),
run: () => {} // should ask for website now
}, {
trigger: "input.o_composer_text_field",
run: "text https://www.fakeaddress.com"
}, {
trigger: "input.o_composer_text_field",
run: () => {
$('input.o_composer_text_field').trigger($.Event('keydown', {which: $.ui.keyCode.ENTER}));
}
}, {
trigger: messagesContain("Great, do you want to leave any feedback for us to improve?"),
run: () => {} // should ask for feedback now
}, {
trigger: "input.o_composer_text_field",
run: "text Yes, actually, I'm glad you asked!"
}, {
trigger: "input.o_composer_text_field",
run: () => {
$('input.o_composer_text_field').trigger($.Event('keydown', {which: $.ui.keyCode.ENTER}));
}
}, {
trigger: "input.o_composer_text_field",
run: "text I think it's outrageous that you ask for all my personal information!"
}, {
trigger: "input.o_composer_text_field",
run: () => {
$('input.o_composer_text_field').trigger($.Event('keydown', {which: $.ui.keyCode.ENTER}));
}
}, {
trigger: "input.o_composer_text_field",
run: "text I will be sure to take this to your manager!"
}, {
trigger: "input.o_composer_text_field",
run: () => {
$('input.o_composer_text_field').trigger($.Event('keydown', {which: $.ui.keyCode.ENTER}));
}
}, {
trigger: messagesContain("Ok bye!"),
run: () => {} // last step is displayed
}, {
trigger: '.o_livechat_chatbot_restart',
run: 'click'
}, {
trigger: messagesContain("Restarting conversation..."),
run: () => {} // check that conversation is properly restarting
}, {
trigger: messagesContain("Hello! I'm a bot!"),
run: () => {} // check first welcome message is posted
}, {
trigger: messagesContain("I help lost visitors find their way."),
run: () => {} // check second welcome message is posted
}, {
trigger: messagesContain("How can I help you?"),
run: () => {} // check question_selection message is posted
}, {
trigger: '.o_livechat_chatbot_options li:contains("Pricing Question")',
run: 'click'
}, {
trigger: messagesContain("For any pricing question, feel free ton contact us at pricing@mycompany.com"),
run: () => {} // the path should now go towards 'Pricing Question (first part)'
}, {
trigger: messagesContain("We will reach back to you as soon as we can!"),
run: () => {} // the path should now go towards 'Pricing Question (second part)'
}, {
trigger: messagesContain("Would you mind providing your website address?"),
run: () => {} // should ask for website now
}, {
trigger: "input.o_composer_text_field",
run: "text no"
}, {
trigger: "input.o_composer_text_field",
run: () => {
$('input.o_composer_text_field').trigger($.Event('keydown', {which: $.ui.keyCode.ENTER}));
}
}, {
trigger: messagesContain("Great, do you want to leave any feedback for us to improve?"),
run: () => {} // should ask for feedback now
}, {
trigger: "input.o_composer_text_field",
run: "text no, nothing so say"
}, {
trigger: "input.o_composer_text_field",
run: () => {
$('input.o_composer_text_field').trigger($.Event('keydown', {which: $.ui.keyCode.ENTER}));
}
}, {
trigger: messagesContain("Ok bye!"),
}, {
// wait for chatbot script to finish.
trigger: '.o_livechat_chatbot_restart',
run() {},
}
]});
steps: [
{
trigger: messagesContain("Hello! I'm a bot!"),
async run() {
const { messaging } = await odoo.__DEBUG__;
/**
* Make it a bit faster than the default delay (3500ms).
* Also debounce waiting for more user inputs for only 500ms.
*/
messaging.publicLivechatGlobal.chatbot.update({ isWebsiteLivechatTourFlow: true });
},
},
{
trigger: messagesContain("I help lost visitors find their way."),
run: () => {}, // check second welcome message is posted
},
{
trigger: messagesContain("How can I help you?"),
run: () => {}, // check question_selection message is posted
},
{
trigger: '.o_livechat_chatbot_options li:contains("I want to buy the software")',
run: "click",
},
{
trigger: messagesContain("I want to buy the software"),
run: () => {}, // check selected option is posted
},
{
trigger: messagesContain("Can you give us your email please?"),
run: () => {}, // check ask email step following selecting option A
},
{
trigger: "input.o_composer_text_field",
run: "text No, you won't get my email!",
},
{
trigger: "input.o_composer_text_field",
run: () => {
$("input.o_composer_text_field").trigger(
$.Event("keydown", { which: $.ui.keyCode.ENTER })
);
},
},
{
trigger: messagesContain(
"'No, you won't get my email!' does not look like a valid email. Can you please try again?"
),
run: () => {}, // check invalid email detected and the bot asks for a retry
},
{
trigger: "input.o_composer_text_field",
run: "text okfine@fakeemail.com",
},
{
trigger: "input.o_composer_text_field",
run: () => {
$("input.o_composer_text_field").trigger(
$.Event("keydown", { which: $.ui.keyCode.ENTER })
);
},
},
{
trigger: messagesContain("Your email is validated, thank you!"),
run: () => {}, // check that this time the email goes through and we proceed to next step
},
{
trigger: messagesContain("Would you mind providing your website address?"),
run: () => {}, // should ask for website now
},
{
trigger: "input.o_composer_text_field",
run: "text https://www.fakeaddress.com",
},
{
trigger: "input.o_composer_text_field",
run: () => {
$("input.o_composer_text_field").trigger(
$.Event("keydown", { which: $.ui.keyCode.ENTER })
);
},
},
{
trigger: messagesContain("Great, do you want to leave any feedback for us to improve?"),
run: () => {}, // should ask for feedback now
},
{
trigger: "input.o_composer_text_field",
run: "text Yes, actually, I'm glad you asked!",
},
{
trigger: "input.o_composer_text_field",
run: () => {
$("input.o_composer_text_field").trigger(
$.Event("keydown", { which: $.ui.keyCode.ENTER })
);
},
},
{
trigger: "input.o_composer_text_field",
run: "text I think it's outrageous that you ask for all my personal information!",
},
{
trigger: "input.o_composer_text_field",
run: () => {
$("input.o_composer_text_field").trigger(
$.Event("keydown", { which: $.ui.keyCode.ENTER })
);
},
},
{
trigger: "input.o_composer_text_field",
run: "text I will be sure to take this to your manager!",
},
{
trigger: "input.o_composer_text_field",
run: () => {
$("input.o_composer_text_field").trigger(
$.Event("keydown", { which: $.ui.keyCode.ENTER })
);
},
},
{
trigger: messagesContain("Ok bye!"),
run: () => {}, // last step is displayed
},
{
trigger: ".o_livechat_chatbot_restart",
run: "click",
},
{
trigger: messagesContain("Restarting conversation..."),
run: () => {}, // check that conversation is properly restarting
},
{
trigger: messagesContain("Hello! I'm a bot!"),
run: () => {}, // check first welcome message is posted
},
{
trigger: messagesContain("I help lost visitors find their way."),
run: () => {}, // check second welcome message is posted
},
{
trigger: messagesContain("How can I help you?"),
run: () => {}, // check question_selection message is posted
},
{
trigger: '.o_livechat_chatbot_options li:contains("Pricing Question")',
run: "click",
},
{
trigger: messagesContain(
"For any pricing question, feel free ton contact us at pricing@mycompany.com"
),
run: () => {}, // the path should now go towards 'Pricing Question (first part)'
},
{
trigger: messagesContain("We will reach back to you as soon as we can!"),
run: () => {}, // the path should now go towards 'Pricing Question (second part)'
},
{
trigger: messagesContain("Would you mind providing your website address?"),
run: () => {}, // should ask for website now
},
{
trigger: "input.o_composer_text_field",
run: "text no",
},
{
trigger: "input.o_composer_text_field",
run: () => {
$("input.o_composer_text_field").trigger(
$.Event("keydown", { which: $.ui.keyCode.ENTER })
);
},
},
{
trigger: messagesContain("Great, do you want to leave any feedback for us to improve?"),
run: () => {}, // should ask for feedback now
},
{
trigger: "input.o_composer_text_field",
run: "text no, nothing so say",
},
{
trigger: "input.o_composer_text_field",
run: () => {
$("input.o_composer_text_field").trigger(
$.Event("keydown", { which: $.ui.keyCode.ENTER })
);
},
},
{
trigger: messagesContain("Ok bye!"),
},
{
// wait for chatbot script to finish.
trigger: ".o_livechat_chatbot_restart",
run() {},
},
],
});
@@ -10,7 +10,7 @@ import "@im_livechat/legacy/public_models/livechat_button_view";
import { Patch } from "@im_livechat/legacy/model";
Patch({
name: 'LivechatButtonView',
name: "LivechatButtonView",
recordMethods: {
/**
* Alter this method for test purposes.
@@ -31,13 +31,13 @@ Patch({
async sendMessage(message) {
await this._super(message);
if (message.isFeedback) {
$('div.o_thread_window_header').addClass('feedback_sent');
$("div.o_thread_window_header").addClass("feedback_sent");
} else {
this.messaging.rpc({ route: '/bus/test_mode_activated' }).then(in_test_mode => {
this.messaging.rpc({ route: "/bus/test_mode_activated" }).then((in_test_mode) => {
if (!in_test_mode) {
return;
}
this.env.services['bus_service'].forceUpdateChannels();
this.env.services["bus_service"].forceUpdateChannels();
});
}
},
@@ -45,117 +45,152 @@ Patch({
});
/*******************************
* Common Steps
*******************************/
* 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 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 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 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 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 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=5]",
}, {
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 goodRatingStep = [
{
content: "Send Good Rating",
trigger: "div.o_livechat_rating_choices > img[data-value=5]",
},
{
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=3]",
}];
var okRatingStep = [
{
content: "Send ok Rating",
trigger: "div.o_livechat_rating_choices > img[data-value=3]",
},
];
var sadRatingStep = [{
content: "Send bad Rating",
trigger: "div.o_livechat_rating_choices > img[data-value=1]",
}];
var sadRatingStep = [
{
content: "Send bad Rating",
trigger: "div.o_livechat_rating_choices > img[data-value=1]",
},
];
export default {
'startStep': startStep,
'endDiscussionStep': endDiscussionStep,
'transcriptStep': transcriptStep,
'feedbackStep': feedbackStep,
'closeStep': closeStep,
'goodRatingStep': goodRatingStep,
'okRatingStep': okRatingStep,
'sadRatingStep': sadRatingStep,
startStep: startStep,
endDiscussionStep: endDiscussionStep,
transcriptStep: transcriptStep,
feedbackStep: feedbackStep,
closeStep: closeStep,
goodRatingStep: goodRatingStep,
okRatingStep: okRatingStep,
sadRatingStep: sadRatingStep,
};
@@ -3,34 +3,66 @@
import commonSteps from "website_livechat.tour_common";
import { registry } from "@web/core/registry";
registry.category("web_tour.tours").add('website_livechat_complete_flow_tour', {
registry.category("web_tour.tours").add("website_livechat_complete_flow_tour", {
test: true,
url: '/',
steps: [].concat(commonSteps.startStep, commonSteps.endDiscussionStep, commonSteps.okRatingStep, commonSteps.feedbackStep, commonSteps.transcriptStep, commonSteps.closeStep)});
url: "/",
steps: [].concat(
commonSteps.startStep,
commonSteps.endDiscussionStep,
commonSteps.okRatingStep,
commonSteps.feedbackStep,
commonSteps.transcriptStep,
commonSteps.closeStep
),
});
registry.category("web_tour.tours").add('website_livechat_happy_rating_tour', {
registry.category("web_tour.tours").add("website_livechat_happy_rating_tour", {
test: true,
url: '/',
steps: [].concat(commonSteps.startStep, commonSteps.endDiscussionStep, commonSteps.goodRatingStep)});
url: "/",
steps: [].concat(
commonSteps.startStep,
commonSteps.endDiscussionStep,
commonSteps.goodRatingStep
),
});
registry.category("web_tour.tours").add('website_livechat_ok_rating_tour', {
registry.category("web_tour.tours").add("website_livechat_ok_rating_tour", {
test: true,
url: '/',
steps: [].concat(commonSteps.startStep, commonSteps.endDiscussionStep, commonSteps.okRatingStep, commonSteps.feedbackStep)});
url: "/",
steps: [].concat(
commonSteps.startStep,
commonSteps.endDiscussionStep,
commonSteps.okRatingStep,
commonSteps.feedbackStep
),
});
registry.category("web_tour.tours").add('website_livechat_sad_rating_tour', {
registry.category("web_tour.tours").add("website_livechat_sad_rating_tour", {
test: true,
url: '/',
steps: [].concat(commonSteps.startStep, commonSteps.endDiscussionStep, commonSteps.sadRatingStep, commonSteps.feedbackStep)});
url: "/",
steps: [].concat(
commonSteps.startStep,
commonSteps.endDiscussionStep,
commonSteps.sadRatingStep,
commonSteps.feedbackStep
),
});
registry.category("web_tour.tours").add('website_livechat_no_rating_tour', {
registry.category("web_tour.tours").add("website_livechat_no_rating_tour", {
test: true,
url: '/',
steps: [].concat(commonSteps.startStep, commonSteps.endDiscussionStep, commonSteps.transcriptStep, commonSteps.closeStep)});
url: "/",
steps: [].concat(
commonSteps.startStep,
commonSteps.endDiscussionStep,
commonSteps.transcriptStep,
commonSteps.closeStep
),
});
registry.category("web_tour.tours").add('website_livechat_no_rating_no_close_tour', {
registry.category("web_tour.tours").add("website_livechat_no_rating_no_close_tour", {
test: true,
url: '/',
steps: [].concat(commonSteps.startStep)});
url: "/",
steps: [].concat(commonSteps.startStep),
});
export default {};
@@ -3,42 +3,61 @@
import commonSteps from "website_livechat.tour_common";
import { registry } from "@web/core/registry";
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",
},
];
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'
}];
registry.category("web_tour.tours").add('website_livechat_chat_request_part_1_no_close_tour', {
registry.category("web_tour.tours").add("website_livechat_chat_request_part_1_no_close_tour", {
test: true,
url: '/',
steps: [].concat(stepWithChatRequestStep)});
url: "/",
steps: [].concat(stepWithChatRequestStep),
});
registry.category("web_tour.tours").add('website_livechat_chat_request_part_2_end_session_tour', {
registry.category("web_tour.tours").add("website_livechat_chat_request_part_2_end_session_tour", {
test: true,
url: '/',
steps: [].concat(commonSteps.endDiscussionStep, commonSteps.okRatingStep, commonSteps.feedbackStep, commonSteps.transcriptStep, commonSteps.closeStep)});
url: "/",
steps: [].concat(
commonSteps.endDiscussionStep,
commonSteps.okRatingStep,
commonSteps.feedbackStep,
commonSteps.transcriptStep,
commonSteps.closeStep
),
});
export default {};