@@ -531,6 +531,46 @@ describe("DismissibleUpsell", () => {
531531 } )
532532 } )
533533
534+ it ( "dismisses on container click when dismissOnClick is true and no onClick is provided; tracks only dismissal" , async ( ) => {
535+ const onDismiss = vi . fn ( )
536+ const { container } = render (
537+ < DismissibleUpsell upsellId = "test-upsell" onDismiss = { onDismiss } dismissOnClick = { true } >
538+ < div > Test content</ div >
539+ </ DismissibleUpsell > ,
540+ )
541+
542+ // Make component visible
543+ makeUpsellVisible ( )
544+
545+ // Wait for component to be visible
546+ await waitFor ( ( ) => {
547+ expect ( screen . getByText ( "Test content" ) ) . toBeInTheDocument ( )
548+ } )
549+
550+ // Click on the container (not the dismiss button)
551+ const containerDiv = screen . getByText ( "Test content" ) . parentElement as HTMLElement
552+ fireEvent . click ( containerDiv )
553+
554+ // onDismiss should be called
555+ expect ( onDismiss ) . toHaveBeenCalledTimes ( 1 )
556+
557+ // Telemetry: only dismissal should be tracked
558+ expect ( mockCapture ) . toHaveBeenCalledWith ( TelemetryEventName . UPSELL_DISMISSED , {
559+ upsellId : "test-upsell" ,
560+ } )
561+ expect ( mockCapture ) . not . toHaveBeenCalledWith ( TelemetryEventName . UPSELL_CLICKED , expect . anything ( ) )
562+
563+ // Dismiss message should be sent
564+ expect ( mockPostMessage ) . toHaveBeenCalledWith ( {
565+ type : "dismissUpsell" ,
566+ upsellId : "test-upsell" ,
567+ } )
568+
569+ // Component should be hidden
570+ await waitFor ( ( ) => {
571+ expect ( container . firstChild ) . toBeNull ( )
572+ } )
573+ } )
534574 it ( "does not dismiss when clicked if dismissOnClick is false" , async ( ) => {
535575 const onClick = vi . fn ( )
536576 const onDismiss = vi . fn ( )
0 commit comments