@thoughtspot/visual-embed-sdk 1.39.1 → 1.39.2-spotter-agent

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 (181) hide show
  1. package/cjs/package.json +1 -1
  2. package/cjs/src/config.spec.js +9 -0
  3. package/cjs/src/config.spec.js.map +1 -1
  4. package/cjs/src/embed/app.d.ts.map +1 -1
  5. package/cjs/src/embed/app.js +2 -1
  6. package/cjs/src/embed/app.js.map +1 -1
  7. package/cjs/src/embed/app.spec.js +18 -8
  8. package/cjs/src/embed/app.spec.js.map +1 -1
  9. package/cjs/src/embed/bodyless-conversation.d.ts +19 -7
  10. package/cjs/src/embed/bodyless-conversation.d.ts.map +1 -1
  11. package/cjs/src/embed/bodyless-conversation.js +24 -4
  12. package/cjs/src/embed/bodyless-conversation.js.map +1 -1
  13. package/cjs/src/embed/bodyless-conversation.spec.js +8 -190
  14. package/cjs/src/embed/bodyless-conversation.spec.js.map +1 -1
  15. package/cjs/src/embed/conversation.spec.js +28 -0
  16. package/cjs/src/embed/conversation.spec.js.map +1 -1
  17. package/cjs/src/embed/embedConfig.d.ts +9 -7
  18. package/cjs/src/embed/embedConfig.d.ts.map +1 -1
  19. package/cjs/src/embed/embedConfig.js +9 -7
  20. package/cjs/src/embed/embedConfig.js.map +1 -1
  21. package/cjs/src/embed/liveboard.d.ts +0 -17
  22. package/cjs/src/embed/liveboard.d.ts.map +1 -1
  23. package/cjs/src/embed/liveboard.js +2 -4
  24. package/cjs/src/embed/liveboard.js.map +1 -1
  25. package/cjs/src/embed/liveboard.spec.js +12 -11
  26. package/cjs/src/embed/liveboard.spec.js.map +1 -1
  27. package/cjs/src/embed/ts-embed.d.ts +5 -0
  28. package/cjs/src/embed/ts-embed.d.ts.map +1 -1
  29. package/cjs/src/embed/ts-embed.js +16 -1
  30. package/cjs/src/embed/ts-embed.js.map +1 -1
  31. package/cjs/src/embed/ts-embed.spec.js +164 -0
  32. package/cjs/src/embed/ts-embed.spec.js.map +1 -1
  33. package/cjs/src/errors.d.ts +1 -0
  34. package/cjs/src/errors.d.ts.map +1 -1
  35. package/cjs/src/errors.js +1 -0
  36. package/cjs/src/errors.js.map +1 -1
  37. package/cjs/src/pages/embed-test.page.d.ts +8 -0
  38. package/cjs/src/pages/embed-test.page.d.ts.map +1 -0
  39. package/cjs/src/pages/embed-test.page.js +20 -0
  40. package/cjs/src/pages/embed-test.page.js.map +1 -0
  41. package/cjs/src/pages/home.page.d.ts +6 -0
  42. package/cjs/src/pages/home.page.d.ts.map +1 -0
  43. package/cjs/src/pages/home.page.js +12 -0
  44. package/cjs/src/pages/home.page.js.map +1 -0
  45. package/cjs/src/pages/login.page.d.ts +15 -0
  46. package/cjs/src/pages/login.page.d.ts.map +1 -0
  47. package/cjs/src/pages/login.page.js +22 -0
  48. package/cjs/src/pages/login.page.js.map +1 -0
  49. package/cjs/src/react/all-types-export.d.ts +1 -1
  50. package/cjs/src/react/all-types-export.d.ts.map +1 -1
  51. package/cjs/src/react/all-types-export.js +3 -2
  52. package/cjs/src/react/all-types-export.js.map +1 -1
  53. package/cjs/src/react/index.d.ts +71 -20
  54. package/cjs/src/react/index.d.ts.map +1 -1
  55. package/cjs/src/react/index.js +79 -42
  56. package/cjs/src/react/index.js.map +1 -1
  57. package/cjs/src/react/index.spec.js +436 -100
  58. package/cjs/src/react/index.spec.js.map +1 -1
  59. package/cjs/src/tests/auth.test.d.ts +1 -0
  60. package/cjs/src/tests/auth.test.d.ts.map +1 -0
  61. package/cjs/src/tests/auth.test.js +1 -0
  62. package/cjs/src/tests/auth.test.js.map +1 -0
  63. package/cjs/src/tests/e2e/auth.spec.d.ts +2 -0
  64. package/cjs/src/tests/e2e/auth.spec.d.ts.map +1 -0
  65. package/cjs/src/tests/e2e/auth.spec.js +54 -0
  66. package/cjs/src/tests/e2e/auth.spec.js.map +1 -0
  67. package/cjs/src/types.d.ts +34 -2
  68. package/cjs/src/types.d.ts.map +1 -1
  69. package/cjs/src/types.js +17 -1
  70. package/cjs/src/types.js.map +1 -1
  71. package/cjs/src/utils/graphql/nlsService/conversation-service.d.ts.map +1 -1
  72. package/cjs/src/utils/graphql/nlsService/conversation-service.js +2 -0
  73. package/cjs/src/utils/graphql/nlsService/conversation-service.js.map +1 -1
  74. package/cjs/src/utils.spec.js +25 -0
  75. package/cjs/src/utils.spec.js.map +1 -1
  76. package/dist/index-2QHwuA-G.js +7371 -0
  77. package/dist/index-Cj4BVGHL.js +7371 -0
  78. package/dist/index-DUaG1OG2.js +7447 -0
  79. package/dist/{index-JaFaxrvQ.js → index-DnIvX1FR.js} +1 -1
  80. package/dist/index-Fhk1V_Gw.js +7371 -0
  81. package/dist/index-OuiZF3zE.js +7371 -0
  82. package/dist/src/embed/app.d.ts.map +1 -1
  83. package/dist/src/embed/bodyless-conversation.d.ts +19 -7
  84. package/dist/src/embed/bodyless-conversation.d.ts.map +1 -1
  85. package/dist/src/embed/embedConfig.d.ts +9 -7
  86. package/dist/src/embed/embedConfig.d.ts.map +1 -1
  87. package/dist/src/embed/liveboard.d.ts +0 -17
  88. package/dist/src/embed/liveboard.d.ts.map +1 -1
  89. package/dist/src/embed/ts-embed.d.ts +5 -0
  90. package/dist/src/embed/ts-embed.d.ts.map +1 -1
  91. package/dist/src/errors.d.ts +1 -0
  92. package/dist/src/errors.d.ts.map +1 -1
  93. package/dist/src/react/all-types-export.d.ts +1 -1
  94. package/dist/src/react/all-types-export.d.ts.map +1 -1
  95. package/dist/src/react/index.d.ts +71 -20
  96. package/dist/src/react/index.d.ts.map +1 -1
  97. package/dist/src/types.d.ts +34 -2
  98. package/dist/src/types.d.ts.map +1 -1
  99. package/dist/src/utils/graphql/nlsService/conversation-service.d.ts.map +1 -1
  100. package/dist/tsembed-react.es.js +157 -68
  101. package/dist/tsembed-react.js +157 -66
  102. package/dist/tsembed.es.js +74 -20
  103. package/dist/tsembed.js +73 -19
  104. package/dist/visual-embed-sdk-react-full.d.ts +132 -52
  105. package/dist/visual-embed-sdk-react.d.ts +132 -52
  106. package/dist/visual-embed-sdk.d.ts +62 -33
  107. package/lib/package.json +1 -1
  108. package/lib/src/config.spec.js +9 -0
  109. package/lib/src/config.spec.js.map +1 -1
  110. package/lib/src/embed/app.d.ts.map +1 -1
  111. package/lib/src/embed/app.js +2 -1
  112. package/lib/src/embed/app.js.map +1 -1
  113. package/lib/src/embed/app.spec.js +19 -9
  114. package/lib/src/embed/app.spec.js.map +1 -1
  115. package/lib/src/embed/bodyless-conversation.d.ts +19 -7
  116. package/lib/src/embed/bodyless-conversation.d.ts.map +1 -1
  117. package/lib/src/embed/bodyless-conversation.js +23 -4
  118. package/lib/src/embed/bodyless-conversation.js.map +1 -1
  119. package/lib/src/embed/bodyless-conversation.spec.js +9 -191
  120. package/lib/src/embed/bodyless-conversation.spec.js.map +1 -1
  121. package/lib/src/embed/conversation.spec.js +30 -2
  122. package/lib/src/embed/conversation.spec.js.map +1 -1
  123. package/lib/src/embed/embedConfig.d.ts +9 -7
  124. package/lib/src/embed/embedConfig.d.ts.map +1 -1
  125. package/lib/src/embed/embedConfig.js +9 -7
  126. package/lib/src/embed/embedConfig.js.map +1 -1
  127. package/lib/src/embed/liveboard.d.ts +0 -17
  128. package/lib/src/embed/liveboard.d.ts.map +1 -1
  129. package/lib/src/embed/liveboard.js +2 -4
  130. package/lib/src/embed/liveboard.js.map +1 -1
  131. package/lib/src/embed/liveboard.spec.js +12 -11
  132. package/lib/src/embed/liveboard.spec.js.map +1 -1
  133. package/lib/src/embed/ts-embed.d.ts +5 -0
  134. package/lib/src/embed/ts-embed.d.ts.map +1 -1
  135. package/lib/src/embed/ts-embed.js +16 -1
  136. package/lib/src/embed/ts-embed.js.map +1 -1
  137. package/lib/src/embed/ts-embed.spec.js +164 -0
  138. package/lib/src/embed/ts-embed.spec.js.map +1 -1
  139. package/lib/src/errors.d.ts +1 -0
  140. package/lib/src/errors.d.ts.map +1 -1
  141. package/lib/src/errors.js +1 -0
  142. package/lib/src/errors.js.map +1 -1
  143. package/lib/src/react/all-types-export.d.ts +1 -1
  144. package/lib/src/react/all-types-export.d.ts.map +1 -1
  145. package/lib/src/react/all-types-export.js +1 -1
  146. package/lib/src/react/all-types-export.js.map +1 -1
  147. package/lib/src/react/index.d.ts +71 -20
  148. package/lib/src/react/index.d.ts.map +1 -1
  149. package/lib/src/react/index.js +79 -43
  150. package/lib/src/react/index.js.map +1 -1
  151. package/lib/src/react/index.spec.js +439 -103
  152. package/lib/src/react/index.spec.js.map +1 -1
  153. package/lib/src/types.d.ts +34 -2
  154. package/lib/src/types.d.ts.map +1 -1
  155. package/lib/src/types.js +17 -1
  156. package/lib/src/types.js.map +1 -1
  157. package/lib/src/utils/graphql/nlsService/conversation-service.d.ts.map +1 -1
  158. package/lib/src/utils/graphql/nlsService/conversation-service.js +2 -0
  159. package/lib/src/utils/graphql/nlsService/conversation-service.js.map +1 -1
  160. package/lib/src/utils.spec.js +26 -1
  161. package/lib/src/utils.spec.js.map +1 -1
  162. package/lib/src/visual-embed-sdk.d.ts +62 -33
  163. package/package.json +1 -1
  164. package/src/config.spec.ts +11 -0
  165. package/src/embed/app.spec.ts +36 -23
  166. package/src/embed/app.ts +2 -0
  167. package/src/embed/bodyless-conversation.spec.ts +9 -203
  168. package/src/embed/bodyless-conversation.ts +24 -10
  169. package/src/embed/conversation.spec.ts +40 -2
  170. package/src/embed/embedConfig.ts +10 -8
  171. package/src/embed/liveboard.spec.ts +5 -4
  172. package/src/embed/liveboard.ts +2 -22
  173. package/src/embed/ts-embed.spec.ts +225 -0
  174. package/src/embed/ts-embed.ts +19 -0
  175. package/src/errors.ts +1 -0
  176. package/src/react/all-types-export.ts +2 -1
  177. package/src/react/index.spec.tsx +556 -157
  178. package/src/react/index.tsx +117 -51
  179. package/src/types.ts +75 -43
  180. package/src/utils/graphql/nlsService/conversation-service.ts +2 -0
  181. package/src/utils.spec.ts +29 -0
@@ -3,8 +3,8 @@ import {
3
3
  SpotterEmbedViewConfig,
4
4
  } from './conversation';
5
5
  import * as authInstance from '../auth';
6
- import { init } from '../index';
7
- import { AuthType } from '../types';
6
+ import { Action, init } from '../index';
7
+ import { AuthType, Param } from '../types';
8
8
  import {
9
9
  getDocumentBody,
10
10
  getIFrameSrc,
@@ -142,4 +142,42 @@ describe('ConversationEmbed', () => {
142
142
  `http://${thoughtSpotHost}/v2/?${defaultParams}&isSpotterExperienceEnabled=true&enableDataPanelV2=true#/embed/insights/conv-assist?worksheet=worksheetId&query=searchQuery`,
143
143
  );
144
144
  });
145
+
146
+ it('should render the conversation embed with hidden actions of InConversationTraining if set', async () => {
147
+ const viewConfig: SpotterEmbedViewConfig = {
148
+ worksheetId: 'worksheetId',
149
+ searchOptions: {
150
+ searchQuery: 'searchQuery',
151
+ },
152
+ dataPanelV2: true,
153
+ hiddenActions: [Action.InConversationTraining]
154
+ };
155
+
156
+ const conversationEmbed = new SpotterEmbed(getRootEl(), viewConfig);
157
+ await conversationEmbed.render();
158
+ expectUrlMatchesWithParams(
159
+ getIFrameSrc(),
160
+ `http://${thoughtSpotHost}/v2/?${defaultParams}&hideAction=[%22${Action.ReportError}%22,%22${Action.InConversationTraining}%22]&isSpotterExperienceEnabled=true&enableDataPanelV2=true#/embed/insights/conv-assist?worksheet=worksheetId&query=searchQuery`,
161
+ );
162
+ });
163
+
164
+ it('should render the conversation embed with disabled actions of InConversationTraining if set', async () => {
165
+ const disabledReason = 'testing disabled reason';
166
+ const viewConfig: SpotterEmbedViewConfig = {
167
+ worksheetId: 'worksheetId',
168
+ searchOptions: {
169
+ searchQuery: 'searchQuery',
170
+ },
171
+ dataPanelV2: true,
172
+ disabledActions: [Action.InConversationTraining],
173
+ disabledActionReason: disabledReason,
174
+ };
175
+
176
+ const conversationEmbed = new SpotterEmbed(getRootEl(), viewConfig);
177
+ await conversationEmbed.render();
178
+ expectUrlMatchesWithParams(
179
+ getIFrameSrc(),
180
+ `http://${thoughtSpotHost}/v2/?${defaultParams}&${Param.DisableActions}=[%22${Action.InConversationTraining}%22]&${Param.DisableActionReason}=${disabledReason}&isSpotterExperienceEnabled=true&enableDataPanelV2=true#/embed/insights/conv-assist?worksheet=worksheetId&query=searchQuery`,
181
+ );
182
+ });
145
183
  });
@@ -10,13 +10,14 @@ const configKey = 'embedConfig';
10
10
  *
11
11
  * @example
12
12
  * ```js
13
+ * import { getInitConfig } from '@thoughtspot/visual-embed-sdk';
14
+ * // Call the getInitConfig method to retrieve the embed configuration
13
15
  * const config = getInitConfig();
16
+ * // Log the configuration settings
14
17
  * console.log(config);
15
18
  * ```
16
- * @example
17
- *
18
- * Returns the `EmbedConfig` object, which
19
- * contains the configuration settings used to
19
+ * Returns the link:https://developers.thoughtspot.com/docs/Interface_EmbedConfig[EmbedConfig]
20
+ * object, which contains the configuration settings used to
20
21
  * initialize the SDK, including the following:
21
22
  *
22
23
  * - `thoughtSpotHost` - ThoughtSpot host URL
@@ -24,10 +25,11 @@ const configKey = 'embedConfig';
24
25
  * `AuthServerCookieless` for `AuthType.TrustedAuthTokenCookieless`
25
26
  * - `customizations` - Style, text, and icon customization settings
26
27
  * that were applied during the SDK initialization.
27
- *
28
- * For a comprehensive list of embed configuration settings,
29
- * see link:https://developers.thoughtspot.com/docs/Interface_EmbedConfig[Developer Documentation].
30
28
  *
29
+ * The following JSON output shows the embed configuration
30
+ * settings returned from the code in the previous example:
31
+ *
32
+ * @example
31
33
  * ```json
32
34
  * {
33
35
  * "thoughtSpotHost": "https://{ThoughtSpot-Host}",
@@ -49,7 +51,7 @@ const configKey = 'embedConfig';
49
51
  * "authTriggerContainer": "#your-own-div"
50
52
  * }
51
53
  * ```
52
- * @version SDK: 1.19.0 | ThoughtSpot: 9.0.0.cl, 9.0.1.cl, and later
54
+ * @version SDK: 1.19.0 | ThoughtSpot: 9.0.0.cl, 9.0.1.sw, and later
53
55
  * @group Global methods
54
56
  */
55
57
  export const getEmbedConfig = (): EmbedConfig => getValueFromWindow(configKey) || ({} as any);
@@ -347,7 +347,7 @@ describe('Liveboard/viz embed tests', () => {
347
347
  await executeAfterWait(() => {
348
348
  expectUrlMatchesWithParams(
349
349
  getIFrameSrc(),
350
- `http://${thoughtSpotHost}/?embedApp=true${defaultParams}&coverAndFilterOptionInPDF=true${prefixParams}#/embed/viz/${liveboardId}`,
350
+ `http://${thoughtSpotHost}/?embedApp=true${defaultParams}&arePdfCoverFilterPageCheckboxesEnabled=true${prefixParams}#/embed/viz/${liveboardId}`,
351
351
  );
352
352
  });
353
353
  });
@@ -362,7 +362,7 @@ describe('Liveboard/viz embed tests', () => {
362
362
  await executeAfterWait(() => {
363
363
  expectUrlMatchesWithParams(
364
364
  getIFrameSrc(),
365
- `http://${thoughtSpotHost}/?embedApp=true${defaultParams}&coverAndFilterOptionInPDF=false&${prefixParams}#/embed/viz/${liveboardId}`,
365
+ `http://${thoughtSpotHost}/?embedApp=true${defaultParams}&arePdfCoverFilterPageCheckboxesEnabled=false&${prefixParams}#/embed/viz/${liveboardId}`,
366
366
  );
367
367
  });
368
368
  });
@@ -770,8 +770,9 @@ describe('Liveboard/viz embed tests', () => {
770
770
  });
771
771
 
772
772
  let resizeObserverCb: any;
773
- (window as any).ResizeObserver = window.ResizeObserver
774
- || jest.fn().mockImplementation((resizeObserverCbParam: any) => {
773
+ (window as any).ResizeObserver =
774
+ window.ResizeObserver ||
775
+ jest.fn().mockImplementation((resizeObserverCbParam: any) => {
775
776
  resizeObserverCb = resizeObserverCbParam;
776
777
  return {
777
778
  disconnect: jest.fn(),
@@ -269,24 +269,6 @@ export interface LiveboardViewConfig extends BaseViewConfig, LiveboardOtherViewC
269
269
  * })
270
270
  */
271
271
  dataSourceId?: string;
272
-
273
- /**
274
- * This flag is for show/hide checkboxes for include or exclude
275
- * cover page and filters in the Liveboard PDF.
276
- *
277
- * Supported embed types: `LiveboardEmbed`
278
- * @version SDK: 1.37.0 | ThoughtSpot:10.8.0.cl
279
- * @default true
280
- * Supported embed types: `LiveboardEmbed`
281
- * @example
282
- * ```js
283
- * const embed = new LiveboardEmbed('#tsEmbed', {
284
- * ... //other embed view config
285
- * coverAndFilterOptionInPDF: false,
286
- * })
287
- * ```
288
- */
289
- coverAndFilterOptionInPDF?: boolean;
290
272
  /**
291
273
  * The list of tab IDs to hide from the embedded.
292
274
  * This Tabs will be hidden from their respective LBs.
@@ -411,7 +393,7 @@ export class LiveboardEmbed extends V1Embed {
411
393
  oAuthPollingInterval,
412
394
  isForceRedirect,
413
395
  dataSourceId,
414
- coverAndFilterOptionInPDF,
396
+ coverAndFilterOptionInPDF = false,
415
397
  isLiveboardStylingAndGroupingEnabled,
416
398
  } = this.viewConfig;
417
399
 
@@ -471,9 +453,6 @@ export class LiveboardEmbed extends V1Embed {
471
453
  params[Param.DataSourceId] = dataSourceId;
472
454
  }
473
455
 
474
- if (coverAndFilterOptionInPDF !== undefined) {
475
- params[Param.CoverAndFilterOptionInPDF] = coverAndFilterOptionInPDF;
476
- }
477
456
 
478
457
  if (isLiveboardStylingAndGroupingEnabled !== undefined) {
479
458
  params[Param.IsLiveboardStylingAndGroupingEnabled] = isLiveboardStylingAndGroupingEnabled;
@@ -486,6 +465,7 @@ export class LiveboardEmbed extends V1Embed {
486
465
  params[Param.HideIrrelevantFiltersInTab] = hideIrrelevantChipsInLiveboardTabs;
487
466
  params[Param.DataPanelV2Enabled] = dataPanelV2;
488
467
  params[Param.EnableCustomColumnGroups] = enableCustomColumnGroups;
468
+ params[Param.CoverAndFilterOptionInPDF] = coverAndFilterOptionInPDF;
489
469
  const queryParams = getQueryParamString(params, true);
490
470
 
491
471
  return queryParams;
@@ -1360,6 +1360,231 @@ describe('Unit test case for ts embed', () => {
1360
1360
  });
1361
1361
  });
1362
1362
 
1363
+ describe('Preauth Cache for FullAppEmbed with PrimaryNavBar', () => {
1364
+ beforeAll(() => {
1365
+ jest.clearAllMocks();
1366
+ init({
1367
+ thoughtSpotHost,
1368
+ authType: AuthType.None,
1369
+ });
1370
+ });
1371
+ afterEach(() => {
1372
+ jest.clearAllMocks();
1373
+ });
1374
+
1375
+ afterAll(() => {
1376
+ jest.clearAllMocks();
1377
+ });
1378
+
1379
+ const setupPreauthTest = async (
1380
+ embedType: 'AppEmbed' | 'SearchEmbed',
1381
+ showPrimaryNavbar?: boolean,
1382
+ overrideOrgId?: number,
1383
+ disablePreauthCache?: boolean
1384
+ ) => {
1385
+ jest.spyOn(window, 'addEventListener').mockImplementationOnce(
1386
+ (event, handler, options) => {
1387
+ handler({
1388
+ data: { type: 'xyz' },
1389
+ ports: [3000],
1390
+ source: null,
1391
+ });
1392
+ },
1393
+ );
1394
+ mockProcessTrigger.mockResolvedValueOnce({ session: 'test' });
1395
+ jest.spyOn(baseInstance, 'getAuthPromise').mockResolvedValueOnce(true);
1396
+
1397
+ let mockGetPreauthInfo = null;
1398
+
1399
+ // Determine if preauth cache should be enabled
1400
+ const isAppEmbedWithPrimaryNavbar = embedType === 'AppEmbed' && showPrimaryNavbar === true;
1401
+ const shouldDisableCache = overrideOrgId || disablePreauthCache || isAppEmbedWithPrimaryNavbar;
1402
+
1403
+ if (shouldDisableCache) {
1404
+ mockGetPreauthInfo = jest.spyOn(sessionInfoService, 'getPreauthInfo')
1405
+ .mockImplementation(jest.fn());
1406
+ } else {
1407
+ mockGetPreauthInfo = jest.spyOn(sessionInfoService, 'getPreauthInfo')
1408
+ .mockResolvedValue({ info: { test: 'data' } });
1409
+ }
1410
+
1411
+ const mockPreauthInfoFetch = jest.spyOn(authService, 'fetchPreauthInfoService')
1412
+ .mockResolvedValueOnce({
1413
+ ok: true,
1414
+ headers: new Headers({ 'content-type': 'application/json' }),
1415
+ json: async () => ({
1416
+ info: { test: 'data' },
1417
+ }),
1418
+ } as any);
1419
+
1420
+ const viewConfig: any = {
1421
+ frameParams: { width: 1280, height: 720 },
1422
+ };
1423
+
1424
+ if (showPrimaryNavbar !== undefined) {
1425
+ viewConfig.showPrimaryNavbar = showPrimaryNavbar;
1426
+ }
1427
+ if (overrideOrgId !== undefined) {
1428
+ viewConfig.overrideOrgId = overrideOrgId;
1429
+ }
1430
+
1431
+ // Mock getEmbedConfig for disablePreauthCache
1432
+ if (disablePreauthCache !== undefined) {
1433
+ jest.spyOn(embedConfig, 'getEmbedConfig').mockReturnValueOnce({
1434
+ thoughtSpotHost,
1435
+ authType: AuthType.None,
1436
+ disablePreauthCache,
1437
+ });
1438
+ }
1439
+
1440
+ let embed;
1441
+ if (embedType === 'AppEmbed') {
1442
+ embed = new AppEmbed(getRootEl(), viewConfig);
1443
+ } else {
1444
+ embed = new SearchEmbed(getRootEl(), viewConfig);
1445
+ }
1446
+
1447
+ const iFrame: any = document.createElement('div');
1448
+ iFrame.contentWindow = {
1449
+ postMessage: jest.fn(),
1450
+ };
1451
+ jest.spyOn(iFrame, 'addEventListener').mockImplementationOnce(
1452
+ (event, handler, options) => {
1453
+ handler({});
1454
+ },
1455
+ );
1456
+ jest.spyOn(document, 'createElement').mockReturnValueOnce(iFrame);
1457
+
1458
+ await embed.render();
1459
+
1460
+ return {
1461
+ embed,
1462
+ mockGetPreauthInfo,
1463
+ mockPreauthInfoFetch,
1464
+ iFrame,
1465
+ };
1466
+ };
1467
+
1468
+ test('should disable preauth cache for FullAppEmbed with showPrimaryNavbar = true (default)', async () => {
1469
+ const { mockGetPreauthInfo } = await setupPreauthTest('AppEmbed', true);
1470
+
1471
+ // Wait for any async operations
1472
+ await executeAfterWait(() => {
1473
+ expect(mockGetPreauthInfo).toHaveBeenCalledTimes(0);
1474
+ });
1475
+ });
1476
+
1477
+ test('should enable preauth cache for FullAppEmbed with showPrimaryNavbar = undefined (no longer defaults to true)', async () => {
1478
+ const { mockGetPreauthInfo } = await setupPreauthTest('AppEmbed', undefined);
1479
+
1480
+ await executeAfterWait(() => {
1481
+ expect(mockGetPreauthInfo).toHaveBeenCalledTimes(1);
1482
+ expect(mockProcessTrigger).toHaveBeenCalledWith(
1483
+ expect.any(Object),
1484
+ HostEvent.InfoSuccess,
1485
+ 'http://tshost',
1486
+ expect.objectContaining({ info: expect.any(Object) }),
1487
+ );
1488
+ });
1489
+ });
1490
+
1491
+ test('should enable preauth cache for FullAppEmbed with showPrimaryNavbar = false', async () => {
1492
+ const { mockGetPreauthInfo } = await setupPreauthTest('AppEmbed', false);
1493
+
1494
+ await executeAfterWait(() => {
1495
+ expect(mockGetPreauthInfo).toHaveBeenCalledTimes(1);
1496
+ expect(mockProcessTrigger).toHaveBeenCalledWith(
1497
+ expect.any(Object),
1498
+ HostEvent.InfoSuccess,
1499
+ 'http://tshost',
1500
+ expect.objectContaining({ info: expect.any(Object) }),
1501
+ );
1502
+ });
1503
+ });
1504
+
1505
+ test('should enable preauth cache for SearchEmbed regardless of showPrimaryNavbar', async () => {
1506
+ const { mockGetPreauthInfo } = await setupPreauthTest('SearchEmbed', true);
1507
+
1508
+ await executeAfterWait(() => {
1509
+ expect(mockGetPreauthInfo).toHaveBeenCalledTimes(1);
1510
+ expect(mockProcessTrigger).toHaveBeenCalledWith(
1511
+ expect.any(Object),
1512
+ HostEvent.InfoSuccess,
1513
+ 'http://tshost',
1514
+ expect.objectContaining({ info: expect.any(Object) }),
1515
+ );
1516
+ });
1517
+ });
1518
+
1519
+ test('should enable preauth cache for SearchEmbed (verifies fix for embed type regression)', async () => {
1520
+ const { mockGetPreauthInfo } = await setupPreauthTest('SearchEmbed', false);
1521
+
1522
+ await executeAfterWait(() => {
1523
+ expect(mockGetPreauthInfo).toHaveBeenCalledTimes(1);
1524
+ expect(mockProcessTrigger).toHaveBeenCalledWith(
1525
+ expect.any(Object),
1526
+ HostEvent.InfoSuccess,
1527
+ 'http://tshost',
1528
+ expect.objectContaining({ info: expect.any(Object) }),
1529
+ );
1530
+ });
1531
+ });
1532
+
1533
+ test('should disable preauth cache for FullAppEmbed with overrideOrgId (combined condition)', async () => {
1534
+ const { mockGetPreauthInfo } = await setupPreauthTest('AppEmbed', false, 123);
1535
+
1536
+ await executeAfterWait(() => {
1537
+ expect(mockGetPreauthInfo).toHaveBeenCalledTimes(0);
1538
+ });
1539
+ });
1540
+
1541
+ test('should disable preauth cache for FullAppEmbed with disablePreauthCache = true', async () => {
1542
+ const { mockGetPreauthInfo } = await setupPreauthTest('AppEmbed', false, undefined, true);
1543
+
1544
+ await executeAfterWait(() => {
1545
+ expect(mockGetPreauthInfo).toHaveBeenCalledTimes(0);
1546
+ });
1547
+ });
1548
+ });
1549
+
1550
+ describe('isFullAppEmbedWithVisiblePrimaryNavbar helper method', () => {
1551
+ beforeAll(() => {
1552
+ init({
1553
+ thoughtSpotHost,
1554
+ authType: AuthType.None,
1555
+ });
1556
+ });
1557
+
1558
+ afterEach(() => {
1559
+ jest.clearAllMocks();
1560
+ });
1561
+
1562
+ test('should return true for AppEmbed with showPrimaryNavbar = true', () => {
1563
+ const appEmbed = new AppEmbed(getRootEl(), { showPrimaryNavbar: true });
1564
+ expect(appEmbed['isFullAppEmbedWithVisiblePrimaryNavbar']()).toBe(true);
1565
+ });
1566
+
1567
+ test('should return false for AppEmbed with showPrimaryNavbar = undefined (no longer defaults to true)', () => {
1568
+ const appEmbed = new AppEmbed(getRootEl(), {});
1569
+ expect(appEmbed['isFullAppEmbedWithVisiblePrimaryNavbar']()).toBe(false);
1570
+ });
1571
+
1572
+ test('should return false for AppEmbed with showPrimaryNavbar = false', () => {
1573
+ const appEmbed = new AppEmbed(getRootEl(), { showPrimaryNavbar: false });
1574
+ expect(appEmbed['isFullAppEmbedWithVisiblePrimaryNavbar']()).toBe(false);
1575
+ });
1576
+
1577
+ test('should return false for SearchEmbed (not FullAppEmbed)', () => {
1578
+ const searchEmbed = new SearchEmbed(getRootEl(), {});
1579
+ expect(searchEmbed['isFullAppEmbedWithVisiblePrimaryNavbar']()).toBe(false);
1580
+ });
1581
+
1582
+ test('should return false for LiveboardEmbed (not FullAppEmbed)', () => {
1583
+ const liveboardEmbed = new LiveboardEmbed(getRootEl(), { liveboardId: 'test-id' });
1584
+ expect(liveboardEmbed['isFullAppEmbedWithVisiblePrimaryNavbar']()).toBe(false);
1585
+ });
1586
+ });
1587
+
1363
1588
  describe('when thoughtSpotHost have value and authPromise return error', () => {
1364
1589
  beforeAll(() => {
1365
1590
  init({
@@ -264,13 +264,32 @@ export class TsEmbed {
264
264
  // - cached auth info would be for wrong org
265
265
  // - info call response changes for each different overrideOrgId
266
266
  // 2. disablePreauthCache is explicitly set to true
267
+ // 3. FullAppEmbed has primary navbar visible since:
268
+ // - primary navbar requires fresh auth state for navigation
269
+ // - cached auth may not reflect current user permissions
267
270
  const isDisabled = (
268
271
  this.viewConfig.overrideOrgId !== undefined
269
272
  || this.embedConfig.disablePreauthCache === true
273
+ || this.isFullAppEmbedWithVisiblePrimaryNavbar()
270
274
  );
271
275
  return !isDisabled;
272
276
  }
273
277
 
278
+ /**
279
+ * Checks if current embed is FullAppEmbed with visible primary navbar
280
+ * @returns boolean
281
+ */
282
+ private isFullAppEmbedWithVisiblePrimaryNavbar(): boolean {
283
+ const appViewConfig = this.viewConfig as any;
284
+
285
+ // Check if this is a FullAppEmbed (AppEmbed)
286
+ // showPrimaryNavbar defaults to true if not explicitly set to false
287
+ return (
288
+ appViewConfig.embedComponentType === 'AppEmbed'
289
+ && appViewConfig.showPrimaryNavbar === true
290
+ );
291
+ }
292
+
274
293
  /**
275
294
  * fix for ts7.sep.cl
276
295
  * will be removed for ts7.oct.cl
package/src/errors.ts CHANGED
@@ -17,4 +17,5 @@ export const ERROR_MESSAGE = {
17
17
  CSP_FRAME_HOST_VIOLATION_LOG_MESSAGE: 'Please set up CSP correctly for the application to start working. For more information, see https://developers.thoughtspot.com/docs/security-settings#csp-viz-embed-hosts. \n If the issue persists, refer to https://developers.thoughtspot.com/docs/security-settings#csp-viz-embed-hosts',
18
18
  MISSING_REPORTING_OBSERVER: 'ReportingObserver not supported',
19
19
  RENDER_CALLED_BEFORE_INIT: 'Looks like render was called before calling init, the render won\'t start until init is called.\nFor more info check\n1. https://developers.thoughtspot.com/docs/Function_init#_init\n2.https://developers.thoughtspot.com/docs/getting-started#initSdk',
20
+ SPOTTER_AGENT_NOT_INITIALIZED: 'SpotterAgent not initialized',
20
21
  };
@@ -12,7 +12,8 @@ export {
12
12
  SpotterEmbed,
13
13
  ConversationEmbed,
14
14
  PreRenderedConversationEmbed,
15
- SpotterAgentEmbed,
15
+ SpotterMessage,
16
+ useSpotterAgent,
16
17
  useEmbedRef,
17
18
  useInit,
18
19
  } from './index';