summaryrefslogtreecommitdiff
path: root/addons/mail/static/tests/models/cc_throttle_function_tests.js
diff options
context:
space:
mode:
authorSébastien Theys <seb@odoo.com>2020-06-15 18:12:21 +0000
committerSébastien Theys <seb@odoo.com>2020-06-15 18:12:21 +0000
commit3fea5b2136627c1d7e83b2a5e111952fe3eb10a1 (patch)
tree5eefad07972a87ce4689b83260f981bc87aadad4 /addons/mail/static/tests/models/cc_throttle_function_tests.js
parent0a82848606151ef60eb6523e9c4c161171f214e7 (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/models/cc_throttle_function_tests.js')
-rw-r--r--addons/mail/static/tests/models/cc_throttle_function_tests.js154
1 files changed, 0 insertions, 154 deletions
diff --git a/addons/mail/static/tests/models/cc_throttle_function_tests.js b/addons/mail/static/tests/models/cc_throttle_function_tests.js
deleted file mode 100644
index f760675b1f3..00000000000
--- a/addons/mail/static/tests/models/cc_throttle_function_tests.js
+++ /dev/null
@@ -1,154 +0,0 @@
-odoo.define('mail.model.CCThrottleFunctionTests', function (require) {
-"use strict";
-
-var CCThrottleFunction = require('mail.model.CCThrottleFunction');
-var CCThrottleFunctionObject = require('mail.model.CCThrottleFunctionObject');
-
-var testUtils = require('web.test_utils');
-
-QUnit.module('mail', {
- beforeEach: function () {
-
- var self = this;
- this.timeoutCDDef = testUtils.makeTestPromise();
-
- this.patch = function () {
- self.ORIGINAL_CCTFO_ON_CD_TIMEOUT = CCThrottleFunctionObject.prototype._onCooldownTimeout;
- CCThrottleFunctionObject.prototype._onCooldownTimeout = function () {
- self.timeoutCDDef.then(self.ORIGINAL_CCTFO_ON_CD_TIMEOUT.apply(this, arguments));
- };
- };
- this.unpatch = function () {
- CCThrottleFunctionObject.prototype._onCooldownTimeout = self.ORIGINAL_CCTFO_ON_CD_TIMEOUT;
- };
- this.patch();
- },
- afterEach: function () {
- this.unpatch();
- },
-}, function () {
-
-QUnit.module('model', {}, function () {
-QUnit.module('CC Throttle Function');
-
-QUnit.test('cancel()', async function (assert) {
- var done = assert.async();
- assert.expect(3);
-
- var self = this;
- var def = testUtils.makeTestPromise();
- var step = 1;
-
- var widget = await testUtils.createParent({
- mockRPC: function (route, args) {
- if (args.method === '__rpc__') {
- assert.step(args.method + args.args[0]);
-
- if (step === 1) {
- def.resolve();
- }
- else {
- assert.notOk(true, "should not perform rpc more than once");
- }
- step++;
-
- return Promise.resolve();
- }
- return this._super.apply(this, arguments);
- },
- });
-
- var func = function () {
- widget._rpc({
- method: '__rpc__',
- args: arguments,
- });
- };
-
- var cctFunc = CCThrottleFunction({
- duration: 0,
- func: func,
- });
-
- cctFunc(1);
-
- def.then(function () {
- assert.verifySteps(['__rpc__1'], "function should have been called once");
- }).then(function () {
- cctFunc(2);
- cctFunc.cancel();
- self.timeoutCDDef.resolve();
- });
- this.timeoutCDDef.then(function () {
- assert.verifySteps([],
- "function should still have been called once after 2nd function call cancelled");
- widget.destroy();
- done();
- });
-});
-
-QUnit.test('clear()', async function (assert) {
- var done = assert.async();
- assert.expect(5);
-
- var self = this;
- var def1 = testUtils.makeTestPromise();
- var def2 = testUtils.makeTestPromise();
- var step = 1;
-
- var widget = await testUtils.createParent({
- mockRPC: function (route, args) {
- if (args.method === '__rpc__') {
- assert.step(args.method + args.args[0]);
-
- if (step === 1) {
- def1.resolve();
- } else if (step === 2) {
- def2.resolve();
- } else {
- assert.notOk(true, "should not perform rpc more than twice");
- }
- step++;
-
- return Promise.resolve();
- }
- return this._super.apply(this, arguments);
- },
- });
-
- var func = function () {
- widget._rpc({
- method: '__rpc__',
- args: arguments,
- });
- };
-
- var cctFunc = CCThrottleFunction({
- duration: 1000*1000,
- func: func,
- });
-
- cctFunc(1);
-
- def1.then(function () {
- assert.verifySteps(['__rpc__1'], "function should have been called once");
- }).then(function () {
- cctFunc(2);
- }).then(function () {
- assert.verifySteps([],
- "function should still have been called once (due to long throttle)");
- cctFunc.clear();
- self.timeoutCDDef.resolve();
- def2.resolve();
- });
- Promise.all([self.timeoutCDDef, def2]).then(function () {
- assert.verifySteps(['__rpc__2'],
- "function should have been called twice after 'clear' (buffered 2nd function call)");
- widget.destroy();
- done();
- });
-});
-
-});
-});
-});