o
    i                     @   sL   d Z ddlZddlmZ dd Zdd Zd	d
 Zdd Zdd Zdd Z	dS )z&Test the notification area and widgets    N   )EDITOR_PAGEc                 C      | j d| dtdS )Nz5() => { return IPython.notification_area.get_widget('') !== undefined }pageevaluater   notebookname r   h/var/www/edux/Edux_v2/venv/lib/python3.10/site-packages/nbclassic/tests/end_to_end/test_notifications.py
get_widget      
r   c                 C   r   )Nz1() => { return IPython.notification_area.widget('r   r   r   r
   r   r   r   widget   r   r   c                 C   r   )NzB() => { return IPython.notification_area.new_notification_widget('r   r   r   r
   r   r   r   new_notification_widget   r   r   c                 C   s   | j d| d| dtdS )N>() => {
        var w = IPython.notification_area.get_widget('z'');
        return w.element.hasClass('z'); }
        r   r   )r   r   
class_namer   r   r   widget_has_class   s   r   c                 C   r   )Nr   z.');
        return w.get_message(); }
        r   r   r
   r   r   r   widget_message'   s   r   c                    s  t  dr
t dsJ dt  drt dsJ dtt t  d W d    n1 s1w   Y  t ds?J dtt t d W d    n1 sTw   Y  dD ]5} jd	| d
| dtd  jdtd t	 d|sJ | dt
 dd| ksJ | dq[ jdtd  jdtd t
 ddksJ d jdtdd t
 ddksJ d jdtd  jdtd t
 ddksJ d jdtd    fdd  jdtdd t
 ddksJ dd S )Nkernelz%The kernel notification widget existsr   z'The notebook notification widget existsfoobarzwidget: new widget is created)infowarningdangerzQ
            var tnw = IPython.notification_area.widget('test');
            tnw.z('test z');
            r   z#notification_testtestz: class is incorrectztest z: message is incorrectzt
        var tnw = IPython.notification_area.widget('test');
        tnw.set_message('test timeout', 1000);
        ztest timeoutztimeout: message is incorrecthidden)state z timeout: message was not clearedz
        var tnw = IPython.notification_area.widget('test');
        tnw._clicked = false;
        tnw.set_message('test click', undefined, function () {
            tnw._clicked = true;
            return true;
        });
        z
test clickzcallback: message is correctc                      s    j dtdS )NzC() => { return IPython.notification_area.widget("test")._clicked; }r   r   r   notebook_frontendr   r   <lambda>p   s    z#test_notification.<locals>.<lambda>z!callback: message was not cleared)r   r   pytestraises	Exceptionr   r	   r   wait_for_selectorr   r   locateclickwait_for_condition)r"   levelr   r!   r   test_notification1   sZ   $
r,   )
__doc__r$   utilsr   r   r   r   r   r   r,   r   r   r   r   <module>   s    

