@thoughtspot/visual-embed-sdk 1.44.1 → 1.44.2

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 (235) hide show
  1. package/cjs/package.json +6 -5
  2. package/cjs/src/api-intercept.d.ts.map +1 -1
  3. package/cjs/src/api-intercept.js +8 -3
  4. package/cjs/src/api-intercept.js.map +1 -1
  5. package/cjs/src/api-intercept.spec.js +19 -3
  6. package/cjs/src/api-intercept.spec.js.map +1 -1
  7. package/cjs/src/auth.spec.js +43 -42
  8. package/cjs/src/auth.spec.js.map +1 -1
  9. package/cjs/src/authToken.spec.js +3 -3
  10. package/cjs/src/authToken.spec.js.map +1 -1
  11. package/cjs/src/embed/app.d.ts +17 -0
  12. package/cjs/src/embed/app.d.ts.map +1 -1
  13. package/cjs/src/embed/app.js +9 -5
  14. package/cjs/src/embed/app.js.map +1 -1
  15. package/cjs/src/embed/app.spec.js +96 -6
  16. package/cjs/src/embed/app.spec.js.map +1 -1
  17. package/cjs/src/embed/base.spec.js +11 -15
  18. package/cjs/src/embed/base.spec.js.map +1 -1
  19. package/cjs/src/embed/bodyless-conversation.spec.js +2 -2
  20. package/cjs/src/embed/bodyless-conversation.spec.js.map +1 -1
  21. package/cjs/src/embed/conversation.d.ts.map +1 -1
  22. package/cjs/src/embed/conversation.js +6 -1
  23. package/cjs/src/embed/conversation.js.map +1 -1
  24. package/cjs/src/embed/conversation.spec.js +8 -3
  25. package/cjs/src/embed/conversation.spec.js.map +1 -1
  26. package/cjs/src/embed/embed.spec.js +101 -2
  27. package/cjs/src/embed/embed.spec.js.map +1 -1
  28. package/cjs/src/embed/events.spec.js +2 -2
  29. package/cjs/src/embed/events.spec.js.map +1 -1
  30. package/cjs/src/embed/hostEventClient/host-event-client.spec.js +1 -1
  31. package/cjs/src/embed/hostEventClient/host-event-client.spec.js.map +1 -1
  32. package/cjs/src/embed/liveboard.d.ts +18 -0
  33. package/cjs/src/embed/liveboard.d.ts.map +1 -1
  34. package/cjs/src/embed/liveboard.js +13 -6
  35. package/cjs/src/embed/liveboard.js.map +1 -1
  36. package/cjs/src/embed/liveboard.spec.js +114 -26
  37. package/cjs/src/embed/liveboard.spec.js.map +1 -1
  38. package/cjs/src/embed/pinboard.spec.js +1 -1
  39. package/cjs/src/embed/pinboard.spec.js.map +1 -1
  40. package/cjs/src/embed/sage.spec.js +2 -2
  41. package/cjs/src/embed/sage.spec.js.map +1 -1
  42. package/cjs/src/embed/search.spec.js +118 -2
  43. package/cjs/src/embed/search.spec.js.map +1 -1
  44. package/cjs/src/embed/ts-embed-trigger.spec.js +2 -3
  45. package/cjs/src/embed/ts-embed-trigger.spec.js.map +1 -1
  46. package/cjs/src/embed/ts-embed.d.ts +3 -2
  47. package/cjs/src/embed/ts-embed.d.ts.map +1 -1
  48. package/cjs/src/embed/ts-embed.js +51 -17
  49. package/cjs/src/embed/ts-embed.js.map +1 -1
  50. package/cjs/src/embed/ts-embed.spec.d.ts.map +1 -1
  51. package/cjs/src/embed/ts-embed.spec.js +335 -71
  52. package/cjs/src/embed/ts-embed.spec.js.map +1 -1
  53. package/cjs/src/errors.d.ts +7 -0
  54. package/cjs/src/errors.d.ts.map +1 -1
  55. package/cjs/src/errors.js +7 -0
  56. package/cjs/src/errors.js.map +1 -1
  57. package/cjs/src/mixpanel-service.spec.js +1 -1
  58. package/cjs/src/mixpanel-service.spec.js.map +1 -1
  59. package/cjs/src/react/index.spec.js +3 -4
  60. package/cjs/src/react/index.spec.js.map +1 -1
  61. package/cjs/src/test/test-utils.js +1 -1
  62. package/cjs/src/test/test-utils.js.map +1 -1
  63. package/cjs/src/types.d.ts +194 -1
  64. package/cjs/src/types.d.ts.map +1 -1
  65. package/cjs/src/types.js +94 -2
  66. package/cjs/src/types.js.map +1 -1
  67. package/cjs/src/utils/authService/authService.spec.js +8 -8
  68. package/cjs/src/utils/authService/authService.spec.js.map +1 -1
  69. package/cjs/src/utils/authService/tokenizedAuthService.spec.js.map +1 -1
  70. package/cjs/src/utils/graphql/answerService/answerService.spec.js +1 -1
  71. package/cjs/src/utils/graphql/answerService/answerService.spec.js.map +1 -1
  72. package/cjs/src/utils/graphql/graphql-request.spec.js +1 -1
  73. package/cjs/src/utils/graphql/graphql-request.spec.js.map +1 -1
  74. package/cjs/src/utils/graphql/sourceService.spec.js +1 -1
  75. package/cjs/src/utils/graphql/sourceService.spec.js.map +1 -1
  76. package/cjs/src/utils/logger.spec.d.ts +5 -20
  77. package/cjs/src/utils/logger.spec.d.ts.map +1 -1
  78. package/cjs/src/utils/processData.spec.js +17 -17
  79. package/cjs/src/utils/processData.spec.js.map +1 -1
  80. package/cjs/src/utils/processTrigger.spec.js +8 -8
  81. package/cjs/src/utils/processTrigger.spec.js.map +1 -1
  82. package/cjs/src/utils.d.ts +6 -0
  83. package/cjs/src/utils.d.ts.map +1 -1
  84. package/cjs/src/utils.js +32 -1
  85. package/cjs/src/utils.js.map +1 -1
  86. package/cjs/src/utils.spec.js +19 -10
  87. package/cjs/src/utils.spec.js.map +1 -1
  88. package/dist/{index-BE9gGzRX.js → index-CSFjfTVk.js} +1 -1
  89. package/dist/src/api-intercept.d.ts.map +1 -1
  90. package/dist/src/embed/app.d.ts +17 -0
  91. package/dist/src/embed/app.d.ts.map +1 -1
  92. package/dist/src/embed/conversation.d.ts.map +1 -1
  93. package/dist/src/embed/liveboard.d.ts +18 -0
  94. package/dist/src/embed/liveboard.d.ts.map +1 -1
  95. package/dist/src/embed/ts-embed.d.ts +3 -2
  96. package/dist/src/embed/ts-embed.d.ts.map +1 -1
  97. package/dist/src/embed/ts-embed.spec.d.ts.map +1 -1
  98. package/dist/src/errors.d.ts +7 -0
  99. package/dist/src/errors.d.ts.map +1 -1
  100. package/dist/src/types.d.ts +194 -1
  101. package/dist/src/types.d.ts.map +1 -1
  102. package/dist/src/utils/logger.spec.d.ts +5 -20
  103. package/dist/src/utils/logger.spec.d.ts.map +1 -1
  104. package/dist/src/utils.d.ts +6 -0
  105. package/dist/src/utils.d.ts.map +1 -1
  106. package/dist/tsembed-react.es.js +219 -36
  107. package/dist/tsembed-react.js +218 -35
  108. package/dist/tsembed.es.js +219 -36
  109. package/dist/tsembed.js +218 -35
  110. package/dist/visual-embed-sdk-react-full.d.ts +184 -2
  111. package/dist/visual-embed-sdk-react.d.ts +184 -2
  112. package/dist/visual-embed-sdk.d.ts +184 -2
  113. package/lib/package.json +6 -5
  114. package/lib/src/api-intercept.d.ts.map +1 -1
  115. package/lib/src/api-intercept.js +9 -4
  116. package/lib/src/api-intercept.js.map +1 -1
  117. package/lib/src/api-intercept.spec.js +20 -4
  118. package/lib/src/api-intercept.spec.js.map +1 -1
  119. package/lib/src/auth.spec.js +43 -42
  120. package/lib/src/auth.spec.js.map +1 -1
  121. package/lib/src/authToken.spec.js +3 -3
  122. package/lib/src/authToken.spec.js.map +1 -1
  123. package/lib/src/embed/app.d.ts +17 -0
  124. package/lib/src/embed/app.d.ts.map +1 -1
  125. package/lib/src/embed/app.js +10 -6
  126. package/lib/src/embed/app.js.map +1 -1
  127. package/lib/src/embed/app.spec.js +96 -6
  128. package/lib/src/embed/app.spec.js.map +1 -1
  129. package/lib/src/embed/base.spec.js +11 -15
  130. package/lib/src/embed/base.spec.js.map +1 -1
  131. package/lib/src/embed/bodyless-conversation.spec.js +2 -2
  132. package/lib/src/embed/bodyless-conversation.spec.js.map +1 -1
  133. package/lib/src/embed/conversation.d.ts.map +1 -1
  134. package/lib/src/embed/conversation.js +7 -2
  135. package/lib/src/embed/conversation.js.map +1 -1
  136. package/lib/src/embed/conversation.spec.js +9 -4
  137. package/lib/src/embed/conversation.spec.js.map +1 -1
  138. package/lib/src/embed/embed.spec.js +103 -4
  139. package/lib/src/embed/embed.spec.js.map +1 -1
  140. package/lib/src/embed/events.spec.js +2 -2
  141. package/lib/src/embed/events.spec.js.map +1 -1
  142. package/lib/src/embed/hostEventClient/host-event-client.spec.js +2 -2
  143. package/lib/src/embed/hostEventClient/host-event-client.spec.js.map +1 -1
  144. package/lib/src/embed/liveboard.d.ts +18 -0
  145. package/lib/src/embed/liveboard.d.ts.map +1 -1
  146. package/lib/src/embed/liveboard.js +15 -8
  147. package/lib/src/embed/liveboard.js.map +1 -1
  148. package/lib/src/embed/liveboard.spec.js +114 -26
  149. package/lib/src/embed/liveboard.spec.js.map +1 -1
  150. package/lib/src/embed/pinboard.spec.js +1 -1
  151. package/lib/src/embed/pinboard.spec.js.map +1 -1
  152. package/lib/src/embed/sage.spec.js +2 -2
  153. package/lib/src/embed/sage.spec.js.map +1 -1
  154. package/lib/src/embed/search.spec.js +118 -2
  155. package/lib/src/embed/search.spec.js.map +1 -1
  156. package/lib/src/embed/ts-embed-trigger.spec.js +2 -3
  157. package/lib/src/embed/ts-embed-trigger.spec.js.map +1 -1
  158. package/lib/src/embed/ts-embed.d.ts +3 -2
  159. package/lib/src/embed/ts-embed.d.ts.map +1 -1
  160. package/lib/src/embed/ts-embed.js +52 -18
  161. package/lib/src/embed/ts-embed.js.map +1 -1
  162. package/lib/src/embed/ts-embed.spec.d.ts.map +1 -1
  163. package/lib/src/embed/ts-embed.spec.js +336 -72
  164. package/lib/src/embed/ts-embed.spec.js.map +1 -1
  165. package/lib/src/errors.d.ts +7 -0
  166. package/lib/src/errors.d.ts.map +1 -1
  167. package/lib/src/errors.js +7 -0
  168. package/lib/src/errors.js.map +1 -1
  169. package/lib/src/mixpanel-service.spec.js +1 -1
  170. package/lib/src/mixpanel-service.spec.js.map +1 -1
  171. package/lib/src/react/index.spec.js +3 -4
  172. package/lib/src/react/index.spec.js.map +1 -1
  173. package/lib/src/test/test-utils.js +1 -1
  174. package/lib/src/test/test-utils.js.map +1 -1
  175. package/lib/src/types.d.ts +194 -1
  176. package/lib/src/types.d.ts.map +1 -1
  177. package/lib/src/types.js +93 -1
  178. package/lib/src/types.js.map +1 -1
  179. package/lib/src/utils/authService/authService.spec.js +8 -8
  180. package/lib/src/utils/authService/authService.spec.js.map +1 -1
  181. package/lib/src/utils/authService/tokenizedAuthService.spec.js.map +1 -1
  182. package/lib/src/utils/graphql/answerService/answerService.spec.js +1 -1
  183. package/lib/src/utils/graphql/answerService/answerService.spec.js.map +1 -1
  184. package/lib/src/utils/graphql/graphql-request.spec.js +1 -1
  185. package/lib/src/utils/graphql/graphql-request.spec.js.map +1 -1
  186. package/lib/src/utils/graphql/sourceService.spec.js +1 -1
  187. package/lib/src/utils/graphql/sourceService.spec.js.map +1 -1
  188. package/lib/src/utils/logger.spec.d.ts +5 -20
  189. package/lib/src/utils/logger.spec.d.ts.map +1 -1
  190. package/lib/src/utils/processData.spec.js +17 -17
  191. package/lib/src/utils/processData.spec.js.map +1 -1
  192. package/lib/src/utils/processTrigger.spec.js +8 -8
  193. package/lib/src/utils/processTrigger.spec.js.map +1 -1
  194. package/lib/src/utils.d.ts +6 -0
  195. package/lib/src/utils.d.ts.map +1 -1
  196. package/lib/src/utils.js +30 -0
  197. package/lib/src/utils.js.map +1 -1
  198. package/lib/src/utils.spec.js +20 -11
  199. package/lib/src/utils.spec.js.map +1 -1
  200. package/package.json +6 -5
  201. package/src/api-intercept.spec.ts +23 -10
  202. package/src/api-intercept.ts +9 -4
  203. package/src/auth.spec.ts +53 -51
  204. package/src/authToken.spec.ts +3 -3
  205. package/src/embed/app.spec.ts +128 -7
  206. package/src/embed/app.ts +30 -4
  207. package/src/embed/base.spec.ts +16 -20
  208. package/src/embed/bodyless-conversation.spec.ts +2 -2
  209. package/src/embed/conversation.spec.ts +9 -4
  210. package/src/embed/conversation.ts +7 -2
  211. package/src/embed/embed.spec.ts +122 -2
  212. package/src/embed/events.spec.ts +2 -2
  213. package/src/embed/hostEventClient/host-event-client.spec.ts +2 -2
  214. package/src/embed/liveboard.spec.ts +137 -29
  215. package/src/embed/liveboard.ts +36 -6
  216. package/src/embed/pinboard.spec.ts +1 -1
  217. package/src/embed/sage.spec.ts +2 -2
  218. package/src/embed/search.spec.ts +133 -2
  219. package/src/embed/ts-embed-trigger.spec.ts +2 -3
  220. package/src/embed/ts-embed.spec.ts +424 -91
  221. package/src/embed/ts-embed.ts +56 -19
  222. package/src/errors.ts +7 -0
  223. package/src/mixpanel-service.spec.ts +1 -1
  224. package/src/react/index.spec.tsx +4 -5
  225. package/src/test/test-utils.ts +2 -2
  226. package/src/types.ts +206 -1
  227. package/src/utils/authService/authService.spec.ts +17 -17
  228. package/src/utils/authService/tokenizedAuthService.spec.ts +4 -4
  229. package/src/utils/graphql/answerService/answerService.spec.ts +3 -3
  230. package/src/utils/graphql/graphql-request.spec.ts +2 -2
  231. package/src/utils/graphql/sourceService.spec.ts +1 -1
  232. package/src/utils/processData.spec.ts +26 -26
  233. package/src/utils/processTrigger.spec.ts +8 -8
  234. package/src/utils.spec.ts +22 -11
  235. package/src/utils.ts +34 -0
package/src/embed/app.ts CHANGED
@@ -9,7 +9,7 @@
9
9
  */
10
10
 
11
11
  import { logger } from '../utils/logger';
12
- import { calculateVisibleElementData, getQueryParamString, isUndefined } from '../utils';
12
+ import { calculateVisibleElementData, getQueryParamString, isUndefined, isValidCssMargin } from '../utils';
13
13
  import {
14
14
  Param,
15
15
  DOMSelector,
@@ -626,6 +626,23 @@ export interface AppViewConfig extends AllEmbedViewConfig {
626
626
  * @version SDK: 1.45.0 | ThoughtSpot: 26.2.0.cl
627
627
  */
628
628
  updatedSpotterChatPrompt?: boolean;
629
+ /**
630
+ * This is the minimum height (in pixels) for a full-height App.
631
+ * Setting this height helps resolve issues with empty Apps and
632
+ * other screens navigable from an App.
633
+ *
634
+ * @version SDK: 1.44.2 | ThoughtSpot: 26.0.2.cl
635
+ * @default 500
636
+ * @example
637
+ * ```js
638
+ * const embed = new AppEmbed('#embed', {
639
+ * ... // other app view config
640
+ * fullHeight: true,
641
+ * minimumHeight: 600,
642
+ * });
643
+ * ```
644
+ */
645
+ minimumHeight?: number;
629
646
  }
630
647
 
631
648
  /**
@@ -635,7 +652,7 @@ export interface AppViewConfig extends AllEmbedViewConfig {
635
652
  export class AppEmbed extends V1Embed {
636
653
  protected viewConfig: AppViewConfig;
637
654
 
638
- private defaultHeight = '100%';
655
+ private defaultHeight = 500;
639
656
 
640
657
 
641
658
  constructor(domSelector: DOMSelector, viewConfig: AppViewConfig) {
@@ -672,6 +689,8 @@ export class AppEmbed extends V1Embed {
672
689
  hideLiveboardHeader = false,
673
690
  showLiveboardTitle = true,
674
691
  showLiveboardDescription = true,
692
+ showMaskedFilterChip = false,
693
+ isLiveboardMasterpiecesEnabled = false,
675
694
  hideHomepageLeftNav = false,
676
695
  modularHomeExperience = false,
677
696
  isLiveboardHeaderSticky = true,
@@ -697,6 +716,7 @@ export class AppEmbed extends V1Embed {
697
716
  isCentralizedLiveboardFilterUXEnabled = false,
698
717
  isLinkParametersEnabled,
699
718
  updatedSpotterChatPrompt,
719
+ minimumHeight,
700
720
  } = this.viewConfig;
701
721
 
702
722
  let params: any = {};
@@ -707,6 +727,8 @@ export class AppEmbed extends V1Embed {
707
727
  params[Param.HideLiveboardHeader] = hideLiveboardHeader;
708
728
  params[Param.ShowLiveboardTitle] = showLiveboardTitle;
709
729
  params[Param.ShowLiveboardDescription] = !!showLiveboardDescription;
730
+ params[Param.ShowMaskedFilterChip] = showMaskedFilterChip;
731
+ params[Param.IsLiveboardMasterpiecesEnabled] = isLiveboardMasterpiecesEnabled;
710
732
  params[Param.LiveboardHeaderSticky] = isLiveboardHeaderSticky;
711
733
  params[Param.IsFullAppEmbed] = true;
712
734
  params[Param.LiveboardHeaderV2] = isLiveboardCompactHeaderEnabled;
@@ -739,7 +761,9 @@ export class AppEmbed extends V1Embed {
739
761
  params[Param.fullHeight] = true;
740
762
  if (this.viewConfig.lazyLoadingForFullHeight) {
741
763
  params[Param.IsLazyLoadingForEmbedEnabled] = true;
742
- params[Param.RootMarginForLazyLoad] = this.viewConfig.lazyLoadingMargin;
764
+ if (isValidCssMargin(this.viewConfig.lazyLoadingMargin)) {
765
+ params[Param.RootMarginForLazyLoad] = this.viewConfig.lazyLoadingMargin;
766
+ }
743
767
  }
744
768
  }
745
769
 
@@ -799,6 +823,8 @@ export class AppEmbed extends V1Embed {
799
823
  ] = isCentralizedLiveboardFilterUXEnabled;
800
824
  }
801
825
 
826
+ this.defaultHeight = minimumHeight || this.defaultHeight;
827
+
802
828
  params[Param.DataPanelV2Enabled] = dataPanelV2;
803
829
  params[Param.HideHomepageLeftNav] = hideHomepageLeftNav;
804
830
  params[Param.ModularHomeExperienceEnabled] = modularHomeExperience;
@@ -900,7 +926,7 @@ export class AppEmbed extends V1Embed {
900
926
  * @param data The event payload
901
927
  */
902
928
  protected updateIFrameHeight = (data: MessagePayload) => {
903
- this.setIFrameHeight(Math.max(data.data, this.iFrame?.scrollHeight));
929
+ this.setIFrameHeight(Math.max(data.data, this.defaultHeight));
904
930
  this.sendFullHeightLazyLoadData();
905
931
  };
906
932
 
@@ -32,14 +32,14 @@ describe('Base TS Embed', () => {
32
32
  thoughtSpotHost,
33
33
  authType: index.AuthType.None,
34
34
  }) as EventEmitter;
35
- jest.spyOn(auth, 'postLoginService').mockImplementation(() => Promise.resolve({}));
35
+ jest.spyOn(auth, 'postLoginService').mockImplementation(() => Promise.resolve(undefined));
36
36
  });
37
37
 
38
38
  beforeEach(() => {
39
39
  document.body.innerHTML = getDocumentBody();
40
40
  });
41
41
 
42
- test('Should show an alert when third party cookie access is blocked', (done) => {
42
+ test('Should show an alert when third party cookie access is blocked', () => {
43
43
  const tsEmbed = new index.SearchEmbed(getRootEl(), {});
44
44
  const iFrame: any = document.createElement('div');
45
45
  iFrame.contentWindow = null;
@@ -59,18 +59,17 @@ describe('Base TS Embed', () => {
59
59
  jest.spyOn(window, 'alert').mockImplementation(() => undefined);
60
60
  authEE.on(auth.AuthStatus.FAILURE, (reason) => {
61
61
  expect(reason).toEqual(auth.AuthFailureType.NO_COOKIE_ACCESS);
62
- expect(window.alert).toBeCalledWith(
62
+ expect(window.alert).toHaveBeenCalledWith(
63
63
  'Third-party cookie access is blocked on this browser. Please allow third-party cookies for this to work properly. \nYou can use `suppressNoCookieAccessAlert` to suppress this message.',
64
64
  );
65
- done();
66
65
  });
67
66
  });
68
67
 
69
- test('Should ignore cookie blocked alert if ignoreNoCookieAccess is true', async (done) => {
68
+ test('Should ignore cookie blocked alert if ignoreNoCookieAccess is true', async () => {
70
69
  jest.spyOn(window, 'fetch').mockResolvedValue({
71
70
  ok: true,
72
71
  json: jest.fn().mockResolvedValue({}),
73
- });
72
+ } as any);
74
73
  const authEE = index.init({
75
74
  thoughtSpotHost,
76
75
  authType: index.AuthType.None,
@@ -96,7 +95,6 @@ describe('Base TS Embed', () => {
96
95
  authEE.on(auth.AuthStatus.FAILURE, (reason) => {
97
96
  expect(reason).toEqual(auth.AuthFailureType.NO_COOKIE_ACCESS);
98
97
  expect(window.alert).not.toHaveBeenCalled();
99
- done();
100
98
  });
101
99
  });
102
100
 
@@ -104,7 +102,7 @@ describe('Base TS Embed', () => {
104
102
  jest.spyOn(window, 'fetch').mockResolvedValue({
105
103
  ok: true,
106
104
  json: jest.fn().mockResolvedValue({}),
107
- });
105
+ } as any);
108
106
  index.init({
109
107
  thoughtSpotHost,
110
108
  authType: index.AuthType.None,
@@ -161,7 +159,7 @@ describe('Base TS Embed', () => {
161
159
  jest.spyOn(tokenizedFetchInstance, 'tokenizedFetch').mockResolvedValueOnce({
162
160
  ok: true,
163
161
  json: jest.fn().mockResolvedValue({}),
164
- });
162
+ } as any);
165
163
  index.init({
166
164
  thoughtSpotHost,
167
165
  authType: index.AuthType.TrustedAuthTokenCookieless,
@@ -229,7 +227,7 @@ describe('Base TS Embed', () => {
229
227
  jest.spyOn(tokenizedFetchInstance, 'tokenizedFetch').mockResolvedValueOnce({
230
228
  ok: true,
231
229
  json: jest.fn().mockResolvedValue({}),
232
- });
230
+ } as any);
233
231
  index.init({
234
232
  thoughtSpotHost,
235
233
  authType: index.AuthType.None,
@@ -388,7 +386,7 @@ describe('Base TS Embed', () => {
388
386
  });
389
387
  });
390
388
 
391
- test('handleAuth notifies for SDK auth failure', (done) => {
389
+ test('handleAuth notifies for SDK auth failure', () => {
392
390
  jest.spyOn(auth, 'authenticate').mockResolvedValue(false);
393
391
  const authEmitter = index.init({
394
392
  thoughtSpotHost,
@@ -398,11 +396,10 @@ describe('Base TS Embed', () => {
398
396
  });
399
397
  authEmitter.on(auth.AuthStatus.FAILURE, (reason) => {
400
398
  expect(reason).toBe(auth.AuthFailureType.SDK);
401
- done();
402
399
  });
403
400
  });
404
401
 
405
- test('handleAuth notifies for SDK auth success', (done) => {
402
+ test('handleAuth notifies for SDK auth success', () => {
406
403
  jest.spyOn(auth, 'authenticate').mockResolvedValue(true);
407
404
  const failureCallback = jest.fn();
408
405
  const authEmitter = index.init({
@@ -414,16 +411,15 @@ describe('Base TS Embed', () => {
414
411
 
415
412
  authEmitter.on(auth.AuthStatus.FAILURE, failureCallback);
416
413
  authEmitter.on(auth.AuthStatus.SDK_SUCCESS, (...args) => {
417
- expect(failureCallback).not.toBeCalled();
414
+ expect(failureCallback).not.toHaveBeenCalled();
418
415
  expect(args.length).toBe(0);
419
- done();
420
416
  });
421
417
  });
422
418
 
423
419
  test('Logout method should disable autoLogin', () => {
424
420
  jest.spyOn(window, 'fetch').mockResolvedValueOnce({
425
421
  type: 'opaque',
426
- });
422
+ } as any);
427
423
  index.init({
428
424
  thoughtSpotHost,
429
425
  authType: index.AuthType.None,
@@ -461,7 +457,7 @@ describe('Base TS Embed', () => {
461
457
  index.init({
462
458
  authType: index.AuthType.None,
463
459
  } as EmbedConfig);
464
- }).toThrowError();
460
+ }).toThrow();
465
461
  });
466
462
 
467
463
  test('config sanity, no username in trusted auth', () => {
@@ -470,7 +466,7 @@ describe('Base TS Embed', () => {
470
466
  authType: index.AuthType.TrustedAuthToken,
471
467
  thoughtSpotHost,
472
468
  } as EmbedConfig);
473
- }).toThrowError();
469
+ }).toThrow();
474
470
  });
475
471
 
476
472
  test('config sanity, no authEndpoint and getAuthToken', () => {
@@ -480,7 +476,7 @@ describe('Base TS Embed', () => {
480
476
  thoughtSpotHost,
481
477
  username: 'test',
482
478
  });
483
- }).toThrowError();
479
+ }).toThrow();
484
480
  });
485
481
  test('config backward compat, should assign inPopup when noRedirect is set', () => {
486
482
  index.init({
@@ -532,6 +528,6 @@ describe('Init tests', () => {
532
528
  thoughtSpotHost,
533
529
  authType: index.AuthType.None,
534
530
  });
535
- expect(resetService.resetAllCachedServices).toBeCalled();
531
+ expect(resetService.resetAllCachedServices).toHaveBeenCalled();
536
532
  });
537
533
  });
@@ -22,8 +22,8 @@ describe('SpotterAgentEmbed', () => {
22
22
  thoughtSpotHost,
23
23
  authType: AuthType.None,
24
24
  });
25
- jest.spyOn(authInstance, 'postLoginService').mockImplementation(() => Promise.resolve({}));
26
- spyOn(window, 'alert');
25
+ jest.spyOn(authInstance, 'postLoginService').mockImplementation(() => Promise.resolve(undefined));
26
+ jest.spyOn(window, 'alert').mockImplementation(() => undefined);
27
27
  document.body.innerHTML = getDocumentBody();
28
28
  });
29
29
 
@@ -2,7 +2,7 @@ import { SpotterEmbed, SpotterEmbedViewConfig, ConversationEmbed } from './conve
2
2
  import { TsEmbed } from './ts-embed';
3
3
  import * as authInstance from '../auth';
4
4
  import { Action, init } from '../index';
5
- import { AuthType, Param, RuntimeFilterOp } from '../types';
5
+ import { AuthType, Param, RuntimeFilterOp, ErrorDetailsTypes, EmbedErrorCodes } from '../types';
6
6
  import {
7
7
  getDocumentBody,
8
8
  getIFrameSrc,
@@ -19,8 +19,8 @@ beforeAll(() => {
19
19
  thoughtSpotHost,
20
20
  authType: AuthType.None,
21
21
  });
22
- jest.spyOn(authInstance, 'postLoginService').mockImplementation(() => Promise.resolve({}));
23
- spyOn(window, 'alert');
22
+ jest.spyOn(authInstance, 'postLoginService').mockImplementation(() => Promise.resolve(undefined));
23
+ jest.spyOn(window, 'alert');
24
24
  document.body.innerHTML = getDocumentBody();
25
25
  });
26
26
 
@@ -120,7 +120,12 @@ describe('ConversationEmbed', () => {
120
120
  (conversationEmbed as any).handleError = jest.fn();
121
121
  await conversationEmbed.render();
122
122
  expect((conversationEmbed as any).handleError).toHaveBeenCalledWith(
123
- ERROR_MESSAGE.SPOTTER_EMBED_WORKSHEED_ID_NOT_FOUND,
123
+ {
124
+ errorType: ErrorDetailsTypes.VALIDATION_ERROR,
125
+ message: ERROR_MESSAGE.SPOTTER_EMBED_WORKSHEED_ID_NOT_FOUND,
126
+ code: EmbedErrorCodes.WORKSHEET_ID_NOT_FOUND,
127
+ error: ERROR_MESSAGE.SPOTTER_EMBED_WORKSHEED_ID_NOT_FOUND,
128
+ },
124
129
  );
125
130
  });
126
131
 
@@ -1,6 +1,6 @@
1
1
  import isUndefined from 'lodash/isUndefined';
2
2
  import { ERROR_MESSAGE } from '../errors';
3
- import { Param, BaseViewConfig, RuntimeFilter, RuntimeParameter } from '../types';
3
+ import { Param, BaseViewConfig, RuntimeFilter, RuntimeParameter, ErrorDetailsTypes, EmbedErrorCodes } from '../types';
4
4
  import { TsEmbed } from './ts-embed';
5
5
  import { getQueryParamString, getFilterQuery, getRuntimeParameters } from '../utils';
6
6
 
@@ -246,7 +246,12 @@ export class SpotterEmbed extends TsEmbed {
246
246
  } = this.viewConfig;
247
247
 
248
248
  if (!worksheetId) {
249
- this.handleError(ERROR_MESSAGE.SPOTTER_EMBED_WORKSHEED_ID_NOT_FOUND);
249
+ this.handleError({
250
+ errorType: ErrorDetailsTypes.VALIDATION_ERROR,
251
+ message: ERROR_MESSAGE.SPOTTER_EMBED_WORKSHEED_ID_NOT_FOUND,
252
+ code: EmbedErrorCodes.WORKSHEET_ID_NOT_FOUND,
253
+ error: ERROR_MESSAGE.SPOTTER_EMBED_WORKSHEED_ID_NOT_FOUND,
254
+ });
250
255
  }
251
256
  const queryParams = this.getBaseQueryParams();
252
257
  queryParams[Param.SpotterEnabled] = true;
@@ -1,13 +1,18 @@
1
1
  import { logger } from '../utils/logger';
2
2
  import {
3
3
  init, AuthType, SearchEmbed, EmbedEvent,
4
+ RuntimeFilterOp,
5
+ Action,
4
6
  } from '../index';
5
7
  import {
6
8
  EVENT_WAIT_TIME,
7
9
  executeAfterWait,
10
+ expectUrlToHaveParamsWithValues,
8
11
  getDocumentBody,
9
12
  getIFrameEl,
13
+ getIFrameSrc,
10
14
  getRootEl,
15
+ postMessageToParent,
11
16
  } from '../test/test-utils';
12
17
  import * as authInstance from '../auth';
13
18
 
@@ -24,8 +29,8 @@ beforeAll(() => {
24
29
  thoughtSpotHost,
25
30
  authType: AuthType.None,
26
31
  });
27
- spyOn(window, 'alert');
28
- jest.spyOn(authInstance, 'postLoginService').mockResolvedValue(true);
32
+ jest.spyOn(window, 'alert');
33
+ jest.spyOn(authInstance, 'postLoginService').mockImplementation(() => Promise.resolve(undefined));
29
34
  });
30
35
 
31
36
  describe('test view config', () => {
@@ -52,4 +57,119 @@ describe('test view config', () => {
52
57
  expect(iframe.style.height).toBe(`${height}px`);
53
58
  });
54
59
  });
60
+
61
+ test('should pass hideResults parameter when configured', async () => {
62
+ const searchEmbed = new SearchEmbed(getRootEl(), {
63
+ ...defaultViewConfig,
64
+ hideResults: true,
65
+ });
66
+ searchEmbed.render();
67
+
68
+ await executeAfterWait(() => {
69
+ const iframeSrc = getIFrameSrc();
70
+ expectUrlToHaveParamsWithValues(iframeSrc, {
71
+ hideResult: true,
72
+ });
73
+ });
74
+ });
75
+
76
+ test('should pass forceTable parameter when configured', async () => {
77
+ const searchEmbed = new SearchEmbed(getRootEl(), {
78
+ ...defaultViewConfig,
79
+ forceTable: true,
80
+ });
81
+ searchEmbed.render();
82
+
83
+ await executeAfterWait(() => {
84
+ const iframeSrc = getIFrameSrc();
85
+ expectUrlToHaveParamsWithValues(iframeSrc, {
86
+ forceTable: true,
87
+ });
88
+ });
89
+ });
90
+
91
+ test('should pass enableSearchAssist parameter when configured', async () => {
92
+ const searchEmbed = new SearchEmbed(getRootEl(), {
93
+ ...defaultViewConfig,
94
+ enableSearchAssist: true,
95
+ });
96
+ searchEmbed.render();
97
+
98
+ await executeAfterWait(() => {
99
+ const iframeSrc = getIFrameSrc();
100
+ expectUrlToHaveParamsWithValues(iframeSrc, {
101
+ enableSearchAssist: true,
102
+ });
103
+ });
104
+ });
105
+
106
+ test('should pass hideSearchBar parameter when configured', async () => {
107
+ const searchEmbed = new SearchEmbed(getRootEl(), {
108
+ ...defaultViewConfig,
109
+ hideSearchBar: true,
110
+ });
111
+ searchEmbed.render();
112
+
113
+ await executeAfterWait(() => {
114
+ const iframeSrc = getIFrameSrc();
115
+ expectUrlToHaveParamsWithValues(iframeSrc, {
116
+ hideSearchBar: true,
117
+ });
118
+ });
119
+ });
120
+
121
+ test('should register and trigger event listeners', async () => {
122
+ const searchEmbed = new SearchEmbed(getRootEl(), defaultViewConfig);
123
+ const mockCallback = jest.fn();
124
+
125
+ searchEmbed.on(EmbedEvent.Load, mockCallback);
126
+ await searchEmbed.render();
127
+
128
+ await executeAfterWait(() => {
129
+ const iframe = getIFrameEl();
130
+ postMessageToParent(iframe.contentWindow, {
131
+ type: EmbedEvent.Load,
132
+ });
133
+ });
134
+
135
+ await executeAfterWait(() => {
136
+ expect(mockCallback).toHaveBeenCalled();
137
+ }, EVENT_WAIT_TIME);
138
+ });
139
+
140
+ test('should pass disabledActions parameter when configured', async () => {
141
+ const disabledActions = [Action.Download, Action.Share];
142
+ const searchEmbed = new SearchEmbed(getRootEl(), {
143
+ ...defaultViewConfig,
144
+ disabledActions,
145
+ });
146
+ searchEmbed.render();
147
+
148
+ await executeAfterWait(() => {
149
+ const iframeSrc = getIFrameSrc();
150
+ expect(iframeSrc).toContain('disableAction');
151
+ });
152
+ });
153
+
154
+ test('should pass runtime filters when configured', async () => {
155
+ const runtimeFilters = [
156
+ {
157
+ columnName: 'revenue',
158
+ operator: RuntimeFilterOp.GT,
159
+ values: [1000],
160
+ },
161
+ ];
162
+ const searchEmbed = new SearchEmbed(getRootEl(), {
163
+ ...defaultViewConfig,
164
+ runtimeFilters,
165
+ });
166
+ searchEmbed.render();
167
+
168
+ await executeAfterWait(() => {
169
+ const iframeSrc = getIFrameSrc();
170
+ expect(iframeSrc).toContain('col1=revenue');
171
+ expect(iframeSrc).toContain('op1=GT');
172
+ expect(iframeSrc).toContain('val1=1000');
173
+ });
174
+ });
55
175
  });
@@ -36,8 +36,8 @@ beforeAll(() => {
36
36
  thoughtSpotHost,
37
37
  authType: AuthType.None,
38
38
  });
39
- spyOn(window, 'alert');
40
- jest.spyOn(authInstance, 'postLoginService').mockReturnValue(true);
39
+ jest.spyOn(window, 'alert');
40
+ jest.spyOn(authInstance, 'postLoginService').mockImplementation(() => Promise.resolve(undefined));
41
41
  });
42
42
 
43
43
  describe('test communication between host app and ThoughtSpot', () => {
@@ -1,5 +1,5 @@
1
1
  import { getIFrameEl, getRootEl } from '../../test/test-utils';
2
- import { HostEvent } from '../../types';
2
+ import { AuthType, HostEvent } from '../../types';
3
3
  import { processTrigger } from '../../utils/processTrigger';
4
4
  import * as EmbedConfigService from '../embedConfig';
5
5
  import {
@@ -23,7 +23,7 @@ const createHostEventClient = () => {
23
23
  describe('HostEventClient', () => {
24
24
  const mockThoughtSpotHost = 'http://localhost';
25
25
  beforeEach(() => {
26
- jest.spyOn(EmbedConfigService, 'getEmbedConfig').mockReturnValue({ thoughtSpotHost: mockThoughtSpotHost });
26
+ jest.spyOn(EmbedConfigService, 'getEmbedConfig').mockReturnValue({ thoughtSpotHost: mockThoughtSpotHost, authType: AuthType.None } as any);
27
27
  });
28
28
 
29
29
  afterEach(() => {