@thoughtspot/visual-embed-sdk 1.20.0-alpha.2 → 1.20.0-prerender.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/dist/src/auth.d.ts +75 -5
- package/dist/src/auth.d.ts.map +1 -1
- package/dist/src/config.d.ts +1 -0
- package/dist/src/config.d.ts.map +1 -1
- package/dist/src/embed/app.d.ts +19 -7
- package/dist/src/embed/app.d.ts.map +1 -1
- package/dist/src/embed/base.d.ts +39 -19
- package/dist/src/embed/base.d.ts.map +1 -1
- package/dist/src/embed/liveboard.d.ts +19 -7
- package/dist/src/embed/liveboard.d.ts.map +1 -1
- package/dist/src/embed/search-bar.d.ts +7 -1
- package/dist/src/embed/search-bar.d.ts.map +1 -1
- package/dist/src/embed/search.d.ts +11 -3
- package/dist/src/embed/search.d.ts.map +1 -1
- package/dist/src/embed/ts-embed.d.ts +76 -5
- package/dist/src/embed/ts-embed.d.ts.map +1 -1
- package/dist/src/errors.d.ts.map +1 -1
- package/dist/src/index.d.ts +3 -3
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/mixpanel-service.d.ts +8 -0
- package/dist/src/mixpanel-service.d.ts.map +1 -1
- package/dist/src/react/index.d.ts.map +1 -1
- package/dist/src/react/util.d.ts +4 -0
- package/dist/src/react/util.d.ts.map +1 -1
- package/dist/src/test/test-utils.d.ts +11 -2
- package/dist/src/test/test-utils.d.ts.map +1 -1
- package/dist/src/types.d.ts +429 -97
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/utils/answerService.d.ts +7 -0
- package/dist/src/utils/answerService.d.ts.map +1 -1
- package/dist/src/utils/authService.d.ts +30 -0
- package/dist/src/utils/authService.d.ts.map +1 -1
- package/dist/src/utils/processData.d.ts +12 -0
- package/dist/src/utils/processData.d.ts.map +1 -1
- package/dist/src/utils/processTrigger.d.ts +7 -0
- package/dist/src/utils/processTrigger.d.ts.map +1 -1
- package/dist/src/utils.d.ts +12 -0
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/tsembed.es.js +818 -285
- package/dist/tsembed.js +791 -284
- package/lib/package.json +4 -3
- package/lib/src/auth.d.ts +75 -5
- package/lib/src/auth.d.ts.map +1 -1
- package/lib/src/auth.js +86 -26
- package/lib/src/auth.js.map +1 -1
- package/lib/src/auth.spec.js +14 -5
- package/lib/src/auth.spec.js.map +1 -1
- package/lib/src/config.d.ts +1 -0
- package/lib/src/config.d.ts.map +1 -1
- package/lib/src/config.js +5 -3
- package/lib/src/config.js.map +1 -1
- package/lib/src/config.spec.js.map +1 -1
- package/lib/src/embed/app.d.ts +19 -7
- package/lib/src/embed/app.d.ts.map +1 -1
- package/lib/src/embed/app.js +26 -16
- package/lib/src/embed/app.js.map +1 -1
- package/lib/src/embed/app.spec.js +12 -12
- package/lib/src/embed/app.spec.js.map +1 -1
- package/lib/src/embed/base.d.ts +39 -19
- package/lib/src/embed/base.d.ts.map +1 -1
- package/lib/src/embed/base.js +49 -15
- package/lib/src/embed/base.js.map +1 -1
- package/lib/src/embed/base.spec.js +2 -2
- package/lib/src/embed/base.spec.js.map +1 -1
- package/lib/src/embed/embed.spec.js +1 -1
- package/lib/src/embed/embed.spec.js.map +1 -1
- package/lib/src/embed/liveboard.d.ts +19 -7
- package/lib/src/embed/liveboard.d.ts.map +1 -1
- package/lib/src/embed/liveboard.js +50 -38
- package/lib/src/embed/liveboard.js.map +1 -1
- package/lib/src/embed/liveboard.spec.js +37 -30
- package/lib/src/embed/liveboard.spec.js.map +1 -1
- package/lib/src/embed/pinboard.spec.js +14 -26
- package/lib/src/embed/pinboard.spec.js.map +1 -1
- package/lib/src/embed/search-bar.d.ts +7 -1
- package/lib/src/embed/search-bar.d.ts.map +1 -1
- package/lib/src/embed/search-bar.js +6 -7
- package/lib/src/embed/search-bar.js.map +1 -1
- package/lib/src/embed/search.d.ts +11 -3
- package/lib/src/embed/search.d.ts.map +1 -1
- package/lib/src/embed/search.js +19 -15
- package/lib/src/embed/search.js.map +1 -1
- package/lib/src/embed/search.spec.js +16 -19
- package/lib/src/embed/search.spec.js.map +1 -1
- package/lib/src/embed/searchEmbed-basic-auth.spec.js +4 -0
- package/lib/src/embed/searchEmbed-basic-auth.spec.js.map +1 -1
- package/lib/src/embed/ts-embed.d.ts +76 -5
- package/lib/src/embed/ts-embed.d.ts.map +1 -1
- package/lib/src/embed/ts-embed.js +150 -72
- package/lib/src/embed/ts-embed.js.map +1 -1
- package/lib/src/embed/ts-embed.spec.js +23 -24
- package/lib/src/embed/ts-embed.spec.js.map +1 -1
- package/lib/src/errors.d.ts.map +1 -1
- package/lib/src/errors.js.map +1 -1
- package/lib/src/index.d.ts +3 -3
- package/lib/src/index.d.ts.map +1 -1
- package/lib/src/index.js +3 -3
- package/lib/src/index.js.map +1 -1
- package/lib/src/mixpanel-service.d.ts +8 -0
- package/lib/src/mixpanel-service.d.ts.map +1 -1
- package/lib/src/mixpanel-service.js +13 -1
- package/lib/src/mixpanel-service.js.map +1 -1
- package/lib/src/mixpanel-service.spec.js.map +1 -1
- package/lib/src/react/index.d.ts.map +1 -1
- package/lib/src/react/index.js +4 -6
- package/lib/src/react/index.js.map +1 -1
- package/lib/src/react/index.spec.js +3 -6
- package/lib/src/react/index.spec.js.map +1 -1
- package/lib/src/react/util.d.ts +4 -0
- package/lib/src/react/util.d.ts.map +1 -1
- package/lib/src/react/util.js +4 -0
- package/lib/src/react/util.js.map +1 -1
- package/lib/src/test/test-utils.d.ts +11 -2
- package/lib/src/test/test-utils.d.ts.map +1 -1
- package/lib/src/test/test-utils.js +36 -25
- package/lib/src/test/test-utils.js.map +1 -1
- package/lib/src/types.d.ts +429 -97
- package/lib/src/types.d.ts.map +1 -1
- package/lib/src/types.js +310 -72
- package/lib/src/types.js.map +1 -1
- package/lib/src/utils/answerService.d.ts +7 -0
- package/lib/src/utils/answerService.d.ts.map +1 -1
- package/lib/src/utils/answerService.js +7 -0
- package/lib/src/utils/answerService.js.map +1 -1
- package/lib/src/utils/answerService.spec.js.map +1 -1
- package/lib/src/utils/authService.d.ts +30 -0
- package/lib/src/utils/authService.d.ts.map +1 -1
- package/lib/src/utils/authService.js +39 -2
- package/lib/src/utils/authService.js.map +1 -1
- package/lib/src/utils/authService.spec.js.map +1 -1
- package/lib/src/utils/processData.d.ts +12 -0
- package/lib/src/utils/processData.d.ts.map +1 -1
- package/lib/src/utils/processData.js +33 -5
- package/lib/src/utils/processData.js.map +1 -1
- package/lib/src/utils/processData.spec.js.map +1 -1
- package/lib/src/utils/processTrigger.d.ts +7 -0
- package/lib/src/utils/processTrigger.d.ts.map +1 -1
- package/lib/src/utils/processTrigger.js +17 -3
- package/lib/src/utils/processTrigger.js.map +1 -1
- package/lib/src/utils/processTrigger.spec.js.map +1 -1
- package/lib/src/utils.d.ts +12 -0
- package/lib/src/utils.d.ts.map +1 -1
- package/lib/src/utils.js +24 -19
- package/lib/src/utils.js.map +1 -1
- package/lib/src/utils.spec.js.map +1 -1
- package/lib/src/visual-embed-sdk.d.ts +664 -141
- package/package.json +4 -3
- package/src/auth.spec.ts +68 -150
- package/src/auth.ts +141 -101
- package/src/config.spec.ts +2 -4
- package/src/config.ts +5 -3
- package/src/embed/app.spec.ts +25 -14
- package/src/embed/app.ts +49 -37
- package/src/embed/base.spec.ts +6 -12
- package/src/embed/base.ts +74 -57
- package/src/embed/embed.spec.ts +5 -6
- package/src/embed/liveboard.spec.ts +56 -37
- package/src/embed/liveboard.ts +67 -65
- package/src/embed/pinboard.spec.ts +26 -29
- package/src/embed/search-bar.tsx +14 -9
- package/src/embed/search.spec.ts +31 -21
- package/src/embed/search.ts +28 -22
- package/src/embed/searchEmbed-basic-auth.spec.ts +22 -28
- package/src/embed/ts-embed.spec.ts +70 -148
- package/src/embed/ts-embed.ts +180 -157
- package/src/errors.ts +3 -6
- package/src/index.ts +23 -7
- package/src/mixpanel-service.spec.ts +1 -3
- package/src/mixpanel-service.ts +13 -1
- package/src/react/index.spec.tsx +11 -20
- package/src/react/index.tsx +40 -71
- package/src/react/util.ts +8 -4
- package/src/test/test-utils.ts +43 -39
- package/src/types.ts +427 -97
- package/src/utils/answerService.spec.ts +3 -5
- package/src/utils/answerService.ts +21 -17
- package/src/utils/authService.spec.ts +26 -41
- package/src/utils/authService.ts +47 -21
- package/src/utils/processData.spec.ts +26 -59
- package/src/utils/processData.ts +36 -14
- package/src/utils/processTrigger.spec.ts +1 -6
- package/src/utils/processTrigger.ts +18 -9
- package/src/utils.spec.ts +8 -12
- package/src/utils.ts +25 -26
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
postMessageToParent,
|
|
20
20
|
defaultParamsForPinboardEmbed,
|
|
21
21
|
waitFor,
|
|
22
|
+
expectUrlMatchesWithParams,
|
|
22
23
|
} from '../test/test-utils';
|
|
23
24
|
import * as config from '../config';
|
|
24
25
|
import * as tsEmbedInstance from './ts-embed';
|
|
@@ -63,10 +64,7 @@ const customisationsView = {
|
|
|
63
64
|
};
|
|
64
65
|
|
|
65
66
|
describe('Unit test case for ts embed', () => {
|
|
66
|
-
const mockMixPanelEvent = jest.spyOn(
|
|
67
|
-
mixpanelInstance,
|
|
68
|
-
'uploadMixpanelEvent',
|
|
69
|
-
);
|
|
67
|
+
const mockMixPanelEvent = jest.spyOn(mixpanelInstance, 'uploadMixpanelEvent');
|
|
70
68
|
beforeEach(() => {
|
|
71
69
|
document.body.innerHTML = getDocumentBody();
|
|
72
70
|
});
|
|
@@ -97,11 +95,7 @@ describe('Unit test case for ts embed', () => {
|
|
|
97
95
|
};
|
|
98
96
|
await executeAfterWait(() => {
|
|
99
97
|
const iframe = getIFrameEl();
|
|
100
|
-
postMessageToParent(
|
|
101
|
-
iframe.contentWindow,
|
|
102
|
-
mockEmbedEventPayload,
|
|
103
|
-
mockPort,
|
|
104
|
-
);
|
|
98
|
+
postMessageToParent(iframe.contentWindow, mockEmbedEventPayload, mockPort);
|
|
105
99
|
});
|
|
106
100
|
expect(mockPort.postMessage).toHaveBeenCalledWith({
|
|
107
101
|
type: EmbedEvent.APP_INIT,
|
|
@@ -124,11 +118,7 @@ describe('Unit test case for ts embed', () => {
|
|
|
124
118
|
};
|
|
125
119
|
await executeAfterWait(() => {
|
|
126
120
|
const iframe = getIFrameEl();
|
|
127
|
-
postMessageToParent(
|
|
128
|
-
iframe.contentWindow,
|
|
129
|
-
mockEmbedEventPayload,
|
|
130
|
-
mockPort,
|
|
131
|
-
);
|
|
121
|
+
postMessageToParent(iframe.contentWindow, mockEmbedEventPayload, mockPort);
|
|
132
122
|
});
|
|
133
123
|
expect(mockPort.postMessage).toHaveBeenCalledWith({
|
|
134
124
|
type: EmbedEvent.APP_INIT,
|
|
@@ -159,10 +149,7 @@ describe('Unit test case for ts embed', () => {
|
|
|
159
149
|
|
|
160
150
|
executeAfterWait(() => {
|
|
161
151
|
const iframe = getIFrameEl();
|
|
162
|
-
postMessageToParent(
|
|
163
|
-
iframe.contentWindow,
|
|
164
|
-
mockEmbedEventPayload,
|
|
165
|
-
);
|
|
152
|
+
postMessageToParent(iframe.contentWindow, mockEmbedEventPayload);
|
|
166
153
|
});
|
|
167
154
|
});
|
|
168
155
|
|
|
@@ -182,13 +169,8 @@ describe('Unit test case for ts embed', () => {
|
|
|
182
169
|
executeAfterWait(() => {
|
|
183
170
|
const iframe = getIFrameEl();
|
|
184
171
|
iframe.contentWindow.postMessage = jest.fn();
|
|
185
|
-
postMessageToParent(
|
|
186
|
-
|
|
187
|
-
mockEmbedEventPayload,
|
|
188
|
-
);
|
|
189
|
-
expect(iframe.contentWindow.postMessage).toHaveBeenCalledTimes(
|
|
190
|
-
0,
|
|
191
|
-
);
|
|
172
|
+
postMessageToParent(iframe.contentWindow, mockEmbedEventPayload);
|
|
173
|
+
expect(iframe.contentWindow.postMessage).toHaveBeenCalledTimes(0);
|
|
192
174
|
});
|
|
193
175
|
});
|
|
194
176
|
|
|
@@ -208,10 +190,7 @@ describe('Unit test case for ts embed', () => {
|
|
|
208
190
|
|
|
209
191
|
executeAfterWait(() => {
|
|
210
192
|
const iframe = getIFrameEl();
|
|
211
|
-
postMessageToParent(
|
|
212
|
-
iframe.contentWindow,
|
|
213
|
-
mockEmbedEventPayload,
|
|
214
|
-
);
|
|
193
|
+
postMessageToParent(iframe.contentWindow, mockEmbedEventPayload);
|
|
215
194
|
}, 1000);
|
|
216
195
|
});
|
|
217
196
|
|
|
@@ -235,13 +214,8 @@ describe('Unit test case for ts embed', () => {
|
|
|
235
214
|
executeAfterWait(() => {
|
|
236
215
|
const iframe = getIFrameEl();
|
|
237
216
|
iframe.contentWindow.postMessage = jest.fn();
|
|
238
|
-
postMessageToParent(
|
|
239
|
-
|
|
240
|
-
mockEmbedEventPayload,
|
|
241
|
-
);
|
|
242
|
-
expect(iframe.contentWindow.postMessage).toHaveBeenCalledTimes(
|
|
243
|
-
0,
|
|
244
|
-
);
|
|
217
|
+
postMessageToParent(iframe.contentWindow, mockEmbedEventPayload);
|
|
218
|
+
expect(iframe.contentWindow.postMessage).toHaveBeenCalledTimes(0);
|
|
245
219
|
}, 1000);
|
|
246
220
|
});
|
|
247
221
|
});
|
|
@@ -269,11 +243,7 @@ describe('Unit test case for ts embed', () => {
|
|
|
269
243
|
};
|
|
270
244
|
await executeAfterWait(() => {
|
|
271
245
|
const iframe = getIFrameEl();
|
|
272
|
-
postMessageToParent(
|
|
273
|
-
iframe.contentWindow,
|
|
274
|
-
mockEmbedEventPayload,
|
|
275
|
-
mockPort,
|
|
276
|
-
);
|
|
246
|
+
postMessageToParent(iframe.contentWindow, mockEmbedEventPayload, mockPort);
|
|
277
247
|
});
|
|
278
248
|
await executeAfterWait(() => {
|
|
279
249
|
expect(mockPort.postMessage).toHaveBeenCalledWith({
|
|
@@ -309,11 +279,7 @@ describe('Unit test case for ts embed', () => {
|
|
|
309
279
|
};
|
|
310
280
|
await executeAfterWait(() => {
|
|
311
281
|
const iframe = getIFrameEl();
|
|
312
|
-
postMessageToParent(
|
|
313
|
-
iframe.contentWindow,
|
|
314
|
-
mockEmbedEventPayload,
|
|
315
|
-
mockPort,
|
|
316
|
-
);
|
|
282
|
+
postMessageToParent(iframe.contentWindow, mockEmbedEventPayload, mockPort);
|
|
317
283
|
});
|
|
318
284
|
await executeAfterWait(() => {
|
|
319
285
|
expect(baseInstance.notifyAuthFailure).toBeCalledWith(
|
|
@@ -349,10 +315,7 @@ describe('Unit test case for ts embed', () => {
|
|
|
349
315
|
searchEmbed.render();
|
|
350
316
|
await executeAfterWait(() => {
|
|
351
317
|
const iframe = getIFrameEl();
|
|
352
|
-
postMessageToParent(
|
|
353
|
-
iframe.contentWindow,
|
|
354
|
-
mockEmbedEventPayload,
|
|
355
|
-
);
|
|
318
|
+
postMessageToParent(iframe.contentWindow, mockEmbedEventPayload);
|
|
356
319
|
});
|
|
357
320
|
await executeAfterWait(() => {
|
|
358
321
|
expect(baseInstance.notifyAuthFailure).toBeCalledWith(
|
|
@@ -380,10 +343,7 @@ describe('Unit test case for ts embed', () => {
|
|
|
380
343
|
searchEmbed.render();
|
|
381
344
|
await executeAfterWait(() => {
|
|
382
345
|
const iframe = getIFrameEl();
|
|
383
|
-
postMessageToParent(
|
|
384
|
-
iframe.contentWindow,
|
|
385
|
-
mockEmbedEventPayload,
|
|
386
|
-
);
|
|
346
|
+
postMessageToParent(iframe.contentWindow, mockEmbedEventPayload);
|
|
387
347
|
});
|
|
388
348
|
await executeAfterWait(() => {
|
|
389
349
|
expect(baseInstance.notifyAuthFailure).toBeCalledWith(
|
|
@@ -416,9 +376,7 @@ describe('Unit test case for ts embed', () => {
|
|
|
416
376
|
},
|
|
417
377
|
);
|
|
418
378
|
const iFrame: any = document.createElement('div');
|
|
419
|
-
jest.spyOn(baseInstance, 'getAuthPromise').mockResolvedValueOnce(
|
|
420
|
-
isLoggedIn,
|
|
421
|
-
);
|
|
379
|
+
jest.spyOn(baseInstance, 'getAuthPromise').mockResolvedValueOnce(isLoggedIn);
|
|
422
380
|
const tsEmbed = new SearchEmbed(getRootEl(), {});
|
|
423
381
|
iFrame.contentWindow = null;
|
|
424
382
|
tsEmbed.on(EmbedEvent.CustomAction, jest.fn());
|
|
@@ -433,19 +391,13 @@ describe('Unit test case for ts embed', () => {
|
|
|
433
391
|
|
|
434
392
|
test('mixpanel should call with VISUAL_SDK_RENDER_COMPLETE', async () => {
|
|
435
393
|
await setup(true);
|
|
436
|
-
expect(mockMixPanelEvent).toBeCalledWith(
|
|
437
|
-
|
|
438
|
-
);
|
|
439
|
-
expect(mockMixPanelEvent).toBeCalledWith(
|
|
440
|
-
MIXPANEL_EVENT.VISUAL_SDK_RENDER_COMPLETE,
|
|
441
|
-
);
|
|
394
|
+
expect(mockMixPanelEvent).toBeCalledWith(MIXPANEL_EVENT.VISUAL_SDK_RENDER_START);
|
|
395
|
+
expect(mockMixPanelEvent).toBeCalledWith(MIXPANEL_EVENT.VISUAL_SDK_RENDER_COMPLETE);
|
|
442
396
|
});
|
|
443
397
|
|
|
444
398
|
test('Should remove prefetch iframe', async () => {
|
|
445
399
|
await setup(true);
|
|
446
|
-
const prefetchIframe = document.querySelectorAll<HTMLIFrameElement>(
|
|
447
|
-
'.prefetchIframe',
|
|
448
|
-
);
|
|
400
|
+
const prefetchIframe = document.querySelectorAll<HTMLIFrameElement>('.prefetchIframe');
|
|
449
401
|
expect(prefetchIframe.length).toBe(0);
|
|
450
402
|
});
|
|
451
403
|
|
|
@@ -467,9 +419,7 @@ describe('Unit test case for ts embed', () => {
|
|
|
467
419
|
});
|
|
468
420
|
|
|
469
421
|
beforeEach(() => {
|
|
470
|
-
jest.spyOn(baseInstance, 'getAuthPromise').mockRejectedValueOnce(
|
|
471
|
-
false,
|
|
472
|
-
);
|
|
422
|
+
jest.spyOn(baseInstance, 'getAuthPromise').mockRejectedValueOnce(false);
|
|
473
423
|
const tsEmbed = new SearchEmbed(getRootEl(), {});
|
|
474
424
|
const iFrame: any = document.createElement('div');
|
|
475
425
|
iFrame.contentWindow = null;
|
|
@@ -479,15 +429,10 @@ describe('Unit test case for ts embed', () => {
|
|
|
479
429
|
});
|
|
480
430
|
|
|
481
431
|
test('mixpanel should call with VISUAL_SDK_RENDER_FAILED', () => {
|
|
482
|
-
expect(mockMixPanelEvent).toBeCalledWith(
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
MIXPANEL_EVENT.VISUAL_SDK_RENDER_FAILED,
|
|
487
|
-
{
|
|
488
|
-
error: 'false',
|
|
489
|
-
},
|
|
490
|
-
);
|
|
432
|
+
expect(mockMixPanelEvent).toBeCalledWith(MIXPANEL_EVENT.VISUAL_SDK_RENDER_START);
|
|
433
|
+
expect(mockMixPanelEvent).toBeCalledWith(MIXPANEL_EVENT.VISUAL_SDK_RENDER_FAILED, {
|
|
434
|
+
error: 'false',
|
|
435
|
+
});
|
|
491
436
|
});
|
|
492
437
|
});
|
|
493
438
|
|
|
@@ -516,6 +461,11 @@ describe('Unit test case for ts embed', () => {
|
|
|
516
461
|
expect(pinboardEmbed['isError']).toBe(false);
|
|
517
462
|
});
|
|
518
463
|
|
|
464
|
+
/**
|
|
465
|
+
*
|
|
466
|
+
* @param hiddenActions
|
|
467
|
+
* @param visibleActions
|
|
468
|
+
*/
|
|
519
469
|
async function testActionsForLiveboards(
|
|
520
470
|
hiddenActions: Array<Action>,
|
|
521
471
|
visibleActions: Array<Action>,
|
|
@@ -534,10 +484,7 @@ describe('Unit test case for ts embed', () => {
|
|
|
534
484
|
);
|
|
535
485
|
}
|
|
536
486
|
test('should throw error when there are both visible and hidden action arrays', async () => {
|
|
537
|
-
await testActionsForLiveboards(
|
|
538
|
-
[Action.DownloadAsCsv],
|
|
539
|
-
[Action.DownloadAsCsv],
|
|
540
|
-
);
|
|
487
|
+
await testActionsForLiveboards([Action.DownloadAsCsv], [Action.DownloadAsCsv]);
|
|
541
488
|
});
|
|
542
489
|
test('should throw error when there are both visible and hidden actions arrays as empty', async () => {
|
|
543
490
|
await testActionsForLiveboards([], []);
|
|
@@ -568,9 +515,7 @@ describe('Unit test case for ts embed', () => {
|
|
|
568
515
|
|
|
569
516
|
describe('when thoughtSpotHost is empty', () => {
|
|
570
517
|
beforeAll(() => {
|
|
571
|
-
jest.spyOn(config, 'getThoughtSpotHost').mockImplementation(
|
|
572
|
-
() => '',
|
|
573
|
-
);
|
|
518
|
+
jest.spyOn(config, 'getThoughtSpotHost').mockImplementation(() => '');
|
|
574
519
|
init({
|
|
575
520
|
thoughtSpotHost: '',
|
|
576
521
|
authType: AuthType.None,
|
|
@@ -591,10 +536,7 @@ describe('Unit test case for ts embed', () => {
|
|
|
591
536
|
describe('V1Embed ', () => {
|
|
592
537
|
test('when isRendered is true than isError will be true', () => {
|
|
593
538
|
spyOn(console, 'error');
|
|
594
|
-
const viEmbedIns = new tsEmbedInstance.V1Embed(
|
|
595
|
-
getRootEl(),
|
|
596
|
-
defaultViewConfig,
|
|
597
|
-
);
|
|
539
|
+
const viEmbedIns = new tsEmbedInstance.V1Embed(getRootEl(), defaultViewConfig);
|
|
598
540
|
expect(viEmbedIns['isError']).toBe(false);
|
|
599
541
|
viEmbedIns.render();
|
|
600
542
|
viEmbedIns.on(EmbedEvent.CustomAction, jest.fn()).render();
|
|
@@ -609,9 +551,7 @@ describe('Unit test case for ts embed', () => {
|
|
|
609
551
|
const path = 'viz/e0836cad-4fdf-42d4-bd97-567a6b2a6058';
|
|
610
552
|
|
|
611
553
|
beforeEach(() => {
|
|
612
|
-
jest.spyOn(config, 'getThoughtSpotHost').mockImplementation(
|
|
613
|
-
() => 'http://tshost',
|
|
614
|
-
);
|
|
554
|
+
jest.spyOn(config, 'getThoughtSpotHost').mockImplementation(() => 'http://tshost');
|
|
615
555
|
});
|
|
616
556
|
|
|
617
557
|
test('when app is PinboardEmbed after navigateToPage function call, new path should be set to iframe', async () => {
|
|
@@ -620,7 +560,8 @@ describe('Unit test case for ts embed', () => {
|
|
|
620
560
|
});
|
|
621
561
|
await pinboardEmbed.render();
|
|
622
562
|
// pinboardEmbed.navigateToPage(path);
|
|
623
|
-
|
|
563
|
+
expectUrlMatchesWithParams(
|
|
564
|
+
getIFrameSrc(),
|
|
624
565
|
`http://${thoughtSpotHost}/?embedApp=true&${defaultParamsForPinboardEmbed}&isLiveboardEmbed=true${defaultParamsPost}#/embed/${path}`,
|
|
625
566
|
);
|
|
626
567
|
});
|
|
@@ -633,8 +574,9 @@ describe('Unit test case for ts embed', () => {
|
|
|
633
574
|
},
|
|
634
575
|
});
|
|
635
576
|
await appEmbed.render();
|
|
636
|
-
appEmbed.navigateToPage(path);
|
|
637
|
-
|
|
577
|
+
appEmbed.navigateToPage(path, false);
|
|
578
|
+
expectUrlMatchesWithParams(
|
|
579
|
+
getIFrameSrc(),
|
|
638
580
|
`http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&${defaultParamsForPinboardEmbed}${defaultParamsPost}#/${path}`,
|
|
639
581
|
);
|
|
640
582
|
});
|
|
@@ -647,7 +589,7 @@ describe('Unit test case for ts embed', () => {
|
|
|
647
589
|
height: '100%',
|
|
648
590
|
},
|
|
649
591
|
});
|
|
650
|
-
appEmbed.navigateToPage(path);
|
|
592
|
+
appEmbed.navigateToPage(path, false);
|
|
651
593
|
await appEmbed.render();
|
|
652
594
|
expect(console.log).toHaveBeenCalledWith(
|
|
653
595
|
'Please call render before invoking this method',
|
|
@@ -658,9 +600,7 @@ describe('Unit test case for ts embed', () => {
|
|
|
658
600
|
const path = 'pinboard/e0836cad-4fdf-42d4-bd97-567a6b2a6058';
|
|
659
601
|
|
|
660
602
|
beforeEach(() => {
|
|
661
|
-
jest.spyOn(config, 'getThoughtSpotHost').mockImplementation(
|
|
662
|
-
() => 'http://tshost',
|
|
663
|
-
);
|
|
603
|
+
jest.spyOn(config, 'getThoughtSpotHost').mockImplementation(() => 'http://tshost');
|
|
664
604
|
});
|
|
665
605
|
|
|
666
606
|
test('when app is AppEmbed after navigateToPage function call, new path should be set to iframe', async () => {
|
|
@@ -671,8 +611,9 @@ describe('Unit test case for ts embed', () => {
|
|
|
671
611
|
},
|
|
672
612
|
});
|
|
673
613
|
await appEmbed.render();
|
|
674
|
-
appEmbed.navigateToPage(path);
|
|
675
|
-
|
|
614
|
+
appEmbed.navigateToPage(path, false);
|
|
615
|
+
expectUrlMatchesWithParams(
|
|
616
|
+
getIFrameSrc(),
|
|
676
617
|
`http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&${defaultParamsForPinboardEmbed}${defaultParamsPost}#/${path}`,
|
|
677
618
|
);
|
|
678
619
|
});
|
|
@@ -700,9 +641,7 @@ describe('Unit test case for ts embed', () => {
|
|
|
700
641
|
},
|
|
701
642
|
});
|
|
702
643
|
tsEmbed.render();
|
|
703
|
-
waitFor(() => {
|
|
704
|
-
return !!getIFrameEl();
|
|
705
|
-
}).then(() => {
|
|
644
|
+
waitFor(() => !!getIFrameEl()).then(() => {
|
|
706
645
|
expect(getIFrameSrc()).toContain('?base64UrlEncodedFlags');
|
|
707
646
|
});
|
|
708
647
|
});
|
|
@@ -714,18 +653,14 @@ describe('Unit test case for ts embed', () => {
|
|
|
714
653
|
},
|
|
715
654
|
});
|
|
716
655
|
appEmbed.render();
|
|
717
|
-
waitFor(() => {
|
|
718
|
-
return !!getIFrameEl();
|
|
719
|
-
}).then(() => {
|
|
656
|
+
waitFor(() => !!getIFrameEl()).then(() => {
|
|
720
657
|
expect(getIFrameSrc()).toContain('?base64UrlEncodedFlags');
|
|
721
658
|
});
|
|
722
659
|
});
|
|
723
660
|
});
|
|
724
661
|
describe('Iframe flags', () => {
|
|
725
662
|
beforeEach(() => {
|
|
726
|
-
jest.spyOn(config, 'getThoughtSpotHost').mockImplementation(
|
|
727
|
-
() => 'http://tshost',
|
|
728
|
-
);
|
|
663
|
+
jest.spyOn(config, 'getThoughtSpotHost').mockImplementation(() => 'http://tshost');
|
|
729
664
|
});
|
|
730
665
|
|
|
731
666
|
test('Set Frame params to the iframe as attributes', async () => {
|
|
@@ -754,9 +689,10 @@ describe('Unit test case for ts embed', () => {
|
|
|
754
689
|
},
|
|
755
690
|
});
|
|
756
691
|
await appEmbed.render();
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
692
|
+
expectUrlMatchesWithParams(
|
|
693
|
+
getIFrameSrc(),
|
|
694
|
+
`http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&${defaultParamsForPinboardEmbed}`
|
|
695
|
+
+ `&foo=bar&baz=1&bool=true${defaultParamsPost}#/home`,
|
|
760
696
|
);
|
|
761
697
|
});
|
|
762
698
|
|
|
@@ -769,9 +705,10 @@ describe('Unit test case for ts embed', () => {
|
|
|
769
705
|
showAlerts: true,
|
|
770
706
|
});
|
|
771
707
|
await appEmbed.render();
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
708
|
+
expectUrlMatchesWithParams(
|
|
709
|
+
getIFrameSrc(),
|
|
710
|
+
`http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&${defaultParamsForPinboardEmbed}`
|
|
711
|
+
+ `&showAlerts=true${defaultParamsPost}#/home`,
|
|
775
712
|
);
|
|
776
713
|
});
|
|
777
714
|
it('Sets the locale param', async () => {
|
|
@@ -783,9 +720,10 @@ describe('Unit test case for ts embed', () => {
|
|
|
783
720
|
locale: 'ja-JP',
|
|
784
721
|
});
|
|
785
722
|
await appEmbed.render();
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
723
|
+
expectUrlMatchesWithParams(
|
|
724
|
+
getIFrameSrc(),
|
|
725
|
+
`http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&${defaultParamsForPinboardEmbed}`
|
|
726
|
+
+ `&locale=ja-JP${defaultParamsPost}#/home`,
|
|
789
727
|
);
|
|
790
728
|
});
|
|
791
729
|
it('Sets the iconSprite url', async () => {
|
|
@@ -799,9 +737,10 @@ describe('Unit test case for ts embed', () => {
|
|
|
799
737
|
},
|
|
800
738
|
});
|
|
801
739
|
await appEmbed.render();
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
740
|
+
expectUrlMatchesWithParams(
|
|
741
|
+
getIFrameSrc(),
|
|
742
|
+
`http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&${defaultParamsForPinboardEmbed}`
|
|
743
|
+
+ `&iconSprite=iconSprite.com${defaultParamsPost}#/home`,
|
|
805
744
|
);
|
|
806
745
|
});
|
|
807
746
|
it('inserts as sibling of root node if configured', async () => {
|
|
@@ -842,9 +781,7 @@ describe('Unit test case for ts embed', () => {
|
|
|
842
781
|
},
|
|
843
782
|
});
|
|
844
783
|
appEmbed.render();
|
|
845
|
-
waitFor(() => {
|
|
846
|
-
return !!getIFrameEl();
|
|
847
|
-
}).then(() => {
|
|
784
|
+
waitFor(() => !!getIFrameEl()).then(() => {
|
|
848
785
|
expect(getIFrameSrc()).toContain('authType=EmbeddedSSO');
|
|
849
786
|
expect(getIFrameSrc()).toContain('forceSAMLAutoRedirect=true');
|
|
850
787
|
done();
|
|
@@ -881,9 +818,7 @@ describe('Unit test case for ts embed', () => {
|
|
|
881
818
|
});
|
|
882
819
|
|
|
883
820
|
it("Should remove the error message on destroy if it's present", async () => {
|
|
884
|
-
jest.spyOn(baseInstance, 'getAuthPromise').mockResolvedValueOnce(
|
|
885
|
-
false,
|
|
886
|
-
);
|
|
821
|
+
jest.spyOn(baseInstance, 'getAuthPromise').mockResolvedValueOnce(false);
|
|
887
822
|
const appEmbed = new AppEmbed(getRootEl(), {
|
|
888
823
|
frameParams: {
|
|
889
824
|
width: '100%',
|
|
@@ -892,9 +827,7 @@ describe('Unit test case for ts embed', () => {
|
|
|
892
827
|
insertAsSibling: true,
|
|
893
828
|
});
|
|
894
829
|
await appEmbed.render();
|
|
895
|
-
expect(getRootEl().nextElementSibling.innerHTML).toContain(
|
|
896
|
-
'Not logged in',
|
|
897
|
-
);
|
|
830
|
+
expect(getRootEl().nextElementSibling.innerHTML).toContain('Not logged in');
|
|
898
831
|
appEmbed.destroy();
|
|
899
832
|
expect(getRootEl().nextElementSibling.innerHTML).toBe('');
|
|
900
833
|
});
|
|
@@ -912,9 +845,7 @@ describe('Unit test case for ts embed', () => {
|
|
|
912
845
|
});
|
|
913
846
|
|
|
914
847
|
beforeEach(() => {
|
|
915
|
-
jest.spyOn(config, 'getThoughtSpotHost').mockImplementation(
|
|
916
|
-
() => 'http://tshost',
|
|
917
|
-
);
|
|
848
|
+
jest.spyOn(config, 'getThoughtSpotHost').mockImplementation(() => 'http://tshost');
|
|
918
849
|
});
|
|
919
850
|
|
|
920
851
|
afterAll((): void => {
|
|
@@ -922,29 +853,20 @@ describe('Unit test case for ts embed', () => {
|
|
|
922
853
|
});
|
|
923
854
|
|
|
924
855
|
it('get url params for TS', () => {
|
|
925
|
-
const tsEmbed = new tsEmbedInstance.TsEmbed(
|
|
926
|
-
|
|
927
|
-
defaultViewConfig,
|
|
928
|
-
);
|
|
929
|
-
const urlHash =
|
|
930
|
-
'#/analyze?ts-app=thoughtspot&ts-id=123&title=embed-sdk';
|
|
856
|
+
const tsEmbed = new tsEmbedInstance.TsEmbed(getRootEl(), defaultViewConfig);
|
|
857
|
+
const urlHash = '#/analyze?ts-app=thoughtspot&ts-id=123&title=embed-sdk';
|
|
931
858
|
window.location.hash = urlHash;
|
|
932
859
|
const postHashParams = '?ts-app=thoughtspot&ts-id=123';
|
|
933
860
|
expect(tsEmbed.getThoughtSpotPostUrlParams()).toBe(postHashParams);
|
|
934
861
|
});
|
|
935
862
|
|
|
936
863
|
it('validate query params and postHash params for TS', () => {
|
|
937
|
-
const tsEmbed = new tsEmbedInstance.TsEmbed(
|
|
938
|
-
|
|
939
|
-
defaultViewConfig,
|
|
940
|
-
);
|
|
941
|
-
const urlHash =
|
|
942
|
-
'#/analyze?ts-app=thoughtspot&ts-id=123&title=embed-sdk';
|
|
864
|
+
const tsEmbed = new tsEmbedInstance.TsEmbed(getRootEl(), defaultViewConfig);
|
|
865
|
+
const urlHash = '#/analyze?ts-app=thoughtspot&ts-id=123&title=embed-sdk';
|
|
943
866
|
window.location.hash = urlHash;
|
|
944
867
|
const urlSearch = '?ts-type=subscribe&search-title=abc';
|
|
945
868
|
window.location.search = urlSearch;
|
|
946
|
-
const postHashParams =
|
|
947
|
-
'?ts-type=subscribe&ts-app=thoughtspot&ts-id=123';
|
|
869
|
+
const postHashParams = '?ts-type=subscribe&ts-app=thoughtspot&ts-id=123';
|
|
948
870
|
expect(tsEmbed.getThoughtSpotPostUrlParams()).toBe(postHashParams);
|
|
949
871
|
});
|
|
950
872
|
});
|