odoo-13.0/addons/web/static/tests/helpers/test_utils_fields.js
/**
 * Click on a menuitem in the m2o dropdown.  This helper will target an element
 * which contains some specific text. Note that it assumes that the dropdown
 * is currently open.
 *
 * Example:
 *    testUtils.fields.many2one.clickM2OItem('partner_id', 'George');
 *
 * @param {string} fieldName
 * @param {string} searchText
 * @returns {Promise}
 */
Click on a menuitem in the m2o dropdown.  This helper will target an element
which contains some specific text. Note that it assumes that the dropdown
is currently open.



@param {string} fieldName
@param {string} searchText
@returns {Promise}
Click on a menuitem in the m2o dropdown . This helper will target an element which contains some specific text . Note that it assumes that the dropdown is currently open . @param { string } fieldName @param { string } searchText @returns { Promise }
function clickM2OItem(fieldName, searchText) {
    var m2oSelector = `.o_field_many2one[name=${fieldName}] input`;
    var $dropdown = $(m2oSelector).autocomplete('widget');
    var $target = $dropdown.find(`li:contains(${searchText})`).first();
    if ($target.length !== 1 || !$target.is(':visible')) {
        throw new Error('Menu item should be unique and visible');
    }
    $target.mouseenter();
    $target.click();
    return concurrency.delay(0);
}
function clickM2OItem ( fieldName , searchText ) { var m2oSelector = ` ${ fieldName } ` ; var $dropdown = $ ( m2oSelector ) . autocomplete ( 'widget' ) ; var $target = $dropdown . find ( ` ${ searchText } ` ) . first ( ) ; if ( $target . length !== 1 || ! $target . is ( ':visible' ) ) { throw new Error ( 'Menu item should be unique and visible' ) ; } $target . mouseenter ( ) ; $target . click ( ) ; return concurrency . delay ( 0 ) ; }
Click on a menuitem in the m2o dropdown.
Click on a menuitem in the m2o dropdown .