11/// <reference types="cypress" />
22
3+ beforeEach ( ( ) => {
4+ cy . intercept ( 'https://api-iam.intercom.io/messenger/web/ping' ) . as (
5+ 'intercomPing' ,
6+ ) ;
7+ cy . intercept ( 'https://api-iam.intercom.io/messenger/web/open' ) . as (
8+ 'intercomOpen' ,
9+ ) ;
10+ cy . intercept ( 'https://api-iam.intercom.io/messenger/web/metrics' ) . as (
11+ 'intercomMetrics' ,
12+ ) ;
13+ cy . intercept ( 'https://api-iam.intercom.io/messenger/web/messages' ) . as (
14+ 'intercomMessages' ,
15+ ) ;
16+ cy . intercept ( 'https://api-iam.intercom.io/messenger/web/home' ) . as (
17+ 'intercomHome' ,
18+ ) ;
19+ cy . intercept ( 'https://api-iam.intercom.io/messenger/web/conversations' ) . as (
20+ 'intercomConversations' ,
21+ ) ;
22+ cy . intercept (
23+ 'https://api-iam.intercom.io/messenger/web/self_serve_suggestions' ,
24+ ) . as ( 'intercomSelfServeSuggestions' ) ;
25+ } ) ;
26+
327describe ( 'provider' , ( ) => {
428 it ( 'should render children' , ( ) => {
529 cy . visit ( '/provider' ) ;
@@ -51,6 +75,45 @@ describe('provider with events', () => {
5175
5276 cy . get ( '[data-cy=onHideText]' ) . should ( 'have.text' , 'hide was called' ) ;
5377 } ) ;
78+
79+ it ( 'should execute `onUserEmailSupplied` event on `onUserEmailSupplied`' , ( ) => {
80+ cy . get ( '[data-cy=onUserEmailSuppliedText]' ) . should ( 'have.text' , 'default' ) ;
81+
82+ cy . get ( '[data-cy=boot]' ) . click ( ) ;
83+
84+ cy . get ( '[data-cy=show]' ) . click ( ) ;
85+
86+ cy . get ( 'iframe[name="intercom-messenger-frame"]' ) . then ( ( $iframe ) => {
87+ const $body = $iframe . contents ( ) . find ( 'body' ) ;
88+
89+ cy . wrap ( $body ) . contains ( 'Send us a message' ) . click ( ) ;
90+
91+ cy . wait ( '@intercomHome' ) ;
92+ cy . wait ( '@intercomConversations' ) ;
93+
94+ cy . wrap ( $body )
95+ . find ( 'textarea[name="message"]' )
96+ . should ( 'exist' )
97+ . type ( 'hello' )
98+ . type ( '{enter}' ) ;
99+
100+ cy . wait ( '@intercomMessages' ) ;
101+
102+ cy . wrap ( $body ) . contains ( 'Get notified by email' , { timeout : 10000 } ) ;
103+
104+ cy . wrap ( $body )
105+ . find ( 'input[type="email"]' )
106+ . type ( 'hello@email.com' )
107+ . type ( '{enter}' ) ;
108+
109+ cy . wait ( '@intercomSelfServeSuggestions' ) ;
110+
111+ cy . get ( '[data-cy=onUserEmailSuppliedText]' ) . should (
112+ 'have.text' ,
113+ 'on user email supplied was called' ,
114+ ) ;
115+ } ) ;
116+ } ) ;
54117} ) ;
55118
56119describe ( 'provider with `apiBase`' , ( ) => {
@@ -69,6 +132,10 @@ describe('provider with `apiBase`', () => {
69132} ) ;
70133
71134describe ( 'provider with `autoBootProps`' , ( ) => {
135+ beforeEach ( ( ) => {
136+ cy . visit ( '/providerAutoBootProps' ) ;
137+ } ) ;
138+
72139 it ( 'should set properties if passed to `autoBootProps` when `autoBoot` is `true`' , ( ) => {
73140 cy . get ( 'p' ) . should ( 'be.visible' ) ;
74141
0 commit comments