From cae9820addba5171b80c620bbbb069c333da71b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20K=C3=BChn?= Date: Mon, 8 May 2023 09:30:17 +0000 Subject: [PATCH] [FIX] test_mail: use patched date in activity view test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Before this commit, tests were using current date to make assertion. It's best to avoid making tests that use current date, as it might fail when run at specific time (e.g. at midnight or during holidays). closes odoo/odoo#120800 X-original-commit: 5bcef0f1d6ab48e408bc5058ea90d85f96da8928 Signed-off-by: Sébastien Theys (seb) Signed-off-by: Alexandre Kühn (aku) --- addons/test_mail/static/tests/activity_tests.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/addons/test_mail/static/tests/activity_tests.js b/addons/test_mail/static/tests/activity_tests.js index d39629a27de..b68d32b47db 100644 --- a/addons/test_mail/static/tests/activity_tests.js +++ b/addons/test_mail/static/tests/activity_tests.js @@ -10,6 +10,7 @@ import { legacyExtraNextTick, patchWithCleanup, click, + patchDate, } from "@web/../tests/helpers/utils"; import { doAction } from "@web/../tests/webclient/helpers"; import { session } from "@web/session"; @@ -20,6 +21,7 @@ let pyEnv; QUnit.module("test_mail", {}, function () { QUnit.module("activity view", { async beforeEach() { + patchDate(2023, 4, 8, 10, 0, 0); pyEnv = await startServer(); const mailTemplateIds = pyEnv["mail.template"].create([ { name: "Template1" }, @@ -216,7 +218,7 @@ QUnit.module("test_mail", {}, function () { for (let i = 0; i < 81; i++) { activityToCreate.push({ display_name: "An activity " + i, - date_deadline: moment().add(3, "days").format("YYYY-MM-DD"), // now + date_deadline: moment().add(3, "days").format("YYYY-MM-DD"), can_write: true, state: "planned", activity_type_id: mailActivityTypeIds[0], @@ -238,6 +240,9 @@ QUnit.module("test_mail", {}, function () { }); const activityRecords = document.querySelectorAll(".o_activity_record"); + // 81 test.activity records in tests + // + 2 in global of all tests in this file + // = 83 records assert.strictEqual( activityRecords.length, 83,