
    6i	                         d Z ddlZddlmc mZ ddlZddlm	Z	  G d d      Z
 G d d      Z G d d	      Z G d
 d      Zy)zj
E2E Tests for ReceptionistAI Dashboard.

Tests dashboard functionality (if available at localhost:8889).
    N)expectc                       e Zd ZdZej
                  j                  d      d        Zej
                  j                  d      d        Zy)TestDashboardAccessz(Dashboard availability and access tests.z.Dashboard may not be running at localhost:8889reasonc                 J   	 |j                  | dd      }|j                  }d}||k(  }|st        j                  d|fd||f      dt	        j
                         v st        j                  |      rt        j                  |      ndt        j                  |      t        j                  |      dz  }t        j                  d	      d
z   d|iz  }t        t        j                  |            dx}x}}y# t        $ r"}	t        j                  d|	        Y d}	~	yd}	~	ww xY w)zVerify dashboard is accessible./  timeout   )==)z.%(py2)s
{%(py2)s = %(py0)s.status
} == %(py5)sresponse)py0py2py5zDashboard failed to loadz
>assert %(py7)spy7NDashboard not available: )gotostatus
@pytest_ar_call_reprcompare@py_builtinslocals_should_repr_global_name	_saferepr_format_assertmsgAssertionError_format_explanation	Exceptionpytestskip)
selfpagedashboard_urlr   @py_assert1@py_assert4@py_assert3@py_format6@py_format8es
             1/mnt/e/genesis-system/tests/e2e/test_dashboard.pytest_dashboard_loadsz(TestDashboardAccess.test_dashboard_loads   s    	9yyM?!!4dyCH??EcE?c)EEE?cEEEEEE8EEE8EEE?EEEcEEE+EEEEEEEE 	9KK3A3788	9s   C4C7 7	D" DD"z$Dashboard may require authenticationc                    	 |j                  | dd       |j                  d      |j                  d      |j                  d      g}t        d |D              }y	# t        $ r"}t	        j
                  d|        Y d	}~y	d	}~ww xY w)
z$Verify dashboard has authentication.r	   r
   r   zinput[type="password"]zbutton:has-text("Login")zform[action*="login"]c              3   B   K   | ]  }|j                         d kD    yw)r   N)count).0	indicators     r,   	<genexpr>zCTestDashboardAccess.test_dashboard_requires_auth.<locals>.<genexpr>#   s     TiIOO-1Ts   r   N)r   locatoranyr    r!   r"   )r#   r$   r%   login_indicators	has_loginr+   s         r,   test_dashboard_requires_authz0TestDashboardAccess.test_dashboard_requires_auth   s    	9IIq)4I8 567845  TCSTTI 	9KK3A3788	9s   AA 	B&BBN)	__name__
__module____qualname____doc__r!   markr"   r-   r8        r,   r   r   
   sS    2[[MN9 O9 [[CD9 E9r?   r   c                       e Zd ZdZej
                  j                  d      d        Zej
                  j                  d      d        Zy)TestDashboardNavigationz$Dashboard navigation and menu tests. Dashboard implementation unknownr   c                     |j                  | d       |j                  d      }t        |j                        j	                          y)z%Verify dashboard has navigation menu.r	   z+nav, .sidebar, .menu, [class*="navigation"]N)r   r4   r   firstto_be_visible)r#   r$   r%   navs       r,   test_navigation_menu_presentz4TestDashboardNavigation.test_navigation_menu_present,   s=     			]O1%& llHIsyy'')r?   c                     |j                  | d       g d}|D ].  }|j                  d| d| d      }|j                         dkD  s/0 y)z(Verify dashboard sections are navigable.r	   )ConversationsLeads	AnalyticsSettingsza:has-text("z"), button:has-text("z")r   N)r   r4   r0   )r#   r$   r%   sectionssectionlinks         r,   "test_dashboard_sections_accessiblez:TestDashboardNavigation.test_dashboard_sections_accessible5   s_     			]O1%&
   	G<<,wi7LWIUW XYDzz|a		r?   N)	r9   r:   r;   r<   r!   r=   r"   rG   rP   r>   r?   r,   rA   rA   )   sS    .[[?@* A* [[?@ Ar?   rA   c                       e Zd ZdZej
                  j                  d      d        Zej
                  j                  d      d        Zy)TestDashboardDatazDashboard data display tests.rB   r   c                     |j                  | d       |j                  d      }|j                         dkD  r3|j                          |j	                  d       |j                  d      }yy)z-Verify conversations are listed in dashboard.r	   za:has-text("Conversations")r     z).conversations, .conversation-list, tableNr   r4   r0   clickwait_for_timeout)r#   r$   r%   conversations_linkcontents        r,    test_conversations_list_displaysz2TestDashboardData.test_conversations_list_displaysM   sj     			]O1%& "\\*GH##%)$$&!!$' ll#NOG *r?   c                     |j                  | d       |j                  d      }|j                         dkD  r"|j                          |j	                  d       yy)z+Verify captured leads display in dashboard.r	   za:has-text("Leads")r   rT   NrU   )r#   r$   r%   
leads_links       r,   test_leads_displayz$TestDashboardData.test_leads_display\   sX     			]O1%& \\"78
!!!$' "r?   N)	r9   r:   r;   r<   r!   r=   r"   rZ   r]   r>   r?   r,   rR   rR   J   sU    '[[?@P AP [[?@( A(r?   rR   c                       e Zd ZdZej
                  j                  d      d        Zej
                  j                  d      d        Zy)TestDashboardResponsivez"Dashboard responsive design tests.rB   r   c                 |    |j                  | d       t        |j                  d            j                          y)z!Verify dashboard works on mobile.r	   bodyNr   r   r4   rE   )r#   mobile_pager%   s      r,   test_dashboard_mobile_layoutz4TestDashboardResponsive.test_dashboard_mobile_layoutm   s7     	M?!,- 	{""6*+99;r?   c                 |    |j                  | d       t        |j                  d            j                          y)z!Verify dashboard works on tablet.r	   ra   Nrb   )r#   tablet_pager%   s      r,   test_dashboard_tablet_layoutz4TestDashboardResponsive.test_dashboard_tablet_layoutu   s5     	M?!,-{""6*+99;r?   N)	r9   r:   r;   r<   r!   r=   r"   rd   rg   r>   r?   r,   r_   r_   j   sS    ,[[?@< A< [[?@< A<r?   r_   )r<   builtinsr   _pytest.assertion.rewrite	assertionrewriter   r!   playwright.sync_apir   r   rA   rR   r_   r>   r?   r,   <module>rm      s@   
   &9 9> B( (@< <r?   