From dc5632d085ce8ca1c23bbfe5c773ddd6a52f015b Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Mon, 20 Mar 2023 11:07:27 +0000 Subject: [PATCH] [FIX] web, web_tour: qunit tests: do not log "test successful" Python tests that run chrome headless wait for "test successful" to be printed in the console to end the test with green status. Tours and qunit suites logs that message when their work is done. Commit [1] reworked the tour system and introduced some qunit tests of the tour engine. However, running fake tours in qunit tests produced the "test successful" message, which caused the end of the suite. As a consequence, only a small part of the WebSuite test suite was really executed. This commit mocks console.log in those tour qunit tests, s.t. the suite is now fully executed again. [1] 3a798039d6f200f8e28448ddb6a2d3c46654a203 Part-of: odoo/odoo#115841 --- addons/web/static/tests/qunit.js | 3 ++- addons/web_tour/static/src/tour_service/tour_service.js | 3 ++- addons/web_tour/static/tests/tour_service_tests.js | 6 ++++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/addons/web/static/tests/qunit.js b/addons/web/static/tests/qunit.js index 8187fabae17..9fd8fa50905 100644 --- a/addons/web/static/tests/qunit.js +++ b/addons/web/static/tests/qunit.js @@ -305,7 +305,8 @@ export function setupQUnit() { errorMessages.push(`${result.failed} / ${result.total} tests failed.`); } if (!result.failed && allModulesLoaded) { - console.log("test successful"); + console.log("QUnit test suite done."); + console.log("test successful"); // for ChromeBowser to know it's over and ok } else { logErrors(); } diff --git a/addons/web_tour/static/src/tour_service/tour_service.js b/addons/web_tour/static/src/tour_service/tour_service.js index eefa2da9fdc..7765bafa5d7 100644 --- a/addons/web_tour/static/src/tour_service/tour_service.js +++ b/addons/web_tour/static/src/tour_service/tour_service.js @@ -1,6 +1,7 @@ /** @odoo-module **/ import { markup, whenReady, reactive } from "@odoo/owl"; +import { browser } from "@web/core/browser/browser"; import { isMobileOS } from "@web/core/browser/feature_detection"; import { _t } from "@web/core/l10n/translation"; import { MacroEngine } from "@web/core/macro"; @@ -186,7 +187,7 @@ export const tourService = { } pointer.stop(); // Used to signal the python test runner that the tour finished without error. - console.log("test successful"); + browser.console.log("test successful"); }, }); } diff --git a/addons/web_tour/static/tests/tour_service_tests.js b/addons/web_tour/static/tests/tour_service_tests.js index 734680d9777..db62217cf67 100644 --- a/addons/web_tour/static/tests/tour_service_tests.js +++ b/addons/web_tour/static/tests/tour_service_tests.js @@ -1,5 +1,6 @@ /** @odoo-module **/ +import { browser } from "@web/core/browser/browser"; import { registry } from "@web/core/registry"; import { tourService } from "@web_tour/tour_service/tour_service"; import { rpcService } from "@web/core/network/rpc_service"; @@ -15,6 +16,7 @@ import { click, triggerEvent, nextTick, + patchWithCleanup, } from "@web/../tests/helpers/utils"; import { makeTestEnv } from "@web/../tests/helpers/mock_env"; import { Component, useState, xml } from "@odoo/owl"; @@ -59,6 +61,10 @@ QUnit.module("Tour service", (hooks) => { .add("notification", notificationService) .add("effect", effectService) .add("tour_service", tourService); + patchWithCleanup(browser.console, { + // prevent form logging "tour successful" which would end the qunit suite test + log: () => {} + }); }); hooks.afterEach(() => {