-
Notifications
You must be signed in to change notification settings - Fork 23.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IMP] website: add tests for all snippets (drag and drop)
Image gallery snippet when dropped is throwing a traceback. This lead to the editor not usable anymore, as any JS error will prevent any further action (no JS will work anymore). This introduce a test that will drag and drop every snippet in a page and click on it to load its settings in the right panel. Note that it will remove the snippet before drag & dropping the next one, as having too many snippet will impact the perf, even killing the browser entirely if there is a lot. task-2604383 closes #74135 Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
- Loading branch information
Showing
2 changed files
with
105 additions
and
0 deletions.
There are no files selected for viewing
94 changes: 94 additions & 0 deletions
94
addons/website/static/tests/tours/snippets_all_drag_and_drop.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
odoo.define("website.tour.snippets_all_drag_and_drop", async function (require) { | ||
"use strict"; | ||
|
||
const tour = require("web_tour.tour"); | ||
|
||
let snippetsNames = (new URL(document.location.href)).searchParams.get('snippets_names') || ''; | ||
snippetsNames = snippetsNames.split(','); | ||
let steps = []; | ||
let n = 0; | ||
for (const snippet of snippetsNames) { | ||
n++; | ||
const snippetSteps = [{ | ||
content: `Drop ${snippet} snippet [${n}/${snippetsNames.length}]`, | ||
trigger: `#oe_snippets .oe_snippet:has( > [data-snippet='${snippet}']) .oe_snippet_thumbnail`, | ||
run: "drag_and_drop #wrap", | ||
}, { | ||
content: `Edit ${snippet} snippet`, | ||
trigger: `#wrap.o_editable [data-snippet='${snippet}']`, | ||
}, { | ||
content: `check ${snippet} setting are loaded, wait panel is visible`, | ||
trigger: ".o_we_customize_panel", | ||
run: function () {}, // it's a check | ||
}, { | ||
content: `Remove the ${snippet} snippet`, // Avoid bad perf if many snippets | ||
trigger: "we-button.oe_snippet_remove:last" | ||
}, { | ||
content: `click on 'BLOCKS' tab (${snippet})`, | ||
trigger: ".o_we_add_snippet_btn", | ||
}]; | ||
|
||
if (snippet === 's_google_map') { | ||
snippetSteps.splice(1, 3, { | ||
content: 'Close API Key popup', | ||
trigger: ".modal-footer .btn-secondary", | ||
}); | ||
} else if (snippet === 's_popup') { | ||
snippetSteps[2]['in_modal'] = false; | ||
snippetSteps.splice(3, 2, { | ||
content: `Hide the ${snippet} popup`, | ||
trigger: ".s_popup_close", | ||
}); | ||
} else if (['s_newsletter_block', 's_newsletter_subscribe_form', 's_newsletter_subscribe_popup'].includes(snippet)) { | ||
snippetSteps.splice(1, 0, { | ||
content: `Confirm the ${snippet} popup`, | ||
trigger: `.modal-footer button.btn-primary`, | ||
}); | ||
} | ||
if (snippet === 's_newsletter_subscribe_popup') { | ||
snippetSteps.splice(3, 2, { | ||
content: `Hide the ${snippet} popup`, | ||
trigger: "button.close", | ||
}); | ||
} | ||
steps = steps.concat(snippetSteps); | ||
} | ||
|
||
tour.register("snippets_all_drag_and_drop", { | ||
test: true, | ||
}, [ | ||
{ | ||
content: "Ensure snippets are actually passed at the test.", | ||
trigger: "#oe_snippets", | ||
run: function () { | ||
// safety check, otherwise the test might "break" one day and | ||
// receive no steps. The test would then not test anything anymore | ||
// without us noticing it. | ||
if (steps.lenth < 280) { | ||
console.error("This test is not behaving as it should."); | ||
} | ||
}, | ||
}, | ||
// This first step is needed as it will be used later for inner snippets | ||
// Without this, it will dropped inside the footer and will need an extra | ||
// selector. | ||
{ | ||
content: "Drop s_text_image snippet", | ||
trigger: "#oe_snippets .oe_snippet:has( > [data-snippet='s_text_image']) .oe_snippet_thumbnail", | ||
run: "drag_and_drop #wrap" | ||
}, | ||
{ | ||
content: "Edit s_text_image snippet", | ||
trigger: "#wrap.o_editable [data-snippet='s_text_image']" | ||
}, | ||
{ | ||
content: "check setting are loaded, wait panel is visible", | ||
trigger: ".o_we_customize_panel" | ||
}, | ||
{ | ||
content: "click on 'BLOCKS' tab", | ||
trigger: ".o_we_add_snippet_btn" | ||
}, | ||
].concat(steps) | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters