
    5i3                     X    d Z ddlZddlmZ  G d d      Z G d d      Z G d d	      Zy)
z
E2E Full User Journey Tests.

Simulates complete user workflows based on:
- /mnt/e/genesis-system/RECEPTIONISTAI/DEMO_RECORDING_SUMMARY.md
- /mnt/e/genesis-system/Conversations/gemini_ultra_plan_features_extracted.md
    N)expectc                   (    e Zd ZdZd Zd Zd Zd Zy)TestCompleteUserJourneyz'Full end-to-end user journey scenarios.c                    |j                  | d       |j                  d       t        |j                  d            j	                          |j                  d      j
                  }t        |      j	                          |j                          |j                  d       |j                  d      }t        |      j	                          |j                  d      j
                  }|j                  d       |j                  d	      j
                  }|j                          |j                  d
       |j                  d      }|j                         dkD  sJ d       y)z
        Test: New visitor lands on demo page -> opens widget -> sends message.

        User Story: As a first-time visitor, I want to quickly test
        the chat widget to see how it works.
        
/demo.htmlnetworkidlebody1button.widget-trigger, button[aria-label*="call"]  z1.chat-interface, .chat-window, .message-container;input[type="text"], textarea, input[placeholder*="message"]zWhat are your hours?3button[aria-label*="send"], button:has-text("Send")  +.message, .chat-message, [class*="message"]r   z"No messages appeared after sendingN)
gotowait_for_load_stater   locatorto_be_visiblefirstclickwait_for_timeoutfillcount)selfpage
widget_urltriggerchat_interface
text_inputsend_buttonmessagess           4/mnt/e/genesis-system/tests/e2e/test_user_journey.pytest_first_time_visitor_journeyz7TestCompleteUserJourney.test_first_time_visitor_journey   s&    			ZL
+,  / 	t||F#$224 ,,RSYYw%%' 	d# &YZ~,,. \\"_`ff
./ ll#XY__ 	d# << MN~~!#I%II#    c                 ^   |j                  | d       |j                  d      j                  j                          |j	                  d       |j                  d      j                  }|j                  d       |j                  d      j                  }|j                          |j	                  d       |j                  d      }|j                         d	kD  sJ d
       |j                  d       |j                          |j	                  d       |j                         dk\  sJ d       y)z
        Test: Visitor provides contact info (lead capture scenario).

        User Story: As a potential customer, I want to leave my contact
        details so the business can call me back.
        r   r
   r   r   z-Hi, I'm Sarah. Can you call me on 0412345678?r   r   r   r   z"Lead capture message not processedzDo you service the Bondi area?   zFollow-up message not processedNr   r   r   r   r   r   r   r   r   r   r   r   r    s         r!   test_lead_capture_journeyz1TestCompleteUserJourney.test_lead_capture_journey:   s    			ZL
+,HIOOUUWd# \\"_`ff
GHll#XY__d# << MN~~!#I%II# 	89d# ~~1$G&GG$r#   c                    |j                  | d       |j                  d      j                  j                          |j	                  d       g d}|D ]j  }|j                  d      j                  }|j                  |       |j                  d      j                  }|j                          |j	                  d       l |j                  d      }|j                         t        |      k\  sJ d	       y
)z
        Test: User inquires about booking an appointment.

        User Story: As a customer, I want to book a service appointment
        through the chat widget.
        r   r
   r   )zI'd like to book an appointmentz&I have a leaking tap that needs fixingz!How much does a leak repair cost?z"What's your earliest availability?r   r   	  r   zBooking conversation incompleteNr   r   r   r   r   r   r   len)r   r   r   conversationmessager   r   r    s           r!   test_booking_inquiry_journeyz4TestCompleteUserJourney.test_booking_inquiry_journey^   s     			ZL
+,HIOOUUWd#
 $ 	(G&cdjjJOOG$,,'\]ccK!!$'	( << MN~~3|#44W6WW4r#   c                 (   |j                  | d       |j                  d      j                  j                          |j	                  d       |j                  d      j                  }|j                  d       |j                  d      j                  }|j                          |j	                  d       |j                  | d       |j                  d      j                  j                          |j	                  d       |j                  d      j                  }|j                  d       |j                  d      j                  }|j                          |j	                  d       |j                  d	      }|j                         d
kD  sJ y)z
        Test: User starts conversation on mobile, continues on desktop.

        User Story: As a user, I want my conversation to persist
        across devices.
        r   r
   r   r   zI need a plumberr   i  zCan you come today?r   r   Nr&   )r   r   mobile_pager   r   r   r    s          r!   test_multi_device_journeyz1TestCompleteUserJourney.test_multi_device_journey~   sT    	J<z23OPVV\\^$$T* !(()fgmm
*+!))*_`ff$$T* 			ZL
+,HIOOUUWd# \\"_`ff
-.ll#XY__d# << MN~~!###r#   N)__name__
__module____qualname____doc__r"   r(   r/   r2    r#   r!   r   r      s    1'JV HHX@($r#   r   c                   (    e Zd ZdZd Zd Zd Zd Zy)TestRealisticScenariosz9Real-world usage scenarios based on Gemini chat examples.c                    |j                  | d       |j                  d      j                  j                          |j	                  d       |j                  d      j                  }|j                  d       |j                  d      j                  }|j                          |j	                  d       |j                  d      }|j                         d	kD  sJ d
       y)z
        Scenario: Customer calls after business hours (AI handles 24/7).

        Based on: DEMO_RECORDING_SUMMARY.md - "24/7 availability pitch"
        r   r
   r   r   zAre you open now? It's 11pmr   r   r   r   zAfter-hours message not handledNr&   r'   s         r!   test_after_hours_inquiryz/TestRealisticScenarios.test_after_hours_inquiry   s     			ZL
+,HIOOUUWd#\\"_`ff
56ll#XY__d#<< MN~~!#F%FF#r#   c                    |j                  | d       |j                  d      j                  j                          |j	                  d       g d}|D ]j  }|j                  d      j                  }|j                  |       |j                  d      j                  }|j                          |j	                  d       l |j                  d      }|j                         t        |      k\  sJ y	)
z
        Scenario: Customer asks about pricing.

        Based on: ReceptionistAI demo scripts - pricing/quote requests
        r   r
   r   )zHow much do you charge?z$What's the cost for a toilet repair?zDo you have a call-out fee?r   r   r*   r   Nr+   )r   r   r   pricing_questionsquestionr   r   r    s           r!   test_pricing_inquiryz+TestRealisticScenarios.test_pricing_inquiry   s     			ZL
+,HIOOUUWd#
 * 	(H&cdjjJOOH%,,'\]ccK!!$'	( << MN~~3'8#9999r#   c                    |j                  | d       |j                  d      j                  j                          |j	                  d       |j                  d      j                  }|j                  d       |j                  d      j                  }|j                          |j	                  d       |j                  d      }|j                         d	kD  sJ y
)zJ
        Scenario: Customer asks if business services their area.
        r   r
   r   r   z"Do you service Bondi and Randwick?r   r   r   r   Nr&   r'   s         r!   test_service_area_inquiryz0TestRealisticScenarios.test_service_area_inquiry   s     			ZL
+,HIOOUUWd#\\"_`ff
<=ll#XY__d#<< MN~~!###r#   c                    |j                  | d       |j                  d      j                  j                          |j	                  d       |j                  d      j                  }|j                  d       |j                  d      j                  }|j                          |j	                  d       |j                  d      }|j                         d	kD  sJ d
       y)zO
        Scenario: Customer has an emergency (burst pipe, flood, etc).
        r   r
   r   r   z0URGENT: I have a burst pipe flooding my kitchen!r   r   r   r   zEmergency message not handledNr&   r'   s         r!   test_emergency_requestz-TestRealisticScenarios.test_emergency_request   s     			ZL
+,HIOOUUWd#\\"_`ff
JKll#XY__d#<< MN~~!#D%DD#r#   N)r3   r4   r5   r6   r;   r?   rA   rC   r7   r#   r!   r9   r9      s    CG*:8$&Er#   r9   c                   "    e Zd ZdZd Zd Zd Zy)TestWidgetBehaviorz.Test widget-specific behaviors and edge cases.c                 f   |j                  | d       |j                  d      j                  j                          |j	                  d       |j                  d      }t        |      j                          |j                  d      j                  }|j                         r|j                          |j	                  d       t        |      j                          |j                  d      j                  j                          |j	                  d       t        |      j                          yy)zA
        Test: User can minimize and restore the widget.
        r   r
   r   z.chat-interface, .chat-windowzJbutton[aria-label*="close"], button[aria-label*="minimize"], .close-buttoni  N)	r   r   r   r   r   r   r   
is_visiblenot_to_be_visible)r   r   r   r   close_buttons        r!   test_widget_minimize_restorez/TestWidgetBehavior.test_widget_minimize_restore  s     			ZL
+, 	HIOOUUWd#&EF~,,. ||$pqww""$ !!#& >"446 LLLMSSYY[!!#& >"002 %r#   c                     |j                  | d       |j                  d      j                  }|j                         }|j                  }|d   |d   dz  kD  sJ d       |d   |d   d	z  kD  sJ d
       y)zQ
        Test: Widget appears in correct position (bottom-right corner).
        r   r
   xwidthgffffff?z#Widget not positioned on right sideyheightg      ?z#Widget not positioned in lower halfN)r   r   r   bounding_boxviewport_size)r   r   r   r   boxviewports         r!   test_widget_positionz'TestWidgetBehavior.test_widget_position%  s     			ZL
+,,,RSYY ""$%% 3x(7+c11X3XX13x(8,s22Y4YY2r#   c                 P   |j                  | d       |j                  d      j                  j                          |j	                  d       t        d      D ]p  }|j                  d      j                  }|j                  d|dz           |j                  d      j                  }|j                          |j	                  d	       r |j                  d
      j                  }|j                         r/|j                  d      }|j                  d      }||k\  sJ d       yy)zB
        Test: Long conversations should scroll properly.
        r   r
   r   
   r   zTest message number    r   i  z7.messages, .chat-messages, [class*="message-container"]zel => el.scrollHeightzel => el.clientHeightz(Messages container not handling overflowN)	r   r   r   r   r   ranger   rG   evaluate)	r   r   r   ir   r   messages_containerscroll_heightclient_heights	            r!   test_conversation_scrollz+TestWidgetBehavior.test_conversation_scroll7  s    			ZL
+,HIOOUUWd# r 	(A&cdjjJOO21Q3%89,,'\]ccK!!$'	( "\\*cdjj((*.778OPM.778OPM !M1]3]]1 +r#   N)r3   r4   r5   r6   rJ   rT   r^   r7   r#   r!   rE   rE     s    83<Z$^r#   rE   )r6   pytestplaywright.sync_apir   r   r9   rE   r7   r#   r!   <module>ra      s<     &Z$ Z$zXE XEvN^ N^r#   