| 1 |
import { patch } from "@web/core/utils/patch"; |
| 2 |
import { VideoSelector } from "@html_editor/main/media/media_dialog/video_selector"; |
| 3 |
import { |
| 4 |
changeOption, |
| 5 |
insertSnippet, |
| 6 |
registerWebsitePreviewTour, |
| 7 |
} from '@website/js/tours/tour_utils'; |
| 8 |
|
| 9 |
const VIDEO_URL = 'https://www.youtube.com/watch?v=Dpq87YCHmJc'; |
| 10 |
|
| 11 |
/** |
| 12 |
* The purpose of this tour is to check the media replacement flow. |
| 13 |
*/ |
| 14 |
registerWebsitePreviewTour('test_replace_media', { |
| 15 |
url: '/', |
| 16 |
edition: true, |
| 17 |
}, () => [ |
| 18 |
{ |
| 19 |
trigger: "body", |
| 20 |
run: function () { |
| 21 |
// Patch the VideoDialog so that it does not do external calls |
| 22 |
// during the test (note that we don't unpatch but as the patch |
| 23 |
// is only done after the execution of a test_website test and |
| 24 |
// specific to an URL only, it is acceptable). |
| 25 |
// TODO if we ever give the possibility to upload its own videos, |
| 26 |
// this won't be necessary anymore. |
| 27 |
patch(VideoSelector.prototype, { |
| 28 |
async _getVideoURLData(src, options) { |
| 29 |
if (src === VIDEO_URL || src === 'about:blank') { |
| 30 |
return {platform: 'youtube', embed_url: 'about:blank'}; |
| 31 |
} |
| 32 |
return super._getVideoURLData(...arguments); |
| 33 |
}, |
| 34 |
}); |
| 35 |
}, |
| 36 |
}, |
| 37 |
...insertSnippet({ |
| 38 |
name: 'Title - Image', |
| 39 |
id: 's_picture', |
| 40 |
groupName: "Images", |
| 41 |
}), |
| 42 |
{ |
| 43 |
content: "select image", |
| 44 |
trigger: ":iframe .s_picture figure img", |
| 45 |
run: "click", |
| 46 |
}, |
| 47 |
{ |
| 48 |
content: "ensure image size is displayed", |
| 49 |
trigger: ".o_customize_tab [data-container-title='Image'] .options-container-header:contains('kb')", |
| 50 |
}, |
| 51 |
changeOption("Image", "[data-label='Shape'] .dropdown-toggle"), |
| 52 |
{ |
| 53 |
content: "Click on the first image shape", |
| 54 |
trigger: "button[data-action-id='setImageShape']", |
| 55 |
run: "click", |
| 56 |
}, |
| 57 |
{ |
| 58 |
content: "Open MediaDialog from an image", |
| 59 |
trigger: "button[data-action-id='replaceMedia']", |
| 60 |
run: "click", |
| 61 |
}, |
| 62 |
{ |
| 63 |
content: "select svg", |
| 64 |
trigger: ".o_select_media_dialog .o_button_area[aria-label='sample.svg']", |
| 65 |
run: "click", |
| 66 |
}, |
| 67 |
{ |
| 68 |
content: "ensure the svg does have a shape", |
| 69 |
trigger: ":iframe .s_picture figure img[data-shape]", |
| 70 |
}, |
| 71 |
{ |
| 72 |
content: "ensure image size is displayed", |
| 73 |
trigger: ".o_customize_tab [data-container-title='Image'] span[title='Size']", |
| 74 |
}, |
| 75 |
{ |
| 76 |
content: "replace image", |
| 77 |
trigger: "button[data-action-id='replaceMedia']", |
| 78 |
run: "click", |
| 79 |
}, |
| 80 |
{ |
| 81 |
content: "go to pictogram tab", |
| 82 |
trigger: ".o_select_media_dialog .nav-link:contains('Icons')", |
| 83 |
run: "click", |
| 84 |
}, |
| 85 |
{ |
| 86 |
content: "select an icon", |
| 87 |
trigger: ".o_select_media_dialog:has(.nav-link.active:contains('Icons')) .tab-content span.fa-heart", |
| 88 |
run: "click", |
| 89 |
}, |
| 90 |
{ |
| 91 |
content: "ensure icon block is displayed", |
| 92 |
trigger: ".o_customize_tab [data-container-title='Icon']", |
| 93 |
}, |
| 94 |
{ |
| 95 |
content: "select footer", |
| 96 |
trigger: ":iframe footer", |
| 97 |
run: "click", |
| 98 |
}, |
| 99 |
{ |
| 100 |
content: "select icon", |
| 101 |
trigger: ":iframe .s_picture figure span.fa-heart", |
| 102 |
run: "click", |
| 103 |
}, |
| 104 |
{ |
| 105 |
content: "ensure icon block is still displayed", |
| 106 |
trigger: ".o_customize_tab [data-container-title='Icon']", |
| 107 |
}, |
| 108 |
{ |
| 109 |
content: "replace icon", |
| 110 |
trigger: "button[data-action-id='replaceMedia']", |
| 111 |
run: "click", |
| 112 |
}, |
| 113 |
{ |
| 114 |
content: "go to video tab", |
| 115 |
trigger: ".o_select_media_dialog .nav-link:contains('Video')", |
| 116 |
run: "click", |
| 117 |
}, |
| 118 |
{ |
| 119 |
content: "enter a video URL", |
| 120 |
trigger: ".o_select_media_dialog #o_video_text", |
| 121 |
// Design your first web page. |
| 122 |
run: `edit ${VIDEO_URL}`, |
| 123 |
}, |
| 124 |
{ |
| 125 |
content: "wait for preview to appear", |
| 126 |
// "about:blank" because the VideoWidget was patched at the start of this tour |
| 127 |
trigger: ".o_select_media_dialog div.media_iframe_video [src='about:blank']:iframe body", |
| 128 |
}, |
| 129 |
{ |
| 130 |
content: "confirm selection", |
| 131 |
trigger: ".o_select_media_dialog .modal-footer .btn-primary", |
| 132 |
run: "click", |
| 133 |
}, |
| 134 |
{ |
| 135 |
content: "ensure video option block is displayed", |
| 136 |
trigger: ".o_customize_tab [data-container-title='Video']", |
| 137 |
}, |
| 138 |
{ |
| 139 |
content: "replace image", |
| 140 |
trigger: ".btn-success[data-action-id='replaceMedia']", |
| 141 |
run: "click", |
| 142 |
}, |
| 143 |
{ |
| 144 |
content: "go to pictogram tab", |
| 145 |
trigger: ".o_select_media_dialog .nav-link:contains('Icons')", |
| 146 |
run: "click", |
| 147 |
}, |
| 148 |
{ |
| 149 |
content: "select an icon", |
| 150 |
trigger: ".o_select_media_dialog:has(.nav-link.active:contains('Icons')) .tab-content span.fa-heart", |
| 151 |
run: "click", |
| 152 |
}, |
| 153 |
{ |
| 154 |
content: "ensure icon block is displayed", |
| 155 |
trigger: ".o_customize_tab [data-container-title='Icon']", |
| 156 |
}, |
| 157 |
{ |
| 158 |
content: "select footer", |
| 159 |
trigger: ":iframe footer", |
| 160 |
run: "click", |
| 161 |
}, |
| 162 |
{ |
| 163 |
content: "select icon", |
| 164 |
trigger: ":iframe .s_picture figure span.fa-heart", |
| 165 |
run: "click", |
| 166 |
}, |
| 167 |
{ |
| 168 |
content: "ensure icon block is still displayed", |
| 169 |
trigger: ".o_customize_tab [data-container-title='Icon']", |
| 170 |
}, |
| 171 |
]); |