diff options
| author | Sébastien Theys <seb@odoo.com> | 2020-06-15 18:12:21 +0000 |
|---|---|---|
| committer | Sébastien Theys <seb@odoo.com> | 2020-06-15 18:12:21 +0000 |
| commit | 3fea5b2136627c1d7e83b2a5e111952fe3eb10a1 (patch) | |
| tree | 5eefad07972a87ce4689b83260f981bc87aadad4 /addons/mail/static/tests/thread_window/moderation_thread_window_tests.js | |
| parent | 0a82848606151ef60eb6523e9c4c161171f214e7 (diff) | |
[REF] mail, *: refactor messaging with OWL
This commit is a significant rewriting of client-side discuss, chatter,
chat window, and messaging menu using OWL. The behavior should be broadly
the same, with some slight functional changes here and there.
From a technical standpoint, the code of messaging is mainly organized in 2
main groups of modules:
- models, which are logical entities that depict the client-side state of
messaging as a whole.
- components, which are in charge of displaying information from models.
This refactoring also introduces new JS guidelines regarding folder structure
(/static) and naming rules for JS modules.
Community PR: https://github.com/odoo/odoo/pull/39023
Enterprise PR: https://github.com/odoo/enterprise/pull/6249
Task-1914207
This PR is a collaborative work by Alexandre, Julien, Sébastien and Xavier,
with the precious help of Lucas to speed it up towards the end.
closes odoo/odoo#39023
Related: odoo/enterprise#6249
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
Co-authored-by: Alexandre Kühn <aku@odoo.com>
Co-authored-by: Julien Giannone <jgi@odoo.com>
Co-authored-by: Lucas Perais <lpe@odoo.com>
Co-authored-by: Sébastien Theys <seb@odoo.com>
Co-authored-by: Xavier Dubuc <xdu@odoo.com>
Diffstat (limited to 'addons/mail/static/tests/thread_window/moderation_thread_window_tests.js')
| -rw-r--r-- | addons/mail/static/tests/thread_window/moderation_thread_window_tests.js | 138 |
1 files changed, 0 insertions, 138 deletions
diff --git a/addons/mail/static/tests/thread_window/moderation_thread_window_tests.js b/addons/mail/static/tests/thread_window/moderation_thread_window_tests.js deleted file mode 100644 index db2561fd048..00000000000 --- a/addons/mail/static/tests/thread_window/moderation_thread_window_tests.js +++ /dev/null @@ -1,138 +0,0 @@ -odoo.define('mail.moderationThreadWindowTests', function (require) { -"use strict"; - -var mailTestUtils = require('mail.testUtils'); - -var testUtils = require('web.test_utils'); -var Widget = require('web.Widget'); - -QUnit.module('mail', {}, function () { -QUnit.module('Thread Window', {}, function () { -QUnit.module('Moderation', { - beforeEach: function () { - var self = this; - - // define channel to link to chat window - this.data = { - 'mail.message': { - fields: { - author_id: { - string: "Author", - relation: 'res.partner', - }, - channel_ids: { - string: "Channels", - type: 'many2many', - relation: 'mail.channel', - }, - model: { - string: "Related Document model", - type: 'char', - }, - res_id: { - string: "Related Document ID", - type: 'integer', - }, - need_moderation: { - string: "Need moderation", - type: 'boolean', - }, - moderation_status: { - string: "Moderation Status", - type: 'integer', - selection: [ - ['pending_moderation', 'Pending Moderation'], - ['accepted', 'Accepted'], - ['rejected', 'Rejected'] - ], - }, - }, - records: [], - }, - initMessaging: { - channel_slots: { - channel_channel: [{ - id: 1, - channel_type: "channel", - name: "general", - }], - }, - }, - }; - this.services = mailTestUtils.getMailServices(); - this.ORIGINAL_THREAD_WINDOW_APPENDTO = this.services.mail_service.prototype.THREAD_WINDOW_APPENDTO; - - this.createParent = async function (params) { - var widget = new Widget(); - - // in non-debug mode, append thread windows in qunit-fixture - // note that it does not hide thread window because it uses fixed - // position, and qunit-fixture uses absolute... - if (params.debug) { - self.services.mail_service.prototype.THREAD_WINDOW_APPENDTO = 'body'; - } else { - self.services.mail_service.prototype.THREAD_WINDOW_APPENDTO = '#qunit-fixture'; - } - - await testUtils.mock.addMockEnvironment(widget, params); - return widget; - }; - }, - afterEach: function () { - // reset thread window append to body - this.services.mail_service.prototype.THREAD_WINDOW_APPENDTO = this.ORIGINAL_THREAD_WINDOW_APPENDTO; - }, -}); - -QUnit.test('moderator: moderated channel with pending moderation message', async function (assert) { - assert.expect(5); - - this.data.initMessaging = { - channel_slots: { - channel_channel: [{ - id: 1, - channel_type: "channel", - name: "general", - moderation: true, - }], - }, - is_moderator: true, - moderation_counter: 1, - moderation_channel_ids: [1], - }; - this.data['mail.message'].records = [{ - author_id: [2, "Someone"], - body: "<p>test</p>", - id: 100, - model: 'mail.channel', - moderation_status: 'pending_moderation', - need_moderation: true, - res_id: 1, - }]; - - var parent = await this.createParent({ - data: this.data, - services: this.services, - }); - await testUtils.nextTick(); - // detach channel 1, so that it opens corresponding thread window. - parent.call('mail_service', 'getChannel', 1).detach(); - await testUtils.nextTick(); - - assert.strictEqual($('.o_thread_message ').length, 1, - "should display a message in the thread window"); - assert.strictEqual($('.o_thread_author').text().trim(), "Someone", - "should be a message of 'Someone'"); - assert.strictEqual($('.o_thread_icons').text().trim(), "Pending moderation", - "should be pending moderation"); - assert.strictEqual($('.o_thread_message_moderation').length, 0, - "should not display any contextual moderation decisions next to the message"); - assert.strictEqual($('.moderation_checkbox').length, 0, - "should not display any moderation checkbox next to the message"); - - parent.destroy(); -}); - -}); -}); -}); |
