function simulateHybrisSendingHtml() {
    const htmlFromHybris = Wick.FEMock.cartPDP;
    const event = new CustomEvent('productAddedToCart', {
        detail: { html: htmlFromHybris },
    });
    window.dispatchEvent(event);
}

function bindResolveEvent(events) {
    $(window).on(events.join(' '), function ({ detail: { resolve } }) {
        setTimeout(() => {
            resolve();
        }, 200);
    });
}

$(document).ready(function () {
    $('.btn-add-to-basket').on('click', simulateHybrisSendingHtml);

    bindResolveEvent([
        'CLOSE_JUST_ADDED',
        'CLOSE_MINI_BASKET',
        'MINI_BASKET_CHECKOUT',
        'MINI_BASKET_VIEW_BASKET',
    ]);
});
