From 28e4f491faebfc0642d1945f03a6c38ce66c45b8 Mon Sep 17 00:00:00 2001
From: Xavier Morel <xmo@odoo.com>
Date: Thu, 16 Jan 2020 14:42:26 +0000
Subject: [PATCH] [FIX] web_tour: never run default action for a tour's final
 step

A number of steps have a last step which may trigger some async
operation (e.g. reopen a menu, close a modal, ...).

This async operation can span over the cleanup of the browser, in
which case its callback will try running in a seriously broken state.

It's simpler to just assume that the last step's side-effects should
not matter to the test's success and interpret it as a "wait" (used
only for its trigger to wait until a proper end-state).

There was a question of whether we should ignore all final actions,
all non-function actions, or all implicit (default) actions. The
latter seems the least disruptive as hopefully developers having
provided a `run` in the final action have a good use case for it.
---
 addons/web_tour/static/src/js/tour_manager.js | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/addons/web_tour/static/src/js/tour_manager.js b/addons/web_tour/static/src/js/tour_manager.js
index d117c24f9192..cf95b3516c63 100644
--- a/addons/web_tour/static/src/js/tour_manager.js
+++ b/addons/web_tour/static/src/js/tour_manager.js
@@ -414,11 +414,14 @@ return core.Class.extend(mixins.EventDispatcherMixin, ServicesMixin, {
             var action_helper = new RunningTourActionHelper(tip.widget);
             do_before_unload(self._consume_tip.bind(self, tip, tour_name));
 
+            var tour = self.tours[tour_name];
             if (typeof tip.run === "function") {
                 tip.run.call(tip.widget, action_helper);
             } else if (tip.run !== undefined) {
                 var m = tip.run.match(/^([a-zA-Z0-9_]+) *(?:\(? *(.+?) *\)?)?$/);
                 action_helper[m[1]](m[2]);
+            } else if (tour.current_step === tour.steps.length - 1) {
+                console.log('Tour %s: ignoring action (auto) of last step', tour_name);
             } else {
                 action_helper.auto();
             }
-- 
GitLab