summaryrefslogtreecommitdiff
path: root/addons/web/static/tests/owl_compatibility_tests.js
diff options
context:
space:
mode:
authorGéry Debongnie <ged@odoo.com>2021-02-10 13:49:26 +0000
committerGéry Debongnie <ged@odoo.com>2021-02-10 14:27:32 +0000
commit2385e58d76aa5e4bca0fc6d76ecedc7de5fd4267 (patch)
treefb00bd9593ecf27ab075260f9b08734a6fa84e6b /addons/web/static/tests/owl_compatibility_tests.js
parenta622936ab09497086f43715e546a1b33418d0ee3 (diff)
[FIX] web, point_of_sale: update owl to v1.2.4
This commit update owl from 1.2.3 to 1.2.4, and introduces a few fixes for code that was broken (because it accesses private owl values) Note the fix for the test menu code is interesting. Before this commit, the handler for the click on the home menu component was not called, so the click had a side effect: it modified the url to its href, which caused the action manager to load the next application, even though the home menu was not mounted. With the update to Owl, this is no longer true: the handler is called, and call preventDefault on the event. Because of that, the url is not changed. However, since the home menu is itself not mounted, it cannot communicate to the web client that we should load the next app. This is why it was broken. The fix is simple: we actually make sure that the home menu is displayed before clicking on the app menuitem. closes odoo/odoo#65886 Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Diffstat (limited to 'addons/web/static/tests/owl_compatibility_tests.js')
-rw-r--r--addons/web/static/tests/owl_compatibility_tests.js44
1 files changed, 22 insertions, 22 deletions
diff --git a/addons/web/static/tests/owl_compatibility_tests.js b/addons/web/static/tests/owl_compatibility_tests.js
index a4f453867cf..7be3b17b857 100644
--- a/addons/web/static/tests/owl_compatibility_tests.js
+++ b/addons/web/static/tests/owl_compatibility_tests.js
@@ -12,6 +12,9 @@ odoo.define('web.OwlCompatibilityTests', function (require) {
const { Component, tags, useState } = owl;
const { xml } = tags;
+ // from Owl internal status enum
+ const ISMOUNTED = 3;
+ const ISDESTROYED = 5;
const WidgetAdapter = Widget.extend(WidgetAdapterMixin, {
destroy() {
@@ -883,19 +886,19 @@ odoo.define('web.OwlCompatibilityTests', function (require) {
await widget.appendTo(target);
assert.verifySteps(['init', 'willStart', 'mounted']);
- assert.ok(component.__owl__.isMounted);
+ assert.ok(component.__owl__.status === ISMOUNTED);
widget.$el.detach();
widget.on_detach_callback();
assert.verifySteps(['willUnmount']);
- assert.ok(!component.__owl__.isMounted);
+ assert.ok(component.__owl__.status !== ISMOUNTED);
widget.$el.appendTo(target);
widget.on_attach_callback();
assert.verifySteps(['mounted']);
- assert.ok(component.__owl__.isMounted);
+ assert.ok(component.__owl__.status === ISMOUNTED);
widget.destroy();
@@ -903,7 +906,7 @@ odoo.define('web.OwlCompatibilityTests', function (require) {
});
QUnit.test("isMounted with several sub components", async function (assert) {
- assert.expect(11);
+ assert.expect(9);
let c1;
let c2;
@@ -922,31 +925,29 @@ odoo.define('web.OwlCompatibilityTests', function (require) {
await widget.appendTo(target);
assert.strictEqual(widget.el.innerHTML, '<div>Component 1</div><div>Component 2</div>');
- assert.ok(c1.__owl__.isMounted);
- assert.ok(c2.__owl__.isMounted);
+ assert.ok(c1.__owl__.status === ISMOUNTED);
+ assert.ok(c2.__owl__.status === ISMOUNTED);
widget.$el.detach();
widget.on_detach_callback();
- assert.ok(!c1.__owl__.isMounted);
- assert.ok(!c2.__owl__.isMounted);
+ assert.ok(c1.__owl__.status !== ISMOUNTED);
+ assert.ok(c2.__owl__.status !== ISMOUNTED);
widget.$el.appendTo(target);
widget.on_attach_callback();
- assert.ok(c1.__owl__.isMounted);
- assert.ok(c2.__owl__.isMounted);
+ assert.ok(c1.__owl__.status === ISMOUNTED);
+ assert.ok(c2.__owl__.status === ISMOUNTED);
widget.destroy();
- assert.ok(!c1.__owl__.isMounted);
- assert.ok(!c2.__owl__.isMounted);
- assert.ok(c1.__owl__.isDestroyed);
- assert.ok(c2.__owl__.isDestroyed);
+ assert.ok(c1.__owl__.status === ISDESTROYED);
+ assert.ok(c2.__owl__.status === ISDESTROYED);
});
QUnit.test("isMounted with several levels of sub components", async function (assert) {
- assert.expect(6);
+ assert.expect(5);
let child;
class MyChildComponent extends Component {
@@ -971,22 +972,21 @@ odoo.define('web.OwlCompatibilityTests', function (require) {
await widget.appendTo(target);
assert.strictEqual(widget.el.innerHTML, '<div><div>child</div></div>');
- assert.ok(child.__owl__.isMounted);
+ assert.ok(child.__owl__.status === ISMOUNTED);
widget.$el.detach();
widget.on_detach_callback();
- assert.ok(!child.__owl__.isMounted);
+ assert.ok(child.__owl__.status !== ISMOUNTED);
widget.$el.appendTo(target);
widget.on_attach_callback();
- assert.ok(child.__owl__.isMounted);
+ assert.ok(child.__owl__.status === ISMOUNTED);
widget.destroy();
- assert.ok(!child.__owl__.isMounted);
- assert.ok(child.__owl__.isDestroyed);
+ assert.ok(child.__owl__.status === ISDESTROYED);
});
QUnit.test("sub component can be updated (in DOM)", async function (assert) {
@@ -1041,14 +1041,14 @@ odoo.define('web.OwlCompatibilityTests', function (require) {
widget.$el.detach();
widget.on_detach_callback();
- assert.ok(!widget.component.__owl__.isMounted);
+ assert.ok(widget.component.__owl__.status !== ISMOUNTED);
await widget.update();
widget.$el.appendTo(target);
widget.on_attach_callback();
- assert.ok(widget.component.__owl__.isMounted);
+ assert.ok(widget.component.__owl__.status === ISMOUNTED);
assert.strictEqual(widget.el.innerHTML, '<div>Component 2</div>');
widget.destroy();