Debian Codegraph @

addons/test_website/static/tests/tours/website_field_sanitize.js

raw
1 import { clickOnSave, registerWebsitePreviewTour } from "@website/js/tours/tour_utils";
2
3 // As admin, add a YouTube video iframe in a `sanitize_overridable` HTML field.
4 registerWebsitePreviewTour("website_designer_iframe_video",
5 {
6 url: "/test_website/model_item/1",
7 edition: true,
8 },
9 () => [
10 {
11 content: "As administrator, add a video block to the description field",
12 trigger: `.o_block_tab:not(.o_we_ongoing_insertion) #snippet_content .o_snippet[name="Video"].o_draggable .o_snippet_thumbnail`,
13 run: "drag_and_drop :iframe .o_test_website_description",
14 },
15 {
16 content: "Add a video URL",
17 trigger: ".o_select_media_dialog #o_video_text",
18 run: `edit https://www.youtube.com/watch?v=G8b4UZIcTfg`,
19 },
20 {
21 content: "Add the video",
22 trigger: ".o_select_media_dialog .modal-footer .btn-primary",
23 run: "click",
24 },
25 ...clickOnSave(),
26 {
27 content: "Check that the video was correctly saved",
28 trigger: ":iframe .media_iframe_video[data-oe-expression*='G8b4UZIcTfg']",
29 run: () => {},
30 },
31 ]
32 );
33
34 // Check that a restricted editor can edit the field content (even with
35 // a video iframe).
36 registerWebsitePreviewTour("website_restricted_editor_iframe_video", {
37 url: "/test_website/model_item/1",
38 edition: true,
39 },
40 () => [
41 {
42 content: "Check that the video iframe was correctly restored after saving the changes",
43 trigger:
44 ":iframe [data-oe-field]:not([data-oe-sanitize-prevent-edition]) .media_iframe_video[data-oe-expression*='G8b4UZIcTfg']",
45 run: () => {},
46 },
47 {
48 content: "As a restricted editor, edit the HTML field content",
49 trigger: ":iframe .o_test_website_description",
50 run: "editor I can still edit the HTML field",
51 },
52 ...clickOnSave(),
53 {
54 content: "Check that the HTML content (with a video iframe) was correctly updated",
55 trigger:
56 ":iframe .o_test_website_description:contains('I can still edit the HTML field')",
57 run: () => {},
58 },
59 ]
60 );