@thoughtspot/visual-embed-sdk 1.26.3 → 1.27.0-alpha.1
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.
- package/README.md +3 -3
- package/cjs/.DS_Store +0 -0
- package/cjs/package.json +1 -1
- package/cjs/src/.DS_Store +0 -0
- package/cjs/src/auth.d.ts +4 -4
- package/cjs/src/auth.d.ts.map +1 -1
- package/cjs/src/auth.js +10 -4
- package/cjs/src/auth.js.map +1 -1
- package/cjs/src/embed/app.d.ts +15 -15
- package/cjs/src/embed/app.d.ts.map +1 -1
- package/cjs/src/embed/app.js +1 -1
- package/cjs/src/embed/app.js.map +1 -1
- package/cjs/src/embed/liveboard.d.ts +28 -23
- package/cjs/src/embed/liveboard.d.ts.map +1 -1
- package/cjs/src/embed/liveboard.js +4 -3
- package/cjs/src/embed/liveboard.js.map +1 -1
- package/cjs/src/embed/sage.d.ts +48 -30
- package/cjs/src/embed/sage.d.ts.map +1 -1
- package/cjs/src/embed/sage.js +7 -6
- package/cjs/src/embed/sage.js.map +1 -1
- package/cjs/src/embed/sage.spec.js +3 -3
- package/cjs/src/embed/sage.spec.js.map +1 -1
- package/cjs/src/embed/search-bar.d.ts +22 -6
- package/cjs/src/embed/search-bar.d.ts.map +1 -1
- package/cjs/src/embed/search-bar.js.map +1 -1
- package/cjs/src/embed/search.d.ts +34 -19
- package/cjs/src/embed/search.d.ts.map +1 -1
- package/cjs/src/embed/search.js +7 -3
- package/cjs/src/embed/search.js.map +1 -1
- package/cjs/src/embed/search.spec.js +10 -0
- package/cjs/src/embed/search.spec.js.map +1 -1
- package/cjs/src/embed/ts-embed.d.ts +1 -0
- package/cjs/src/embed/ts-embed.d.ts.map +1 -1
- package/cjs/src/embed/ts-embed.js +27 -7
- package/cjs/src/embed/ts-embed.js.map +1 -1
- package/cjs/src/embed/ts-embed.spec.js +114 -0
- package/cjs/src/embed/ts-embed.spec.js.map +1 -1
- package/cjs/src/react/index.spec.js +0 -12
- package/cjs/src/react/index.spec.js.map +1 -1
- package/cjs/src/types.d.ts +680 -231
- package/cjs/src/types.d.ts.map +1 -1
- package/cjs/src/types.js +605 -164
- package/cjs/src/types.js.map +1 -1
- package/cjs/src/utils/answerService.d.ts +10 -0
- package/cjs/src/utils/answerService.d.ts.map +1 -0
- package/cjs/src/utils/answerService.js +61 -0
- package/cjs/src/utils/answerService.js.map +1 -0
- package/cjs/src/utils/answerService.spec.d.ts +2 -0
- package/cjs/src/utils/answerService.spec.d.ts.map +1 -0
- package/cjs/src/utils/answerService.spec.js +31 -0
- package/cjs/src/utils/answerService.spec.js.map +1 -0
- package/cjs/src/utils/authService.d.ts +37 -0
- package/cjs/src/utils/authService.d.ts.map +1 -0
- package/cjs/src/utils/authService.js +106 -0
- package/cjs/src/utils/authService.js.map +1 -0
- package/cjs/src/utils/authService.spec.d.ts +2 -0
- package/cjs/src/utils/authService.spec.d.ts.map +1 -0
- package/cjs/src/utils/authService.spec.js +72 -0
- package/cjs/src/utils/authService.spec.js.map +1 -0
- package/cjs/src/utils/graphql/answerService/answerService.d.ts +2 -4
- package/cjs/src/utils/graphql/answerService/answerService.d.ts.map +1 -1
- package/cjs/src/utils/graphql/answerService/answerService.js +2 -4
- package/cjs/src/utils/graphql/answerService/answerService.js.map +1 -1
- package/cjs/src/utils/processData.d.ts +6 -0
- package/cjs/src/utils/processData.d.ts.map +1 -1
- package/cjs/src/utils/processData.js +5 -1
- package/cjs/src/utils/processData.js.map +1 -1
- package/cjs/src/utils/processTrigger.js +1 -1
- package/dist/src/auth.d.ts +4 -4
- package/dist/src/auth.d.ts.map +1 -1
- package/dist/src/embed/app.d.ts +15 -15
- package/dist/src/embed/app.d.ts.map +1 -1
- package/dist/src/embed/liveboard.d.ts +28 -23
- package/dist/src/embed/liveboard.d.ts.map +1 -1
- package/dist/src/embed/sage.d.ts +48 -30
- package/dist/src/embed/sage.d.ts.map +1 -1
- package/dist/src/embed/search-bar.d.ts +22 -6
- package/dist/src/embed/search-bar.d.ts.map +1 -1
- package/dist/src/embed/search.d.ts +34 -19
- package/dist/src/embed/search.d.ts.map +1 -1
- package/dist/src/embed/ts-embed.d.ts +1 -0
- package/dist/src/embed/ts-embed.d.ts.map +1 -1
- package/dist/src/types.d.ts +680 -231
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/utils/answerService.d.ts +10 -0
- package/dist/src/utils/answerService.d.ts.map +1 -0
- package/dist/src/utils/answerService.spec.d.ts +2 -0
- package/dist/src/utils/answerService.spec.d.ts.map +1 -0
- package/dist/src/utils/authService.d.ts +37 -0
- package/dist/src/utils/authService.d.ts.map +1 -0
- package/dist/src/utils/authService.spec.d.ts +2 -0
- package/dist/src/utils/authService.spec.d.ts.map +1 -0
- package/dist/src/utils/graphql/answerService/answerService.d.ts +2 -4
- package/dist/src/utils/graphql/answerService/answerService.d.ts.map +1 -1
- package/dist/src/utils/processData.d.ts +6 -0
- package/dist/src/utils/processData.d.ts.map +1 -1
- package/dist/tsembed-react.es.js +664 -194
- package/dist/tsembed-react.js +663 -193
- package/dist/tsembed.es.js +667 -194
- package/dist/tsembed.js +665 -192
- package/dist/visual-embed-sdk-react-full.d.ts +851 -328
- package/dist/visual-embed-sdk-react.d.ts +851 -328
- package/dist/visual-embed-sdk.d.ts +851 -328
- package/lib/.DS_Store +0 -0
- package/lib/package.json +1 -1
- package/lib/src/.DS_Store +0 -0
- package/lib/src/auth.d.ts +4 -4
- package/lib/src/auth.d.ts.map +1 -1
- package/lib/src/auth.js +10 -4
- package/lib/src/auth.js.map +1 -1
- package/lib/src/embed/app.d.ts +15 -15
- package/lib/src/embed/app.d.ts.map +1 -1
- package/lib/src/embed/app.js +1 -1
- package/lib/src/embed/app.js.map +1 -1
- package/lib/src/embed/liveboard.d.ts +28 -23
- package/lib/src/embed/liveboard.d.ts.map +1 -1
- package/lib/src/embed/liveboard.js +4 -3
- package/lib/src/embed/liveboard.js.map +1 -1
- package/lib/src/embed/sage.d.ts +48 -30
- package/lib/src/embed/sage.d.ts.map +1 -1
- package/lib/src/embed/sage.js +7 -6
- package/lib/src/embed/sage.js.map +1 -1
- package/lib/src/embed/sage.spec.js +3 -3
- package/lib/src/embed/sage.spec.js.map +1 -1
- package/lib/src/embed/search-bar.d.ts +22 -6
- package/lib/src/embed/search-bar.d.ts.map +1 -1
- package/lib/src/embed/search-bar.js.map +1 -1
- package/lib/src/embed/search.d.ts +34 -19
- package/lib/src/embed/search.d.ts.map +1 -1
- package/lib/src/embed/search.js +7 -3
- package/lib/src/embed/search.js.map +1 -1
- package/lib/src/embed/search.spec.js +10 -0
- package/lib/src/embed/search.spec.js.map +1 -1
- package/lib/src/embed/ts-embed.d.ts +1 -0
- package/lib/src/embed/ts-embed.d.ts.map +1 -1
- package/lib/src/embed/ts-embed.js +28 -8
- package/lib/src/embed/ts-embed.js.map +1 -1
- package/lib/src/embed/ts-embed.spec.js +114 -0
- package/lib/src/embed/ts-embed.spec.js.map +1 -1
- package/lib/src/react/index.spec.js +0 -12
- package/lib/src/react/index.spec.js.map +1 -1
- package/lib/src/types.d.ts +680 -231
- package/lib/src/types.d.ts.map +1 -1
- package/lib/src/types.js +605 -164
- package/lib/src/types.js.map +1 -1
- package/lib/src/utils/answerService.d.ts +10 -0
- package/lib/src/utils/answerService.d.ts.map +1 -0
- package/lib/src/utils/answerService.js +57 -0
- package/lib/src/utils/answerService.js.map +1 -0
- package/lib/src/utils/answerService.spec.d.ts +2 -0
- package/lib/src/utils/answerService.spec.d.ts.map +1 -0
- package/lib/src/utils/answerService.spec.js +29 -0
- package/lib/src/utils/answerService.spec.js.map +1 -0
- package/lib/src/utils/authService.d.ts +37 -0
- package/lib/src/utils/authService.d.ts.map +1 -0
- package/lib/src/utils/authService.js +97 -0
- package/lib/src/utils/authService.js.map +1 -0
- package/lib/src/utils/authService.spec.d.ts +2 -0
- package/lib/src/utils/authService.spec.d.ts.map +1 -0
- package/lib/src/utils/authService.spec.js +70 -0
- package/lib/src/utils/authService.spec.js.map +1 -0
- package/lib/src/utils/graphql/answerService/answerService.d.ts +2 -4
- package/lib/src/utils/graphql/answerService/answerService.d.ts.map +1 -1
- package/lib/src/utils/graphql/answerService/answerService.js +2 -4
- package/lib/src/utils/graphql/answerService/answerService.js.map +1 -1
- package/lib/src/utils/processData.d.ts +6 -0
- package/lib/src/utils/processData.d.ts.map +1 -1
- package/lib/src/utils/processData.js +4 -1
- package/lib/src/utils/processData.js.map +1 -1
- package/lib/src/utils/processTrigger.js +1 -1
- package/lib/src/visual-embed-sdk.d.ts +851 -328
- package/package.json +1 -1
- package/src/.DS_Store +0 -0
- package/src/auth.ts +10 -4
- package/src/embed/app.ts +20 -20
- package/src/embed/liveboard.ts +32 -27
- package/src/embed/sage.spec.ts +3 -3
- package/src/embed/sage.ts +54 -36
- package/src/embed/search-bar.tsx +22 -6
- package/src/embed/search.spec.ts +13 -0
- package/src/embed/search.ts +42 -22
- package/src/embed/ts-embed.spec.ts +132 -0
- package/src/embed/ts-embed.ts +27 -9
- package/src/react/index.spec.tsx +0 -29
- package/src/types.ts +680 -232
- package/src/utils/graphql/answerService/answerService.ts +2 -4
- package/src/utils/processData.ts +4 -1
- package/src/utils/processTrigger.ts +1 -1
package/src/embed/search.ts
CHANGED
|
@@ -23,18 +23,19 @@ import { getReleaseVersion } from '../auth';
|
|
|
23
23
|
import { getEmbedConfig } from './embedConfig';
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
|
-
* Configuration for search options
|
|
26
|
+
* Configuration for search options.
|
|
27
|
+
*
|
|
27
28
|
*/
|
|
28
29
|
export interface SearchOptions {
|
|
29
30
|
/**
|
|
30
|
-
*
|
|
31
|
+
* Search tokens to pass in the query.
|
|
31
32
|
*/
|
|
32
33
|
searchTokenString: string;
|
|
33
34
|
/**
|
|
34
|
-
* Boolean to
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
* the
|
|
35
|
+
* Boolean to define if the search should be executed or not.
|
|
36
|
+
* If it is executed, the focus is placed on the results.
|
|
37
|
+
* If it’s not executed, the focus is placed at the end of
|
|
38
|
+
* the token string in the search bar.
|
|
38
39
|
*/
|
|
39
40
|
executeSearch?: boolean;
|
|
40
41
|
}
|
|
@@ -59,19 +60,15 @@ export interface SearchViewConfig
|
|
|
59
60
|
*/
|
|
60
61
|
collapseDataSources?: boolean;
|
|
61
62
|
/**
|
|
62
|
-
*
|
|
63
|
+
* Show or hide the data sources panel.
|
|
63
64
|
*/
|
|
64
65
|
hideDataSources?: boolean;
|
|
65
66
|
/**
|
|
66
|
-
*
|
|
67
|
+
* Show or hide the charts and tables in search answers.
|
|
67
68
|
* This attribute can be used to create a custom visualization
|
|
68
69
|
* using raw answer data.
|
|
69
70
|
*/
|
|
70
71
|
hideResults?: boolean;
|
|
71
|
-
/**
|
|
72
|
-
* If set to true, expands all the data sources panel.
|
|
73
|
-
*/
|
|
74
|
-
expandAllDataSource?: boolean;
|
|
75
72
|
/**
|
|
76
73
|
* If set to true, the Search Assist feature is enabled.
|
|
77
74
|
*
|
|
@@ -85,9 +82,9 @@ export interface SearchViewConfig
|
|
|
85
82
|
forceTable?: boolean;
|
|
86
83
|
/**
|
|
87
84
|
* The array of data source GUIDs to set on load.
|
|
88
|
-
* Only a single
|
|
85
|
+
* Only a single data source is supported currently.
|
|
89
86
|
*
|
|
90
|
-
* @deprecated Use dataSource instead
|
|
87
|
+
* @deprecated Use `dataSource` instead.
|
|
91
88
|
*/
|
|
92
89
|
dataSources?: string[];
|
|
93
90
|
/**
|
|
@@ -99,11 +96,29 @@ export interface SearchViewConfig
|
|
|
99
96
|
/**
|
|
100
97
|
* The initial search query to load the answer with.
|
|
101
98
|
*
|
|
102
|
-
* @deprecated
|
|
99
|
+
* @deprecated
|
|
100
|
+
*
|
|
101
|
+
* Use {@link searchOptions} instead.
|
|
103
102
|
*/
|
|
104
103
|
searchQuery?: string;
|
|
105
104
|
/**
|
|
106
|
-
* Configuration for search options
|
|
105
|
+
* Configuration for search options.
|
|
106
|
+
* Includes the following properties:
|
|
107
|
+
*
|
|
108
|
+
* `searchTokenString`: Search tokens to pass in the query.
|
|
109
|
+
*
|
|
110
|
+
* `executeSearch`: Boolean to define if the search should be executed or not.
|
|
111
|
+
* If it is executed, the focus is placed on the results.
|
|
112
|
+
* If it’s not executed, the focus is placed at the end of
|
|
113
|
+
* the token string in the search bar.
|
|
114
|
+
*
|
|
115
|
+
* @example
|
|
116
|
+
* ```js
|
|
117
|
+
* searchOptions: {
|
|
118
|
+
* searchTokenString: '[quantity purchased] [region]',
|
|
119
|
+
* executeSearch: true,
|
|
120
|
+
* }
|
|
121
|
+
* ```
|
|
107
122
|
*/
|
|
108
123
|
searchOptions?: SearchOptions;
|
|
109
124
|
/**
|
|
@@ -111,10 +126,10 @@ export interface SearchViewConfig
|
|
|
111
126
|
*/
|
|
112
127
|
answerId?: string;
|
|
113
128
|
/**
|
|
114
|
-
* If set to true, search page will render without the Search Bar
|
|
129
|
+
* If set to true, the search page will render without the Search Bar
|
|
115
130
|
* The chart/table should still be visible.
|
|
116
131
|
*
|
|
117
|
-
* @version SDK: 1.21.0 | ThoughtSpot: 9.2.0.cl
|
|
132
|
+
* @version SDK: 1.21.0 | ThoughtSpot: 9.2.0.cl, 9.5.0.sw
|
|
118
133
|
*/
|
|
119
134
|
hideSearchBar?: boolean;
|
|
120
135
|
/**
|
|
@@ -175,7 +190,6 @@ export class SearchEmbed extends TsEmbed {
|
|
|
175
190
|
protected getEmbedParams(): string {
|
|
176
191
|
const {
|
|
177
192
|
hideResults,
|
|
178
|
-
expandAllDataSource,
|
|
179
193
|
enableSearchAssist,
|
|
180
194
|
forceTable,
|
|
181
195
|
searchOptions,
|
|
@@ -183,6 +197,7 @@ export class SearchEmbed extends TsEmbed {
|
|
|
183
197
|
dataSource,
|
|
184
198
|
dataSources,
|
|
185
199
|
excludeRuntimeFiltersfromURL,
|
|
200
|
+
hideSearchBar,
|
|
186
201
|
dataPanelV2 = false,
|
|
187
202
|
useLastSelectedSources = false,
|
|
188
203
|
runtimeParameters,
|
|
@@ -219,6 +234,10 @@ export class SearchEmbed extends TsEmbed {
|
|
|
219
234
|
queryParams[Param.ForceTable] = true;
|
|
220
235
|
}
|
|
221
236
|
|
|
237
|
+
if (hideSearchBar) {
|
|
238
|
+
queryParams[Param.HideSearchBar] = true;
|
|
239
|
+
}
|
|
240
|
+
|
|
222
241
|
queryParams[Param.DataPanelV2Enabled] = dataPanelV2;
|
|
223
242
|
queryParams[Param.DataSourceMode] = this.getDataSourceMode();
|
|
224
243
|
|
|
@@ -251,7 +270,8 @@ export class SearchEmbed extends TsEmbed {
|
|
|
251
270
|
* @param answerId The GUID of a saved answer
|
|
252
271
|
* @param dataSources A list of data source GUIDs
|
|
253
272
|
*/
|
|
254
|
-
|
|
273
|
+
public getIFrameSrc(): string {
|
|
274
|
+
const { answerId } = this.viewConfig;
|
|
255
275
|
const answerPath = answerId ? `saved-answer/${answerId}` : 'answer';
|
|
256
276
|
const tsPostHashParams = this.getThoughtSpotPostUrlParams();
|
|
257
277
|
|
|
@@ -265,14 +285,14 @@ export class SearchEmbed extends TsEmbed {
|
|
|
265
285
|
super.render();
|
|
266
286
|
const { answerId } = this.viewConfig;
|
|
267
287
|
|
|
268
|
-
const src = this.getIFrameSrc(
|
|
288
|
+
const src = this.getIFrameSrc();
|
|
269
289
|
this.renderIFrame(src);
|
|
270
290
|
getAuthPromise().then(() => {
|
|
271
291
|
if (
|
|
272
292
|
checkReleaseVersionInBeta(
|
|
273
293
|
getReleaseVersion(),
|
|
274
294
|
getEmbedConfig().suppressSearchEmbedBetaWarning
|
|
275
|
-
|
|
295
|
+
|| getEmbedConfig().suppressErrorAlerts,
|
|
276
296
|
)
|
|
277
297
|
) {
|
|
278
298
|
alert(ERROR_MESSAGE.SEARCHEMBED_BETA_WRANING_MESSAGE);
|
|
@@ -562,6 +562,138 @@ describe('Unit test case for ts embed', () => {
|
|
|
562
562
|
});
|
|
563
563
|
});
|
|
564
564
|
|
|
565
|
+
describe('Token fetch fails in cookieless authentication authType', () => {
|
|
566
|
+
beforeEach(() => {
|
|
567
|
+
jest.spyOn(authInstance, 'doCookielessTokenAuth').mockResolvedValueOnce(true);
|
|
568
|
+
init({
|
|
569
|
+
thoughtSpotHost: 'tshost',
|
|
570
|
+
customizations: customisations,
|
|
571
|
+
customCssUrl: 'http://localhost:5000',
|
|
572
|
+
authType: AuthType.TrustedAuthTokenCookieless,
|
|
573
|
+
getAuthToken: () => Promise.reject(),
|
|
574
|
+
});
|
|
575
|
+
});
|
|
576
|
+
|
|
577
|
+
afterEach(() => {
|
|
578
|
+
jest.clearAllMocks();
|
|
579
|
+
baseInstance.reset();
|
|
580
|
+
});
|
|
581
|
+
|
|
582
|
+
test('should show login failure message if token failed during app_init', async () => {
|
|
583
|
+
const a = jest.spyOn(authService, 'verifyTokenService');
|
|
584
|
+
a.mockResolvedValue(true);
|
|
585
|
+
|
|
586
|
+
// authVerifyMock.mockResolvedValue(true);
|
|
587
|
+
const mockEmbedEventPayload = {
|
|
588
|
+
type: EmbedEvent.APP_INIT,
|
|
589
|
+
data: {},
|
|
590
|
+
};
|
|
591
|
+
const searchEmbed = new SearchEmbed(getRootEl(), defaultViewConfig);
|
|
592
|
+
searchEmbed.render();
|
|
593
|
+
const mockPort: any = {
|
|
594
|
+
postMessage: jest.fn(),
|
|
595
|
+
};
|
|
596
|
+
await executeAfterWait(() => {
|
|
597
|
+
const iframe = getIFrameEl();
|
|
598
|
+
postMessageToParent(iframe.contentWindow, mockEmbedEventPayload, mockPort);
|
|
599
|
+
});
|
|
600
|
+
await executeAfterWait(() => {
|
|
601
|
+
expect(mockPort.postMessage).not.toHaveBeenCalled();
|
|
602
|
+
expect(getRootEl().innerHTML).toContain('Not logged in');
|
|
603
|
+
});
|
|
604
|
+
|
|
605
|
+
jest.spyOn(authService, 'verifyTokenService').mockClear();
|
|
606
|
+
});
|
|
607
|
+
|
|
608
|
+
test('should show login failure message if token failed during app_init prerender', async () => {
|
|
609
|
+
const a = jest.spyOn(authService, 'verifyTokenService');
|
|
610
|
+
a.mockResolvedValue(true);
|
|
611
|
+
|
|
612
|
+
// authVerifyMock.mockResolvedValue(true);
|
|
613
|
+
const mockEmbedEventPayload = {
|
|
614
|
+
type: EmbedEvent.APP_INIT,
|
|
615
|
+
data: {},
|
|
616
|
+
};
|
|
617
|
+
const searchEmbed = new SearchEmbed(getRootEl(), { ...defaultViewConfig, preRenderId: 'test' });
|
|
618
|
+
searchEmbed.preRender();
|
|
619
|
+
const mockPort: any = {
|
|
620
|
+
postMessage: jest.fn(),
|
|
621
|
+
};
|
|
622
|
+
await executeAfterWait(() => {
|
|
623
|
+
const iframe = getIFrameEl();
|
|
624
|
+
postMessageToParent(iframe.contentWindow, mockEmbedEventPayload, mockPort);
|
|
625
|
+
});
|
|
626
|
+
const preRenderWrapper = document.getElementById('tsEmbed-pre-render-wrapper-test');
|
|
627
|
+
await executeAfterWait(() => {
|
|
628
|
+
expect(mockPort.postMessage).not.toHaveBeenCalled();
|
|
629
|
+
expect(preRenderWrapper.innerHTML).toContain('Not logged in');
|
|
630
|
+
});
|
|
631
|
+
|
|
632
|
+
jest.spyOn(authService, 'verifyTokenService').mockClear();
|
|
633
|
+
});
|
|
634
|
+
|
|
635
|
+
test('should show login failure message if update token failed', async () => {
|
|
636
|
+
const a = jest.spyOn(authService, 'verifyTokenService');
|
|
637
|
+
a.mockResolvedValue(true);
|
|
638
|
+
|
|
639
|
+
// authVerifyMock.mockResolvedValue(true);
|
|
640
|
+
const mockEmbedEventPayload = {
|
|
641
|
+
type: EmbedEvent.AuthExpire,
|
|
642
|
+
data: {},
|
|
643
|
+
};
|
|
644
|
+
const searchEmbed = new SearchEmbed(getRootEl(), defaultViewConfig);
|
|
645
|
+
jest.spyOn(baseInstance, 'notifyAuthFailure');
|
|
646
|
+
searchEmbed.render();
|
|
647
|
+
const mockPort: any = {
|
|
648
|
+
postMessage: jest.fn(),
|
|
649
|
+
};
|
|
650
|
+
await executeAfterWait(() => {
|
|
651
|
+
const iframe = getIFrameEl();
|
|
652
|
+
postMessageToParent(iframe.contentWindow, mockEmbedEventPayload, mockPort);
|
|
653
|
+
});
|
|
654
|
+
await executeAfterWait(() => {
|
|
655
|
+
expect(getRootEl().innerHTML).toContain('Not logged in');
|
|
656
|
+
expect(baseInstance.notifyAuthFailure).toBeCalledWith(
|
|
657
|
+
authInstance.AuthFailureType.EXPIRY,
|
|
658
|
+
);
|
|
659
|
+
});
|
|
660
|
+
|
|
661
|
+
jest.spyOn(authService, 'verifyTokenService').mockClear();
|
|
662
|
+
jest.spyOn(baseInstance, 'notifyAuthFailure').mockClear();
|
|
663
|
+
});
|
|
664
|
+
|
|
665
|
+
test('should show login failure message if update token failed prerender', async () => {
|
|
666
|
+
const a = jest.spyOn(authService, 'verifyTokenService');
|
|
667
|
+
a.mockResolvedValue(true);
|
|
668
|
+
|
|
669
|
+
// authVerifyMock.mockResolvedValue(true);
|
|
670
|
+
const mockEmbedEventPayload = {
|
|
671
|
+
type: EmbedEvent.AuthExpire,
|
|
672
|
+
data: {},
|
|
673
|
+
};
|
|
674
|
+
const searchEmbed = new SearchEmbed(getRootEl(), { ...defaultViewConfig, preRenderId: 'test' });
|
|
675
|
+
jest.spyOn(baseInstance, 'notifyAuthFailure');
|
|
676
|
+
searchEmbed.preRender();
|
|
677
|
+
const mockPort: any = {
|
|
678
|
+
postMessage: jest.fn(),
|
|
679
|
+
};
|
|
680
|
+
await executeAfterWait(() => {
|
|
681
|
+
const iframe = getIFrameEl();
|
|
682
|
+
postMessageToParent(iframe.contentWindow, mockEmbedEventPayload, mockPort);
|
|
683
|
+
});
|
|
684
|
+
const preRenderWrapper = document.getElementById('tsEmbed-pre-render-wrapper-test');
|
|
685
|
+
await executeAfterWait(() => {
|
|
686
|
+
expect(preRenderWrapper.innerHTML).toContain('Not logged in');
|
|
687
|
+
expect(baseInstance.notifyAuthFailure).toBeCalledWith(
|
|
688
|
+
authInstance.AuthFailureType.EXPIRY,
|
|
689
|
+
);
|
|
690
|
+
});
|
|
691
|
+
|
|
692
|
+
jest.spyOn(authService, 'verifyTokenService').mockClear();
|
|
693
|
+
jest.spyOn(baseInstance, 'notifyAuthFailure').mockClear();
|
|
694
|
+
});
|
|
695
|
+
});
|
|
696
|
+
|
|
565
697
|
xdescribe('AuthExpire embedEvent in TrustedAuthToken authType', () => {
|
|
566
698
|
test('AutoLogin true scenario', async () => {
|
|
567
699
|
init({
|
package/src/embed/ts-embed.ts
CHANGED
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import isEqual from 'lodash/isEqual';
|
|
11
|
-
|
|
12
11
|
import { getAuthenticationToken } from '../authToken';
|
|
13
12
|
import { AnswerService } from '../utils/graphql/answerService/answerService';
|
|
14
13
|
import {
|
|
@@ -52,7 +51,7 @@ import {
|
|
|
52
51
|
RuntimeFilter,
|
|
53
52
|
} from '../types';
|
|
54
53
|
import { uploadMixpanelEvent, MIXPANEL_EVENT } from '../mixpanel-service';
|
|
55
|
-
import { processEventData } from '../utils/processData';
|
|
54
|
+
import { processEventData, processAuthFailure } from '../utils/processData';
|
|
56
55
|
import { processTrigger } from '../utils/processTrigger';
|
|
57
56
|
import pkgInfo from '../../package.json';
|
|
58
57
|
import {
|
|
@@ -306,7 +305,12 @@ export class TsEmbed {
|
|
|
306
305
|
private appInitCb = async (_: any, responder: any) => {
|
|
307
306
|
let authToken = '';
|
|
308
307
|
if (this.embedConfig.authType === AuthType.TrustedAuthTokenCookieless) {
|
|
309
|
-
|
|
308
|
+
try {
|
|
309
|
+
authToken = await getAuthenticationToken(this.embedConfig);
|
|
310
|
+
} catch (e) {
|
|
311
|
+
processAuthFailure(e, this.isPreRendered ? this.preRenderWrapper : this.el);
|
|
312
|
+
return;
|
|
313
|
+
}
|
|
310
314
|
}
|
|
311
315
|
this.isAppInitialized = true;
|
|
312
316
|
responder({
|
|
@@ -336,11 +340,16 @@ export class TsEmbed {
|
|
|
336
340
|
private updateAuthToken = async (_: any, responder: any) => {
|
|
337
341
|
const { autoLogin = false, authType } = this.embedConfig; // Set autoLogin default to false
|
|
338
342
|
if (authType === AuthType.TrustedAuthTokenCookieless) {
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
343
|
+
let authToken = '';
|
|
344
|
+
try {
|
|
345
|
+
authToken = await getAuthenticationToken(this.embedConfig);
|
|
346
|
+
responder({
|
|
347
|
+
type: EmbedEvent.AuthExpire,
|
|
348
|
+
data: { authToken },
|
|
349
|
+
});
|
|
350
|
+
} catch (e) {
|
|
351
|
+
processAuthFailure(e, this.isPreRendered ? this.preRenderWrapper : this.el);
|
|
352
|
+
}
|
|
344
353
|
} else if (autoLogin) {
|
|
345
354
|
handleAuth();
|
|
346
355
|
}
|
|
@@ -505,7 +514,11 @@ export class TsEmbed {
|
|
|
505
514
|
const queryParams = this.shouldEncodeUrlQueryParams
|
|
506
515
|
? `?base64UrlEncodedFlags=${getEncodedQueryParamsString(queryString)}`
|
|
507
516
|
: `?${queryString}`;
|
|
508
|
-
|
|
517
|
+
let host = this.thoughtSpotHost;
|
|
518
|
+
if (!isUndefined(this.embedConfig.enableReactShell)) {
|
|
519
|
+
host = this.embedConfig.enableReactShell as boolean ? '/v2' : '/v1';
|
|
520
|
+
}
|
|
521
|
+
const path = `${host}/${queryParams}#`;
|
|
509
522
|
return path;
|
|
510
523
|
}
|
|
511
524
|
|
|
@@ -524,6 +537,7 @@ export class TsEmbed {
|
|
|
524
537
|
|
|
525
538
|
iFrame.src = frameSrc;
|
|
526
539
|
iFrame.id = TS_EMBED_ID;
|
|
540
|
+
iFrame.setAttribute('data-ts-iframe', 'true');
|
|
527
541
|
|
|
528
542
|
// according to screenfull.js documentation
|
|
529
543
|
// allowFullscreen, webkitallowfullscreen and mozallowfullscreen must be
|
|
@@ -966,6 +980,10 @@ export class TsEmbed {
|
|
|
966
980
|
return this;
|
|
967
981
|
}
|
|
968
982
|
|
|
983
|
+
public getIframeSrc(): string {
|
|
984
|
+
return '';
|
|
985
|
+
}
|
|
986
|
+
|
|
969
987
|
protected handleRenderForPrerender() {
|
|
970
988
|
this.render();
|
|
971
989
|
}
|
package/src/react/index.spec.tsx
CHANGED
|
@@ -199,35 +199,6 @@ describe('React Components', () => {
|
|
|
199
199
|
).toBe(true);
|
|
200
200
|
expect(containerSibling.querySelector('div')).toBe(null);
|
|
201
201
|
});
|
|
202
|
-
|
|
203
|
-
it('Should have the correct container element', async () => {
|
|
204
|
-
const { container } = render(
|
|
205
|
-
<LiveboardEmbed liveboardId="abcd" className="def" />,
|
|
206
|
-
);
|
|
207
|
-
|
|
208
|
-
await waitFor(() => getIFrameEl(container));
|
|
209
|
-
expect(container.querySelector('div')).not.toBe(null);
|
|
210
|
-
expect(
|
|
211
|
-
container.querySelector('div').classList.contains('def'),
|
|
212
|
-
).toBe(true);
|
|
213
|
-
|
|
214
|
-
const { container: containerSibling } = render(
|
|
215
|
-
<LiveboardEmbed
|
|
216
|
-
liveboardId="abcd"
|
|
217
|
-
className="def"
|
|
218
|
-
insertAsSibling={true}
|
|
219
|
-
/>,
|
|
220
|
-
);
|
|
221
|
-
await waitFor(() => getIFrameEl(containerSibling));
|
|
222
|
-
expect(containerSibling.querySelector('span')).not.toBe(null);
|
|
223
|
-
expect(containerSibling.querySelector('span').style.position).toBe(
|
|
224
|
-
'absolute',
|
|
225
|
-
);
|
|
226
|
-
expect(
|
|
227
|
-
getIFrameEl(containerSibling).classList.contains('def'),
|
|
228
|
-
).toBe(true);
|
|
229
|
-
expect(containerSibling.querySelector('div')).toBe(null);
|
|
230
|
-
});
|
|
231
202
|
});
|
|
232
203
|
|
|
233
204
|
describe('SearchBarEmbed', () => {
|