From 81de427ee02414f41b5a7eaaa5f4a51c659e520e Mon Sep 17 00:00:00 2001 From: tsm-odoo Date: Wed, 27 Dec 2023 10:12:20 +0100 Subject: [PATCH] [FIX] calendar: fix non deterministic calendar test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The `calendar notification` tests patch the `setTimeout` function. This sometimes leads to infinite recursion when the `multi_tab` service has enough time to initialize: this service make use of `setTimeout` to call the `heartbeat` method repeatedly. Moreover, patching the `setTimeout` method is not a good idea since it makes this method synchronous which totally changes the flow that is tested. This PR fixes this issue by using the `contains` helper instead: this method will wait for the element to be inserted in the DOM and perform the assertion afterwards. closes odoo/odoo#147503 X-original-commit: 973db5a Signed-off-by: Sébastien Theys (seb) Signed-off-by: Matthieu Stockbauer (tsm) --- .../static/tests/calendar_notification_tests.js | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/addons/calendar/static/tests/calendar_notification_tests.js b/addons/calendar/static/tests/calendar_notification_tests.js index c28ea318e56..456e82306e7 100644 --- a/addons/calendar/static/tests/calendar_notification_tests.js +++ b/addons/calendar/static/tests/calendar_notification_tests.js @@ -6,9 +6,7 @@ import { calendarNotificationService } from "@calendar/js/services/calendar_noti import { start } from "@mail/../tests/helpers/test_utils"; -import { browser } from "@web/core/browser/browser"; import { registry } from "@web/core/registry"; -import { patchWithCleanup } from "@web/../tests/helpers/utils"; import { click, contains } from "@web/../tests/utils"; const serviceRegistry = registry.category("services"); @@ -16,11 +14,6 @@ const serviceRegistry = registry.category("services"); QUnit.module("Calendar Notification", (hooks) => { hooks.beforeEach(() => { serviceRegistry.add("calendarNotification", calendarNotificationService); - patchWithCleanup(browser, { - setTimeout(fn) { - super.setTimeout(fn, 0); - }, - }); }); QUnit.test( @@ -43,7 +36,7 @@ QUnit.module("Calendar Notification", (hooks) => { event_id: 2, title: "Meeting", message: "Very old meeting message", - timer: 20 * 60, + timer: 0, notify_at: "1978-04-14 12:45:00", }, ]); @@ -85,7 +78,7 @@ QUnit.module("Calendar Notification", (hooks) => { event_id: 2, title: "Meeting", message: "Very old meeting message", - timer: 20 * 60, + timer: 0, notify_at: "1978-04-14 12:45:00", }, ]); @@ -116,7 +109,7 @@ QUnit.module("Calendar Notification", (hooks) => { event_id: 2, title: "Meeting", message: "Very old meeting message", - timer: 20 * 60, + timer: 0, notify_at: "1978-04-14 12:45:00", }, ]);