summaryrefslogtreecommitdiff
path: root/addons/mail/static/tests
diff options
context:
space:
mode:
authorAlexandre Kühn <aku@odoo.com>2018-02-14 14:59:03 +0100
committerAlexandre Kühn <aku@odoo.com>2018-02-20 13:31:22 +0100
commit9f2ec57a7e2dc8eb8eb87905ff50ab04e8bd8ddd (patch)
tree62600fa06e73b9ed3b1a3ae83fa10d121584ba2f /addons/mail/static/tests
parent2a09baf0ed3360ac9ac47c71590b19a71605779e (diff)
[FIX] mail: tests: add basic rendering test for discuss
This commit adds a first test of discuss, which checks that the essential DOM elements are present when we create a discuss widget. In particular, there should be a sidebar that contains links to channel_inbox and channel_starred.
Diffstat (limited to 'addons/mail/static/tests')
-rw-r--r--addons/mail/static/tests/discuss_tests.js79
-rw-r--r--addons/mail/static/tests/helpers/test_utils.js3
2 files changed, 34 insertions, 48 deletions
diff --git a/addons/mail/static/tests/discuss_tests.js b/addons/mail/static/tests/discuss_tests.js
index 7f48e3b0450..6c90cf802f7 100644
--- a/addons/mail/static/tests/discuss_tests.js
+++ b/addons/mail/static/tests/discuss_tests.js
@@ -1,11 +1,10 @@
odoo.define('mail.discuss_test', function (require) {
"use strict";
-var testUtils = require('web.test_utils');
-var Widget = require('web.Widget');
-
+var ChatManager = require('mail.ChatManager');
var mailTestUtils = require('mail.testUtils');
+var createBusService = mailTestUtils.createBusService;
var createDiscuss = mailTestUtils.createDiscuss;
QUnit.module('mail', {}, function () {
@@ -17,57 +16,43 @@ QUnit.module('Discuss client action', {
fields: {},
},
};
+ this.services = [ChatManager, createBusService()];
},
});
-QUnit.skip('mobile basic rendering', function (assert) {
- // Unfortunately, this test is skipped for now because there is no way to
- // execute the whole test suite in mobile (it only works test by test), so
- // as the client action include for mobile is rejected when we are not in
- // mobile, it isn't possible to test it
- // Moreover, RPCs done by the chat_manager (e.g. message_fetch) should be
- // properly mocked.
- assert.expect(11);
-
- var parent = new Widget();
- testUtils.addMockEnvironment(parent, {
- data: this.data,
- archs: {
- 'mail.message,false,search': '<search/>',
- },
- config: {device: {isMobile: true}},
- });
+QUnit.test('basic rendering', function (assert) {
+ assert.expect(5);
+ var done = assert.async();
- var params = {
+ createDiscuss({
id: 1,
context: {},
params: {},
- };
- var discuss = createDiscuss(params);
-
- // test basic rendering in mobile
- assert.equal(discuss.$(".o_mail_chat_mobile_control_panel").length, 1, "Mobile control panel created");
- assert.equal(discuss.$(".o_mail_mobile_tab").length, 4, "Four mobile tabs created");
- assert.equal(discuss.$('.o_mail_chat_content').length, 1, "One default chat content pane created");
- assert.equal(discuss.$(".o_mail_chat_tab_pane").length, 3, "Three mobile tab panes created");
-
- // Inbox
- assert.equal(discuss.activeMobileTab, "channel_inbox", "'channel_inbox' is default active tab");
- assert.ok(discuss.$(".o_channel_inbox_item:nth(0)").hasClass("btn-primary"), "Showing 'Inbox'");
-
- // Starred
- discuss.$(".o_channel_inbox_item[data-type='channel_starred']").click();
- assert.ok(discuss.$(".o_channel_inbox_item:nth(1)").hasClass("btn-primary"), "Clicked on 'Starred'");
-
- assert.ok(discuss.$(".o_mail_chat_content").is(":visible"), "Default main content pane visible");
-
- discuss.$(".o_mail_mobile_tab[data-type='dm']").click();
- assert.equal(discuss.activeMobileTab, "dm", "After click on 'Conversation', is now active tab");
-
- assert.ok(!discuss.$(".o_mail_chat_content").is(":visible"), "none", "'Main' content pane is invisible");
- assert.ok(discuss.$(".o_mail_chat_tab_pane:nth(0)").is(":visible"), "'Conversation' pane is visible");
-
- discuss.destroy();
+ data: this.data,
+ services: this.services,
+ })
+ .then(function (discuss) {
+ // test basic rendering
+ var $sidebar = discuss.$('.o_mail_chat_sidebar');
+ assert.strictEqual($sidebar.length, 1,
+ "should have rendered a sidebar");
+
+ var $nocontent = discuss.$('.o_mail_chat_content');
+ assert.strictEqual($nocontent.length, 1,
+ "should have rendered the content");
+ assert.strictEqual($nocontent.find('.o_mail_no_content').length, 1,
+ "should display no content message");
+
+ var $inbox = $sidebar.find('.o_mail_chat_channel_item[data-channel-id=channel_inbox]');
+ assert.strictEqual($inbox.length, 1,
+ "should have the channel item 'channel_inbox' in the sidebar");
+
+ var $starred = $sidebar.find('.o_mail_chat_channel_item[data-channel-id=channel_starred]');
+ assert.strictEqual($starred.length, 1,
+ "should have the channel item 'channel_starred' in the sidebar");
+ discuss.destroy();
+ done();
+ });
});
});
diff --git a/addons/mail/static/tests/helpers/test_utils.js b/addons/mail/static/tests/helpers/test_utils.js
index 05ffc12e7de..095da27be58 100644
--- a/addons/mail/static/tests/helpers/test_utils.js
+++ b/addons/mail/static/tests/helpers/test_utils.js
@@ -74,7 +74,8 @@ function createDiscuss(params) {
}));
var discuss = new Discuss(parent, params);
discuss.set_cp_bus(new Widget());
- discuss.appendTo($('#qunit-fixture'));
+ var selector = params.debug ? 'body' : '#qunit-fixture';
+ discuss.appendTo($(selector));
return discuss.call('chat_manager', 'isReady').then(function () {
return discuss;