summaryrefslogtreecommitdiff
path: root/addons/mail_bot/static
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2022-05-10 21:51:50 +0700
committerstephanchrst <stephanchrst@gmail.com>2022-05-10 21:51:50 +0700
commit3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch)
treea44932296ef4a9b71d5f010906253d8c53727726 /addons/mail_bot/static
parent0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff)
initial commit 2
Diffstat (limited to 'addons/mail_bot/static')
-rw-r--r--addons/mail_bot/static/src/bugfix/bugfix.js10
-rw-r--r--addons/mail_bot/static/src/bugfix/bugfix.scss6
-rw-r--r--addons/mail_bot/static/src/bugfix/bugfix.xml11
-rw-r--r--addons/mail_bot/static/src/bugfix/bugfix_tests.js18
-rw-r--r--addons/mail_bot/static/src/models/messaging/messaging.js13
-rw-r--r--addons/mail_bot/static/src/models/messaging_initializer/messaging_initializer.js37
-rw-r--r--addons/mail_bot/static/src/models/messaging_initializer/messaging_initializer_tests.js56
-rw-r--r--addons/mail_bot/static/src/scss/odoobot_style.scss8
-rw-r--r--addons/mail_bot/static/tests/helpers/mock_server.js36
9 files changed, 195 insertions, 0 deletions
diff --git a/addons/mail_bot/static/src/bugfix/bugfix.js b/addons/mail_bot/static/src/bugfix/bugfix.js
new file mode 100644
index 00000000..bd676eb1
--- /dev/null
+++ b/addons/mail_bot/static/src/bugfix/bugfix.js
@@ -0,0 +1,10 @@
+/**
+ * This file allows introducing new JS modules without contaminating other files.
+ * This is useful when bug fixing requires adding such JS modules in stable
+ * versions of Odoo. Any module that is defined in this file should be isolated
+ * in its own file in master.
+ */
+odoo.define('mail_bot/static/src/bugfix/bugfix.js', function (require) {
+'use strict';
+
+});
diff --git a/addons/mail_bot/static/src/bugfix/bugfix.scss b/addons/mail_bot/static/src/bugfix/bugfix.scss
new file mode 100644
index 00000000..c4272e52
--- /dev/null
+++ b/addons/mail_bot/static/src/bugfix/bugfix.scss
@@ -0,0 +1,6 @@
+/**
+* This file allows introducing new styles without contaminating other files.
+* This is useful when bug fixing requires adding new components for instance in
+* stable versions of Odoo. Any style that is defined in this file should be isolated
+* in its own file in master.
+*/
diff --git a/addons/mail_bot/static/src/bugfix/bugfix.xml b/addons/mail_bot/static/src/bugfix/bugfix.xml
new file mode 100644
index 00000000..c17906f7
--- /dev/null
+++ b/addons/mail_bot/static/src/bugfix/bugfix.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<templates xml:space="preserve">
+
+<!--
+ This file allows introducing new static templates without contaminating other files.
+ This is useful when bug fixing requires adding new components for instance in stable
+ versions of Odoo. Any template that is defined in this file should be isolated
+ in its own file in master.
+-->
+
+</templates>
diff --git a/addons/mail_bot/static/src/bugfix/bugfix_tests.js b/addons/mail_bot/static/src/bugfix/bugfix_tests.js
new file mode 100644
index 00000000..3aa5456b
--- /dev/null
+++ b/addons/mail_bot/static/src/bugfix/bugfix_tests.js
@@ -0,0 +1,18 @@
+odoo.define('mail_bot/static/src/bugfix/bugfix_tests.js', function (require) {
+'use strict';
+
+/**
+ * This file allows introducing new QUnit test modules without contaminating
+ * other test files. This is useful when bug fixing requires adding new
+ * components for instance in stable versions of Odoo. Any test that is defined
+ * in this file should be isolated in its own file in master.
+ */
+QUnit.module('mail_bot', {}, function () {
+QUnit.module('bugfix', {}, function () {
+QUnit.module('bugfix_tests.js', {
+
+});
+});
+});
+
+});
diff --git a/addons/mail_bot/static/src/models/messaging/messaging.js b/addons/mail_bot/static/src/models/messaging/messaging.js
new file mode 100644
index 00000000..58923e8e
--- /dev/null
+++ b/addons/mail_bot/static/src/models/messaging/messaging.js
@@ -0,0 +1,13 @@
+odoo.define('mail_bot/static/src/models/messaging/messaging.js', function (require) {
+'use strict';
+
+const { registerInstancePatchModel } = require('mail/static/src/model/model_core.js');
+
+registerInstancePatchModel('mail.messaging', 'mail_bot/static/src/models/messaging/messaging.js', {
+ //----------------------------------------------------------------------
+ // Public
+ //----------------------------------------------------------------------
+
+});
+
+});
diff --git a/addons/mail_bot/static/src/models/messaging_initializer/messaging_initializer.js b/addons/mail_bot/static/src/models/messaging_initializer/messaging_initializer.js
new file mode 100644
index 00000000..9b06fbba
--- /dev/null
+++ b/addons/mail_bot/static/src/models/messaging_initializer/messaging_initializer.js
@@ -0,0 +1,37 @@
+odoo.define('mail_bot/static/src/models/messaging_initializer/messaging_initializer.js', function (require) {
+'use strict';
+
+const { registerInstancePatchModel } = require('mail/static/src/model/model_core.js');
+
+registerInstancePatchModel('mail.messaging_initializer', 'mail_bot/static/src/models/messaging_initializer/messaging_initializer.js', {
+ //--------------------------------------------------------------------------
+ // Private
+ //--------------------------------------------------------------------------
+
+ /**
+ * @private
+ */
+ async _initializeOdooBot() {
+ const data = await this.async(() => this.env.services.rpc({
+ model: 'mail.channel',
+ method: 'init_odoobot',
+ }));
+ if (!data) {
+ return;
+ }
+ this.env.session.odoobot_initialized = true;
+ },
+
+ /**
+ * @override
+ */
+ async start() {
+ await this.async(() => this._super());
+
+ if ('odoobot_initialized' in this.env.session && !this.env.session.odoobot_initialized) {
+ this._initializeOdooBot();
+ }
+ },
+});
+
+});
diff --git a/addons/mail_bot/static/src/models/messaging_initializer/messaging_initializer_tests.js b/addons/mail_bot/static/src/models/messaging_initializer/messaging_initializer_tests.js
new file mode 100644
index 00000000..bfb97067
--- /dev/null
+++ b/addons/mail_bot/static/src/models/messaging_initializer/messaging_initializer_tests.js
@@ -0,0 +1,56 @@
+odoo.define('mail_bot/static/src/models/messaging_initializer/messaging_initializer_tests.js', function (require) {
+"use strict";
+
+const { afterEach, beforeEach, start } = require('mail/static/src/utils/test_utils.js');
+
+QUnit.module('mail_bot', {}, function () {
+QUnit.module('models', {}, function () {
+QUnit.module('messaging_initializer', {}, function () {
+QUnit.module('messaging_initializer_tests.js', {
+ beforeEach() {
+ beforeEach(this);
+
+ this.start = async params => {
+ const { env, widget } = await start(Object.assign({}, params, {
+ data: this.data,
+ }));
+ this.env = env;
+ this.widget = widget;
+ };
+ },
+ afterEach() {
+ afterEach(this);
+ },
+});
+
+
+QUnit.test('OdooBot initialized at init', async function (assert) {
+ // TODO this test should be completed in combination with
+ // implementing _mockMailChannelInitOdooBot task-2300480
+ assert.expect(2);
+
+ await this.start({
+ env: {
+ session: {
+ odoobot_initialized: false,
+ },
+ },
+ async mockRPC(route, args) {
+ if (args.method === 'init_odoobot') {
+ assert.step('init_odoobot');
+ }
+ return this._super(...arguments);
+ },
+ });
+
+ assert.verifySteps(
+ ['init_odoobot'],
+ "should have initialized OdooBot at init"
+ );
+});
+
+});
+});
+});
+
+});
diff --git a/addons/mail_bot/static/src/scss/odoobot_style.scss b/addons/mail_bot/static/src/scss/odoobot_style.scss
new file mode 100644
index 00000000..aa5e187b
--- /dev/null
+++ b/addons/mail_bot/static/src/scss/odoobot_style.scss
@@ -0,0 +1,8 @@
+.o_odoobot_command {
+ background-color: lightgray;
+ border-radius: 4px;
+ padding: 2px;
+ padding-left: 10px;
+ padding-right: 10px;
+ font-weight: bold;
+}
diff --git a/addons/mail_bot/static/tests/helpers/mock_server.js b/addons/mail_bot/static/tests/helpers/mock_server.js
new file mode 100644
index 00000000..63de6c99
--- /dev/null
+++ b/addons/mail_bot/static/tests/helpers/mock_server.js
@@ -0,0 +1,36 @@
+odoo.define('mail_bot/static/tests/helpers/mock_server.js', function (require) {
+"use strict";
+
+const MockServer = require('web.MockServer');
+
+MockServer.include({
+ //--------------------------------------------------------------------------
+ // Private
+ //--------------------------------------------------------------------------
+
+ /**
+ * @override
+ */
+ async _performRpc(route, args) {
+ if (args.model === 'mail.channel' && args.method === 'init_odoobot') {
+ return this._mockMailChannelInitOdooBot();
+ }
+ return this._super(...arguments);
+ },
+
+ //--------------------------------------------------------------------------
+ // Private Mocked Methods
+ //--------------------------------------------------------------------------
+
+ /**
+ * Simulates `init_odoobot` on `mail.channel`.
+ *
+ * @private
+ */
+ _mockMailChannelInitOdooBot() {
+ // TODO implement this mock task-2300480
+ // and improve test "OdooBot initialized after 2 minutes"
+ },
+});
+
+});