From 4efa1b209ce30907a20783addc362bfe51d44945 Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Mon, 27 Sep 2021 15:12:39 +0000 Subject: [PATCH] [FIX] web_tour: display rainbowman at end of tours Since commit [1], it crashed when, at the end of a tour, we tried to display a rainbow man, because we forgot to update the "type" key. 74dc3f654ee5849982b494e46eefb1fc2b4e0c74 closes odoo/odoo#77306 X-original-commit: 6fa92d38e1945414f45411fc2e2528a8ef6f9fd1 Signed-off-by: Lucas Perais (lpe) Signed-off-by: Aaron Bohy (aab) --- addons/web_tour/static/src/js/tour_manager.js | 2 +- .../static/tests/tour_manager_tests.js | 37 +++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/addons/web_tour/static/src/js/tour_manager.js b/addons/web_tour/static/src/js/tour_manager.js index e8e8e0f3497..c5d3f098051 100644 --- a/addons/web_tour/static/src/js/tour_manager.js +++ b/addons/web_tour/static/src/js/tour_manager.js @@ -434,7 +434,7 @@ return core.Class.extend(mixins.EventDispatcherMixin, ServicesMixin, { } const fadeout = this.tours[tour_name].fadeout; core.bus.trigger('show-effect', { - type: "rainbowman", + type: "rainbow_man", message, fadeout, messageIsHtml: true, diff --git a/addons/web_tour/static/tests/tour_manager_tests.js b/addons/web_tour/static/tests/tour_manager_tests.js index b4e994733ad..3d2a4bac0d8 100644 --- a/addons/web_tour/static/tests/tour_manager_tests.js +++ b/addons/web_tour/static/tests/tour_manager_tests.js @@ -1,6 +1,7 @@ odoo.define('web_tour.tour_manager_tests', async function (require) { "use strict"; + const core = require("web.core"); const KanbanView = require('web.KanbanView'); const TourManager = require('web_tour.TourManager'); const testUtils = require('web.test_utils'); @@ -72,6 +73,42 @@ odoo.define('web_tour.tour_manager_tests', async function (require) { tourManager.destroy(); }); + QUnit.test("Displays a rainbow man by default at the end of tours", async function (assert) { + assert.expect(3); + + function onShowEffect(params) { + assert.deepEqual(params, { + fadeout: "medium", + message: "Good job! You went through all steps of this tour.", + messageIsHtml: true, + type: "rainbow_man" + }); + } + core.bus.on("show-effect", null, onShowEffect); + + const tourManager = await createTourManager({ + data: { 'web_tour.tour': { fields: {}, consume() {} } }, + template: ``, + tours: [{ + name: "Some tour", + options: {}, + steps: [{ trigger: '.anchor', content: "anchor" }], + }], + // Use this test in "debug" mode because the tips need to be in + // the viewport to be able to test their normal content + // (otherwise, the tips would indicate to the users that they + // have to scroll). + debug: true, + }); + + assert.containsOnce(document.body, '.o_tooltip'); + await testUtils.dom.click($('.anchor')); + assert.containsNone(document.body, '.o_tooltip'); + + tourManager.destroy(); + core.bus.off("show-effect", onShowEffect); + }); + QUnit.test("Click on invisible tip consumes it", async function (assert) { assert.expect(5);