|
| 1 | +odoo.define("website.tour.snippets_all_drag_and_drop", async function (require) { |
| 2 | +"use strict"; |
| 3 | + |
| 4 | +const tour = require("web_tour.tour"); |
| 5 | + |
| 6 | +let snippetsNames = (new URL(document.location.href)).searchParams.get('snippets_names') || ''; |
| 7 | +snippetsNames = snippetsNames.split(','); |
| 8 | +let steps = []; |
| 9 | +let n = 0; |
| 10 | +for (const snippet of snippetsNames) { |
| 11 | + n++; |
| 12 | + const snippetSteps = [{ |
| 13 | + content: `Drop ${snippet} snippet [${n}/${snippetsNames.length}]`, |
| 14 | + trigger: `#oe_snippets .oe_snippet:has( > [data-snippet='${snippet}']) .oe_snippet_thumbnail`, |
| 15 | + run: "drag_and_drop #wrap", |
| 16 | + }, { |
| 17 | + content: `Edit ${snippet} snippet`, |
| 18 | + trigger: `#wrap.o_editable [data-snippet='${snippet}']`, |
| 19 | + }, { |
| 20 | + content: `check ${snippet} setting are loaded, wait panel is visible`, |
| 21 | + trigger: ".o_we_customize_panel", |
| 22 | + run: function () {}, // it's a check |
| 23 | + }, { |
| 24 | + content: `Remove the ${snippet} snippet`, // Avoid bad perf if many snippets |
| 25 | + trigger: "we-button.oe_snippet_remove:last" |
| 26 | + }, { |
| 27 | + content: `click on 'BLOCKS' tab (${snippet})`, |
| 28 | + trigger: ".o_we_add_snippet_btn", |
| 29 | + }]; |
| 30 | + |
| 31 | + if (snippet === 's_google_map') { |
| 32 | + snippetSteps.splice(1, 3, { |
| 33 | + content: 'Close API Key popup', |
| 34 | + trigger: ".modal-footer .btn-secondary", |
| 35 | + }); |
| 36 | + } else if (snippet === 's_popup') { |
| 37 | + snippetSteps[2]['in_modal'] = false; |
| 38 | + snippetSteps.splice(3, 2, { |
| 39 | + content: `Hide the ${snippet} popup`, |
| 40 | + trigger: ".s_popup_close", |
| 41 | + }); |
| 42 | + } else if (['s_newsletter_block', 's_newsletter_subscribe_form', 's_newsletter_subscribe_popup'].includes(snippet)) { |
| 43 | + snippetSteps.splice(1, 0, { |
| 44 | + content: `Confirm the ${snippet} popup`, |
| 45 | + trigger: `.modal-footer button.btn-primary`, |
| 46 | + }); |
| 47 | + } |
| 48 | + if (snippet === 's_newsletter_subscribe_popup') { |
| 49 | + snippetSteps.splice(3, 2, { |
| 50 | + content: `Hide the ${snippet} popup`, |
| 51 | + trigger: "button.close", |
| 52 | + }); |
| 53 | + } |
| 54 | + steps = steps.concat(snippetSteps); |
| 55 | +} |
| 56 | + |
| 57 | +tour.register("snippets_all_drag_and_drop", { |
| 58 | + test: true, |
| 59 | +}, [ |
| 60 | + { |
| 61 | + content: "Ensure snippets are actually passed at the test.", |
| 62 | + trigger: "#oe_snippets", |
| 63 | + run: function () { |
| 64 | + // safety check, otherwise the test might "break" one day and |
| 65 | + // receive no steps. The test would then not test anything anymore |
| 66 | + // without us noticing it. |
| 67 | + if (steps.lenth < 280) { |
| 68 | + console.error("This test is not behaving as it should."); |
| 69 | + } |
| 70 | + }, |
| 71 | + }, |
| 72 | + // This first step is needed as it will be used later for inner snippets |
| 73 | + // Without this, it will dropped inside the footer and will need an extra |
| 74 | + // selector. |
| 75 | + { |
| 76 | + content: "Drop s_text_image snippet", |
| 77 | + trigger: "#oe_snippets .oe_snippet:has( > [data-snippet='s_text_image']) .oe_snippet_thumbnail", |
| 78 | + run: "drag_and_drop #wrap" |
| 79 | + }, |
| 80 | + { |
| 81 | + content: "Edit s_text_image snippet", |
| 82 | + trigger: "#wrap.o_editable [data-snippet='s_text_image']" |
| 83 | + }, |
| 84 | + { |
| 85 | + content: "check setting are loaded, wait panel is visible", |
| 86 | + trigger: ".o_we_customize_panel" |
| 87 | + }, |
| 88 | + { |
| 89 | + content: "click on 'BLOCKS' tab", |
| 90 | + trigger: ".o_we_add_snippet_btn" |
| 91 | + }, |
| 92 | +].concat(steps) |
| 93 | +); |
| 94 | +}); |
0 commit comments