Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 7 additions & 22 deletions addons/html_builder/static/tests/block_tab/snippet_groups.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
defineWebsiteModels,
getSnippetStructure,
setupWebsiteBuilder,
setupWebsiteBuilderWithDummySnippet,
} from "../helpers";

defineWebsiteModels();
Expand Down Expand Up @@ -370,27 +371,7 @@ test("drag&drop snippet structure", async () => {
});

test("cancel snippet drag & drop over sidebar", async () => {
const snippetsDescription = (withName = false) => {
const name = "Test";
return [
{
name: name,
groupName: "a",
content: getBasicSection("Yop", { name: withName ? name : "" }),
},
];
};

const { getEditableContent } = await setupWebsiteBuilder("", {
snippets: {
snippet_groups: [
'<div name="A" data-oe-thumbnail="a.svg" data-oe-snippet-id="123" data-o-snippet-group="a"><section data-snippet="s_snippet_group"></section></div>',
],
snippet_structure: snippetsDescription().map((snippetDesc) =>
getSnippetStructure(snippetDesc)
),
},
});
const { getEditableContent } = await setupWebsiteBuilderWithDummySnippet();
const initialDropZone = `<div class="oe_drop_zone oe_insert" data-editor-message="DRAG BUILDING BLOCKS HERE"></div>`;
const editableContent = getEditableContent();
expect(editableContent).toHaveInnerHTML(initialDropZone);
Expand All @@ -401,7 +382,11 @@ test("cancel snippet drag & drop over sidebar", async () => {

await moveTo(".o-website-builder_sidebar");
expect(editableContent).toHaveInnerHTML(unformat(initialDropZone));
await drop();
// Specifying an explicit target should not be needed, but the test
// sometimes fails, probably because the snippet is partially touching the
// iframe. We drop on the "Save" button to be as far as possible from the
// iframe.
await drop("button[data-action=save]");
expect(".o_add_snippet_dialog").toHaveCount(0);
expect(editableContent).toHaveInnerHTML(unformat(initialDropZone));
});