Skip to content

Commit a793d24

Browse files
committed
[IMP] Enable and adapt tour edit_link_popover
1 parent 0973924 commit a793d24

File tree

4 files changed

+202
-202
lines changed

4 files changed

+202
-202
lines changed

addons/html_editor/controllers/main.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,12 @@ def link_preview_metadata_internal(self, preview_url):
592592
context = dict(request.env.context)
593593
words = preview_url.strip('/').split('/')
594594

595-
record_id = int(words.pop())
595+
# If there is no recordID in url return empty dict.
596+
try:
597+
record_id = int(words.pop())
598+
except ValueError:
599+
return {}
600+
596601
action_name = words.pop()
597602
if (action_name.startswith('m-') or '.' in action_name) and action_name in request.env and not request.env[action_name]._abstract:
598603
# if path format is `odoo/<model>/<record_id>` so we use `action_name` as model name

addons/html_editor/tests/test_controller.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,9 @@ def test_05_internal_link_preview(self):
192192
}),
193193
headers=self.headers
194194
)
195+
response_not_record_json = response_not_record.json()
195196
self.assertEqual(200, response_not_record.status_code)
196-
self.assertTrue('other_error_msg' in response_not_record.text)
197+
self.assertEqual({}, response_not_record_json["result"])
197198

198199
# Attempt to retrieve metadata for path format `odoo/<model>/<record_id>`
199200
response_model_record = self.url_open(

addons/website/static/src/js/tours/tour_utils.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -631,3 +631,30 @@ export function toggleMobilePreview(toggleOn) {
631631
},
632632
];
633633
}
634+
635+
/**
636+
* Opens the link popup for the specified link element.
637+
*
638+
* @param {string} triggerSelector - Selector for the link element.
639+
* @param {string} [linkName=""] - Name of the link.
640+
* @returns {TourStep[]} The tour steps that opens the link popup.
641+
*/
642+
export function openLinkPopup(triggerSelector, linkName = "", childIndex = 0) {
643+
return [
644+
{
645+
content: `Open '${linkName}' link popup`,
646+
trigger: triggerSelector,
647+
async run(actions) {
648+
actions.click();
649+
const el = this.anchor;
650+
const sel = el.ownerDocument.getSelection();
651+
sel.collapse(el.childNodes[childIndex], 1);
652+
el.focus();
653+
},
654+
},
655+
{
656+
content: "Check if the link popover opened",
657+
trigger: ".o-we-linkpopover",
658+
},
659+
];
660+
}

0 commit comments

Comments
 (0)