[FIX] website_livechat: MockServer: patch _performRPC

The new MockServer has no _mockCallButton method. Due to an issue with
the patch function that does not reasign this._super correctly when
entering the _mockCallButton function, a crash did occur.

Part-of: odoo/odoo#112756
This commit is contained in:
Mathieu Duckerts-Antoine
2023-02-28 20:38:49 +01:00
parent 29b13cbdd6
commit efe09fd7ad
@@ -3,23 +3,16 @@
import { patch } from "@web/core/utils/patch";
import { MockServer } from "@web/../tests/helpers/mock_server";
patch(MockServer.prototype, 'website_livechat/controllers/dataset', {
patch(MockServer.prototype, "website_livechat/controllers/dataset", {
/**
* @override
*/
async _performRPC(route, args) {
if (route === '/web/dataset/call_button') {
return this._mockCallButton(args);
}
return this._super(route, args);
},
/**
* Simulate a 'call_button' operation from a view.
*
* @override
*/
_mockCallButton({ args, kwargs, method, model }) {
if (model === 'website.visitor' && method === 'action_send_chat_request') {
async _performRPC(route, { args, method, model }) {
if (
route === "/web/dataset/call_button" &&
model === "website.visitor" &&
method === "action_send_chat_request"
) {
return this._mockWebsiteVisitorActionSendChatRequest(args[0]);
}
return this._super(...arguments);