[FIX] calendar: fix non deterministic calendar test

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) <seb@odoo.com>
Signed-off-by: Matthieu Stockbauer (tsm) <tsm@odoo.com>
This commit is contained in:
tsm-odoo
2023-12-27 10:07:19 +00:00
parent 97f61bf3a7
commit 81de427ee0
@@ -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",
},
]);