@@ -10,7 +10,7 @@ if (!hasUserLoginInfo) {
1010}
1111const conditionalDescribe = ! hasUserLoginInfo ? describe . skip : describe ;
1212
13- conditionalDescribe ( 'Index page test' , ( ) => {
13+ conditionalDescribe ( 'widget page test' , ( ) => {
1414 let widgetIframe ;
1515
1616 beforeAll ( async ( ) => {
@@ -76,4 +76,60 @@ conditionalDescribe('Index page test', () => {
7676 const headerLabel = await widgetIframe . getHeaderLabel ( ) ;
7777 expect ( headerLabel ) . toEqual ( 'Calling' ) ;
7878 } ) ;
79+
80+ it ( 'should register service successfully' , async ( ) => {
81+ await widgetIframe . clickNavigationButton ( 'More Menu' ) ;
82+ await widgetIframe . clickDropdownNavigationMenu ( 'Settings' ) ;
83+ await page . evaluate ( ( ) => {
84+ const iframe = document . querySelector ( "#rc-widget-adapter-frame" ) . contentWindow ;
85+ window . addEventListener ( 'message' , function ( e ) {
86+ var data = e . data ;
87+ if ( data && data . type === 'rc-post-message-request' ) {
88+ if ( data . path === '/contacts' ) {
89+ const contacts = [ {
90+ id : '123456' ,
91+ name : 'TestService Name' ,
92+ type : 'TestService' ,
93+ phoneNumbers : [ {
94+ phoneNumber : '+1234567890' ,
95+ phoneType : 'direct' ,
96+ } ] ,
97+ company : 'CompanyName' ,
98+ jobTitle : 'Engineer' ,
99+ 100+ deleted : false ,
101+ } ] ;
102+ iframe . postMessage ( {
103+ type : 'rc-post-message-response' ,
104+ responseId : data . requestId ,
105+ response : {
106+ data : contacts ,
107+ nextPage : null ,
108+ syncTimestamp : Date . now ( )
109+ } ,
110+ } , '*' ) ;
111+ }
112+ }
113+ } ) ;
114+ iframe . postMessage ( {
115+ type : 'rc-adapter-register-third-party-service' ,
116+ service : {
117+ name : 'TestService' ,
118+ authorizationPath : '/authorize' ,
119+ authorizedTitle : 'Unauthorize' ,
120+ unauthorizedTitle : 'Authorize' ,
121+ contactsPath : '/contacts' ,
122+ authorized : true ,
123+ } ,
124+ } , '*' ) ;
125+ } ) ;
126+ const serviceName = await widgetIframe . getServiceNameInAuthorizationSettings ( ) ;
127+ expect ( serviceName ) . toEqual ( 'TestService' ) ;
128+ await widgetIframe . clickNavigationButton ( 'More Menu' ) ;
129+ await widgetIframe . clickDropdownNavigationMenu ( 'Contacts' ) ;
130+ const contactsFilters = await widgetIframe . getContactFilters ( ) ;
131+ expect ( contactsFilters ) . toEqual ( expect . stringContaining ( 'TestService' ) ) ;
132+ const contacts = await widgetIframe . getContactNames ( ) ;
133+ expect ( contacts ) . toEqual ( expect . arrayContaining ( [ 'TestService Name' ] ) ) ;
134+ } ) ;
79135} ) ;
0 commit comments