From 69afcfcc1ad78e04622c77ff396f84d40d51898c Mon Sep 17 00:00:00 2001 From: "Michael (mcm)" Date: Fri, 26 May 2023 12:49:37 +0000 Subject: [PATCH] [FIX] web: prevent false test fail The commit [1] removed two async module and caused a reorganisation on the module loading. Since that commit, two tests that throw an error failed because the error message was written in the console and the server considered this as a test fail. Now, the error message is not written in the console anymore. [1]: 96687f29496ab4cf16ae2ab1584ef1a6a3fb4a11 Part-of: odoo/odoo#121185 --- .../web/static/tests/views/form/form_view_tests.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/addons/web/static/tests/views/form/form_view_tests.js b/addons/web/static/tests/views/form/form_view_tests.js index 07643c5340f..d9c00a6d652 100644 --- a/addons/web/static/tests/views/form/form_view_tests.js +++ b/addons/web/static/tests/views/form/form_view_tests.js @@ -13041,6 +13041,13 @@ QUnit.module("Views", (hooks) => { QUnit.test( "coming to an action with an error from a form view with a dirty x2m", async function (assert) { + const handler = (ev) => { + // need to preventDefault to remove error from console (so python test pass) + ev.preventDefault(); + }; + window.addEventListener("unhandledrejection", handler); + registerCleanup(() => window.removeEventListener("unhandledrejection", handler)); + class TestClientAction extends Component { setup() { throw new Error("Something went wrong"); @@ -13124,6 +13131,13 @@ QUnit.module("Views", (hooks) => { QUnit.test( "coming to an action with an error from a form view with a record in creation", async function (assert) { + const handler = (ev) => { + // need to preventDefault to remove error from console (so python test pass) + ev.preventDefault(); + }; + window.addEventListener("unhandledrejection", handler); + registerCleanup(() => window.removeEventListener("unhandledrejection", handler)); + class TestClientAction extends Component { setup() { throw new Error("Something went wrong");