Skip to content

[FIX] website: adapt test_custom_snippet tour #4595

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: master-mysterious-egg
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions addons/html_builder/static/src/snippets/snippet_service.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,9 @@ export class SnippetModel extends Reactive {
view_id: snippet.viewId,
template_key: this.snippetsName,
});
// Reload snippet to have updated name.
this.loadProm = null;
await this.load();
}

setSnippetName(snippetsDocument) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,22 +129,7 @@ export class VideoSelector extends Component {
}
});

onMounted(async () => {
await Promise.all(
this.props.vimeoPreviewIds.map(async (videoId) => {
const { thumbnail_url: thumbnailSrc } = await this.http.get(
`https://vimeo.com/api/oembed.json?url=http%3A//vimeo.com/${encodeURIComponent(
videoId
)}`
);
this.state.vimeoPreviews.push({
id: videoId,
thumbnailSrc,
src: `https://player.vimeo.com/video/${encodeURIComponent(videoId)}`,
});
})
);
});
onMounted(async () => this.prepareVimeoPreviews());

useAutofocus();

Expand Down Expand Up @@ -275,4 +260,24 @@ export class VideoSelector extends Component {
return div;
});
}

/**
* Based on the config vimeo ids, prepare the vimeo previews.
*/
async prepareVimeoPreviews() {
await Promise.all(
this.props.vimeoPreviewIds.map(async (videoId) => {
const { thumbnail_url: thumbnailSrc } = await this.http.get(
`https://vimeo.com/api/oembed.json?url=http%3A//vimeo.com/${encodeURIComponent(
videoId
)}`
);
this.state.vimeoPreviews.push({
id: videoId,
thumbnailSrc,
src: `https://player.vimeo.com/video/${encodeURIComponent(videoId)}`,
});
})
);
}
}
2 changes: 2 additions & 0 deletions addons/html_editor/static/src/main/media/media_plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ export class MediaPlugin extends Plugin {
extraTabs: this.getResource("media_dialog_extra_tabs").filter(
(tab) => !(tab.id === "DOCUMENTS" && params.noDocuments)
),
vimeoPreviewIds: ["528686125", "430330731", "509869821", "397142251", "763851966", "486931161",
"499761556", "392935303", "728584384", "865314310", "511727912", "466830211"],
...this.config.mediaModalParams,
...params,
});
Expand Down
21 changes: 13 additions & 8 deletions addons/test_website/static/tests/tours/custom_snippets.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,22 @@ registerWebsitePreviewTour('test_custom_snippet', {
},
{
content: "Save custom snippet",
trigger: ".snippet-option-SnippetSave we-button",
trigger: "div[data-container-title='Banner'] .oe_snippet_save",
run: "click",
},
{
content: "Confirm reload",
trigger: ".modal-dialog button:contains('Save and Reload')",
trigger: ".modal-dialog button:contains('Save')",
run: "click",
},
{
content: "Click on the block tab",
trigger: ".o-snippets-tabs button[data-name='blocks']",
run: "click",
},
{
content: "Click on the Custom category block",
trigger: "#oe_snippets .oe_snippet[name='Custom'].o_we_draggable .oe_snippet_thumbnail",
trigger: "#snippet_groups .o_snippet[name='Custom'].o_draggable .o_snippet_thumbnail:not(.o_we_ongoing_insertion) .o_snippet_thumbnail_area",
run: "click",
},
{
Expand All @@ -54,17 +59,17 @@ registerWebsitePreviewTour('test_custom_snippet', {
},
{
content: "Rename custom snippet",
trigger: ":iframe .o_custom_snippet_wrap > .o_custom_snippet_edit > button",
trigger: ":iframe .o_custom_snippet_edit > button",
run: "click",
},
{
content: "Set name",
trigger: ".o_rename_custom_snippet_dialog input[id='customSnippetName']",
trigger: ".modal-dialog:not(.o_inactive_modal body) input[id='inputConfirmation']",
run: "edit Bruce Banner",
},
{
content: "Confirm rename",
trigger: ".o_rename_custom_snippet_dialog footer .btn-primary",
trigger: ".modal-dialog:not(.o_inactive_modal body) footer .btn-primary",
run: "click",
},
{
Expand All @@ -82,12 +87,12 @@ registerWebsitePreviewTour('test_custom_snippet', {
},
{
content: "Click on the Custom category block",
trigger: "#oe_snippets .oe_snippet[name='Custom'].o_we_draggable .oe_snippet_thumbnail",
trigger: "#snippet_groups .o_snippet[name='Custom'].o_draggable .o_snippet_thumbnail:not(.o_we_ongoing_insertion) .o_snippet_thumbnail_area",
run: "click",
},
{
content: "Delete custom snippet",
trigger: ":iframe .o_custom_snippet_wrap > .o_custom_snippet_edit > button + button",
trigger: ":iframe .o_custom_snippet_edit > button + button",
run: "click",
},
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/** @odoo-module **/

import { patch } from "@web/core/utils/patch";
import { VideoSelector } from '@web_editor/components/media_dialog/video_selector';
import { VideoSelector } from "@html_editor/main/media/media_dialog/video_selector";
import { insertSnippet, registerWebsitePreviewTour } from "@website/js/tours/tour_utils";

registerWebsitePreviewTour(
Expand Down Expand Up @@ -54,7 +54,7 @@ registerWebsitePreviewTour(
},
{
content: "Click on the 'Background Video' button option.",
trigger: "we-button[data-name='bg_video_toggler_opt']",
trigger: "button[data-action-id='toggleBgVideo']",
run: "click",
},
{
Expand Down
3 changes: 1 addition & 2 deletions addons/test_website/tests/test_custom_snippet.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
from odoo.tools import mute_logger
import unittest

# TODO master-mysterious-egg fix error
@unittest.skip("prepare mysterious-egg for merging")

@odoo.tests.common.tagged('post_install', '-at_install')
class TestCustomSnippet(odoo.tests.HttpCase):

Expand Down
3 changes: 1 addition & 2 deletions addons/test_website/tests/test_snippet_background_video.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

@odoo.tests.common.tagged('post_install', '-at_install')
class TestSnippetBackgroundVideo(odoo.tests.HttpCase):
# TODO master-mysterious-egg fix error
@unittest.skip("prepare mysterious-egg for merging")

def test_snippet_background_video(self):
self.start_tour("/", "snippet_background_video", login="admin")