o
    i                     @   s\   d Z ddlZddlmZ ddlmZ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)By   )wait_for_selectorwait_for_script_to_return_truec                 C      | j d| dS )Nz-return IPython.notification_area.get_widget('') !== undefinedbrowserexecute_scriptnotebookname r   e/var/www/edux/Edux_v2/venv/lib/python3.10/site-packages/notebook/tests/selenium/test_notifications.py
get_widget
      
r   c                 C   r   )Nz)return IPython.notification_area.widget('r   r   r   r   r   r   widget   r   r   c                 C   r   )Nz:return IPython.notification_area.new_notification_widget('r   r   r   r   r   r   new_notification_widget   r   r   c                 C   s   | j d| d| dS )N7
        var w = IPython.notification_area.get_widget('z'');
        return w.element.hasClass('');
        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   widget_message%   s
   r   c                 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| jddd t	| d|sJ | dt
| dd| ksJ | dq[| jd t| jddd t
| ddksJ dt| jddd t
| ddksJ d| jd t| jddd t
| ddksJ d| jtjd  t| jd t| jd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 r   z#notification_testT)visibletestz: class is correctztest z: message is correctzt
        var tnw = IPython.notification_area.widget('test');
        tnw.set_message('test timeout', 1000);
        ztest timeoutztimeout: message is correct)obscures ztimeout: message was 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 correctnotification_testz9return IPython.notification_area.widget("test")._clicked;zcallback: message was cleared)r   r   pytestraises	Exceptionr   r	   r
   r   r   r   find_elementr   IDclickr   )r   levelr   r   r   test_notification.   sH   
$r+   )__doc__r$   selenium.webdriver.common.byr   utilsr   r   r   r   r   r   r   r+   r   r   r   r   <module>   s    		