diff --git a/addons/html_builder/static/src/snippets/snippet_service.js b/addons/html_builder/static/src/snippets/snippet_service.js
index e577ab0a69ec8..12ba2cddab5c0 100644
--- a/addons/html_builder/static/src/snippets/snippet_service.js
+++ b/addons/html_builder/static/src/snippets/snippet_service.js
@@ -156,9 +156,9 @@ export class SnippetModel extends Reactive {
this.orm.silent
.call("ir.ui.view", "render_public_asset", [this.snippetsName, {}], { context })
.then((html) => {
- const snippetsDocument = new DOMParser().parseFromString(html, "text/html");
- this.computeSnippetTemplates(snippetsDocument);
- this.setSnippetName(snippetsDocument);
+ this.snippetsDocument = new DOMParser().parseFromString(html, "text/html");
+ this.computeSnippetTemplates(this.snippetsDocument);
+ this.setSnippetName(this.snippetsDocument);
resolve();
});
});
@@ -274,6 +274,13 @@ export class SnippetModel extends Reactive {
return;
}
snippet.title = newName;
+ for (const snippetEl of this.snippetsDocument.body.querySelectorAll("snippets#snippet_custom > *")) {
+ if (snippetEl.getAttribute("data-oe-snippet-key") === snippet.key) {
+ snippetEl.setAttribute("name", newName);
+ snippetEl.children[0].dataset["name"] = newName;
+ }
+ }
+
await this.orm.call("ir.ui.view", "rename_snippet", [], {
name: newName,
view_id: snippet.viewId,
diff --git a/addons/test_website/static/tests/tours/custom_snippets.js b/addons/test_website/static/tests/tours/custom_snippets.js
index ec6395526b009..56b67d80cab35 100644
--- a/addons/test_website/static/tests/tours/custom_snippets.js
+++ b/addons/test_website/static/tests/tours/custom_snippets.js
@@ -35,17 +35,22 @@ registerWebsitePreviewTour('test_custom_snippet', {
},
{
content: "Save custom snippet",
- trigger: ".snippet-option-SnippetSave we-button",
+ trigger: "button.oe_snippet_save",
run: "click",
},
{
- content: "Confirm reload",
- trigger: ".modal-dialog button:contains('Save and Reload')",
+ content: "Confirm Save",
+ trigger: ".modal-dialog button:contains('Save')",
+ run: "click",
+ },
+ {
+ content: "Click on Blocks",
+ trigger: ".o-snippets-tabs button[data-name='blocks']",
run: "click",
},
{
content: "Click on the Custom category block",
- trigger: "#oe_snippets .oe_snippet[name='Custom'].o_we_draggable .oe_snippet_thumbnail",
+ trigger: ".o-snippets-menu .o_snippet[name='Custom'].o_draggable .o_snippet_thumbnail_area",
run: "click",
},
{
@@ -54,22 +59,22 @@ registerWebsitePreviewTour('test_custom_snippet', {
},
{
content: "Rename custom snippet",
- trigger: ":iframe .o_custom_snippet_wrap > .o_custom_snippet_edit > button",
+ trigger: ":iframe .o_snippet_preview_wrap[data-snippet-id^='s_banner_'] + .o_custom_snippet_edit > button.fa-pencil",
run: "click",
},
{
content: "Set name",
- trigger: ".o_rename_custom_snippet_dialog input[id='customSnippetName']",
+ trigger: ".modal-dialog input#inputConfirmation",
run: "edit Bruce Banner",
},
{
content: "Confirm rename",
- trigger: ".o_rename_custom_snippet_dialog footer .btn-primary",
+ trigger: ".modal-dialog footer .btn-primary",
run: "click",
},
{
content: "Click on the 'Bruce Banner' snippet",
- trigger: ":iframe .o_snippet_preview_wrap[data-snippet-id^='s_banner_']:has(section[data-name='Bruce Banner'])",
+ trigger: ":iframe .o_snippet_preview_wrap[data-snippet-id^='s_banner_'] section[data-name='Bruce Banner']",
run: "click",
},
{
@@ -82,12 +87,12 @@ registerWebsitePreviewTour('test_custom_snippet', {
},
{
content: "Click on the Custom category block",
- trigger: "#oe_snippets .oe_snippet[name='Custom'].o_we_draggable .oe_snippet_thumbnail",
+ trigger: ".o-snippets-menu .o_snippet[name='Custom'].o_draggable .o_snippet_thumbnail_area",
run: "click",
},
{
content: "Delete custom snippet",
- trigger: ":iframe .o_custom_snippet_wrap > .o_custom_snippet_edit > button + button",
+ trigger: ":iframe .o_snippet_preview_wrap + .o_custom_snippet_edit > button + button.fa-trash",
run: "click",
},
{
@@ -97,6 +102,6 @@ registerWebsitePreviewTour('test_custom_snippet', {
},
{
content: "Ensure custom snippet disappeared",
- trigger: ":iframe .o_add_snippets_preview:not(:has(section[data-name='Bruce Banner']))",
+ trigger: ":iframe .o_add_snippets_preview:not(:has([data-name='Bruce Banner']))",
},
]);
diff --git a/addons/test_website/tests/test_custom_snippet.py b/addons/test_website/tests/test_custom_snippet.py
index 223efc5622894..b29bc706117d3 100644
--- a/addons/test_website/tests/test_custom_snippet.py
+++ b/addons/test_website/tests/test_custom_snippet.py
@@ -3,10 +3,7 @@
import odoo.tests
from odoo.tools import mute_logger
-import unittest
-# TODO master-mysterious-egg fix error
-@unittest.skip("prepare mysterious-egg for merging")
@odoo.tests.common.tagged('post_install', '-at_install')
class TestCustomSnippet(odoo.tests.HttpCase):