| 1 |
/** @odoo-module **/ |
| 2 |
|
| 3 |
import { patch } from "@web/core/utils/patch"; |
| 4 |
import { VideoSelector } from "@html_editor/main/media/media_dialog/video_selector"; |
| 5 |
import { insertSnippet, registerWebsitePreviewTour } from "@website/js/tours/tour_utils"; |
| 6 |
|
| 7 |
registerWebsitePreviewTour( |
| 8 |
"snippet_background_video", |
| 9 |
{ |
| 10 |
url: "/", |
| 11 |
edition: true, |
| 12 |
}, () => [ |
| 13 |
{ |
| 14 |
trigger: "body", |
| 15 |
run: function () { |
| 16 |
// Patch the VideoDialog so that it does not do external calls |
| 17 |
// during the test (note that we don't unpatch but as the patch |
| 18 |
// is only done after the execution of a test_website test, it |
| 19 |
// is acceptable). |
| 20 |
// TODO we should investigate to rather mock the external calls, |
| 21 |
// maybe not using a tour. Probably easier to discuss when the |
| 22 |
// new OWL editor will have been implemented. |
| 23 |
patch(VideoSelector.prototype, { |
| 24 |
async prepareVimeoPreviews() { |
| 25 |
// Ignore the super call and directly push a fake video |
| 26 |
this.state.vimeoPreviews.push({ |
| 27 |
id: 1, |
| 28 |
// Those lead to 404 but it's fine for the test |
| 29 |
thumbnailSrc: "/hello/world.jpg", |
| 30 |
src: "/hello/world.mp4", |
| 31 |
}); |
| 32 |
}, |
| 33 |
async _getVideoURLData(src, options) { |
| 34 |
if (src === '/hello/world.mp4') { |
| 35 |
return { |
| 36 |
'platform': 'vimeo', |
| 37 |
'embed_url': 'about:blank', |
| 38 |
}; |
| 39 |
} |
| 40 |
return super._getVideoURLData(...arguments); |
| 41 |
}, |
| 42 |
}); |
| 43 |
}, |
| 44 |
}, |
| 45 |
...insertSnippet({ |
| 46 |
id: "s_text_block", |
| 47 |
name: "Text", |
| 48 |
groupName: "Text", |
| 49 |
}), |
| 50 |
{ |
| 51 |
content: "Click on the text block.", |
| 52 |
trigger: ":iframe #wrap section.s_text_block", |
| 53 |
run: "click", |
| 54 |
}, |
| 55 |
{ |
| 56 |
content: "Click on the 'Background Video' button option.", |
| 57 |
trigger: "button[data-action-id='toggleBgVideo']", |
| 58 |
run: "click", |
| 59 |
}, |
| 60 |
{ |
| 61 |
content: "Click on the first sample video in the modal.", |
| 62 |
trigger: "#video-suggestion .o_sample_video", |
| 63 |
run: "click", |
| 64 |
}, |
| 65 |
{ |
| 66 |
content: "Check the video is select.", |
| 67 |
trigger: "textarea.is-valid", |
| 68 |
}, |
| 69 |
{ |
| 70 |
content: "Click on the 'Add' button to apply the selected video as the background.", |
| 71 |
trigger: ".modal-footer button.btn-primary", |
| 72 |
run: "click", |
| 73 |
}, |
| 74 |
{ |
| 75 |
content: "Verify that the video is set as the background of the snippet.", |
| 76 |
trigger: ":iframe #wrap section.o_background_video", |
| 77 |
}, |
| 78 |
{ |
| 79 |
content: "Check that the video container is not editable.", |
| 80 |
trigger: ":iframe #wrap section.o_background_video > .o_bg_video_container[contenteditable=false]", |
| 81 |
}, |
| 82 |
] |
| 83 |
); |