@thoughtspot/visual-embed-sdk 1.26.3 → 1.27.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (188) hide show
  1. package/README.md +3 -3
  2. package/cjs/.DS_Store +0 -0
  3. package/cjs/package.json +1 -1
  4. package/cjs/src/.DS_Store +0 -0
  5. package/cjs/src/auth.d.ts +4 -4
  6. package/cjs/src/auth.d.ts.map +1 -1
  7. package/cjs/src/auth.js +10 -4
  8. package/cjs/src/auth.js.map +1 -1
  9. package/cjs/src/embed/app.d.ts +15 -15
  10. package/cjs/src/embed/app.d.ts.map +1 -1
  11. package/cjs/src/embed/app.js +1 -1
  12. package/cjs/src/embed/app.js.map +1 -1
  13. package/cjs/src/embed/liveboard.d.ts +28 -23
  14. package/cjs/src/embed/liveboard.d.ts.map +1 -1
  15. package/cjs/src/embed/liveboard.js +4 -3
  16. package/cjs/src/embed/liveboard.js.map +1 -1
  17. package/cjs/src/embed/sage.d.ts +48 -30
  18. package/cjs/src/embed/sage.d.ts.map +1 -1
  19. package/cjs/src/embed/sage.js +7 -6
  20. package/cjs/src/embed/sage.js.map +1 -1
  21. package/cjs/src/embed/sage.spec.js +3 -3
  22. package/cjs/src/embed/sage.spec.js.map +1 -1
  23. package/cjs/src/embed/search-bar.d.ts +22 -6
  24. package/cjs/src/embed/search-bar.d.ts.map +1 -1
  25. package/cjs/src/embed/search-bar.js.map +1 -1
  26. package/cjs/src/embed/search.d.ts +34 -19
  27. package/cjs/src/embed/search.d.ts.map +1 -1
  28. package/cjs/src/embed/search.js +7 -3
  29. package/cjs/src/embed/search.js.map +1 -1
  30. package/cjs/src/embed/search.spec.js +10 -0
  31. package/cjs/src/embed/search.spec.js.map +1 -1
  32. package/cjs/src/embed/ts-embed.d.ts +1 -0
  33. package/cjs/src/embed/ts-embed.d.ts.map +1 -1
  34. package/cjs/src/embed/ts-embed.js +27 -7
  35. package/cjs/src/embed/ts-embed.js.map +1 -1
  36. package/cjs/src/embed/ts-embed.spec.js +114 -0
  37. package/cjs/src/embed/ts-embed.spec.js.map +1 -1
  38. package/cjs/src/react/index.spec.js +0 -12
  39. package/cjs/src/react/index.spec.js.map +1 -1
  40. package/cjs/src/types.d.ts +680 -231
  41. package/cjs/src/types.d.ts.map +1 -1
  42. package/cjs/src/types.js +605 -164
  43. package/cjs/src/types.js.map +1 -1
  44. package/cjs/src/utils/answerService.d.ts +10 -0
  45. package/cjs/src/utils/answerService.d.ts.map +1 -0
  46. package/cjs/src/utils/answerService.js +61 -0
  47. package/cjs/src/utils/answerService.js.map +1 -0
  48. package/cjs/src/utils/answerService.spec.d.ts +2 -0
  49. package/cjs/src/utils/answerService.spec.d.ts.map +1 -0
  50. package/cjs/src/utils/answerService.spec.js +31 -0
  51. package/cjs/src/utils/answerService.spec.js.map +1 -0
  52. package/cjs/src/utils/authService.d.ts +37 -0
  53. package/cjs/src/utils/authService.d.ts.map +1 -0
  54. package/cjs/src/utils/authService.js +106 -0
  55. package/cjs/src/utils/authService.js.map +1 -0
  56. package/cjs/src/utils/authService.spec.d.ts +2 -0
  57. package/cjs/src/utils/authService.spec.d.ts.map +1 -0
  58. package/cjs/src/utils/authService.spec.js +72 -0
  59. package/cjs/src/utils/authService.spec.js.map +1 -0
  60. package/cjs/src/utils/graphql/answerService/answerService.d.ts +2 -4
  61. package/cjs/src/utils/graphql/answerService/answerService.d.ts.map +1 -1
  62. package/cjs/src/utils/graphql/answerService/answerService.js +2 -4
  63. package/cjs/src/utils/graphql/answerService/answerService.js.map +1 -1
  64. package/cjs/src/utils/processData.d.ts +6 -0
  65. package/cjs/src/utils/processData.d.ts.map +1 -1
  66. package/cjs/src/utils/processData.js +5 -1
  67. package/cjs/src/utils/processData.js.map +1 -1
  68. package/cjs/src/utils/processTrigger.js +1 -1
  69. package/dist/src/auth.d.ts +4 -4
  70. package/dist/src/auth.d.ts.map +1 -1
  71. package/dist/src/embed/app.d.ts +15 -15
  72. package/dist/src/embed/app.d.ts.map +1 -1
  73. package/dist/src/embed/liveboard.d.ts +28 -23
  74. package/dist/src/embed/liveboard.d.ts.map +1 -1
  75. package/dist/src/embed/sage.d.ts +48 -30
  76. package/dist/src/embed/sage.d.ts.map +1 -1
  77. package/dist/src/embed/search-bar.d.ts +22 -6
  78. package/dist/src/embed/search-bar.d.ts.map +1 -1
  79. package/dist/src/embed/search.d.ts +34 -19
  80. package/dist/src/embed/search.d.ts.map +1 -1
  81. package/dist/src/embed/ts-embed.d.ts +1 -0
  82. package/dist/src/embed/ts-embed.d.ts.map +1 -1
  83. package/dist/src/types.d.ts +680 -231
  84. package/dist/src/types.d.ts.map +1 -1
  85. package/dist/src/utils/answerService.d.ts +10 -0
  86. package/dist/src/utils/answerService.d.ts.map +1 -0
  87. package/dist/src/utils/answerService.spec.d.ts +2 -0
  88. package/dist/src/utils/answerService.spec.d.ts.map +1 -0
  89. package/dist/src/utils/authService.d.ts +37 -0
  90. package/dist/src/utils/authService.d.ts.map +1 -0
  91. package/dist/src/utils/authService.spec.d.ts +2 -0
  92. package/dist/src/utils/authService.spec.d.ts.map +1 -0
  93. package/dist/src/utils/graphql/answerService/answerService.d.ts +2 -4
  94. package/dist/src/utils/graphql/answerService/answerService.d.ts.map +1 -1
  95. package/dist/src/utils/processData.d.ts +6 -0
  96. package/dist/src/utils/processData.d.ts.map +1 -1
  97. package/dist/tsembed-react.es.js +664 -194
  98. package/dist/tsembed-react.js +663 -193
  99. package/dist/tsembed.es.js +667 -194
  100. package/dist/tsembed.js +665 -192
  101. package/dist/visual-embed-sdk-react-full.d.ts +851 -328
  102. package/dist/visual-embed-sdk-react.d.ts +851 -328
  103. package/dist/visual-embed-sdk.d.ts +851 -328
  104. package/lib/.DS_Store +0 -0
  105. package/lib/package.json +1 -1
  106. package/lib/src/.DS_Store +0 -0
  107. package/lib/src/auth.d.ts +4 -4
  108. package/lib/src/auth.d.ts.map +1 -1
  109. package/lib/src/auth.js +10 -4
  110. package/lib/src/auth.js.map +1 -1
  111. package/lib/src/embed/app.d.ts +15 -15
  112. package/lib/src/embed/app.d.ts.map +1 -1
  113. package/lib/src/embed/app.js +1 -1
  114. package/lib/src/embed/app.js.map +1 -1
  115. package/lib/src/embed/liveboard.d.ts +28 -23
  116. package/lib/src/embed/liveboard.d.ts.map +1 -1
  117. package/lib/src/embed/liveboard.js +4 -3
  118. package/lib/src/embed/liveboard.js.map +1 -1
  119. package/lib/src/embed/sage.d.ts +48 -30
  120. package/lib/src/embed/sage.d.ts.map +1 -1
  121. package/lib/src/embed/sage.js +7 -6
  122. package/lib/src/embed/sage.js.map +1 -1
  123. package/lib/src/embed/sage.spec.js +3 -3
  124. package/lib/src/embed/sage.spec.js.map +1 -1
  125. package/lib/src/embed/search-bar.d.ts +22 -6
  126. package/lib/src/embed/search-bar.d.ts.map +1 -1
  127. package/lib/src/embed/search-bar.js.map +1 -1
  128. package/lib/src/embed/search.d.ts +34 -19
  129. package/lib/src/embed/search.d.ts.map +1 -1
  130. package/lib/src/embed/search.js +7 -3
  131. package/lib/src/embed/search.js.map +1 -1
  132. package/lib/src/embed/search.spec.js +10 -0
  133. package/lib/src/embed/search.spec.js.map +1 -1
  134. package/lib/src/embed/ts-embed.d.ts +1 -0
  135. package/lib/src/embed/ts-embed.d.ts.map +1 -1
  136. package/lib/src/embed/ts-embed.js +28 -8
  137. package/lib/src/embed/ts-embed.js.map +1 -1
  138. package/lib/src/embed/ts-embed.spec.js +114 -0
  139. package/lib/src/embed/ts-embed.spec.js.map +1 -1
  140. package/lib/src/react/index.spec.js +0 -12
  141. package/lib/src/react/index.spec.js.map +1 -1
  142. package/lib/src/types.d.ts +680 -231
  143. package/lib/src/types.d.ts.map +1 -1
  144. package/lib/src/types.js +605 -164
  145. package/lib/src/types.js.map +1 -1
  146. package/lib/src/utils/answerService.d.ts +10 -0
  147. package/lib/src/utils/answerService.d.ts.map +1 -0
  148. package/lib/src/utils/answerService.js +57 -0
  149. package/lib/src/utils/answerService.js.map +1 -0
  150. package/lib/src/utils/answerService.spec.d.ts +2 -0
  151. package/lib/src/utils/answerService.spec.d.ts.map +1 -0
  152. package/lib/src/utils/answerService.spec.js +29 -0
  153. package/lib/src/utils/answerService.spec.js.map +1 -0
  154. package/lib/src/utils/authService.d.ts +37 -0
  155. package/lib/src/utils/authService.d.ts.map +1 -0
  156. package/lib/src/utils/authService.js +97 -0
  157. package/lib/src/utils/authService.js.map +1 -0
  158. package/lib/src/utils/authService.spec.d.ts +2 -0
  159. package/lib/src/utils/authService.spec.d.ts.map +1 -0
  160. package/lib/src/utils/authService.spec.js +70 -0
  161. package/lib/src/utils/authService.spec.js.map +1 -0
  162. package/lib/src/utils/graphql/answerService/answerService.d.ts +2 -4
  163. package/lib/src/utils/graphql/answerService/answerService.d.ts.map +1 -1
  164. package/lib/src/utils/graphql/answerService/answerService.js +2 -4
  165. package/lib/src/utils/graphql/answerService/answerService.js.map +1 -1
  166. package/lib/src/utils/processData.d.ts +6 -0
  167. package/lib/src/utils/processData.d.ts.map +1 -1
  168. package/lib/src/utils/processData.js +4 -1
  169. package/lib/src/utils/processData.js.map +1 -1
  170. package/lib/src/utils/processTrigger.js +1 -1
  171. package/lib/src/visual-embed-sdk.d.ts +851 -328
  172. package/package.json +1 -1
  173. package/src/.DS_Store +0 -0
  174. package/src/auth.ts +10 -4
  175. package/src/embed/app.ts +20 -20
  176. package/src/embed/liveboard.ts +32 -27
  177. package/src/embed/sage.spec.ts +3 -3
  178. package/src/embed/sage.ts +54 -36
  179. package/src/embed/search-bar.tsx +22 -6
  180. package/src/embed/search.spec.ts +13 -0
  181. package/src/embed/search.ts +42 -22
  182. package/src/embed/ts-embed.spec.ts +132 -0
  183. package/src/embed/ts-embed.ts +27 -9
  184. package/src/react/index.spec.tsx +0 -29
  185. package/src/types.ts +680 -232
  186. package/src/utils/graphql/answerService/answerService.ts +2 -4
  187. package/src/utils/processData.ts +4 -1
  188. package/src/utils/processTrigger.ts +1 -1
@@ -23,18 +23,19 @@ import { getReleaseVersion } from '../auth';
23
23
  import { getEmbedConfig } from './embedConfig';
24
24
 
25
25
  /**
26
- * Configuration for search options
26
+ * Configuration for search options.
27
+ *
27
28
  */
28
29
  export interface SearchOptions {
29
30
  /**
30
- * The tml string to load the answer
31
+ * Search tokens to pass in the query.
31
32
  */
32
33
  searchTokenString: string;
33
34
  /**
34
- * Boolean to determine if the search should be executed or not.
35
- * if it is executed, put the focus on the results.
36
- * if it’s not executed, put the focus in the search bar - at the end of
37
- * the tokens
35
+ * Boolean to define if the search should be executed or not.
36
+ * If it is executed, the focus is placed on the results.
37
+ * If it’s not executed, the focus is placed at the end of
38
+ * the token string in the search bar.
38
39
  */
39
40
  executeSearch?: boolean;
40
41
  }
@@ -59,19 +60,15 @@ export interface SearchViewConfig
59
60
  */
60
61
  collapseDataSources?: boolean;
61
62
  /**
62
- * If set to true, hides the data sources panel.
63
+ * Show or hide the data sources panel.
63
64
  */
64
65
  hideDataSources?: boolean;
65
66
  /**
66
- * If set to true, hides the charts and tables in search answers.
67
+ * Show or hide the charts and tables in search answers.
67
68
  * This attribute can be used to create a custom visualization
68
69
  * using raw answer data.
69
70
  */
70
71
  hideResults?: boolean;
71
- /**
72
- * If set to true, expands all the data sources panel.
73
- */
74
- expandAllDataSource?: boolean;
75
72
  /**
76
73
  * If set to true, the Search Assist feature is enabled.
77
74
  *
@@ -85,9 +82,9 @@ export interface SearchViewConfig
85
82
  forceTable?: boolean;
86
83
  /**
87
84
  * The array of data source GUIDs to set on load.
88
- * Only a single dataSource supported currently.
85
+ * Only a single data source is supported currently.
89
86
  *
90
- * @deprecated Use dataSource instead
87
+ * @deprecated Use `dataSource` instead.
91
88
  */
92
89
  dataSources?: string[];
93
90
  /**
@@ -99,11 +96,29 @@ export interface SearchViewConfig
99
96
  /**
100
97
  * The initial search query to load the answer with.
101
98
  *
102
- * @deprecated Use {@link searchOptions} instead
99
+ * @deprecated
100
+ *
101
+ * Use {@link searchOptions} instead.
103
102
  */
104
103
  searchQuery?: string;
105
104
  /**
106
- * Configuration for search options
105
+ * Configuration for search options.
106
+ * Includes the following properties:
107
+ *
108
+ * `searchTokenString`: Search tokens to pass in the query.
109
+ *
110
+ * `executeSearch`: Boolean to define if the search should be executed or not.
111
+ * If it is executed, the focus is placed on the results.
112
+ * If it’s not executed, the focus is placed at the end of
113
+ * the token string in the search bar.
114
+ *
115
+ * @example
116
+ * ```js
117
+ * searchOptions: {
118
+ * searchTokenString: '[quantity purchased] [region]',
119
+ * executeSearch: true,
120
+ * }
121
+ * ```
107
122
  */
108
123
  searchOptions?: SearchOptions;
109
124
  /**
@@ -111,10 +126,10 @@ export interface SearchViewConfig
111
126
  */
112
127
  answerId?: string;
113
128
  /**
114
- * If set to true, search page will render without the Search Bar
129
+ * If set to true, the search page will render without the Search Bar
115
130
  * The chart/table should still be visible.
116
131
  *
117
- * @version SDK: 1.21.0 | ThoughtSpot: 9.2.0.cl
132
+ * @version SDK: 1.21.0 | ThoughtSpot: 9.2.0.cl, 9.5.0.sw
118
133
  */
119
134
  hideSearchBar?: boolean;
120
135
  /**
@@ -175,7 +190,6 @@ export class SearchEmbed extends TsEmbed {
175
190
  protected getEmbedParams(): string {
176
191
  const {
177
192
  hideResults,
178
- expandAllDataSource,
179
193
  enableSearchAssist,
180
194
  forceTable,
181
195
  searchOptions,
@@ -183,6 +197,7 @@ export class SearchEmbed extends TsEmbed {
183
197
  dataSource,
184
198
  dataSources,
185
199
  excludeRuntimeFiltersfromURL,
200
+ hideSearchBar,
186
201
  dataPanelV2 = false,
187
202
  useLastSelectedSources = false,
188
203
  runtimeParameters,
@@ -219,6 +234,10 @@ export class SearchEmbed extends TsEmbed {
219
234
  queryParams[Param.ForceTable] = true;
220
235
  }
221
236
 
237
+ if (hideSearchBar) {
238
+ queryParams[Param.HideSearchBar] = true;
239
+ }
240
+
222
241
  queryParams[Param.DataPanelV2Enabled] = dataPanelV2;
223
242
  queryParams[Param.DataSourceMode] = this.getDataSourceMode();
224
243
 
@@ -251,7 +270,8 @@ export class SearchEmbed extends TsEmbed {
251
270
  * @param answerId The GUID of a saved answer
252
271
  * @param dataSources A list of data source GUIDs
253
272
  */
254
- private getIFrameSrc(answerId: string) {
273
+ public getIFrameSrc(): string {
274
+ const { answerId } = this.viewConfig;
255
275
  const answerPath = answerId ? `saved-answer/${answerId}` : 'answer';
256
276
  const tsPostHashParams = this.getThoughtSpotPostUrlParams();
257
277
 
@@ -265,14 +285,14 @@ export class SearchEmbed extends TsEmbed {
265
285
  super.render();
266
286
  const { answerId } = this.viewConfig;
267
287
 
268
- const src = this.getIFrameSrc(answerId);
288
+ const src = this.getIFrameSrc();
269
289
  this.renderIFrame(src);
270
290
  getAuthPromise().then(() => {
271
291
  if (
272
292
  checkReleaseVersionInBeta(
273
293
  getReleaseVersion(),
274
294
  getEmbedConfig().suppressSearchEmbedBetaWarning
275
- || getEmbedConfig().suppressErrorAlerts,
295
+ || getEmbedConfig().suppressErrorAlerts,
276
296
  )
277
297
  ) {
278
298
  alert(ERROR_MESSAGE.SEARCHEMBED_BETA_WRANING_MESSAGE);
@@ -562,6 +562,138 @@ describe('Unit test case for ts embed', () => {
562
562
  });
563
563
  });
564
564
 
565
+ describe('Token fetch fails in cookieless authentication authType', () => {
566
+ beforeEach(() => {
567
+ jest.spyOn(authInstance, 'doCookielessTokenAuth').mockResolvedValueOnce(true);
568
+ init({
569
+ thoughtSpotHost: 'tshost',
570
+ customizations: customisations,
571
+ customCssUrl: 'http://localhost:5000',
572
+ authType: AuthType.TrustedAuthTokenCookieless,
573
+ getAuthToken: () => Promise.reject(),
574
+ });
575
+ });
576
+
577
+ afterEach(() => {
578
+ jest.clearAllMocks();
579
+ baseInstance.reset();
580
+ });
581
+
582
+ test('should show login failure message if token failed during app_init', async () => {
583
+ const a = jest.spyOn(authService, 'verifyTokenService');
584
+ a.mockResolvedValue(true);
585
+
586
+ // authVerifyMock.mockResolvedValue(true);
587
+ const mockEmbedEventPayload = {
588
+ type: EmbedEvent.APP_INIT,
589
+ data: {},
590
+ };
591
+ const searchEmbed = new SearchEmbed(getRootEl(), defaultViewConfig);
592
+ searchEmbed.render();
593
+ const mockPort: any = {
594
+ postMessage: jest.fn(),
595
+ };
596
+ await executeAfterWait(() => {
597
+ const iframe = getIFrameEl();
598
+ postMessageToParent(iframe.contentWindow, mockEmbedEventPayload, mockPort);
599
+ });
600
+ await executeAfterWait(() => {
601
+ expect(mockPort.postMessage).not.toHaveBeenCalled();
602
+ expect(getRootEl().innerHTML).toContain('Not logged in');
603
+ });
604
+
605
+ jest.spyOn(authService, 'verifyTokenService').mockClear();
606
+ });
607
+
608
+ test('should show login failure message if token failed during app_init prerender', async () => {
609
+ const a = jest.spyOn(authService, 'verifyTokenService');
610
+ a.mockResolvedValue(true);
611
+
612
+ // authVerifyMock.mockResolvedValue(true);
613
+ const mockEmbedEventPayload = {
614
+ type: EmbedEvent.APP_INIT,
615
+ data: {},
616
+ };
617
+ const searchEmbed = new SearchEmbed(getRootEl(), { ...defaultViewConfig, preRenderId: 'test' });
618
+ searchEmbed.preRender();
619
+ const mockPort: any = {
620
+ postMessage: jest.fn(),
621
+ };
622
+ await executeAfterWait(() => {
623
+ const iframe = getIFrameEl();
624
+ postMessageToParent(iframe.contentWindow, mockEmbedEventPayload, mockPort);
625
+ });
626
+ const preRenderWrapper = document.getElementById('tsEmbed-pre-render-wrapper-test');
627
+ await executeAfterWait(() => {
628
+ expect(mockPort.postMessage).not.toHaveBeenCalled();
629
+ expect(preRenderWrapper.innerHTML).toContain('Not logged in');
630
+ });
631
+
632
+ jest.spyOn(authService, 'verifyTokenService').mockClear();
633
+ });
634
+
635
+ test('should show login failure message if update token failed', async () => {
636
+ const a = jest.spyOn(authService, 'verifyTokenService');
637
+ a.mockResolvedValue(true);
638
+
639
+ // authVerifyMock.mockResolvedValue(true);
640
+ const mockEmbedEventPayload = {
641
+ type: EmbedEvent.AuthExpire,
642
+ data: {},
643
+ };
644
+ const searchEmbed = new SearchEmbed(getRootEl(), defaultViewConfig);
645
+ jest.spyOn(baseInstance, 'notifyAuthFailure');
646
+ searchEmbed.render();
647
+ const mockPort: any = {
648
+ postMessage: jest.fn(),
649
+ };
650
+ await executeAfterWait(() => {
651
+ const iframe = getIFrameEl();
652
+ postMessageToParent(iframe.contentWindow, mockEmbedEventPayload, mockPort);
653
+ });
654
+ await executeAfterWait(() => {
655
+ expect(getRootEl().innerHTML).toContain('Not logged in');
656
+ expect(baseInstance.notifyAuthFailure).toBeCalledWith(
657
+ authInstance.AuthFailureType.EXPIRY,
658
+ );
659
+ });
660
+
661
+ jest.spyOn(authService, 'verifyTokenService').mockClear();
662
+ jest.spyOn(baseInstance, 'notifyAuthFailure').mockClear();
663
+ });
664
+
665
+ test('should show login failure message if update token failed prerender', async () => {
666
+ const a = jest.spyOn(authService, 'verifyTokenService');
667
+ a.mockResolvedValue(true);
668
+
669
+ // authVerifyMock.mockResolvedValue(true);
670
+ const mockEmbedEventPayload = {
671
+ type: EmbedEvent.AuthExpire,
672
+ data: {},
673
+ };
674
+ const searchEmbed = new SearchEmbed(getRootEl(), { ...defaultViewConfig, preRenderId: 'test' });
675
+ jest.spyOn(baseInstance, 'notifyAuthFailure');
676
+ searchEmbed.preRender();
677
+ const mockPort: any = {
678
+ postMessage: jest.fn(),
679
+ };
680
+ await executeAfterWait(() => {
681
+ const iframe = getIFrameEl();
682
+ postMessageToParent(iframe.contentWindow, mockEmbedEventPayload, mockPort);
683
+ });
684
+ const preRenderWrapper = document.getElementById('tsEmbed-pre-render-wrapper-test');
685
+ await executeAfterWait(() => {
686
+ expect(preRenderWrapper.innerHTML).toContain('Not logged in');
687
+ expect(baseInstance.notifyAuthFailure).toBeCalledWith(
688
+ authInstance.AuthFailureType.EXPIRY,
689
+ );
690
+ });
691
+
692
+ jest.spyOn(authService, 'verifyTokenService').mockClear();
693
+ jest.spyOn(baseInstance, 'notifyAuthFailure').mockClear();
694
+ });
695
+ });
696
+
565
697
  xdescribe('AuthExpire embedEvent in TrustedAuthToken authType', () => {
566
698
  test('AutoLogin true scenario', async () => {
567
699
  init({
@@ -8,7 +8,6 @@
8
8
  */
9
9
 
10
10
  import isEqual from 'lodash/isEqual';
11
-
12
11
  import { getAuthenticationToken } from '../authToken';
13
12
  import { AnswerService } from '../utils/graphql/answerService/answerService';
14
13
  import {
@@ -52,7 +51,7 @@ import {
52
51
  RuntimeFilter,
53
52
  } from '../types';
54
53
  import { uploadMixpanelEvent, MIXPANEL_EVENT } from '../mixpanel-service';
55
- import { processEventData } from '../utils/processData';
54
+ import { processEventData, processAuthFailure } from '../utils/processData';
56
55
  import { processTrigger } from '../utils/processTrigger';
57
56
  import pkgInfo from '../../package.json';
58
57
  import {
@@ -306,7 +305,12 @@ export class TsEmbed {
306
305
  private appInitCb = async (_: any, responder: any) => {
307
306
  let authToken = '';
308
307
  if (this.embedConfig.authType === AuthType.TrustedAuthTokenCookieless) {
309
- authToken = await getAuthenticationToken(this.embedConfig);
308
+ try {
309
+ authToken = await getAuthenticationToken(this.embedConfig);
310
+ } catch (e) {
311
+ processAuthFailure(e, this.isPreRendered ? this.preRenderWrapper : this.el);
312
+ return;
313
+ }
310
314
  }
311
315
  this.isAppInitialized = true;
312
316
  responder({
@@ -336,11 +340,16 @@ export class TsEmbed {
336
340
  private updateAuthToken = async (_: any, responder: any) => {
337
341
  const { autoLogin = false, authType } = this.embedConfig; // Set autoLogin default to false
338
342
  if (authType === AuthType.TrustedAuthTokenCookieless) {
339
- const authToken = await getAuthenticationToken(this.embedConfig);
340
- responder({
341
- type: EmbedEvent.AuthExpire,
342
- data: { authToken },
343
- });
343
+ let authToken = '';
344
+ try {
345
+ authToken = await getAuthenticationToken(this.embedConfig);
346
+ responder({
347
+ type: EmbedEvent.AuthExpire,
348
+ data: { authToken },
349
+ });
350
+ } catch (e) {
351
+ processAuthFailure(e, this.isPreRendered ? this.preRenderWrapper : this.el);
352
+ }
344
353
  } else if (autoLogin) {
345
354
  handleAuth();
346
355
  }
@@ -505,7 +514,11 @@ export class TsEmbed {
505
514
  const queryParams = this.shouldEncodeUrlQueryParams
506
515
  ? `?base64UrlEncodedFlags=${getEncodedQueryParamsString(queryString)}`
507
516
  : `?${queryString}`;
508
- const path = `${this.thoughtSpotHost}/${queryParams}#`;
517
+ let host = this.thoughtSpotHost;
518
+ if (!isUndefined(this.embedConfig.enableReactShell)) {
519
+ host = this.embedConfig.enableReactShell as boolean ? '/v2' : '/v1';
520
+ }
521
+ const path = `${host}/${queryParams}#`;
509
522
  return path;
510
523
  }
511
524
 
@@ -524,6 +537,7 @@ export class TsEmbed {
524
537
 
525
538
  iFrame.src = frameSrc;
526
539
  iFrame.id = TS_EMBED_ID;
540
+ iFrame.setAttribute('data-ts-iframe', 'true');
527
541
 
528
542
  // according to screenfull.js documentation
529
543
  // allowFullscreen, webkitallowfullscreen and mozallowfullscreen must be
@@ -966,6 +980,10 @@ export class TsEmbed {
966
980
  return this;
967
981
  }
968
982
 
983
+ public getIframeSrc(): string {
984
+ return '';
985
+ }
986
+
969
987
  protected handleRenderForPrerender() {
970
988
  this.render();
971
989
  }
@@ -199,35 +199,6 @@ describe('React Components', () => {
199
199
  ).toBe(true);
200
200
  expect(containerSibling.querySelector('div')).toBe(null);
201
201
  });
202
-
203
- it('Should have the correct container element', async () => {
204
- const { container } = render(
205
- <LiveboardEmbed liveboardId="abcd" className="def" />,
206
- );
207
-
208
- await waitFor(() => getIFrameEl(container));
209
- expect(container.querySelector('div')).not.toBe(null);
210
- expect(
211
- container.querySelector('div').classList.contains('def'),
212
- ).toBe(true);
213
-
214
- const { container: containerSibling } = render(
215
- <LiveboardEmbed
216
- liveboardId="abcd"
217
- className="def"
218
- insertAsSibling={true}
219
- />,
220
- );
221
- await waitFor(() => getIFrameEl(containerSibling));
222
- expect(containerSibling.querySelector('span')).not.toBe(null);
223
- expect(containerSibling.querySelector('span').style.position).toBe(
224
- 'absolute',
225
- );
226
- expect(
227
- getIFrameEl(containerSibling).classList.contains('def'),
228
- ).toBe(true);
229
- expect(containerSibling.querySelector('div')).toBe(null);
230
- });
231
202
  });
232
203
 
233
204
  describe('SearchBarEmbed', () => {