@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
@@ -1,7 +1,7 @@
1
1
  /* eslint-disable dot-notation */
2
2
  import { resetCachedAuthToken } from '../authToken';
3
- import { AuthType, init, EmbedEvent, SearchEmbed, PinboardEmbed, AppEmbed, LiveboardEmbed, SageEmbed, ConversationEmbed, AnswerService, } from '../index';
4
- import { Action, HomeLeftNavItem, RuntimeFilterOp, HomepageModule, HostEvent, } from '../types';
3
+ import { AuthType, init, EmbedEvent, SearchEmbed, PinboardEmbed, AppEmbed, LiveboardEmbed, SageEmbed, AnswerService, } from '../index';
4
+ import { Action, HomeLeftNavItem, RuntimeFilterOp, HomepageModule, HostEvent, ContextMenuTriggerOptions, } from '../types';
5
5
  import { executeAfterWait, getDocumentBody, getIFrameEl, getIFrameSrc, getRootEl, postMessageToParent, defaultParamsForPinboardEmbed, waitFor, expectUrlMatchesWithParams, expectUrlToHaveParamsWithValues, mockMessageChannel, createRootEleForEmbed, expectUrlMatch, fixedEncodeURI, } from '../test/test-utils';
6
6
  import * as config from '../config';
7
7
  import * as tsEmbedInstance from './ts-embed';
@@ -182,6 +182,38 @@ describe('Unit test case for ts embed', () => {
182
182
  });
183
183
  });
184
184
  });
185
+ test('check for new authToken based on getAuthToken function', async () => {
186
+ init({
187
+ thoughtSpotHost: 'tshost',
188
+ customizations: customisations,
189
+ authType: AuthType.TrustedAuthToken,
190
+ getAuthToken: () => Promise.resolve('test_auth_token2'),
191
+ autoLogin: true,
192
+ });
193
+ const mockEmbedEventPayload = {
194
+ type: EmbedEvent.AuthExpire,
195
+ data: {},
196
+ };
197
+ const searchEmbed = new SearchEmbed(getRootEl(), defaultViewConfig);
198
+ jest.spyOn(baseInstance, 'notifyAuthFailure');
199
+ jest.spyOn(baseInstance, 'handleAuth');
200
+ searchEmbed.render();
201
+ const mockPort = {
202
+ postMessage: jest.fn(),
203
+ };
204
+ await executeAfterWait(() => {
205
+ const iframe = getIFrameEl();
206
+ postMessageToParent(iframe.contentWindow, mockEmbedEventPayload, mockPort);
207
+ });
208
+ await executeAfterWait(() => {
209
+ expect(baseInstance.notifyAuthFailure).toBeCalledWith(authInstance.AuthFailureType.EXPIRY);
210
+ expect(mockPort.postMessage).not.toHaveBeenCalledWith({
211
+ type: EmbedEvent.AuthExpire,
212
+ data: { authToken: 'test_auth_token2' },
213
+ });
214
+ expect(baseInstance.handleAuth).toHaveBeenCalled();
215
+ });
216
+ });
185
217
  });
186
218
  describe('Called Embed event status for start and end', () => {
187
219
  beforeAll(() => {
@@ -1415,49 +1447,15 @@ describe('Unit test case for ts embed', () => {
1415
1447
  orgId: overrideOrgId,
1416
1448
  });
1417
1449
  });
1418
- it('AppEmbed: Should add flipTooltipToContextMenuEnabled flag to the iframe src', async () => {
1419
- const appEmbed = new AppEmbed(getRootEl(), {
1420
- ...defaultViewConfig,
1421
- enableFlipTooltipToContextMenu: true,
1422
- });
1423
- appEmbed.render();
1424
- await executeAfterWait(() => {
1425
- expectUrlMatchesWithParams(getIFrameSrc(), `http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&flipTooltipToContextMenuEnabled=true${defaultParams}${defaultParamsPost}#/home`);
1426
- });
1427
- });
1428
- it('AppEmbed: Should not add flipTooltipToContextMenuEnabled flag to the iframe src when if false', async () => {
1429
- const appEmbed = new AppEmbed(getRootEl(), {
1430
- ...defaultViewConfig,
1431
- enableFlipTooltipToContextMenu: false,
1432
- });
1433
- appEmbed.render();
1434
- await executeAfterWait(() => {
1435
- expectUrlMatchesWithParams(getIFrameSrc(), `http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false${defaultParams}${defaultParamsPost}#/home`);
1436
- });
1437
- });
1438
- it('LiveboardEmbed: Should add flipTooltipToContextMenuEnabled flag to the iframe src', async () => {
1439
- const appEmbed = new LiveboardEmbed(getRootEl(), {
1440
- ...defaultViewConfig,
1441
- liveboardId,
1442
- enableFlipTooltipToContextMenu: true,
1443
- });
1444
- appEmbed.render();
1445
- await executeAfterWait(() => {
1446
- expectUrlMatchesWithParams(getIFrameSrc(), `http://${thoughtSpotHost}/?embedApp=true&flipTooltipToContextMenuEnabled=true${defaultParams}#/embed/viz/${liveboardId}`);
1447
- });
1448
- });
1449
- it('LiveboardEmbed: Should not add flipTooltipToContextMenuEnabled flag to the iframe src when if false', async () => {
1450
- const appEmbed = new LiveboardEmbed(getRootEl(), {
1450
+ it('Should not add contextMenuEnabledOnWhichClick flag to the iframe src when it is not passed', async () => {
1451
+ const liveboardEmbed = new LiveboardEmbed(getRootEl(), {
1451
1452
  ...defaultViewConfig,
1452
1453
  liveboardId,
1453
- enableFlipTooltipToContextMenu: false,
1454
1454
  });
1455
- appEmbed.render();
1455
+ liveboardEmbed.render();
1456
1456
  await executeAfterWait(() => {
1457
1457
  expectUrlMatchesWithParams(getIFrameSrc(), `http://${thoughtSpotHost}/?embedApp=true${defaultParams}#/embed/viz/${liveboardId}`);
1458
1458
  });
1459
- });
1460
- it('SageViewConfig: Should add flipTooltipToContextMenuEnabled flag to the iframe src', async () => {
1461
1459
  const defaultConfig = {
1462
1460
  disableWorksheetChange: false,
1463
1461
  hideWorksheetSelector: false,
@@ -1467,16 +1465,24 @@ describe('Unit test case for ts embed', () => {
1467
1465
  isProductTour: false,
1468
1466
  dataPanelV2: false,
1469
1467
  };
1470
- const appEmbed = new SageEmbed(getRootEl(), {
1468
+ const sageEmbed = new SageEmbed(getRootEl(), {
1471
1469
  ...defaultConfig,
1472
- enableFlipTooltipToContextMenu: true,
1473
1470
  });
1474
- appEmbed.render();
1471
+ sageEmbed.render();
1475
1472
  await executeAfterWait(() => {
1476
- expectUrlMatch(getIFrameSrc(), `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`);
1473
+ expectUrlMatch(getIFrameSrc(), `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`);
1477
1474
  });
1478
1475
  });
1479
- it('SageViewConfig: Should not add flipTooltipToContextMenuEnabled flag to the iframe src when if false', async () => {
1476
+ it('Should add contextMenuEnabledOnWhichClick flag to the iframe with left value', async () => {
1477
+ const liveboardEmbed = new LiveboardEmbed(getRootEl(), {
1478
+ ...defaultViewConfig,
1479
+ liveboardId,
1480
+ contextMenuTrigger: ContextMenuTriggerOptions.LEFT_CLICK,
1481
+ });
1482
+ liveboardEmbed.render();
1483
+ await executeAfterWait(() => {
1484
+ expectUrlMatchesWithParams(getIFrameSrc(), `http://${thoughtSpotHost}/?embedApp=true${defaultParams}&contextMenuEnabledOnWhichClick=left#/embed/viz/${liveboardId}`);
1485
+ });
1480
1486
  const defaultConfig = {
1481
1487
  disableWorksheetChange: false,
1482
1488
  hideWorksheetSelector: false,
@@ -1486,63 +1492,69 @@ describe('Unit test case for ts embed', () => {
1486
1492
  isProductTour: false,
1487
1493
  dataPanelV2: false,
1488
1494
  };
1489
- const appEmbed = new SageEmbed(getRootEl(), {
1495
+ const sageEmbed = new SageEmbed(getRootEl(), {
1490
1496
  ...defaultConfig,
1491
- enableFlipTooltipToContextMenu: false,
1497
+ contextMenuTrigger: ContextMenuTriggerOptions.LEFT_CLICK,
1492
1498
  });
1493
- appEmbed.render();
1499
+ sageEmbed.render();
1494
1500
  await executeAfterWait(() => {
1495
- expectUrlMatch(getIFrameSrc(), `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`);
1501
+ expectUrlMatch(getIFrameSrc(), `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`);
1496
1502
  });
1497
1503
  });
1498
- it('ConversationEmbed: Should add flipTooltipToContextMenuEnabled flag to the iframe src', async () => {
1499
- const appEmbed = new ConversationEmbed(getRootEl(), {
1500
- worksheetId: 'worksheetId',
1501
- searchOptions: {
1502
- searchQuery: 'searchQuery',
1503
- },
1504
- enableFlipTooltipToContextMenu: true,
1504
+ it('Should add contextMenuEnabledOnWhichClick flag to the iframe with right value', async () => {
1505
+ const livebaordEmbed = new LiveboardEmbed(getRootEl(), {
1506
+ ...defaultViewConfig,
1507
+ liveboardId,
1508
+ contextMenuTrigger: ContextMenuTriggerOptions.RIGHT_CLICK,
1505
1509
  });
1506
- appEmbed.render();
1510
+ livebaordEmbed.render();
1507
1511
  await executeAfterWait(() => {
1508
- expectUrlMatchesWithParams(getIFrameSrc(), `http://${thoughtSpotHost}/v2/?${defaultParams}&isSpotterExperienceEnabled=true&flipTooltipToContextMenuEnabled=true#/embed/insights/conv-assist?worksheet=worksheetId&query=searchQuery`);
1512
+ expectUrlMatchesWithParams(getIFrameSrc(), `http://${thoughtSpotHost}/?embedApp=true${defaultParams}&contextMenuEnabledOnWhichClick=right#/embed/viz/${liveboardId}`);
1509
1513
  });
1510
- });
1511
- it('ConversationEmbed: Should not add flipTooltipToContextMenuEnabled flag to the iframe src when flag is false', async () => {
1512
- const appEmbed = new ConversationEmbed(getRootEl(), {
1513
- worksheetId: 'worksheetId',
1514
- searchOptions: {
1515
- searchQuery: 'searchQuery',
1516
- },
1517
- enableFlipTooltipToContextMenu: false,
1514
+ const defaultConfig = {
1515
+ disableWorksheetChange: false,
1516
+ hideWorksheetSelector: false,
1517
+ hideSageAnswerHeader: false,
1518
+ hideAutocompleteSuggestions: false,
1519
+ hideSampleQuestions: false,
1520
+ isProductTour: false,
1521
+ dataPanelV2: false,
1522
+ };
1523
+ const sageEmbed = new SageEmbed(getRootEl(), {
1524
+ ...defaultConfig,
1525
+ contextMenuTrigger: ContextMenuTriggerOptions.RIGHT_CLICK,
1518
1526
  });
1519
- appEmbed.render();
1527
+ sageEmbed.render();
1520
1528
  await executeAfterWait(() => {
1521
- expectUrlMatchesWithParams(getIFrameSrc(), `http://${thoughtSpotHost}/v2/?${defaultParams}&isSpotterExperienceEnabled=true#/embed/insights/conv-assist?worksheet=worksheetId&query=searchQuery`);
1529
+ expectUrlMatch(getIFrameSrc(), `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`);
1522
1530
  });
1523
1531
  });
1524
- it('SearchEmbed: Should add flipTooltipToContextMenuEnabled flag to the iframe src', async () => {
1525
- const dataSources = ['data-source-1'];
1526
- const appEmbed = new SearchEmbed(getRootEl(), {
1532
+ it('Should add contextMenuEnabledOnWhichClick flag to the iframe with both value', async () => {
1533
+ const livebaordEmbed = new LiveboardEmbed(getRootEl(), {
1527
1534
  ...defaultViewConfig,
1528
- dataSources,
1529
- enableFlipTooltipToContextMenu: true,
1535
+ liveboardId,
1536
+ contextMenuTrigger: ContextMenuTriggerOptions.BOTH_CLICKS,
1530
1537
  });
1531
- appEmbed.render();
1538
+ livebaordEmbed.render();
1532
1539
  await executeAfterWait(() => {
1533
- expectUrlMatchesWithParams(getIFrameSrc(), `http://${thoughtSpotHost}/v2/?${defaultParamsWithHiddenActions}&dataSources=[%22data-source-1%22]&dataSourceMode=expand&useLastSelectedSources=false&flipTooltipToContextMenuEnabled=true#/embed/answer`);
1540
+ expectUrlMatchesWithParams(getIFrameSrc(), `http://${thoughtSpotHost}/?embedApp=true${defaultParams}&contextMenuEnabledOnWhichClick=both#/embed/viz/${liveboardId}`);
1534
1541
  });
1535
- });
1536
- it('SearchEmbed: Should not add flipTooltipToContextMenuEnabled flag to the iframe src when if false', async () => {
1537
- const dataSources = ['data-source-1'];
1538
- const appEmbed = new SearchEmbed(getRootEl(), {
1539
- ...defaultViewConfig,
1540
- dataSources,
1541
- enableFlipTooltipToContextMenu: false,
1542
+ const defaultConfig = {
1543
+ disableWorksheetChange: false,
1544
+ hideWorksheetSelector: false,
1545
+ hideSageAnswerHeader: false,
1546
+ hideAutocompleteSuggestions: false,
1547
+ hideSampleQuestions: false,
1548
+ isProductTour: false,
1549
+ dataPanelV2: false,
1550
+ };
1551
+ const sageEmbed = new SageEmbed(getRootEl(), {
1552
+ ...defaultConfig,
1553
+ contextMenuTrigger: ContextMenuTriggerOptions.BOTH_CLICKS,
1542
1554
  });
1543
- appEmbed.render();
1555
+ sageEmbed.render();
1544
1556
  await executeAfterWait(() => {
1545
- expectUrlMatchesWithParams(getIFrameSrc(), `http://${thoughtSpotHost}/v2/?${defaultParamsWithHiddenActions}&dataSources=[%22data-source-1%22]&dataSourceMode=expand&useLastSelectedSources=false#/embed/answer`);
1557
+ expectUrlMatch(getIFrameSrc(), `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`);
1546
1558
  });
1547
1559
  });
1548
1560
  });
@@ -1816,5 +1828,105 @@ describe('Unit test case for ts embed', () => {
1816
1828
  logger.error.mockClear();
1817
1829
  });
1818
1830
  });
1831
+ describe('IdleSessionTimeout embedEvent for TrustedAuthTokenCookieless authType with autoLogin true', () => {
1832
+ beforeAll(() => {
1833
+ jest.spyOn(authInstance, 'doCookielessTokenAuth').mockResolvedValueOnce(true);
1834
+ jest.spyOn(authService, 'verifyTokenService').mockResolvedValueOnce(true);
1835
+ init({
1836
+ thoughtSpotHost: 'tshost',
1837
+ customizations: customisations,
1838
+ authType: AuthType.TrustedAuthTokenCookieless,
1839
+ getAuthToken: () => Promise.resolve('test_auth_token2'),
1840
+ autoLogin: true,
1841
+ });
1842
+ });
1843
+ test('should handle idle session timeout and send updated auth token', async () => {
1844
+ const mockEmbedEventPayload = {
1845
+ type: EmbedEvent.IdleSessionTimeout,
1846
+ data: {},
1847
+ };
1848
+ const searchEmbed = new SearchEmbed(getRootEl(), defaultViewConfig);
1849
+ jest.spyOn(baseInstance, 'handleAuth');
1850
+ jest.spyOn(baseInstance, 'notifyAuthFailure');
1851
+ searchEmbed.render();
1852
+ const mockPort = {
1853
+ postMessage: jest.fn(),
1854
+ };
1855
+ await executeAfterWait(() => {
1856
+ const iframe = getIFrameEl();
1857
+ postMessageToParent(iframe.contentWindow, mockEmbedEventPayload, mockPort);
1858
+ });
1859
+ await executeAfterWait(() => {
1860
+ expect(baseInstance.notifyAuthFailure).toBeCalledWith(authInstance.AuthFailureType.IDLE_SESSION_TIMEOUT);
1861
+ expect(baseInstance.handleAuth).toHaveBeenCalled();
1862
+ expect(mockPort.postMessage).toHaveBeenCalledWith({
1863
+ type: EmbedEvent.IdleSessionTimeout,
1864
+ data: { authToken: 'test_auth_token2' },
1865
+ });
1866
+ });
1867
+ });
1868
+ test('should handle idle session timeout and show login failure message if token fetch fails', async () => {
1869
+ init({
1870
+ thoughtSpotHost: 'tshost',
1871
+ customizations: customisations,
1872
+ authType: AuthType.TrustedAuthTokenCookieless,
1873
+ getAuthToken: () => Promise.reject(),
1874
+ autoLogin: true,
1875
+ });
1876
+ const mockEmbedEventPayload = {
1877
+ type: EmbedEvent.IdleSessionTimeout,
1878
+ data: {},
1879
+ };
1880
+ const searchEmbed = new SearchEmbed(getRootEl(), defaultViewConfig);
1881
+ jest.spyOn(baseInstance, 'notifyAuthFailure');
1882
+ searchEmbed.render();
1883
+ const mockPort = {
1884
+ postMessage: jest.fn(),
1885
+ };
1886
+ const loggerSpy = jest.spyOn(logger, 'error').mockResolvedValueOnce(true);
1887
+ await executeAfterWait(() => {
1888
+ const iframe = getIFrameEl();
1889
+ postMessageToParent(iframe.contentWindow, mockEmbedEventPayload, mockPort);
1890
+ });
1891
+ await executeAfterWait(() => {
1892
+ expect(getRootEl().innerHTML).toContain('Not logged in');
1893
+ expect(baseInstance.notifyAuthFailure).toBeCalledWith(authInstance.AuthFailureType.IDLE_SESSION_TIMEOUT);
1894
+ expect(loggerSpy).toHaveBeenCalledTimes(1);
1895
+ });
1896
+ jest.spyOn(authService, 'verifyTokenService').mockClear();
1897
+ jest.spyOn(baseInstance, 'notifyAuthFailure').mockClear();
1898
+ });
1899
+ test('should handle idle session timeout and show login failure message if handleAuth fails', async () => {
1900
+ init({
1901
+ thoughtSpotHost: 'tshost',
1902
+ customizations: customisations,
1903
+ authType: AuthType.TrustedAuthTokenCookieless,
1904
+ getAuthToken: () => Promise.resolve('test_auth_token2'),
1905
+ autoLogin: true,
1906
+ });
1907
+ const mockEmbedEventPayload = {
1908
+ type: EmbedEvent.IdleSessionTimeout,
1909
+ data: {},
1910
+ };
1911
+ const searchEmbed = new SearchEmbed(getRootEl(), defaultViewConfig);
1912
+ jest.spyOn(baseInstance, 'notifyAuthFailure');
1913
+ jest.spyOn(authInstance, 'authenticate').mockResolvedValue(false);
1914
+ searchEmbed.render();
1915
+ const mockPort = {
1916
+ postMessage: jest.fn(),
1917
+ };
1918
+ const loggerSpy = jest.spyOn(logger, 'error').mockResolvedValueOnce(true);
1919
+ await executeAfterWait(() => {
1920
+ const iframe = getIFrameEl();
1921
+ postMessageToParent(iframe.contentWindow, mockEmbedEventPayload, mockPort);
1922
+ });
1923
+ await executeAfterWait(() => {
1924
+ expect(baseInstance.notifyAuthFailure).toBeCalledWith(authInstance.AuthFailureType.IDLE_SESSION_TIMEOUT);
1925
+ expect(loggerSpy).toHaveBeenCalledTimes(0);
1926
+ });
1927
+ jest.spyOn(authService, 'verifyTokenService').mockClear();
1928
+ jest.spyOn(baseInstance, 'notifyAuthFailure').mockClear();
1929
+ });
1930
+ });
1819
1931
  });
1820
1932
  //# sourceMappingURL=ts-embed.spec.js.map