diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
| commit | 3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch) | |
| tree | a44932296ef4a9b71d5f010906253d8c53727726 /addons/im_livechat/static/src/components/composer | |
| parent | 0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff) | |
initial commit 2
Diffstat (limited to 'addons/im_livechat/static/src/components/composer')
| -rw-r--r-- | addons/im_livechat/static/src/components/composer/composer.xml | 10 | ||||
| -rw-r--r-- | addons/im_livechat/static/src/components/composer/composer_tests.js | 68 |
2 files changed, 78 insertions, 0 deletions
diff --git a/addons/im_livechat/static/src/components/composer/composer.xml b/addons/im_livechat/static/src/components/composer/composer.xml new file mode 100644 index 00000000..52195220 --- /dev/null +++ b/addons/im_livechat/static/src/components/composer/composer.xml @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="UTF-8"?> +<templates xml:space="preserve"> + + <t t-inherit="mail.Composer" t-inherit-mode="extension"> + <xpath expr="//*[hasclass('o_Composer_buttonAttachment')]" position="replace"> + <t t-if="!composer.thread or composer.thread.channel_type !== 'livechat'">$0</t> + </xpath> + </t> + +</templates> diff --git a/addons/im_livechat/static/src/components/composer/composer_tests.js b/addons/im_livechat/static/src/components/composer/composer_tests.js new file mode 100644 index 00000000..b0559b98 --- /dev/null +++ b/addons/im_livechat/static/src/components/composer/composer_tests.js @@ -0,0 +1,68 @@ +odoo.define('im_livechat/static/src/components/composer/composer_tests.js', function (require) { +'use strict'; + +const components = { + Composer: require('mail/static/src/components/composer/composer.js'), +}; +const { + afterEach, + afterNextRender, + beforeEach, + start, +} = require('mail/static/src/utils/test_utils.js'); + +QUnit.module('im_livechat', {}, function () { +QUnit.module('components', {}, function () { +QUnit.module('composer', {}, function () { +QUnit.module('composer_tests.js', { + beforeEach() { + beforeEach(this); + + this.createComposerComponent = async (composer, otherProps) => { + const ComposerComponent = components.Composer; + ComposerComponent.env = this.env; + this.component = new ComposerComponent(null, Object.assign({ + composerLocalId: composer.localId, + }, otherProps)); + delete ComposerComponent.env; + await afterNextRender(() => this.component.mount(this.widget.el)); + }; + + 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('livechat: no add attachment button', async function (assert) { + // Attachments are not yet supported in livechat, especially from livechat + // visitor PoV. This may likely change in the future with task-2029065. + assert.expect(2); + + await this.start(); + const thread = this.env.models['mail.thread'].create({ + channel_type: 'livechat', + id: 10, + model: 'mail.channel', + }); + await this.createComposerComponent(thread.composer); + assert.containsOnce(document.body, '.o_Composer', "should have a composer"); + assert.containsNone( + document.body, + '.o_Composer_buttonAttachment', + "composer linked to livechat should not have a 'Add attachment' button" + ); +}); + +}); +}); +}); + +}); |
