@thoughtspot/visual-embed-sdk 1.26.2 → 1.27.0-alpha.0
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 +1 -1
- package/cjs/package.json +1 -1
- 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 +1 -1
- package/cjs/src/embed/sage.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 +727 -242
- package/cjs/src/types.d.ts.map +1 -1
- package/cjs/src/types.js +653 -175
- package/cjs/src/types.js.map +1 -1
- 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 +727 -242
- package/dist/src/types.d.ts.map +1 -1
- 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 +706 -200
- package/dist/tsembed-react.js +705 -199
- package/dist/tsembed.es.js +709 -200
- package/dist/tsembed.js +707 -198
- package/dist/visual-embed-sdk-react-full.d.ts +898 -339
- package/dist/visual-embed-sdk-react.d.ts +898 -339
- package/dist/visual-embed-sdk.d.ts +898 -339
- package/lib/package.json +1 -1
- 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 +1 -1
- package/lib/src/embed/sage.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 +727 -242
- package/lib/src/types.d.ts.map +1 -1
- package/lib/src/types.js +653 -175
- package/lib/src/types.js.map +1 -1
- 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 +898 -339
- package/package.json +1 -1
- package/src/auth.ts +10 -4
- package/src/embed/app.ts +20 -20
- package/src/embed/liveboard.ts +32 -27
- package/src/embed/sage.ts +48 -30
- 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 +32 -14
- package/src/react/index.spec.tsx +0 -29
- package/src/types.ts +727 -243
- package/src/utils/graphql/answerService/answerService.ts +2 -4
- package/src/utils/processData.ts +4 -1
- package/src/utils/processTrigger.ts +1 -1
- package/cjs/src/embed/TsEmbed.d.ts +0 -302
- package/cjs/src/embed/TsEmbed.d.ts.map +0 -1
- package/cjs/src/embed/TsEmbed.js +0 -851
- package/cjs/src/embed/TsEmbed.js.map +0 -1
- package/cjs/src/utils/answerService.d.ts +0 -10
- package/cjs/src/utils/answerService.d.ts.map +0 -1
- package/cjs/src/utils/answerService.js +0 -61
- package/cjs/src/utils/answerService.js.map +0 -1
- package/cjs/src/utils/answerService.spec.d.ts +0 -2
- package/cjs/src/utils/answerService.spec.d.ts.map +0 -1
- package/cjs/src/utils/answerService.spec.js +0 -31
- package/cjs/src/utils/answerService.spec.js.map +0 -1
- package/cjs/src/utils/authService/tokenisedAuthSerice.d.ts +0 -11
- package/cjs/src/utils/authService/tokenisedAuthSerice.d.ts.map +0 -1
- package/cjs/src/utils/authService/tokenisedAuthSerice.js +0 -44
- package/cjs/src/utils/authService/tokenisedAuthSerice.js.map +0 -1
- package/cjs/src/utils/authService.d.ts +0 -55
- package/cjs/src/utils/authService.d.ts.map +0 -1
- package/cjs/src/utils/authService.js +0 -139
- package/cjs/src/utils/authService.js.map +0 -1
- package/cjs/src/utils/authService.spec.d.ts +0 -2
- package/cjs/src/utils/authService.spec.d.ts.map +0 -1
- package/cjs/src/utils/authService.spec.js +0 -82
- package/cjs/src/utils/authService.spec.js.map +0 -1
- package/cjs/src/utils/graphql/graphql-request.spec.d.ts +0 -2
- package/cjs/src/utils/graphql/graphql-request.spec.d.ts.map +0 -1
- package/cjs/src/utils/graphql/graphql-request.spec.js +0 -39
- package/cjs/src/utils/graphql/graphql-request.spec.js.map +0 -1
- package/cjs/src/utils/logger.d.ts +0 -28
- package/cjs/src/utils/logger.d.ts.map +0 -1
- package/cjs/src/utils/logger.js +0 -82
- package/cjs/src/utils/logger.js.map +0 -1
- package/dist/src/utils/answerService.d.ts +0 -10
- package/dist/src/utils/answerService.d.ts.map +0 -1
- package/dist/src/utils/answerService.spec.d.ts +0 -2
- package/dist/src/utils/answerService.spec.d.ts.map +0 -1
- package/dist/src/utils/authService/tokenisedAuthSerice.d.ts +0 -11
- package/dist/src/utils/authService/tokenisedAuthSerice.d.ts.map +0 -1
- package/dist/src/utils/authService.d.ts +0 -55
- package/dist/src/utils/authService.d.ts.map +0 -1
- package/dist/src/utils/authService.spec.d.ts +0 -2
- package/dist/src/utils/authService.spec.d.ts.map +0 -1
- package/dist/src/utils/graphql/graphql-request.spec.d.ts +0 -2
- package/dist/src/utils/graphql/graphql-request.spec.d.ts.map +0 -1
- package/dist/src/utils/logger.d.ts +0 -28
- package/dist/src/utils/logger.d.ts.map +0 -1
- package/lib/src/embed/TsEmbed.d.ts +0 -302
- package/lib/src/embed/TsEmbed.d.ts.map +0 -1
- package/lib/src/embed/TsEmbed.js +0 -847
- package/lib/src/embed/TsEmbed.js.map +0 -1
- package/lib/src/utils/answerService.d.ts +0 -10
- package/lib/src/utils/answerService.d.ts.map +0 -1
- package/lib/src/utils/answerService.js +0 -57
- package/lib/src/utils/answerService.js.map +0 -1
- package/lib/src/utils/answerService.spec.d.ts +0 -2
- package/lib/src/utils/answerService.spec.d.ts.map +0 -1
- package/lib/src/utils/answerService.spec.js +0 -29
- package/lib/src/utils/answerService.spec.js.map +0 -1
- package/lib/src/utils/authService/tokenisedAuthSerice.d.ts +0 -11
- package/lib/src/utils/authService/tokenisedAuthSerice.d.ts.map +0 -1
- package/lib/src/utils/authService/tokenisedAuthSerice.js +0 -39
- package/lib/src/utils/authService/tokenisedAuthSerice.js.map +0 -1
- package/lib/src/utils/authService.d.ts +0 -55
- package/lib/src/utils/authService.d.ts.map +0 -1
- package/lib/src/utils/authService.js +0 -129
- package/lib/src/utils/authService.js.map +0 -1
- package/lib/src/utils/authService.spec.d.ts +0 -2
- package/lib/src/utils/authService.spec.d.ts.map +0 -1
- package/lib/src/utils/authService.spec.js +0 -80
- package/lib/src/utils/authService.spec.js.map +0 -1
- package/lib/src/utils/graphql/graphql-request.spec.d.ts +0 -2
- package/lib/src/utils/graphql/graphql-request.spec.d.ts.map +0 -1
- package/lib/src/utils/graphql/graphql-request.spec.js +0 -36
- package/lib/src/utils/graphql/graphql-request.spec.js.map +0 -1
- package/lib/src/utils/logger.d.ts +0 -28
- package/lib/src/utils/logger.d.ts.map +0 -1
- package/lib/src/utils/logger.js +0 -75
- package/lib/src/utils/logger.js.map +0 -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
|
/**
|
|
@@ -177,7 +192,6 @@ export class SearchEmbed extends TsEmbed {
|
|
|
177
192
|
protected getEmbedParams(): string {
|
|
178
193
|
const {
|
|
179
194
|
hideResults,
|
|
180
|
-
expandAllDataSource,
|
|
181
195
|
enableSearchAssist,
|
|
182
196
|
forceTable,
|
|
183
197
|
searchOptions,
|
|
@@ -185,6 +199,7 @@ export class SearchEmbed extends TsEmbed {
|
|
|
185
199
|
dataSource,
|
|
186
200
|
dataSources,
|
|
187
201
|
excludeRuntimeFiltersfromURL,
|
|
202
|
+
hideSearchBar,
|
|
188
203
|
dataPanelV2 = false,
|
|
189
204
|
useLastSelectedSources = false,
|
|
190
205
|
runtimeParameters,
|
|
@@ -221,6 +236,10 @@ export class SearchEmbed extends TsEmbed {
|
|
|
221
236
|
queryParams[Param.ForceTable] = true;
|
|
222
237
|
}
|
|
223
238
|
|
|
239
|
+
if (hideSearchBar) {
|
|
240
|
+
queryParams[Param.HideSearchBar] = true;
|
|
241
|
+
}
|
|
242
|
+
|
|
224
243
|
queryParams[Param.DataPanelV2Enabled] = dataPanelV2;
|
|
225
244
|
queryParams[Param.DataSourceMode] = this.getDataSourceMode();
|
|
226
245
|
|
|
@@ -253,7 +272,8 @@ export class SearchEmbed extends TsEmbed {
|
|
|
253
272
|
* @param answerId The GUID of a saved answer
|
|
254
273
|
* @param dataSources A list of data source GUIDs
|
|
255
274
|
*/
|
|
256
|
-
|
|
275
|
+
public getIFrameSrc(): string {
|
|
276
|
+
const { answerId } = this.viewConfig;
|
|
257
277
|
const answerPath = answerId ? `saved-answer/${answerId}` : 'answer';
|
|
258
278
|
const tsPostHashParams = this.getThoughtSpotPostUrlParams();
|
|
259
279
|
|
|
@@ -267,14 +287,14 @@ export class SearchEmbed extends TsEmbed {
|
|
|
267
287
|
super.render();
|
|
268
288
|
const { answerId } = this.viewConfig;
|
|
269
289
|
|
|
270
|
-
const src = this.getIFrameSrc(
|
|
290
|
+
const src = this.getIFrameSrc();
|
|
271
291
|
this.renderIFrame(src);
|
|
272
292
|
getAuthPromise().then(() => {
|
|
273
293
|
if (
|
|
274
294
|
checkReleaseVersionInBeta(
|
|
275
295
|
getReleaseVersion(),
|
|
276
296
|
getEmbedConfig().suppressSearchEmbedBetaWarning
|
|
277
|
-
|
|
297
|
+
|| getEmbedConfig().suppressErrorAlerts,
|
|
278
298
|
)
|
|
279
299
|
) {
|
|
280
300
|
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 {
|
|
@@ -309,7 +308,12 @@ export class TsEmbed {
|
|
|
309
308
|
private appInitCb = async (_: any, responder: any) => {
|
|
310
309
|
let authToken = '';
|
|
311
310
|
if (this.embedConfig.authType === AuthType.TrustedAuthTokenCookieless) {
|
|
312
|
-
|
|
311
|
+
try {
|
|
312
|
+
authToken = await getAuthenticationToken(this.embedConfig);
|
|
313
|
+
} catch (e) {
|
|
314
|
+
processAuthFailure(e, this.isPreRendered ? this.preRenderWrapper : this.el);
|
|
315
|
+
return;
|
|
316
|
+
}
|
|
313
317
|
}
|
|
314
318
|
this.isAppInitialized = true;
|
|
315
319
|
responder({
|
|
@@ -339,11 +343,16 @@ export class TsEmbed {
|
|
|
339
343
|
private updateAuthToken = async (_: any, responder: any) => {
|
|
340
344
|
const { autoLogin = false, authType } = this.embedConfig; // Set autoLogin default to false
|
|
341
345
|
if (authType === AuthType.TrustedAuthTokenCookieless) {
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
346
|
+
let authToken = '';
|
|
347
|
+
try {
|
|
348
|
+
authToken = await getAuthenticationToken(this.embedConfig);
|
|
349
|
+
responder({
|
|
350
|
+
type: EmbedEvent.AuthExpire,
|
|
351
|
+
data: { authToken },
|
|
352
|
+
});
|
|
353
|
+
} catch (e) {
|
|
354
|
+
processAuthFailure(e, this.isPreRendered ? this.preRenderWrapper : this.el);
|
|
355
|
+
}
|
|
347
356
|
} else if (autoLogin) {
|
|
348
357
|
handleAuth();
|
|
349
358
|
}
|
|
@@ -508,7 +517,11 @@ export class TsEmbed {
|
|
|
508
517
|
const queryParams = this.shouldEncodeUrlQueryParams
|
|
509
518
|
? `?base64UrlEncodedFlags=${getEncodedQueryParamsString(queryString)}`
|
|
510
519
|
: `?${queryString}`;
|
|
511
|
-
|
|
520
|
+
let host = this.thoughtSpotHost;
|
|
521
|
+
if (!isUndefined(this.embedConfig.enableReactShell)) {
|
|
522
|
+
host = this.embedConfig.enableReactShell as boolean ? '/v2' : '/v1';
|
|
523
|
+
}
|
|
524
|
+
const path = `${host}/${queryParams}#`;
|
|
512
525
|
return path;
|
|
513
526
|
}
|
|
514
527
|
|
|
@@ -527,6 +540,7 @@ export class TsEmbed {
|
|
|
527
540
|
|
|
528
541
|
iFrame.src = frameSrc;
|
|
529
542
|
iFrame.id = TS_EMBED_ID;
|
|
543
|
+
iFrame.setAttribute('data-ts-iframe', 'true');
|
|
530
544
|
|
|
531
545
|
// according to screenfull.js documentation
|
|
532
546
|
// allowFullscreen, webkitallowfullscreen and mozallowfullscreen must be
|
|
@@ -969,6 +983,10 @@ export class TsEmbed {
|
|
|
969
983
|
return this;
|
|
970
984
|
}
|
|
971
985
|
|
|
986
|
+
public getIframeSrc(): string {
|
|
987
|
+
return '';
|
|
988
|
+
}
|
|
989
|
+
|
|
972
990
|
protected handleRenderForPrerender() {
|
|
973
991
|
this.render();
|
|
974
992
|
}
|
|
@@ -1071,11 +1089,11 @@ export class TsEmbed {
|
|
|
1071
1089
|
) {
|
|
1072
1090
|
console.warn(
|
|
1073
1091
|
`${this.embedComponentType} was pre-rendered with `
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1092
|
+
+ `"${key}" as "${JSON.stringify(preRenderedObject.viewConfig[key])}" `
|
|
1093
|
+
+ `but a different value "${JSON.stringify(viewConfig[key])}" `
|
|
1094
|
+
+ 'was passed to the Embed component. '
|
|
1095
|
+
+ 'The new value provided is ignored, the value provided during '
|
|
1096
|
+
+ 'preRender is used.',
|
|
1079
1097
|
);
|
|
1080
1098
|
}
|
|
1081
1099
|
});
|
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', () => {
|