From a8976144feee42fb17fd955fd45158b2c1556985 Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Fri, 9 Jul 2021 11:38:17 +0000 Subject: [PATCH] [FIX] web: correctly call dialog service --- addons/web/static/src/legacy/utils.js | 2 +- .../tests/webclient/actions/legacy_tests.js | 29 +++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/addons/web/static/src/legacy/utils.js b/addons/web/static/src/legacy/utils.js index c3167a9f8a8..76987f79352 100644 --- a/addons/web/static/src/legacy/utils.js +++ b/addons/web/static/src/legacy/utils.js @@ -277,7 +277,7 @@ export function makeLegacyCrashManagerService(legacyEnv) { start(env) { legacyEnv.services.crash_manager = { show_message(message) { - env.services.dialog.open(ErrorDialog, { traceback: message }); + env.services.dialog.add(ErrorDialog, { traceback: message }); }, rpc_error(errorResponse) { // Will be handled by error_service diff --git a/addons/web/static/tests/webclient/actions/legacy_tests.js b/addons/web/static/tests/webclient/actions/legacy_tests.js index ca160410ab3..30115e47d90 100644 --- a/addons/web/static/tests/webclient/actions/legacy_tests.js +++ b/addons/web/static/tests/webclient/actions/legacy_tests.js @@ -6,11 +6,15 @@ import ListController from "web.ListController"; import ListView from "web.ListView"; import { click, legacyExtraNextTick, patchWithCleanup } from "../../helpers/utils"; import { registerCleanup } from "../../helpers/cleanup"; +import { makeTestEnv } from "../../helpers/mock_env"; import { createWebClient, doAction, getActionManagerServerData } from "./../helpers"; +import makeTestEnvironment from "web.test_env"; import { ClientActionAdapter } from "@web/legacy/action_adapters"; +import { makeLegacyCrashManagerService } from "@web/legacy/utils"; import { useDebugMenu } from "@web/core/debug/debug_menu"; import { debugService } from "@web/core/debug/debug_service"; +import { ErrorDialog } from "@web/core/errors/error_dialogs"; import ControlPanel from "web.ControlPanel"; import core from "web.core"; @@ -80,6 +84,31 @@ QUnit.module("ActionManager", (hooks) => { assert.strictEqual($(".modal-body").text(), "This is a warning..."); }); + QUnit.test( + "legacy crash manager is still properly remapped to error service", + async function (assert) { + // this test can be removed as soon as the legacy layer is dropped + assert.expect(2); + + const legacyEnv = makeTestEnvironment(); + registry + .category("services") + .add("legacy_crash_manager", makeLegacyCrashManagerService(legacyEnv)) + .add("dialog", { + start() { + return { + add(dialogClass, props) { + assert.strictEqual(dialogClass, ErrorDialog); + assert.strictEqual(props.traceback, "BOOM"); + }, + }; + }, + }); + await makeTestEnv(); + legacyEnv.services.crash_manager.show_message("BOOM"); + } + ); + QUnit.test("redraw a controller and open debugManager does not crash", async (assert) => { assert.expect(11);