[FIX] web_tour: tours should override with the saveAs option

Steps to reproduce
==================

- Enable the debug mode
- Use an odoo instance with the design-themes
- Click on the debug menu
- Click on Start tour

`OwlError: Got duplicate key in t-foreach: homepage`

Cause of the issue
==================

Website theme tours are registered here :
https://github.com/odoo/odoo/blob/5c01439cf20b2c0ca08d618df6f249617127e6d1/addons/website/static/src/js/tours/tour_utils.js#L348-L358

The saveAs option is used but since the owl refactor, it doesn't
override the previous tour.

There is a default homepage tour in the website addon and then one for
each theme.
There should only be one available at a time (same as in 16.2).
When selecting a new theme, the action button_choose_theme is called and
that ensures that only one theme can be installed at the same time.

opw-3595512

closes odoo/odoo#142350

X-original-commit: 69a361681c909cee5bf73a588dd4263bd49f1d5a
Related: odoo/design-themes#745
Signed-off-by: Francois Georis (fge) <fge@odoo.com>
Signed-off-by: Hubert Van De Walle <huvw@odoo.com>
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
This commit is contained in:
Hubert Van de Walle (huvw)
2023-11-21 20:06:43 +00:00
parent 83efa5993e
commit 66e43af468
2 changed files with 19 additions and 1 deletions
@@ -63,8 +63,9 @@ export const tourService = {
const tours = {};
const tourRegistry = registry.category("web_tour.tours");
function register(name, tour) {
name = tour.saveAs || name
tours[name] = {
name: tour.saveAs || name,
name,
get steps() {
if (typeof tour.steps === "function") {
return tour.steps().map((step) => {
@@ -101,6 +101,23 @@ QUnit.module("Tour service", (hooks) => {
assert.strictEqual(sortedTours[0].name, "Tour 3");
});
QUnit.test("override existing tour by using saveAs", async function (assert) {
registry.category("web_tour.tours")
.add("Tour 1", {
steps: () => [{ trigger: "#1" }],
saveAs: "homepage"
})
.add("Tour 2", {
steps: () => [{ trigger: "#2" }],
saveAs: "homepage"
});
const env = await makeTestEnv({});
const sortedTours = env.services.tour_service.getSortedTours();
assert.strictEqual(sortedTours.length, 1);
assert.deepEqual(sortedTours[0].steps, [{ shadow_dom: undefined, trigger: "#2" }]);
assert.deepEqual(sortedTours[0].name, "homepage");
});
QUnit.test("points to next step", async function (assert) {
registry.category("web_tour.tours").add("tour1", {
sequence: 10,