From 46bc0b110e76a542d056c754bd0c6f098b28ab41 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Tue, 15 Jun 2021 13:08:20 +0000 Subject: [PATCH] [FIX] web_tour: warning during tip consumption test Tip consumption is an RPC request. Because the test did not mock the model or RPC, a warning would be triggered by the mock server. * update `createTourManager` to forward parameters outside its very own to the mock environment setup * pass in a `data` to set up our model, including `fields` because for some reason the default RPC mocking is quite cross when a model doesn't have fields --- addons/web_tour/static/tests/tour_manager_tests.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/addons/web_tour/static/tests/tour_manager_tests.js b/addons/web_tour/static/tests/tour_manager_tests.js index 26ebaeb398c..b4e994733ad 100644 --- a/addons/web_tour/static/tests/tour_manager_tests.js +++ b/addons/web_tour/static/tests/tour_manager_tests.js @@ -14,16 +14,17 @@ odoo.define('web_tour.tour_manager_tests', async function (require) { /** * Create a widget and a TourManager instance with a list of given Tour objects. - * @see TourManager.register() for more details on the Tours registry system. - * @param {Object} params + * @see `TourManager.register()` for more details on the Tours registry system. + * @param {Object} params aside from the parameters defined below, passed + * to {@see addMockEnvironment}. * @param {string[]} [params.consumed_tours] - * @param {boolean} [params.debug] + * @param {boolean} [params.debug] also passed along * @param {boolean} [params.disabled] * @param {string} params.template inner HTML content of the widget * @param {Object[]} params.tours { {string} name, {Object} option, {Object[]} steps } */ - async function createTourManager({ consumed_tours, debug, disabled, template, tours }) { - const parent = await testUtils.createParent({ debug }); + async function createTourManager({ consumed_tours, disabled, template, tours, ...params }) { + const parent = await testUtils.createParent(params); const tourManager = new TourManager(parent, consumed_tours, disabled); tourManager.running_step_delay = 0; for (const { name, options, steps } of tours) { @@ -34,7 +35,7 @@ odoo.define('web_tour.tour_manager_tests', async function (require) { tourManager.destroy = _destroy; parent.destroy(); }; - await parent.prependTo(testUtils.prepareTarget(debug)); + await parent.prependTo(testUtils.prepareTarget(params.debug)); parent.el.innerHTML = template; await tourManager._register_all(true); // Wait for possible tooltips to be loaded and appended. @@ -75,6 +76,7 @@ odoo.define('web_tour.tour_manager_tests', async function (require) { assert.expect(5); const tourManager = await createTourManager({ + data: { 'web_tour.tour': { fields: {}, consume() {} } }, template: `