@thoughtspot/visual-embed-sdk 1.35.11 → 1.35.13

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 (143) hide show
  1. package/cjs/package.json +1 -1
  2. package/cjs/src/auth.d.ts +2 -1
  3. package/cjs/src/auth.d.ts.map +1 -1
  4. package/cjs/src/auth.js +3 -1
  5. package/cjs/src/auth.js.map +1 -1
  6. package/cjs/src/embed/app.d.ts.map +1 -1
  7. package/cjs/src/embed/app.js +2 -0
  8. package/cjs/src/embed/app.js.map +1 -1
  9. package/cjs/src/embed/conversation.d.ts +44 -0
  10. package/cjs/src/embed/conversation.d.ts.map +1 -1
  11. package/cjs/src/embed/conversation.js +10 -1
  12. package/cjs/src/embed/conversation.js.map +1 -1
  13. package/cjs/src/embed/conversation.spec.js +36 -0
  14. package/cjs/src/embed/conversation.spec.js.map +1 -1
  15. package/cjs/src/embed/hostEventClient/contracts.d.ts +3 -3
  16. package/cjs/src/embed/hostEventClient/contracts.d.ts.map +1 -1
  17. package/cjs/src/embed/hostEventClient/host-event-client.d.ts.map +1 -1
  18. package/cjs/src/embed/hostEventClient/host-event-client.js +6 -1
  19. package/cjs/src/embed/hostEventClient/host-event-client.js.map +1 -1
  20. package/cjs/src/embed/liveboard.d.ts +5 -4
  21. package/cjs/src/embed/liveboard.d.ts.map +1 -1
  22. package/cjs/src/embed/liveboard.js +11 -4
  23. package/cjs/src/embed/liveboard.js.map +1 -1
  24. package/cjs/src/embed/liveboard.spec.js +1 -1
  25. package/cjs/src/embed/liveboard.spec.js.map +1 -1
  26. package/cjs/src/embed/search-bar.d.ts.map +1 -1
  27. package/cjs/src/embed/search-bar.js +4 -2
  28. package/cjs/src/embed/search-bar.js.map +1 -1
  29. package/cjs/src/embed/search.d.ts.map +1 -1
  30. package/cjs/src/embed/search.js +4 -2
  31. package/cjs/src/embed/search.js.map +1 -1
  32. package/cjs/src/embed/search.spec.js +56 -3
  33. package/cjs/src/embed/search.spec.js.map +1 -1
  34. package/cjs/src/embed/ts-embed.d.ts +6 -0
  35. package/cjs/src/embed/ts-embed.d.ts.map +1 -1
  36. package/cjs/src/embed/ts-embed.js +43 -15
  37. package/cjs/src/embed/ts-embed.js.map +1 -1
  38. package/cjs/src/embed/ts-embed.spec.d.ts.map +1 -1
  39. package/cjs/src/embed/ts-embed.spec.js +193 -81
  40. package/cjs/src/embed/ts-embed.spec.js.map +1 -1
  41. package/cjs/src/types.d.ts +85 -20
  42. package/cjs/src/types.d.ts.map +1 -1
  43. package/cjs/src/types.js +80 -9
  44. package/cjs/src/types.js.map +1 -1
  45. package/cjs/src/utils/processData.d.ts.map +1 -1
  46. package/cjs/src/utils/processData.js +9 -2
  47. package/cjs/src/utils/processData.js.map +1 -1
  48. package/cjs/src/utils/processData.spec.js +51 -0
  49. package/cjs/src/utils/processData.spec.js.map +1 -1
  50. package/dist/index-B3hd6DTM.js +7370 -0
  51. package/dist/index-D-9WUCUl.js +7370 -0
  52. package/dist/src/auth.d.ts +2 -1
  53. package/dist/src/auth.d.ts.map +1 -1
  54. package/dist/src/embed/app.d.ts.map +1 -1
  55. package/dist/src/embed/conversation.d.ts +44 -0
  56. package/dist/src/embed/conversation.d.ts.map +1 -1
  57. package/dist/src/embed/hostEventClient/contracts.d.ts +3 -3
  58. package/dist/src/embed/hostEventClient/contracts.d.ts.map +1 -1
  59. package/dist/src/embed/hostEventClient/host-event-client.d.ts.map +1 -1
  60. package/dist/src/embed/liveboard.d.ts +5 -4
  61. package/dist/src/embed/liveboard.d.ts.map +1 -1
  62. package/dist/src/embed/search-bar.d.ts.map +1 -1
  63. package/dist/src/embed/search.d.ts.map +1 -1
  64. package/dist/src/embed/ts-embed.d.ts +6 -0
  65. package/dist/src/embed/ts-embed.d.ts.map +1 -1
  66. package/dist/src/embed/ts-embed.spec.d.ts.map +1 -1
  67. package/dist/src/types.d.ts +85 -20
  68. package/dist/src/types.d.ts.map +1 -1
  69. package/dist/src/utils/processData.d.ts.map +1 -1
  70. package/dist/tsembed-react.es.js +175 -40
  71. package/dist/tsembed-react.js +174 -39
  72. package/dist/tsembed.es.js +175 -40
  73. package/dist/tsembed.js +174 -39
  74. package/dist/visual-embed-sdk-react-full.d.ts +138 -27
  75. package/dist/visual-embed-sdk-react.d.ts +138 -27
  76. package/dist/visual-embed-sdk.d.ts +138 -27
  77. package/lib/package.json +1 -1
  78. package/lib/src/auth.d.ts +2 -1
  79. package/lib/src/auth.d.ts.map +1 -1
  80. package/lib/src/auth.js +3 -1
  81. package/lib/src/auth.js.map +1 -1
  82. package/lib/src/embed/app.d.ts.map +1 -1
  83. package/lib/src/embed/app.js +2 -0
  84. package/lib/src/embed/app.js.map +1 -1
  85. package/lib/src/embed/conversation.d.ts +44 -0
  86. package/lib/src/embed/conversation.d.ts.map +1 -1
  87. package/lib/src/embed/conversation.js +10 -1
  88. package/lib/src/embed/conversation.js.map +1 -1
  89. package/lib/src/embed/conversation.spec.js +36 -0
  90. package/lib/src/embed/conversation.spec.js.map +1 -1
  91. package/lib/src/embed/hostEventClient/contracts.d.ts +3 -3
  92. package/lib/src/embed/hostEventClient/contracts.d.ts.map +1 -1
  93. package/lib/src/embed/hostEventClient/host-event-client.d.ts.map +1 -1
  94. package/lib/src/embed/hostEventClient/host-event-client.js +6 -1
  95. package/lib/src/embed/hostEventClient/host-event-client.js.map +1 -1
  96. package/lib/src/embed/liveboard.d.ts +5 -4
  97. package/lib/src/embed/liveboard.d.ts.map +1 -1
  98. package/lib/src/embed/liveboard.js +11 -4
  99. package/lib/src/embed/liveboard.js.map +1 -1
  100. package/lib/src/embed/liveboard.spec.js +1 -1
  101. package/lib/src/embed/liveboard.spec.js.map +1 -1
  102. package/lib/src/embed/search-bar.d.ts.map +1 -1
  103. package/lib/src/embed/search-bar.js +4 -2
  104. package/lib/src/embed/search-bar.js.map +1 -1
  105. package/lib/src/embed/search.d.ts.map +1 -1
  106. package/lib/src/embed/search.js +4 -2
  107. package/lib/src/embed/search.js.map +1 -1
  108. package/lib/src/embed/search.spec.js +56 -3
  109. package/lib/src/embed/search.spec.js.map +1 -1
  110. package/lib/src/embed/ts-embed.d.ts +6 -0
  111. package/lib/src/embed/ts-embed.d.ts.map +1 -1
  112. package/lib/src/embed/ts-embed.js +43 -15
  113. package/lib/src/embed/ts-embed.js.map +1 -1
  114. package/lib/src/embed/ts-embed.spec.d.ts.map +1 -1
  115. package/lib/src/embed/ts-embed.spec.js +195 -83
  116. package/lib/src/embed/ts-embed.spec.js.map +1 -1
  117. package/lib/src/types.d.ts +85 -20
  118. package/lib/src/types.d.ts.map +1 -1
  119. package/lib/src/types.js +80 -9
  120. package/lib/src/types.js.map +1 -1
  121. package/lib/src/utils/processData.d.ts.map +1 -1
  122. package/lib/src/utils/processData.js +9 -2
  123. package/lib/src/utils/processData.js.map +1 -1
  124. package/lib/src/utils/processData.spec.js +51 -0
  125. package/lib/src/utils/processData.spec.js.map +1 -1
  126. package/lib/src/visual-embed-sdk.d.ts +139 -28
  127. package/package.json +1 -1
  128. package/src/auth.ts +3 -1
  129. package/src/embed/app.ts +2 -0
  130. package/src/embed/conversation.spec.ts +52 -3
  131. package/src/embed/conversation.ts +60 -1
  132. package/src/embed/hostEventClient/contracts.ts +3 -3
  133. package/src/embed/hostEventClient/host-event-client.ts +7 -1
  134. package/src/embed/liveboard.spec.ts +1 -1
  135. package/src/embed/liveboard.ts +18 -12
  136. package/src/embed/search-bar.tsx +6 -4
  137. package/src/embed/search.spec.ts +71 -3
  138. package/src/embed/search.ts +6 -5
  139. package/src/embed/ts-embed.spec.ts +234 -102
  140. package/src/embed/ts-embed.ts +50 -34
  141. package/src/types.ts +89 -16
  142. package/src/utils/processData.spec.ts +63 -0
  143. package/src/utils/processData.ts +12 -2
@@ -539,10 +539,10 @@ describe('Search embed tests', () => {
539
539
  });
540
540
  });
541
541
 
542
- test('with excludeSearchTokenStringFromURL', async () => {
542
+ test('with excludeSearchTokenStringFromURL, execute as false', async () => {
543
543
  const searchOptions: SearchOptions = {
544
544
  searchTokenString: '[commit date][revenue]',
545
- executeSearch: true,
545
+ executeSearch: false,
546
546
  };
547
547
  const searchEmbed = new SearchEmbed(getRootEl(), {
548
548
  ...defaultViewConfig,
@@ -570,6 +570,9 @@ describe('Search embed tests', () => {
570
570
  );
571
571
  });
572
572
 
573
+ expect(getIFrameSrc().includes('searchTokenString')).toBeFalsy();
574
+ expect(getIFrameSrc().includes('executeSearch')).toBeFalsy();
575
+
573
576
  expect(mockPort.postMessage).toHaveBeenCalledWith({
574
577
  type: EmbedEvent.APP_INIT,
575
578
  data: expect.objectContaining({
@@ -580,22 +583,87 @@ describe('Search embed tests', () => {
580
583
  });
581
584
  });
582
585
 
583
- test('without excludeSearchTokenStringFromURL', async () => {
586
+ test('with excludeSearchTokenStringFromURL with execute true', async () => {
584
587
  const searchOptions: SearchOptions = {
585
588
  searchTokenString: '[commit date][revenue]',
586
589
  executeSearch: true,
587
590
  };
591
+ const searchEmbed = new SearchEmbed(getRootEl(), {
592
+ ...defaultViewConfig,
593
+ searchOptions,
594
+ excludeSearchTokenStringFromURL: true,
595
+ });
596
+ const mockEmbedEventPayload = {
597
+ type: EmbedEvent.APP_INIT,
598
+ data: {},
599
+ };
600
+ searchEmbed.render();
601
+
602
+ const mockPort: any = {
603
+ postMessage: jest.fn(),
604
+ };
605
+ await executeAfterWait(() => {
606
+ const iframe = getIFrameEl();
607
+ postMessageToParent(iframe.contentWindow, mockEmbedEventPayload, mockPort);
608
+ });
609
+
610
+ expect(getIFrameSrc().includes('searchTokenString')).toBeFalsy();
611
+
612
+ await executeAfterWait(() => {
613
+ expectUrlMatchesWithParams(
614
+ getIFrameSrc(),
615
+ `http://${thoughtSpotHost}/v2/?${defaultParamsWithHiddenActions}&executeSearch=true&dataSourceMode=expand&enableDataPanelV2=false&useLastSelectedSources=false${prefixParams}#/embed/saved-answer/${answerId}`,
616
+ );
617
+ });
618
+
619
+ expect(mockPort.postMessage).toHaveBeenCalledWith({
620
+ type: EmbedEvent.APP_INIT,
621
+ data: expect.objectContaining({
622
+ searchOptions: {
623
+ searchTokenString: '[commit date][revenue]',
624
+ },
625
+ }),
626
+ });
627
+ });
628
+
629
+ test('without excludeSearchTokenStringFromURL with execute search as false', async () => {
630
+ const searchOptions: SearchOptions = {
631
+ searchTokenString: '[commit date][revenue]',
632
+ executeSearch: false,
633
+ };
634
+ const searchEmbed = new SearchEmbed(getRootEl(), {
635
+ ...defaultViewConfig,
636
+ searchOptions,
637
+ excludeSearchTokenStringFromURL: false,
638
+ });
639
+ searchEmbed.render();
640
+ await executeAfterWait(() => {
641
+ expectUrlMatchesWithParams(
642
+ getIFrameSrc(),
643
+ `http://${thoughtSpotHost}/v2/?${defaultParamsWithHiddenActions}&dataSourceMode=expand&enableDataPanelV2=false&useLastSelectedSources=false&searchTokenString=[commit date][revenue]${prefixParams}#/embed/saved-answer/${answerId}`,
644
+ );
645
+ });
646
+ });
647
+
648
+ test('without excludeSearchTokenStringFromURL with executeSearch as false', async () => {
649
+ const searchOptions: SearchOptions = {
650
+ searchTokenString: '[commit date][revenue]',
651
+ executeSearch: false,
652
+ };
588
653
  const searchEmbed = new SearchEmbed(getRootEl(), {
589
654
  ...defaultViewConfig,
590
655
  searchOptions,
591
656
  excludeSearchTokenStringFromURL: false,
592
657
  });
593
658
  searchEmbed.render();
659
+
594
660
  await executeAfterWait(() => {
595
661
  expectUrlMatchesWithParams(
596
662
  getIFrameSrc(),
597
663
  `http://${thoughtSpotHost}/v2/?${defaultParamsWithHiddenActions}&dataSourceMode=expand&enableDataPanelV2=false&useLastSelectedSources=false&searchTokenString=[commit date][revenue]${prefixParams}#/embed/saved-answer/${answerId}`,
598
664
  );
599
665
  });
666
+
667
+ expect(getIFrameSrc().includes('executeSearch')).toBeFalsy();
600
668
  });
601
669
  });
@@ -392,11 +392,12 @@ export class SearchEmbed extends TsEmbed {
392
392
  if (dataSource) {
393
393
  queryParams[Param.DataSources] = `["${dataSource}"]`;
394
394
  }
395
- if (searchOptions?.searchTokenString && !excludeSearchTokenStringFromURL) {
396
- queryParams[Param.searchTokenString] = encodeURIComponent(
397
- searchOptions.searchTokenString,
398
- );
399
-
395
+ if (searchOptions?.searchTokenString) {
396
+ if (!excludeSearchTokenStringFromURL) {
397
+ queryParams[Param.searchTokenString] = encodeURIComponent(
398
+ searchOptions.searchTokenString,
399
+ );
400
+ }
400
401
  if (searchOptions.executeSearch) {
401
402
  queryParams[Param.executeSearch] = true;
402
403
  }
@@ -18,9 +18,15 @@ import {
18
18
  AnswerService,
19
19
  } from '../index';
20
20
  import {
21
- Action, HomeLeftNavItem, RuntimeFilter, RuntimeFilterOp, HomepageModule, HostEvent,
21
+ Action,
22
+ HomeLeftNavItem,
23
+ RuntimeFilter,
24
+ RuntimeFilterOp,
25
+ HomepageModule,
26
+ HostEvent,
22
27
  RuntimeParameter,
23
28
  Param,
29
+ ContextMenuTriggerOptions,
24
30
  } from '../types';
25
31
  import {
26
32
  executeAfterWait,
@@ -264,7 +270,45 @@ describe('Unit test case for ts embed', () => {
264
270
  });
265
271
  });
266
272
  });
273
+
274
+ test('check for new authToken based on getAuthToken function', async () => {
275
+ init({
276
+ thoughtSpotHost: 'tshost',
277
+ customizations: customisations,
278
+ authType: AuthType.TrustedAuthToken,
279
+ getAuthToken: () => Promise.resolve('test_auth_token2'),
280
+ autoLogin: true,
281
+ });
282
+
283
+ const mockEmbedEventPayload = {
284
+ type: EmbedEvent.AuthExpire,
285
+ data: {},
286
+ };
287
+ const searchEmbed = new SearchEmbed(getRootEl(), defaultViewConfig);
288
+ jest.spyOn(baseInstance, 'notifyAuthFailure');
289
+ jest.spyOn(baseInstance, 'handleAuth');
290
+
291
+ searchEmbed.render();
292
+ const mockPort: any = {
293
+ postMessage: jest.fn(),
294
+ };
295
+ await executeAfterWait(() => {
296
+ const iframe = getIFrameEl();
297
+ postMessageToParent(iframe.contentWindow, mockEmbedEventPayload, mockPort);
298
+ });
299
+ await executeAfterWait(() => {
300
+ expect(baseInstance.notifyAuthFailure).toBeCalledWith(
301
+ authInstance.AuthFailureType.EXPIRY,
302
+ );
303
+ expect(mockPort.postMessage).not.toHaveBeenCalledWith({
304
+ type: EmbedEvent.AuthExpire,
305
+ data: { authToken: 'test_auth_token2' },
306
+ });
307
+ expect(baseInstance.handleAuth).toHaveBeenCalled();
308
+ });
309
+ });
267
310
  });
311
+
268
312
  describe('Called Embed event status for start and end', () => {
269
313
  beforeAll(() => {
270
314
  init({
@@ -1430,6 +1474,7 @@ describe('Unit test case for ts embed', () => {
1430
1474
  expect(getIFrameSrc()).toContain('?base64UrlEncodedFlags');
1431
1475
  });
1432
1476
  });
1477
+
1433
1478
  it('should return the correct encoded query params string when app is embeded', async () => {
1434
1479
  const appEmbed = new AppEmbed(getRootEl(), {
1435
1480
  frameParams: {
@@ -1658,69 +1703,58 @@ describe('Unit test case for ts embed', () => {
1658
1703
  });
1659
1704
  });
1660
1705
 
1661
- it('AppEmbed: Should add flipTooltipToContextMenuEnabled flag to the iframe src', async () => {
1662
- const appEmbed = new AppEmbed(getRootEl(), {
1706
+ it('Should not add contextMenuEnabledOnWhichClick flag to the iframe src when it is not passed', async () => {
1707
+ const liveboardEmbed = new LiveboardEmbed(getRootEl(), {
1663
1708
  ...defaultViewConfig,
1664
- enableFlipTooltipToContextMenu: true,
1665
- } as AppViewConfig);
1709
+ liveboardId,
1710
+ } as LiveboardViewConfig);
1666
1711
 
1667
- appEmbed.render();
1712
+ liveboardEmbed.render();
1668
1713
  await executeAfterWait(() => {
1669
1714
  expectUrlMatchesWithParams(
1670
1715
  getIFrameSrc(),
1671
- `http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&flipTooltipToContextMenuEnabled=true${defaultParams}${defaultParamsPost}#/home`,
1716
+ `http://${thoughtSpotHost}/?embedApp=true${defaultParams}#/embed/viz/${liveboardId}`,
1672
1717
  );
1673
1718
  });
1674
- });
1675
-
1676
- it('AppEmbed: Should not add flipTooltipToContextMenuEnabled flag to the iframe src when if false', async () => {
1677
- const appEmbed = new AppEmbed(getRootEl(), {
1678
- ...defaultViewConfig,
1679
- enableFlipTooltipToContextMenu: false,
1680
- } as AppViewConfig);
1681
1719
 
1682
- appEmbed.render();
1683
- await executeAfterWait(() => {
1684
- expectUrlMatchesWithParams(
1685
- getIFrameSrc(),
1686
- `http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false${defaultParams}${defaultParamsPost}#/home`,
1687
- );
1688
- });
1689
- });
1720
+ const defaultConfig: SageViewConfig = {
1721
+ disableWorksheetChange: false,
1722
+ hideWorksheetSelector: false,
1723
+ hideSageAnswerHeader: false,
1724
+ hideAutocompleteSuggestions: false,
1725
+ hideSampleQuestions: false,
1726
+ isProductTour: false,
1727
+ dataPanelV2: false,
1728
+ };
1690
1729
 
1691
- it('LiveboardEmbed: Should add flipTooltipToContextMenuEnabled flag to the iframe src', async () => {
1692
- const appEmbed = new LiveboardEmbed(getRootEl(), {
1693
- ...defaultViewConfig,
1694
- liveboardId,
1695
- enableFlipTooltipToContextMenu: true,
1696
- } as LiveboardViewConfig);
1730
+ const sageEmbed = new SageEmbed(getRootEl(), {
1731
+ ...defaultConfig,
1732
+ } as SageViewConfig);
1697
1733
 
1698
- appEmbed.render();
1734
+ sageEmbed.render();
1699
1735
  await executeAfterWait(() => {
1700
- expectUrlMatchesWithParams(
1736
+ expectUrlMatch(
1701
1737
  getIFrameSrc(),
1702
- `http://${thoughtSpotHost}/?embedApp=true&flipTooltipToContextMenuEnabled=true${defaultParams}#/embed/viz/${liveboardId}`,
1738
+ `http://${thoughtSpotHost}/?embedApp=true&enableDataPanelV2=false&isSageEmbed=true&disableWorksheetChange=false&hideWorksheetSelector=false&hideEurekaSuggestions=false&isProductTour=false&hideSageAnswerHeader=false&hideAction=%5B%22reportError%22%5D#/embed/eureka`,
1703
1739
  );
1704
1740
  });
1705
1741
  });
1706
1742
 
1707
- it('LiveboardEmbed: Should not add flipTooltipToContextMenuEnabled flag to the iframe src when if false', async () => {
1708
- const appEmbed = new LiveboardEmbed(getRootEl(), {
1743
+ it('Should add contextMenuEnabledOnWhichClick flag to the iframe with left value', async () => {
1744
+ const liveboardEmbed = new LiveboardEmbed(getRootEl(), {
1709
1745
  ...defaultViewConfig,
1710
1746
  liveboardId,
1711
- enableFlipTooltipToContextMenu: false,
1747
+ contextMenuTrigger: ContextMenuTriggerOptions.LEFT_CLICK,
1712
1748
  } as LiveboardViewConfig);
1713
1749
 
1714
- appEmbed.render();
1750
+ liveboardEmbed.render();
1715
1751
  await executeAfterWait(() => {
1716
1752
  expectUrlMatchesWithParams(
1717
1753
  getIFrameSrc(),
1718
- `http://${thoughtSpotHost}/?embedApp=true${defaultParams}#/embed/viz/${liveboardId}`,
1754
+ `http://${thoughtSpotHost}/?embedApp=true${defaultParams}&contextMenuEnabledOnWhichClick=left#/embed/viz/${liveboardId}`,
1719
1755
  );
1720
1756
  });
1721
- });
1722
1757
 
1723
- it('SageViewConfig: Should add flipTooltipToContextMenuEnabled flag to the iframe src', async () => {
1724
1758
  const defaultConfig: SageViewConfig = {
1725
1759
  disableWorksheetChange: false,
1726
1760
  hideWorksheetSelector: false,
@@ -1730,21 +1764,35 @@ describe('Unit test case for ts embed', () => {
1730
1764
  isProductTour: false,
1731
1765
  dataPanelV2: false,
1732
1766
  };
1733
- const appEmbed = new SageEmbed(getRootEl(), {
1767
+
1768
+ const sageEmbed = new SageEmbed(getRootEl(), {
1734
1769
  ...defaultConfig,
1735
- enableFlipTooltipToContextMenu: true,
1770
+ contextMenuTrigger: ContextMenuTriggerOptions.LEFT_CLICK,
1736
1771
  } as SageViewConfig);
1737
1772
 
1738
- appEmbed.render();
1773
+ sageEmbed.render();
1739
1774
  await executeAfterWait(() => {
1740
1775
  expectUrlMatch(
1741
1776
  getIFrameSrc(),
1742
- `http://${thoughtSpotHost}/?embedApp=true&enableDataPanelV2=false&isSageEmbed=true&disableWorksheetChange=false&hideWorksheetSelector=false&hideEurekaSuggestions=false&isProductTour=false&hideSageAnswerHeader=false&hideAction=%5B%22reportError%22%5D&flipTooltipToContextMenuEnabled=true#/embed/eureka`,
1777
+ `http://${thoughtSpotHost}/?embedApp=true&enableDataPanelV2=false&contextMenuEnabledOnWhichClick=left&isSageEmbed=true&disableWorksheetChange=false&hideWorksheetSelector=false&hideEurekaSuggestions=false&isProductTour=false&hideSageAnswerHeader=false&hideAction=%5B%22reportError%22%5D#/embed/eureka`,
1743
1778
  );
1744
1779
  });
1745
1780
  });
1746
1781
 
1747
- it('SageViewConfig: Should not add flipTooltipToContextMenuEnabled flag to the iframe src when if false', async () => {
1782
+ it('Should add contextMenuEnabledOnWhichClick flag to the iframe with right value', async () => {
1783
+ const livebaordEmbed = new LiveboardEmbed(getRootEl(), {
1784
+ ...defaultViewConfig,
1785
+ liveboardId,
1786
+ contextMenuTrigger: ContextMenuTriggerOptions.RIGHT_CLICK,
1787
+ } as LiveboardViewConfig);
1788
+
1789
+ livebaordEmbed.render();
1790
+ await executeAfterWait(() => {
1791
+ expectUrlMatchesWithParams(
1792
+ getIFrameSrc(),
1793
+ `http://${thoughtSpotHost}/?embedApp=true${defaultParams}&contextMenuEnabledOnWhichClick=right#/embed/viz/${liveboardId}`,
1794
+ );
1795
+ });
1748
1796
  const defaultConfig: SageViewConfig = {
1749
1797
  disableWorksheetChange: false,
1750
1798
  hideWorksheetSelector: false,
@@ -1754,86 +1802,55 @@ describe('Unit test case for ts embed', () => {
1754
1802
  isProductTour: false,
1755
1803
  dataPanelV2: false,
1756
1804
  };
1757
- const appEmbed = new SageEmbed(getRootEl(), {
1805
+
1806
+ const sageEmbed = new SageEmbed(getRootEl(), {
1758
1807
  ...defaultConfig,
1759
- enableFlipTooltipToContextMenu: false,
1808
+ contextMenuTrigger: ContextMenuTriggerOptions.RIGHT_CLICK,
1760
1809
  } as SageViewConfig);
1761
1810
 
1762
- appEmbed.render();
1811
+ sageEmbed.render();
1763
1812
  await executeAfterWait(() => {
1764
1813
  expectUrlMatch(
1765
1814
  getIFrameSrc(),
1766
- `http://${thoughtSpotHost}/?embedApp=true&enableDataPanelV2=false&isSageEmbed=true&disableWorksheetChange=false&hideWorksheetSelector=false&hideEurekaSuggestions=false&isProductTour=false&hideSageAnswerHeader=false&hideAction=%5B%22reportError%22%5D#/embed/eureka`,
1767
- );
1768
- });
1769
- });
1770
-
1771
- it('ConversationEmbed: Should add flipTooltipToContextMenuEnabled flag to the iframe src', async () => {
1772
- const appEmbed = new ConversationEmbed(getRootEl(), {
1773
- worksheetId: 'worksheetId',
1774
- searchOptions: {
1775
- searchQuery: 'searchQuery',
1776
- },
1777
- enableFlipTooltipToContextMenu: true,
1778
- } as ConversationViewConfig);
1779
-
1780
- appEmbed.render();
1781
- await executeAfterWait(() => {
1782
- expectUrlMatchesWithParams(
1783
- getIFrameSrc(),
1784
- `http://${thoughtSpotHost}/v2/?${defaultParams}&isSpotterExperienceEnabled=true&flipTooltipToContextMenuEnabled=true#/embed/insights/conv-assist?worksheet=worksheetId&query=searchQuery`,
1815
+ `http://${thoughtSpotHost}/?embedApp=true&enableDataPanelV2=false&contextMenuEnabledOnWhichClick=right&isSageEmbed=true&disableWorksheetChange=false&hideWorksheetSelector=false&hideEurekaSuggestions=false&isProductTour=false&hideSageAnswerHeader=false&hideAction=%5B%22reportError%22%5D#/embed/eureka`,
1785
1816
  );
1786
1817
  });
1787
1818
  });
1788
1819
 
1789
- it('ConversationEmbed: Should not add flipTooltipToContextMenuEnabled flag to the iframe src when flag is false', async () => {
1790
- const appEmbed = new ConversationEmbed(getRootEl(), {
1791
- worksheetId: 'worksheetId',
1792
- searchOptions: {
1793
- searchQuery: 'searchQuery',
1794
- },
1795
- enableFlipTooltipToContextMenu: false,
1796
- } as ConversationViewConfig);
1797
-
1798
- appEmbed.render();
1799
- await executeAfterWait(() => {
1800
- expectUrlMatchesWithParams(
1801
- getIFrameSrc(),
1802
- `http://${thoughtSpotHost}/v2/?${defaultParams}&isSpotterExperienceEnabled=true#/embed/insights/conv-assist?worksheet=worksheetId&query=searchQuery`,
1803
- );
1804
- });
1805
- });
1806
-
1807
- it('SearchEmbed: Should add flipTooltipToContextMenuEnabled flag to the iframe src', async () => {
1808
- const dataSources = ['data-source-1'];
1809
- const appEmbed = new SearchEmbed(getRootEl(), {
1820
+ it('Should add contextMenuEnabledOnWhichClick flag to the iframe with both value', async () => {
1821
+ const livebaordEmbed = new LiveboardEmbed(getRootEl(), {
1810
1822
  ...defaultViewConfig,
1811
- dataSources,
1812
- enableFlipTooltipToContextMenu: true,
1813
- } as SearchViewConfig);
1823
+ liveboardId,
1824
+ contextMenuTrigger: ContextMenuTriggerOptions.BOTH_CLICKS,
1825
+ } as LiveboardViewConfig);
1814
1826
 
1815
- appEmbed.render();
1827
+ livebaordEmbed.render();
1816
1828
  await executeAfterWait(() => {
1817
1829
  expectUrlMatchesWithParams(
1818
1830
  getIFrameSrc(),
1819
- `http://${thoughtSpotHost}/v2/?${defaultParamsWithHiddenActions}&dataSources=[%22data-source-1%22]&dataSourceMode=expand&useLastSelectedSources=false&flipTooltipToContextMenuEnabled=true#/embed/answer`,
1831
+ `http://${thoughtSpotHost}/?embedApp=true${defaultParams}&contextMenuEnabledOnWhichClick=both#/embed/viz/${liveboardId}`,
1820
1832
  );
1821
1833
  });
1822
- });
1834
+ const defaultConfig: SageViewConfig = {
1835
+ disableWorksheetChange: false,
1836
+ hideWorksheetSelector: false,
1837
+ hideSageAnswerHeader: false,
1838
+ hideAutocompleteSuggestions: false,
1839
+ hideSampleQuestions: false,
1840
+ isProductTour: false,
1841
+ dataPanelV2: false,
1842
+ };
1823
1843
 
1824
- it('SearchEmbed: Should not add flipTooltipToContextMenuEnabled flag to the iframe src when if false', async () => {
1825
- const dataSources = ['data-source-1'];
1826
- const appEmbed = new SearchEmbed(getRootEl(), {
1827
- ...defaultViewConfig,
1828
- dataSources,
1829
- enableFlipTooltipToContextMenu: false,
1830
- } as SearchViewConfig);
1844
+ const sageEmbed = new SageEmbed(getRootEl(), {
1845
+ ...defaultConfig,
1846
+ contextMenuTrigger: ContextMenuTriggerOptions.BOTH_CLICKS,
1847
+ } as SageViewConfig);
1831
1848
 
1832
- appEmbed.render();
1849
+ sageEmbed.render();
1833
1850
  await executeAfterWait(() => {
1834
- expectUrlMatchesWithParams(
1851
+ expectUrlMatch(
1835
1852
  getIFrameSrc(),
1836
- `http://${thoughtSpotHost}/v2/?${defaultParamsWithHiddenActions}&dataSources=[%22data-source-1%22]&dataSourceMode=expand&useLastSelectedSources=false#/embed/answer`,
1853
+ `http://${thoughtSpotHost}/?embedApp=true&enableDataPanelV2=false&contextMenuEnabledOnWhichClick=both&isSageEmbed=true&disableWorksheetChange=false&hideWorksheetSelector=false&hideEurekaSuggestions=false&isProductTour=false&hideSageAnswerHeader=false&hideAction=%5B%22reportError%22%5D#/embed/eureka`,
1837
1854
  );
1838
1855
  });
1839
1856
  });
@@ -2156,4 +2173,119 @@ describe('Unit test case for ts embed', () => {
2156
2173
  (logger.error as any).mockClear();
2157
2174
  });
2158
2175
  });
2176
+
2177
+ describe('IdleSessionTimeout embedEvent for TrustedAuthTokenCookieless authType with autoLogin true', () => {
2178
+ beforeAll(() => {
2179
+ jest.spyOn(authInstance, 'doCookielessTokenAuth').mockResolvedValueOnce(true);
2180
+ jest.spyOn(authService, 'verifyTokenService').mockResolvedValueOnce(true);
2181
+ init({
2182
+ thoughtSpotHost: 'tshost',
2183
+ customizations: customisations,
2184
+ authType: AuthType.TrustedAuthTokenCookieless,
2185
+ getAuthToken: () => Promise.resolve('test_auth_token2'),
2186
+ autoLogin: true,
2187
+ });
2188
+ });
2189
+
2190
+ test('should handle idle session timeout and send updated auth token', async () => {
2191
+ const mockEmbedEventPayload = {
2192
+ type: EmbedEvent.IdleSessionTimeout,
2193
+ data: {},
2194
+ };
2195
+ const searchEmbed = new SearchEmbed(getRootEl(), defaultViewConfig);
2196
+ jest.spyOn(baseInstance, 'handleAuth');
2197
+ jest.spyOn(baseInstance, 'notifyAuthFailure');
2198
+
2199
+ searchEmbed.render();
2200
+ const mockPort: any = {
2201
+ postMessage: jest.fn(),
2202
+ };
2203
+ await executeAfterWait(() => {
2204
+ const iframe = getIFrameEl();
2205
+ postMessageToParent(iframe.contentWindow, mockEmbedEventPayload, mockPort);
2206
+ });
2207
+ await executeAfterWait(() => {
2208
+ expect(baseInstance.notifyAuthFailure).toBeCalledWith(
2209
+ authInstance.AuthFailureType.IDLE_SESSION_TIMEOUT,
2210
+ );
2211
+ expect(baseInstance.handleAuth).toHaveBeenCalled();
2212
+ expect(mockPort.postMessage).toHaveBeenCalledWith({
2213
+ type: EmbedEvent.IdleSessionTimeout,
2214
+ data: { authToken: 'test_auth_token2' },
2215
+ });
2216
+ });
2217
+ });
2218
+
2219
+ test('should handle idle session timeout and show login failure message if token fetch fails', async () => {
2220
+ init({
2221
+ thoughtSpotHost: 'tshost',
2222
+ customizations: customisations,
2223
+ authType: AuthType.TrustedAuthTokenCookieless,
2224
+ getAuthToken: () => Promise.reject(),
2225
+ autoLogin: true,
2226
+ });
2227
+
2228
+ const mockEmbedEventPayload = {
2229
+ type: EmbedEvent.IdleSessionTimeout,
2230
+ data: {},
2231
+ };
2232
+ const searchEmbed = new SearchEmbed(getRootEl(), defaultViewConfig);
2233
+ jest.spyOn(baseInstance, 'notifyAuthFailure');
2234
+ searchEmbed.render();
2235
+ const mockPort: any = {
2236
+ postMessage: jest.fn(),
2237
+ };
2238
+ const loggerSpy = jest.spyOn(logger, 'error').mockResolvedValueOnce(true);
2239
+ await executeAfterWait(() => {
2240
+ const iframe = getIFrameEl();
2241
+ postMessageToParent(iframe.contentWindow, mockEmbedEventPayload, mockPort);
2242
+ });
2243
+ await executeAfterWait(() => {
2244
+ expect(getRootEl().innerHTML).toContain('Not logged in');
2245
+ expect(baseInstance.notifyAuthFailure).toBeCalledWith(
2246
+ authInstance.AuthFailureType.IDLE_SESSION_TIMEOUT,
2247
+ );
2248
+ expect(loggerSpy).toHaveBeenCalledTimes(1);
2249
+ });
2250
+
2251
+ jest.spyOn(authService, 'verifyTokenService').mockClear();
2252
+ jest.spyOn(baseInstance, 'notifyAuthFailure').mockClear();
2253
+ });
2254
+
2255
+ test('should handle idle session timeout and show login failure message if handleAuth fails', async () => {
2256
+ init({
2257
+ thoughtSpotHost: 'tshost',
2258
+ customizations: customisations,
2259
+ authType: AuthType.TrustedAuthTokenCookieless,
2260
+ getAuthToken: () => Promise.resolve('test_auth_token2'),
2261
+ autoLogin: true,
2262
+ });
2263
+
2264
+ const mockEmbedEventPayload = {
2265
+ type: EmbedEvent.IdleSessionTimeout,
2266
+ data: {},
2267
+ };
2268
+ const searchEmbed = new SearchEmbed(getRootEl(), defaultViewConfig);
2269
+ jest.spyOn(baseInstance, 'notifyAuthFailure');
2270
+ jest.spyOn(authInstance, 'authenticate').mockResolvedValue(false);
2271
+ searchEmbed.render();
2272
+ const mockPort: any = {
2273
+ postMessage: jest.fn(),
2274
+ };
2275
+ const loggerSpy = jest.spyOn(logger, 'error').mockResolvedValueOnce(true);
2276
+ await executeAfterWait(() => {
2277
+ const iframe = getIFrameEl();
2278
+ postMessageToParent(iframe.contentWindow, mockEmbedEventPayload, mockPort);
2279
+ });
2280
+ await executeAfterWait(() => {
2281
+ expect(baseInstance.notifyAuthFailure).toBeCalledWith(
2282
+ authInstance.AuthFailureType.IDLE_SESSION_TIMEOUT,
2283
+ );
2284
+ expect(loggerSpy).toHaveBeenCalledTimes(0);
2285
+ });
2286
+
2287
+ jest.spyOn(authService, 'verifyTokenService').mockClear();
2288
+ jest.spyOn(baseInstance, 'notifyAuthFailure').mockClear();
2289
+ });
2290
+ });
2159
2291
  });