odoo-13.0/addons/mail/static/tests/helpers/test_utils.js
/**
 * Create asynchronously a discuss widget.
 * This is async due to mail_manager/mail_service that needs to be ready.
 *
 * @param {Object} params
 * @return {Promise} resolved with the discuss widget
 */
Create asynchronously a discuss widget.
This is async due to mail_manager/mail_service that needs to be ready.

@param {Object} params
@return {Promise} resolved with the discuss widget
Create asynchronously a discuss widget . This is async due to mail_manager / mail_service that needs to be ready . @param { Object } params @return { Promise } resolved with the discuss widget
async function createDiscuss(params) {
    var Parent = Widget.extend({
        do_push_state: function () {},
    });
    var parent = new Parent();
    params.archs = params.archs || {
        'mail.message,false,search': '<search/>',
    };
    testUtils.mock.addMockEnvironment(parent, params);
    var discuss = new Discuss(parent, params);
    var selector = params.debug ? 'body' : '#qunit-fixture';
    discuss.destroy = function () {
        delete discuss.destroy;
        parent.destroy();
    };
    return discuss.appendTo($(selector)).then(function () {
        return discuss;
    });
}
async function createDiscuss ( params ) { var Parent = Widget . extend ( { do_push_state : function ( ) { } , } ) ; var parent = new Parent ( ) ; params . archs = params . archs || { 'mail.message,false,search' : '<search/>' , } ; testUtils . mock . addMockEnvironment ( parent , params ) ; var discuss = new Discuss ( parent , params ) ; var selector = params . debug ? 'body' : '#qunit-fixture' ; discuss . destroy = function ( ) { delete discuss . destroy ; parent . destroy ( ) ; } ; return discuss . appendTo ( $ ( selector ) ) . then ( function ( ) { return discuss ; } ) ; }
Create asynchronously a discuss widget.
Create asynchronously a discuss widget .
// override 'destroy' of discuss so that it calls 'destroy' on the parent // instead, which is the parent of discuss and the mockServer. // remove the override to properly destroy discuss and its children // when it will be called the second time (by its parent)