Skip to content
Permalink
Browse files

[FIX] web: avoid click on home menu in community

A fix attempt for the clickEveryWhere test was made in 39e7135.
Unfortunately, the last modification of the fix were not tested on the
runbot and introduced two new issues.

1) The click method on the home menu has been changed to use an enhanced
   _click function. This function crash when the jquery element is empty.
   As this menu does not exists in community, the test miserably fails.

2) A "focus" event was added in the _click function that simulates a real click.
   But the "focus" event is not a mouse event and as nothing to do there.

With this commit, the _click function returns immediatly when the
element is empty.

Also, the "focus" event is removed from the _click
simulation but a focus method is used to give focus to the close button.

Giving the focus to the cancel button is itself a fix for the
DateTimePicker field (see 39e7135).

closes #32082

Signed-off-by: Christophe Monniez (moc) <moc@odoo.com>
  • Loading branch information...
d-fence committed Mar 23, 2019
1 parent d87443a commit 9ea4fefed2f94c6d211951e573b9a9a456f00ce6
Showing with 2 additions and 1 deletion.
  1. +2 −1 addons/web/static/src/js/tools/test_menus.js
@@ -131,6 +131,7 @@
if ($modal.length > 0) {
var $closeButton = $('header > button.close');
if ($closeButton.length > 0) {
$closeButton.focus();
_click($closeButton);
} else { $modal.modal('hide'); }
isModal = true;
@@ -285,11 +286,11 @@
* @param {jQueryElement} $element the element on which to perform the click
*/
function _click($element) {
if ($element.length == 0) return;
triggerMouseEvent($element, "mouseover");
triggerMouseEvent($element, "mouseenter");
triggerMouseEvent($element, "mousedown");
triggerMouseEvent($element, "mouseup");
triggerMouseEvent($element, "focus");
triggerMouseEvent($element, "click");

function triggerMouseEvent($el, type, count) {

0 comments on commit 9ea4fef

Please sign in to comment.
You can’t perform that action at this time.