Previously, when saving a custom snippet, the outerHTML of the snippet was naively read directly and saved as a new custom snippet. Unfortunately this completely bypasses all cleanup mechanisms that we have before saving, such as stopping the public widgets, or creating attachments for cropped or optimized images. This would result in weird bugs, where public widgets would appear twice when dropping a custom snippet containing one, as well as the creating a new attachment for any image that was optimized or cropped before saving the custom snippet every time it was dropped in the page again. Unfortunately there is no good mechanism for an option to ask the editor to clean the DOM without actually saving it, as a temporary measure, the snippet-save option will instead save the whole page (which will clean up the DOM) and save the custom snippet after the save, before refreshing the page and reopening the editor, not unlike some theme options. task-2341612 closes odoo/odoo#64166 X-original-commit: 38569777935a7939182f49ca978d98f4079e8f2f Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
101 lines
3.0 KiB
JavaScript
101 lines
3.0 KiB
JavaScript
odoo.define('test_website.custom_snippets', function (require) {
|
|
'use strict';
|
|
|
|
var tour = require('web_tour.tour');
|
|
|
|
/**
|
|
* The purpose of this tour is to check the custom snippets flow:
|
|
*
|
|
* -> go to edit mode
|
|
* -> drag a banner into page content
|
|
* -> customize banner (set text)
|
|
* -> save banner as custom snippet
|
|
* -> confirm name (TODO: remove when implicit default name feature is implemented)
|
|
* -> go to blocks
|
|
* -> ensure custom snippet is available
|
|
* -> drag custom snippet
|
|
* -> ensure block appears as banner
|
|
* -> ensure block appears as custom banner
|
|
* -> delete custom snippet
|
|
* -> confirm delete
|
|
* -> ensure it was deleted
|
|
*/
|
|
|
|
tour.register('test_custom_snippet', {
|
|
url: '/',
|
|
test: true
|
|
}, [
|
|
{
|
|
content: "enter edit mode",
|
|
trigger: "a[data-action=edit]"
|
|
},
|
|
{
|
|
content: "drop a snippet",
|
|
trigger: "#oe_snippets .oe_snippet[name='Banner'] .oe_snippet_thumbnail:not(.o_we_already_dragging)",
|
|
extra_trigger: "body.editor_enable.editor_has_snippets",
|
|
moveTrigger: ".oe_drop_zone",
|
|
run: "drag_and_drop #wrap",
|
|
},
|
|
{
|
|
content: "customize snippet",
|
|
trigger: "#wrapwrap .s_banner h1",
|
|
run: "text",
|
|
consumeEvent: "input",
|
|
},
|
|
{
|
|
content: "save custom snippet",
|
|
trigger: ".snippet-option-SnippetSave we-button",
|
|
},
|
|
{
|
|
content: "confirm save name",
|
|
trigger: ".modal-dialog button span:contains('Save')",
|
|
},
|
|
{
|
|
content: "confirm reload",
|
|
trigger: ".modal-dialog button span:contains('Save and Reload')",
|
|
},
|
|
{
|
|
content: "go to blocks",
|
|
trigger: ".o_we_add_snippet_btn",
|
|
},
|
|
{
|
|
content: "ensure custom snippet appeared",
|
|
trigger: "#oe_snippets .oe_snippet[name='Custom Banner']",
|
|
run: function() {}, // check
|
|
},
|
|
{
|
|
content: "drop custom snippet",
|
|
trigger: ".oe_snippet[name='Custom Banner'] .oe_snippet_thumbnail:not(.o_we_already_dragging)",
|
|
extra_trigger: "body.editor_enable.editor_has_snippets",
|
|
moveTrigger: ".oe_drop_zone",
|
|
run: "drag_and_drop #wrap",
|
|
},
|
|
{
|
|
content: "ensure banner section exists",
|
|
trigger: "#wrap section[data-name='Banner']",
|
|
run: function() {}, // check
|
|
},
|
|
{
|
|
content: "ensure custom banner section exists",
|
|
trigger: "#wrap section[data-name='Custom Banner']",
|
|
run: function() {}, // check
|
|
},
|
|
{
|
|
content: "delete custom snippet",
|
|
trigger: ".oe_snippet[name='Custom Banner'] we-button.o_delete_btn",
|
|
extra_trigger: ".oe_snippet[name='Custom Banner'] .oe_snippet_thumbnail:not(.o_we_already_dragging)",
|
|
},
|
|
{
|
|
content: "confirm delete",
|
|
trigger: ".modal-dialog button:has(span:contains('Yes'))",
|
|
},
|
|
{
|
|
content: "ensure custom snippet disappeared",
|
|
trigger: "#oe_snippets",
|
|
extra_trigger: "#oe_snippets:not(:has(.oe_snippet[name='Custom Banner']))",
|
|
run: function() {}, // check
|
|
},
|
|
]);
|
|
|
|
});
|