@thoughtspot/visual-embed-sdk 1.20.0 → 1.20.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 (73) hide show
  1. package/dist/src/auth.d.ts +38 -4
  2. package/dist/src/auth.d.ts.map +1 -1
  3. package/dist/src/embed/app.d.ts +2 -2
  4. package/dist/src/embed/base.d.ts +25 -14
  5. package/dist/src/embed/base.d.ts.map +1 -1
  6. package/dist/src/embed/liveboard.d.ts +13 -3
  7. package/dist/src/embed/liveboard.d.ts.map +1 -1
  8. package/dist/src/embed/search-bar.d.ts +4 -1
  9. package/dist/src/embed/search-bar.d.ts.map +1 -1
  10. package/dist/src/embed/search.d.ts +2 -2
  11. package/dist/src/embed/ts-embed.d.ts +35 -1
  12. package/dist/src/embed/ts-embed.d.ts.map +1 -1
  13. package/dist/src/index.d.ts +3 -3
  14. package/dist/src/index.d.ts.map +1 -1
  15. package/dist/src/react/index.d.ts.map +1 -1
  16. package/dist/src/types.d.ts +201 -27
  17. package/dist/src/types.d.ts.map +1 -1
  18. package/dist/tsembed.es.js +247 -38
  19. package/dist/tsembed.js +228 -38
  20. package/lib/package.json +2 -3
  21. package/lib/src/auth.d.ts +38 -4
  22. package/lib/src/auth.d.ts.map +1 -1
  23. package/lib/src/auth.js +17 -2
  24. package/lib/src/auth.js.map +1 -1
  25. package/lib/src/embed/app.d.ts +2 -2
  26. package/lib/src/embed/app.js +1 -1
  27. package/lib/src/embed/base.d.ts +25 -14
  28. package/lib/src/embed/base.d.ts.map +1 -1
  29. package/lib/src/embed/base.js +24 -4
  30. package/lib/src/embed/base.js.map +1 -1
  31. package/lib/src/embed/base.spec.js +2 -2
  32. package/lib/src/embed/base.spec.js.map +1 -1
  33. package/lib/src/embed/liveboard.d.ts +13 -3
  34. package/lib/src/embed/liveboard.d.ts.map +1 -1
  35. package/lib/src/embed/liveboard.js +12 -2
  36. package/lib/src/embed/liveboard.js.map +1 -1
  37. package/lib/src/embed/search-bar.d.ts +4 -1
  38. package/lib/src/embed/search-bar.d.ts.map +1 -1
  39. package/lib/src/embed/search-bar.js +1 -1
  40. package/lib/src/embed/search-bar.js.map +1 -1
  41. package/lib/src/embed/search.d.ts +2 -2
  42. package/lib/src/embed/search.js +1 -1
  43. package/lib/src/embed/ts-embed.d.ts +35 -1
  44. package/lib/src/embed/ts-embed.d.ts.map +1 -1
  45. package/lib/src/embed/ts-embed.js +35 -2
  46. package/lib/src/embed/ts-embed.js.map +1 -1
  47. package/lib/src/index.d.ts +3 -3
  48. package/lib/src/index.d.ts.map +1 -1
  49. package/lib/src/index.js +1 -1
  50. package/lib/src/index.js.map +1 -1
  51. package/lib/src/react/index.d.ts.map +1 -1
  52. package/lib/src/react/index.js +4 -2
  53. package/lib/src/react/index.js.map +1 -1
  54. package/lib/src/react/index.spec.js +14 -2
  55. package/lib/src/react/index.spec.js.map +1 -1
  56. package/lib/src/types.d.ts +201 -27
  57. package/lib/src/types.d.ts.map +1 -1
  58. package/lib/src/types.js +155 -24
  59. package/lib/src/types.js.map +1 -1
  60. package/lib/src/visual-embed-sdk.d.ts +323 -57
  61. package/package.json +2 -3
  62. package/src/auth.ts +51 -5
  63. package/src/embed/app.ts +2 -2
  64. package/src/embed/base.spec.ts +3 -3
  65. package/src/embed/base.ts +30 -9
  66. package/src/embed/liveboard.ts +13 -3
  67. package/src/embed/search-bar.tsx +4 -1
  68. package/src/embed/search.ts +2 -2
  69. package/src/embed/ts-embed.ts +35 -2
  70. package/src/index.ts +24 -2
  71. package/src/react/index.spec.tsx +35 -2
  72. package/src/react/index.tsx +10 -2
  73. package/src/types.ts +202 -26
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thoughtspot/visual-embed-sdk",
3
- "version": "1.20.0",
3
+ "version": "1.20.2",
4
4
  "description": "ThoughtSpot Embed SDK",
5
5
  "module": "lib/src/index.js",
6
6
  "main": "dist/tsembed.js",
@@ -135,8 +135,7 @@
135
135
  "ts-jest": "^26.5.5",
136
136
  "ts-loader": "8.0.4",
137
137
  "typedoc": "0.21.6",
138
- "typedoc-neo-theme": "^1.1.0",
139
- "typedoc-plugin-toc-group": "0.0.5",
138
+ "typedoc-plugin-toc-group": "thoughtspot/typedoc-plugin-toc-group",
140
139
  "typescript": "^4.9.4",
141
140
  "url-search-params-polyfill": "^8.1.0",
142
141
  "util": "^0.12.4"
package/src/auth.ts CHANGED
@@ -39,6 +39,11 @@ export const EndPoints = {
39
39
  LOGOUT: '/callosum/v1/session/logout',
40
40
  };
41
41
 
42
+ /**
43
+ * Enum for auth failure types. This is the parameter passed to the listner
44
+ * of {@link AuthStatus.FAILURE}.
45
+ * @group Authentication / Init
46
+ */
42
47
  export enum AuthFailureType {
43
48
  SDK = 'SDK',
44
49
  NO_COOKIE_ACCESS = 'NO_COOKIE_ACCESS',
@@ -46,6 +51,10 @@ export enum AuthFailureType {
46
51
  OTHER = 'OTHER',
47
52
  }
48
53
 
54
+ /**
55
+ * Enum for auth status emitted by the emitter returned from {@link init}.
56
+ * @group Authentication / Init
57
+ */
49
58
  export enum AuthStatus {
50
59
  /**
51
60
  * Emits when the SDK fails to authenticate
@@ -72,20 +81,56 @@ export enum AuthStatus {
72
81
  WAITING_FOR_POPUP = 'WAITING_FOR_POPUP',
73
82
  }
74
83
 
84
+ /**
85
+ * Event emitter returned from {@link init}.
86
+ * @group Authentication / Init
87
+ */
88
+ export interface AuthEventEmitter {
89
+ /**
90
+ * Registed a listener on Auth failure.
91
+ * @param event
92
+ * @param listener
93
+ */
94
+ on(
95
+ event: AuthStatus.FAILURE,
96
+ listener: (failureType: AuthFailureType) => void,
97
+ ): this;
98
+ on(
99
+ event:
100
+ | AuthStatus.SDK_SUCCESS
101
+ | AuthStatus.LOGOUT
102
+ | AuthStatus.WAITING_FOR_POPUP,
103
+ listener: () => void,
104
+ ): this;
105
+ on(event: AuthStatus.SUCCESS, listener: (sessionInfo: any) => void): this;
106
+ /**
107
+ * Trigger an event on the emitter returned from init.
108
+ * @param {@link AuthEvent}
109
+ */
110
+ emit(event: AuthEvent): void;
111
+ }
112
+
113
+ /**
114
+ * Events which can be triggered on the emitter returned from {@link init}.
115
+ * @group Authentication / Init
116
+ */
75
117
  export enum AuthEvent {
76
118
  /**
77
- * Manually trigger the SSO popup.
119
+ * Manually trigger the SSO popup. This is useful with
120
+ * authStatus: SAMLRedirect/OIDCRedicre and inPopup: true
78
121
  */
79
122
  TRIGGER_SSO_POPUP = 'TRIGGER_SSO_POPUP',
80
123
  }
81
124
 
82
- let authEE: EventEmitter;
125
+ let authEE: EventEmitter<AuthStatus | AuthEvent>;
83
126
 
84
- export function getAuthEE(): EventEmitter {
127
+ export function getAuthEE(): EventEmitter<AuthStatus | AuthEvent> {
85
128
  return authEE;
86
129
  }
87
130
 
88
- export function setAuthEE(eventEmitter: EventEmitter): void {
131
+ export function setAuthEE(
132
+ eventEmitter: EventEmitter<AuthStatus | AuthEvent>,
133
+ ): void {
89
134
  authEE = eventEmitter;
90
135
  }
91
136
 
@@ -146,8 +191,9 @@ export function getReleaseVersion() {
146
191
  }
147
192
 
148
193
  /**
149
- * Return a promise that resolves with the session info when authentication is
194
+ * Return a promise that resolves with the session information when authentication is
150
195
  * successful. And info is available.
196
+ * @group Global methods
151
197
  */
152
198
  export function getSessionInfo(): Promise<any> {
153
199
  return sessionInfoPromise;
package/src/embed/app.ts CHANGED
@@ -56,7 +56,7 @@ export enum Page {
56
56
 
57
57
  /**
58
58
  * The view configuration for full app embedding.
59
- * @Category App Embed
59
+ * @group Embed components
60
60
  */
61
61
  export interface AppViewConfig extends ViewConfig {
62
62
  /**
@@ -105,7 +105,7 @@ export interface AppViewConfig extends ViewConfig {
105
105
 
106
106
  /**
107
107
  * Embeds full ThoughtSpot experience in a host application.
108
- * @Category App Embed
108
+ * @group Embed components
109
109
  */
110
110
  export class AppEmbed extends V1Embed {
111
111
  protected viewConfig: AppViewConfig;
@@ -20,7 +20,7 @@ describe('Base TS Embed', () => {
20
20
  authEE = index.init({
21
21
  thoughtSpotHost,
22
22
  authType: index.AuthType.None,
23
- });
23
+ }) as EventEmitter;
24
24
  });
25
25
 
26
26
  beforeEach(() => {
@@ -148,9 +148,9 @@ describe('Base TS Embed', () => {
148
148
  });
149
149
 
150
150
  authEmitter.on(auth.AuthStatus.FAILURE, failureCallback);
151
- authEmitter.on(auth.AuthStatus.SDK_SUCCESS, (reason) => {
151
+ authEmitter.on(auth.AuthStatus.SDK_SUCCESS, (...args) => {
152
152
  expect(failureCallback).not.toBeCalled();
153
- expect(reason).toBe(undefined);
153
+ expect(args.length).toBe(0);
154
154
  done();
155
155
  });
156
156
  });
package/src/embed/base.ts CHANGED
@@ -16,11 +16,13 @@ import {
16
16
  logout as _logout,
17
17
  AuthFailureType,
18
18
  AuthStatus,
19
+ AuthEvent,
19
20
  notifyAuthFailure,
20
21
  notifyAuthSDKSuccess,
21
22
  notifyAuthSuccess,
22
23
  notifyLogout,
23
24
  setAuthEE,
25
+ AuthEventEmitter,
24
26
  } from '../auth';
25
27
  import { uploadMixpanelEvent, MIXPANEL_EVENT } from '../mixpanel-service';
26
28
 
@@ -32,7 +34,13 @@ const CONFIG_DEFAULTS: Partial<EmbedConfig> = {
32
34
  };
33
35
 
34
36
  export let authPromise: Promise<boolean>;
35
-
37
+ /**
38
+ * Gets the configuration embed was initialized with.
39
+ *
40
+ * @returns {@link EmbedConfig} The configuration embed was initialized with.
41
+ * @version SDK: 1.19.0 | ThoughtSpot: *
42
+ * @group Global methods
43
+ */
36
44
  export const getEmbedConfig = (): EmbedConfig => config;
37
45
 
38
46
  export const getAuthPromise = (): Promise<boolean> => authPromise;
@@ -76,6 +84,7 @@ const hostUrlToFeatureUrl = {
76
84
  * @param url The URL provided for prefetch
77
85
  * @param prefetchFeatures Specify features which needs to be prefetched.
78
86
  * @version SDK: 1.4.0 | ThoughtSpot: ts7.sep.cl, 7.2.1
87
+ * @group Global methods
79
88
  */
80
89
  export const prefetch = (
81
90
  url?: string,
@@ -136,15 +145,26 @@ function backwardCompat(embedConfig: EmbedConfig): EmbedConfig {
136
145
 
137
146
  /**
138
147
  * Initializes the Visual Embed SDK globally and perform
139
- * authentication if applicable.
148
+ * authentication if applicable. This function needs to be called before any ThoughtSpot
149
+ * component like liveboard etc can be embedded. But need not wait for AuthEvent.SUCCESS
150
+ * to actually embed. That is handled internally.
140
151
  * @param embedConfig The configuration object containing ThoughtSpot host,
141
152
  * authentication mechanism and so on.
142
- * example: authStatus = init(config);
143
- * authStatus.on(AuthStatus.FAILURE, (reason) => { // do something here });
144
- * @returns event emitter which emits events on authentication success, failure and logout. See {@link AuthStatus}
153
+ *
154
+ * @example
155
+ * ```js
156
+ * const authStatus = init({
157
+ * thoughtSpotHost: 'https://my.thoughtspot.cloud',
158
+ * authType: AuthType.None,
159
+ * });
160
+ * authStatus.on(AuthStatus.FAILURE, (reason) => { // do something here });
161
+ * ```
162
+ *
163
+ * @returns {@link AuthEventEmitter} event emitter which emits events on authentication success, failure and logout. See {@link AuthStatus}
145
164
  * @version SDK: 1.0.0 | ThoughtSpot ts7.april.cl, 7.2.1
165
+ * @group Authentication / Init
146
166
  */
147
- export const init = (embedConfig: EmbedConfig): EventEmitter => {
167
+ export const init = (embedConfig: EmbedConfig): AuthEventEmitter => {
148
168
  sanity(embedConfig);
149
169
  config = {
150
170
  ...CONFIG_DEFAULTS,
@@ -152,7 +172,7 @@ export const init = (embedConfig: EmbedConfig): EventEmitter => {
152
172
  thoughtSpotHost: getThoughtSpotHost(embedConfig),
153
173
  };
154
174
  config = backwardCompat(config);
155
- const authEE = new EventEmitter();
175
+ const authEE = new EventEmitter<AuthStatus | AuthEvent>();
156
176
  setAuthEE(authEE);
157
177
  handleAuth();
158
178
 
@@ -175,7 +195,7 @@ export const init = (embedConfig: EmbedConfig): EventEmitter => {
175
195
  if (config.callPrefetch) {
176
196
  prefetch(config.thoughtSpotHost);
177
197
  }
178
- return authEE;
198
+ return authEE as AuthEventEmitter;
179
199
  };
180
200
 
181
201
  export function disableAutoLogin(): void {
@@ -192,6 +212,7 @@ export function disableAutoLogin(): void {
192
212
  * @param doNotDisableAutoLogin This flag when passed will not disable autoLogin
193
213
  * @returns Promise which resolves when logout completes.
194
214
  * @version SDK: 1.10.1 | ThoughtSpot: 8.2.0.cl, 8.4.1-sw
215
+ * @group Global methods
195
216
  */
196
217
  export const logout = (doNotDisableAutoLogin = false): Promise<boolean> => {
197
218
  if (!doNotDisableAutoLogin) {
@@ -218,7 +239,7 @@ export const renderInQueue = (
218
239
  return renderQueue;
219
240
  }
220
241
  // Sending an empty function to keep it consistent with the above usage.
221
- return fn(() => {}); // eslint-disable-line @typescript-eslint/no-empty-function
242
+ return fn(() => { }); // eslint-disable-line @typescript-eslint/no-empty-function
222
243
  };
223
244
 
224
245
  // For testing purposes only
@@ -24,7 +24,7 @@ import { V1Embed } from './ts-embed';
24
24
 
25
25
  /**
26
26
  * The configuration for the embedded Liveboard or visualization page view.
27
- * @Category Liveboards and Charts
27
+ * @group Embed components
28
28
  */
29
29
  export interface LiveboardViewConfig extends ViewConfig {
30
30
  /**
@@ -91,8 +91,18 @@ export interface LiveboardViewConfig extends ViewConfig {
91
91
  }
92
92
 
93
93
  /**
94
- * Embed a ThoughtSpot Liveboard or visualization
95
- * @Category Liveboards and Charts
94
+ * Embed a ThoughtSpot Liveboard or a Thoughtspot visualization. When rendered it already
95
+ * waits for the authentication to complete, so no need to wait for AuthStatus.SUCCESS.
96
+ * @example
97
+ * ```js
98
+ * import { .. } from '@thoughtspot/visual-embed-sdk';
99
+ * init({ ... });
100
+ * const embed = new LiveboardEmbed("#container", {
101
+ * liveboardId: <your-id-here>,
102
+ * // .. other params here.
103
+ * })
104
+ * ```
105
+ * @group Embed components
96
106
  */
97
107
  export class LiveboardEmbed extends V1Embed {
98
108
  protected viewConfig: LiveboardViewConfig;
@@ -3,6 +3,9 @@ import { getQueryParamString } from '../utils';
3
3
  import { TsEmbed } from './ts-embed';
4
4
  import { SearchOptions } from './search';
5
5
 
6
+ /**
7
+ * @group Embed components
8
+ */
6
9
  export interface SearchBarViewConfig
7
10
  extends Omit<ViewConfig, 'runtimeFilters' | 'showAlerts'> {
8
11
  /**
@@ -25,8 +28,8 @@ export interface SearchBarViewConfig
25
28
  /**
26
29
  * Embed ThoughtSpot search bar
27
30
  *
28
- * @Category Search Embed
29
31
  * @version: SDK: 1.18.0 | ThoughtSpot: 8.10.0.cl, 9.0.1-sw
32
+ * @group Embed components
30
33
  */
31
34
  export class SearchBarEmbed extends TsEmbed {
32
35
  /**
@@ -45,7 +45,7 @@ export interface SearchOptions {
45
45
  /**
46
46
  * The configuration attributes for the embedded search view.
47
47
  *
48
- * @Category Search Embed
48
+ * @group Embed components
49
49
  */
50
50
  export interface SearchViewConfig extends ViewConfig {
51
51
  /**
@@ -120,7 +120,7 @@ export const HiddenActionItemByDefaultForSearchEmbed = [
120
120
  /**
121
121
  * Embed ThoughtSpot search
122
122
  *
123
- * @Category Search Embed
123
+ * @group Embed components
124
124
  */
125
125
  export class SearchEmbed extends TsEmbed {
126
126
  /**
@@ -692,6 +692,20 @@ export class TsEmbed {
692
692
  * @param messageType The message type
693
693
  * @param callback A callback as a function
694
694
  * @param options The message options
695
+ * @example
696
+ * ```js
697
+ * tsEmbed.on(EmbedEvent.Error, (data) => {
698
+ * console.error(data);
699
+ * });
700
+ * ```
701
+ * @example
702
+ * ```js
703
+ * tsEmbed.on(EmbedEvent.Save, (data) => {
704
+ * console.log("Answer save clicked", data);
705
+ * }, {
706
+ * start: true // This will trigger the callback on start of save
707
+ * });
708
+ * ```
695
709
  */
696
710
  public on(
697
711
  messageType: EmbedEvent,
@@ -806,6 +820,8 @@ export class TsEmbed {
806
820
  * Base class for embedding v1 experience
807
821
  * Note: The v1 version of ThoughtSpot Blink works on the AngularJS stack
808
822
  * which is currently under migration to v2
823
+ *
824
+ * @inheritdoc
809
825
  */
810
826
  export class V1Embed extends TsEmbed {
811
827
  protected viewConfig: ViewConfig;
@@ -816,14 +832,31 @@ export class V1Embed extends TsEmbed {
816
832
  }
817
833
 
818
834
  /**
819
- * Render the app in an iframe and set up event handlers
835
+ * Render the ap p in an iframe and set up event handlers
820
836
  * @param iframeSrc
821
837
  */
822
838
  protected renderV1Embed(iframeSrc: string): any {
823
839
  return this.renderIFrame(iframeSrc, this.viewConfig.frameParams);
824
840
  }
825
841
 
826
- // @override
842
+ /**
843
+ * @inheritdoc TsEmbed.on
844
+ *
845
+ * @example
846
+ * ```js
847
+ * tsEmbed.on(EmbedEvent.Error, (data) => {
848
+ * console.error(data);
849
+ * });
850
+ * ```
851
+ * @example
852
+ * ```js
853
+ * tsEmbed.on(EmbedEvent.Save, (data) => {
854
+ * console.log("Answer save clicked", data);
855
+ * }, {
856
+ * start: true // This will trigger the callback on start of save
857
+ * });
858
+ * ```
859
+ */
827
860
  public on(
828
861
  messageType: EmbedEvent,
829
862
  callback: MessageCallback,
package/src/index.ts CHANGED
@@ -7,7 +7,6 @@
7
7
  * @summary ThoughtSpot Visual Embed SDK
8
8
  * @author Ayon Ghosh <ayon.ghosh@thoughtspot.com>
9
9
  */
10
-
11
10
  import { AppEmbed, Page, AppViewConfig } from './embed/app';
12
11
  import { init, prefetch, logout, getEmbedConfig } from './embed/base';
13
12
  import {
@@ -17,7 +16,13 @@ import {
17
16
  } from './embed/liveboard';
18
17
  import { SearchEmbed, SearchViewConfig } from './embed/search';
19
18
  import { SearchBarEmbed, SearchBarViewConfig } from './embed/search-bar';
20
- import { AuthFailureType, AuthStatus, AuthEvent, getSessionInfo } from './auth';
19
+ import {
20
+ AuthFailureType,
21
+ AuthStatus,
22
+ AuthEvent,
23
+ AuthEventEmitter,
24
+ getSessionInfo,
25
+ } from './auth';
21
26
  import {
22
27
  AuthType,
23
28
  RuntimeFilter,
@@ -28,6 +33,14 @@ import {
28
33
  Action,
29
34
  EmbedConfig,
30
35
  PrefetchFeatures,
36
+ FrameParams,
37
+ DOMSelector,
38
+ MessageOptions,
39
+ MessageCallback,
40
+ MessagePayload,
41
+ CustomisationsInterface,
42
+ CustomStyles,
43
+ customCssInterface,
31
44
  } from './types';
32
45
 
33
46
  export {
@@ -44,6 +57,7 @@ export {
44
57
  AuthFailureType,
45
58
  AuthStatus,
46
59
  AuthEvent,
60
+ AuthEventEmitter,
47
61
  // types
48
62
  Page,
49
63
  AuthType,
@@ -59,4 +73,12 @@ export {
59
73
  LiveboardViewConfig,
60
74
  AppViewConfig,
61
75
  PrefetchFeatures,
76
+ FrameParams,
77
+ DOMSelector,
78
+ MessageOptions,
79
+ MessageCallback,
80
+ MessagePayload,
81
+ CustomisationsInterface,
82
+ CustomStyles,
83
+ customCssInterface,
62
84
  };
@@ -41,7 +41,9 @@ describe('React Components', () => {
41
41
  await waitFor(() => getIFrameEl(container));
42
42
 
43
43
  expect(
44
- getIFrameEl(container).classList.contains('embedClass'),
44
+ getIFrameEl(container).parentElement.classList.contains(
45
+ 'embedClass',
46
+ ),
45
47
  ).toBe(true);
46
48
  expect(getIFrameSrc(container)).toBe(
47
49
  `http://${thoughtSpotHost}/?hostAppUrl=local-host&viewPortHeight=768&viewPortWidth=1024&sdkVersion=${version}&authType=None&hideAction=[%22${Action.ReportError}%22,%22editACopy%22,%22saveAsView%22,%22updateTSL%22,%22editTSL%22,%22onDeleteAnswer%22]&dataSourceMode=hide&useLastSelectedSources=false&isSearchEmbed=true#/embed/answer`,
@@ -141,6 +143,35 @@ describe('React Components', () => {
141
143
  'col1=revenue&op1=EQ&val1=100',
142
144
  );
143
145
  });
146
+
147
+ it('Should have the correct container element', async () => {
148
+ const { container } = render(
149
+ <LiveboardEmbed liveboardId="abcd" className="def" />,
150
+ );
151
+
152
+ await waitFor(() => getIFrameEl(container));
153
+ expect(container.querySelector('div')).not.toBe(null);
154
+ expect(
155
+ container.querySelector('div').classList.contains('def'),
156
+ ).toBe(true);
157
+
158
+ const { container: containerSibling } = render(
159
+ <LiveboardEmbed
160
+ liveboardId="abcd"
161
+ className="def"
162
+ insertAsSibling={true}
163
+ />,
164
+ );
165
+ await waitFor(() => getIFrameEl(containerSibling));
166
+ expect(containerSibling.querySelector('span')).not.toBe(null);
167
+ expect(containerSibling.querySelector('span').style.position).toBe(
168
+ 'absolute',
169
+ );
170
+ expect(
171
+ getIFrameEl(containerSibling).classList.contains('def'),
172
+ ).toBe(true);
173
+ expect(containerSibling.querySelector('div')).toBe(null);
174
+ });
144
175
  });
145
176
 
146
177
  describe('SearchBarEmbed', () => {
@@ -159,7 +190,9 @@ describe('React Components', () => {
159
190
  await waitFor(() => getIFrameEl(container));
160
191
 
161
192
  expect(
162
- getIFrameEl(container).classList.contains('embedClass'),
193
+ getIFrameEl(container).parentElement.classList.contains(
194
+ 'embedClass',
195
+ ),
163
196
  ).toBe(true);
164
197
  expect(getIFrameSrc(container)).toBe(
165
198
  `http://${thoughtSpotHost}/?hostAppUrl=local-host&viewPortHeight=768&viewPortWidth=1024&sdkVersion=${version}&authType=None&hideAction=[%22${Action.ReportError}%22]&dataSources=[%22test%22]&searchTokenString=%5Brevenue%5D&executeSearch=true&useLastSelectedSources=false&isSearchEmbed=true#/embed/search-bar-embed`,
@@ -38,7 +38,9 @@ const componentFactory = <
38
38
  {
39
39
  insertAsSibling: viewConfig.insertAsSibling,
40
40
  frameParams: {
41
- class: className || '',
41
+ class: viewConfig.insertAsSibling
42
+ ? className || ''
43
+ : '',
42
44
  },
43
45
  },
44
46
  viewConfig,
@@ -60,12 +62,18 @@ const componentFactory = <
60
62
  };
61
63
  }, [viewConfig, listeners]);
62
64
 
63
- return (
65
+ return viewConfig.insertAsSibling ? (
64
66
  <span
65
67
  data-testid="tsEmbed"
66
68
  ref={ref}
67
69
  style={{ position: 'absolute' }}
68
70
  ></span>
71
+ ) : (
72
+ <div
73
+ data-testid="tsEmbed"
74
+ ref={ref}
75
+ className={className}
76
+ ></div>
69
77
  );
70
78
  },
71
79
  );