@thoughtspot/visual-embed-sdk 1.45.0 → 1.45.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.
- package/cjs/package.json +2 -2
- package/cjs/src/authToken.d.ts +1 -1
- package/cjs/src/authToken.d.ts.map +1 -1
- package/cjs/src/authToken.js +2 -2
- package/cjs/src/authToken.js.map +1 -1
- package/cjs/src/authToken.spec.js +71 -0
- package/cjs/src/authToken.spec.js.map +1 -1
- package/cjs/src/embed/hostEventClient/contracts.d.ts +3 -3
- package/cjs/src/embed/hostEventClient/contracts.d.ts.map +1 -1
- package/cjs/src/embed/hostEventClient/contracts.js.map +1 -1
- package/cjs/src/embed/hostEventClient/host-event-client.d.ts +8 -8
- package/cjs/src/embed/hostEventClient/host-event-client.d.ts.map +1 -1
- package/cjs/src/embed/hostEventClient/host-event-client.js +18 -18
- package/cjs/src/embed/hostEventClient/host-event-client.js.map +1 -1
- package/cjs/src/embed/hostEventClient/host-event-client.spec.js +7 -7
- package/cjs/src/embed/hostEventClient/host-event-client.spec.js.map +1 -1
- package/cjs/src/embed/liveboard.d.ts +2 -2
- package/cjs/src/embed/liveboard.d.ts.map +1 -1
- package/cjs/src/embed/liveboard.js +2 -2
- package/cjs/src/embed/liveboard.js.map +1 -1
- package/cjs/src/embed/liveboard.spec.js +1 -1
- package/cjs/src/embed/liveboard.spec.js.map +1 -1
- package/cjs/src/embed/ts-embed.d.ts +23 -2
- package/cjs/src/embed/ts-embed.d.ts.map +1 -1
- package/cjs/src/embed/ts-embed.js +64 -22
- package/cjs/src/embed/ts-embed.js.map +1 -1
- package/cjs/src/embed/ts-embed.spec.d.ts.map +1 -1
- package/cjs/src/embed/ts-embed.spec.js +138 -19
- package/cjs/src/embed/ts-embed.spec.js.map +1 -1
- package/cjs/src/index.d.ts +2 -2
- package/cjs/src/index.d.ts.map +1 -1
- package/cjs/src/index.js +3 -2
- package/cjs/src/index.js.map +1 -1
- package/cjs/src/types.d.ts +164 -2
- package/cjs/src/types.d.ts.map +1 -1
- package/cjs/src/types.js +43 -1
- package/cjs/src/types.js.map +1 -1
- package/cjs/src/utils/processTrigger.d.ts +3 -2
- package/cjs/src/utils/processTrigger.d.ts.map +1 -1
- package/cjs/src/utils/processTrigger.js +4 -2
- package/cjs/src/utils/processTrigger.js.map +1 -1
- package/cjs/src/utils.d.ts +5 -1
- package/cjs/src/utils.d.ts.map +1 -1
- package/cjs/src/utils.js +8 -1
- package/cjs/src/utils.js.map +1 -1
- package/dist/{index-Dk-SLdNk.js → index-BdkKLLo1.js} +1 -1
- package/dist/src/authToken.d.ts +1 -1
- package/dist/src/authToken.d.ts.map +1 -1
- package/dist/src/embed/hostEventClient/contracts.d.ts +3 -3
- package/dist/src/embed/hostEventClient/contracts.d.ts.map +1 -1
- package/dist/src/embed/hostEventClient/host-event-client.d.ts +8 -8
- package/dist/src/embed/hostEventClient/host-event-client.d.ts.map +1 -1
- package/dist/src/embed/liveboard.d.ts +2 -2
- package/dist/src/embed/liveboard.d.ts.map +1 -1
- package/dist/src/embed/ts-embed.d.ts +23 -2
- package/dist/src/embed/ts-embed.d.ts.map +1 -1
- package/dist/src/embed/ts-embed.spec.d.ts.map +1 -1
- package/dist/src/index.d.ts +2 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/types.d.ts +164 -2
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/utils/processTrigger.d.ts +3 -2
- package/dist/src/utils/processTrigger.d.ts.map +1 -1
- package/dist/src/utils.d.ts +5 -1
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/tsembed-react.es.js +140 -49
- package/dist/tsembed-react.js +139 -48
- package/dist/tsembed.es.js +155 -64
- package/dist/tsembed.js +29640 -29549
- package/dist/visual-embed-sdk-react-full.d.ts +196 -13
- package/dist/visual-embed-sdk-react.d.ts +196 -13
- package/dist/visual-embed-sdk.d.ts +196 -13
- package/lib/package.json +2 -2
- package/lib/src/authToken.d.ts +1 -1
- package/lib/src/authToken.d.ts.map +1 -1
- package/lib/src/authToken.js +2 -2
- package/lib/src/authToken.js.map +1 -1
- package/lib/src/authToken.spec.js +72 -1
- package/lib/src/authToken.spec.js.map +1 -1
- package/lib/src/embed/hostEventClient/contracts.d.ts +3 -3
- package/lib/src/embed/hostEventClient/contracts.d.ts.map +1 -1
- package/lib/src/embed/hostEventClient/contracts.js.map +1 -1
- package/lib/src/embed/hostEventClient/host-event-client.d.ts +8 -8
- package/lib/src/embed/hostEventClient/host-event-client.d.ts.map +1 -1
- package/lib/src/embed/hostEventClient/host-event-client.js +18 -18
- package/lib/src/embed/hostEventClient/host-event-client.js.map +1 -1
- package/lib/src/embed/hostEventClient/host-event-client.spec.js +7 -7
- package/lib/src/embed/hostEventClient/host-event-client.spec.js.map +1 -1
- package/lib/src/embed/liveboard.d.ts +2 -2
- package/lib/src/embed/liveboard.d.ts.map +1 -1
- package/lib/src/embed/liveboard.js +2 -2
- package/lib/src/embed/liveboard.js.map +1 -1
- package/lib/src/embed/liveboard.spec.js +1 -1
- package/lib/src/embed/liveboard.spec.js.map +1 -1
- package/lib/src/embed/ts-embed.d.ts +23 -2
- package/lib/src/embed/ts-embed.d.ts.map +1 -1
- package/lib/src/embed/ts-embed.js +64 -22
- package/lib/src/embed/ts-embed.js.map +1 -1
- package/lib/src/embed/ts-embed.spec.d.ts.map +1 -1
- package/lib/src/embed/ts-embed.spec.js +139 -20
- package/lib/src/embed/ts-embed.spec.js.map +1 -1
- package/lib/src/index.d.ts +2 -2
- package/lib/src/index.d.ts.map +1 -1
- package/lib/src/index.js +2 -2
- package/lib/src/index.js.map +1 -1
- package/lib/src/types.d.ts +164 -2
- package/lib/src/types.d.ts.map +1 -1
- package/lib/src/types.js +42 -0
- package/lib/src/types.js.map +1 -1
- package/lib/src/utils/processTrigger.d.ts +3 -2
- package/lib/src/utils/processTrigger.d.ts.map +1 -1
- package/lib/src/utils/processTrigger.js +4 -2
- package/lib/src/utils/processTrigger.js.map +1 -1
- package/lib/src/utils.d.ts +5 -1
- package/lib/src/utils.d.ts.map +1 -1
- package/lib/src/utils.js +6 -0
- package/lib/src/utils.js.map +1 -1
- package/package.json +2 -2
- package/src/authToken.spec.ts +91 -2
- package/src/authToken.ts +2 -2
- package/src/embed/hostEventClient/contracts.ts +4 -4
- package/src/embed/hostEventClient/host-event-client.spec.ts +7 -1
- package/src/embed/hostEventClient/host-event-client.ts +22 -11
- package/src/embed/liveboard.spec.ts +1 -1
- package/src/embed/liveboard.ts +5 -3
- package/src/embed/ts-embed.spec.ts +184 -8
- package/src/embed/ts-embed.ts +81 -24
- package/src/index.ts +2 -0
- package/src/types.ts +171 -0
- package/src/utils/processTrigger.ts +6 -3
- package/src/utils.ts +8 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { resetValueFromWindow } from '../utils';
|
|
2
2
|
import { ERROR_MESSAGE } from '../errors';
|
|
3
3
|
import { resetCachedAuthToken } from '../authToken';
|
|
4
|
-
import { AuthType, init, EmbedEvent, SearchEmbed, PinboardEmbed, AppEmbed, LiveboardEmbed, SageEmbed, AnswerService, } from '../index';
|
|
4
|
+
import { AuthType, init, EmbedEvent, SearchEmbed, PinboardEmbed, AppEmbed, LiveboardEmbed, SageEmbed, AnswerService, SpotterEmbed, } from '../index';
|
|
5
5
|
import { Action, HomeLeftNavItem, RuntimeFilterOp, HomepageModule, HostEvent, ContextMenuTriggerOptions, CustomActionTarget, CustomActionsPosition, ErrorDetailsTypes, EmbedErrorCodes, } from '../types';
|
|
6
6
|
import { executeAfterWait, getDocumentBody, getIFrameEl, getIFrameSrc, getRootEl, postMessageToParent, defaultParamsForPinboardEmbed, waitFor, expectUrlMatchesWithParams, expectUrlToHaveParamsWithValues, mockMessageChannel, createRootEleForEmbed, expectUrlMatch, fixedEncodeURI, } from '../test/test-utils';
|
|
7
7
|
import * as config from '../config';
|
|
@@ -20,6 +20,7 @@ import { UIPassthroughEvent } from './hostEventClient/contracts';
|
|
|
20
20
|
import * as sessionInfoService from '../utils/sessionInfoService';
|
|
21
21
|
import * as authToken from '../authToken';
|
|
22
22
|
import * as apiIntercept from '../api-intercept';
|
|
23
|
+
import * as processData from '../utils/processData';
|
|
23
24
|
jest.mock('../utils/processTrigger');
|
|
24
25
|
const mockProcessTrigger = processTrigger;
|
|
25
26
|
const mockHandleInterceptEvent = jest.spyOn(apiIntercept, 'handleInterceptEvent');
|
|
@@ -136,7 +137,7 @@ describe('Unit test case for ts embed', () => {
|
|
|
136
137
|
expect(mockProcessTrigger).toHaveBeenCalledWith(getIFrameEl(), HostEvent.UIPassthrough, 'http://tshost', {
|
|
137
138
|
parameters: payload,
|
|
138
139
|
type: UIPassthroughEvent.PinAnswerToLiveboard,
|
|
139
|
-
});
|
|
140
|
+
}, undefined);
|
|
140
141
|
});
|
|
141
142
|
});
|
|
142
143
|
test('Host event with empty param', async () => {
|
|
@@ -148,7 +149,7 @@ describe('Unit test case for ts embed', () => {
|
|
|
148
149
|
mockProcessTrigger.mockResolvedValue({ session: 'test' });
|
|
149
150
|
await executeAfterWait(async () => {
|
|
150
151
|
await liveboardEmbed.trigger(HostEvent.Save);
|
|
151
|
-
expect(mockProcessTrigger).toHaveBeenCalledWith(getIFrameEl(), HostEvent.Save, 'http://tshost', {});
|
|
152
|
+
expect(mockProcessTrigger).toHaveBeenCalledWith(getIFrameEl(), HostEvent.Save, 'http://tshost', {}, undefined);
|
|
152
153
|
});
|
|
153
154
|
});
|
|
154
155
|
test('Host event with falsy param', async () => {
|
|
@@ -160,7 +161,7 @@ describe('Unit test case for ts embed', () => {
|
|
|
160
161
|
mockProcessTrigger.mockResolvedValue({ session: 'test' });
|
|
161
162
|
await executeAfterWait(async () => {
|
|
162
163
|
await liveboardEmbed.trigger(HostEvent.Save, false);
|
|
163
|
-
expect(mockProcessTrigger).toHaveBeenCalledWith(getIFrameEl(), HostEvent.Save, 'http://tshost', false);
|
|
164
|
+
expect(mockProcessTrigger).toHaveBeenCalledWith(getIFrameEl(), HostEvent.Save, 'http://tshost', false, undefined);
|
|
164
165
|
});
|
|
165
166
|
});
|
|
166
167
|
test('should set proper height, width and min-height to iframe', async () => {
|
|
@@ -1116,7 +1117,7 @@ describe('Unit test case for ts embed', () => {
|
|
|
1116
1117
|
const { mockPreauthInfoFetch, iFrame, } = await setup(true);
|
|
1117
1118
|
expect(mockPreauthInfoFetch).toHaveBeenCalledTimes(1);
|
|
1118
1119
|
await executeAfterWait(() => {
|
|
1119
|
-
expect(mockProcessTrigger).toHaveBeenCalledWith(iFrame, HostEvent.InfoSuccess, 'http://tshost', expect.objectContaining({ info: expect.any(Object) }));
|
|
1120
|
+
expect(mockProcessTrigger).toHaveBeenCalledWith(iFrame, HostEvent.InfoSuccess, 'http://tshost', expect.objectContaining({ info: expect.any(Object) }), undefined);
|
|
1120
1121
|
});
|
|
1121
1122
|
});
|
|
1122
1123
|
test('should not call InfoSuccess Event if overrideOrgId is true', async () => {
|
|
@@ -1219,28 +1220,28 @@ describe('Unit test case for ts embed', () => {
|
|
|
1219
1220
|
const { mockGetPreauthInfo } = await setupPreauthTest('AppEmbed', undefined);
|
|
1220
1221
|
await executeAfterWait(() => {
|
|
1221
1222
|
expect(mockGetPreauthInfo).toHaveBeenCalledTimes(1);
|
|
1222
|
-
expect(mockProcessTrigger).toHaveBeenCalledWith(expect.any(Object), HostEvent.InfoSuccess, 'http://tshost', expect.objectContaining({ info: expect.any(Object) }));
|
|
1223
|
+
expect(mockProcessTrigger).toHaveBeenCalledWith(expect.any(Object), HostEvent.InfoSuccess, 'http://tshost', expect.objectContaining({ info: expect.any(Object) }), undefined);
|
|
1223
1224
|
});
|
|
1224
1225
|
});
|
|
1225
1226
|
test('should enable preauth cache for FullAppEmbed with showPrimaryNavbar = false', async () => {
|
|
1226
1227
|
const { mockGetPreauthInfo } = await setupPreauthTest('AppEmbed', false);
|
|
1227
1228
|
await executeAfterWait(() => {
|
|
1228
1229
|
expect(mockGetPreauthInfo).toHaveBeenCalledTimes(1);
|
|
1229
|
-
expect(mockProcessTrigger).toHaveBeenCalledWith(expect.any(Object), HostEvent.InfoSuccess, 'http://tshost', expect.objectContaining({ info: expect.any(Object) }));
|
|
1230
|
+
expect(mockProcessTrigger).toHaveBeenCalledWith(expect.any(Object), HostEvent.InfoSuccess, 'http://tshost', expect.objectContaining({ info: expect.any(Object) }), undefined);
|
|
1230
1231
|
});
|
|
1231
1232
|
});
|
|
1232
1233
|
test('should enable preauth cache for SearchEmbed regardless of showPrimaryNavbar', async () => {
|
|
1233
1234
|
const { mockGetPreauthInfo } = await setupPreauthTest('SearchEmbed', true);
|
|
1234
1235
|
await executeAfterWait(() => {
|
|
1235
1236
|
expect(mockGetPreauthInfo).toHaveBeenCalledTimes(1);
|
|
1236
|
-
expect(mockProcessTrigger).toHaveBeenCalledWith(expect.any(Object), HostEvent.InfoSuccess, 'http://tshost', expect.objectContaining({ info: expect.any(Object) }));
|
|
1237
|
+
expect(mockProcessTrigger).toHaveBeenCalledWith(expect.any(Object), HostEvent.InfoSuccess, 'http://tshost', expect.objectContaining({ info: expect.any(Object) }), undefined);
|
|
1237
1238
|
});
|
|
1238
1239
|
});
|
|
1239
1240
|
test('should enable preauth cache for SearchEmbed (verifies fix for embed type regression)', async () => {
|
|
1240
1241
|
const { mockGetPreauthInfo } = await setupPreauthTest('SearchEmbed', false);
|
|
1241
1242
|
await executeAfterWait(() => {
|
|
1242
1243
|
expect(mockGetPreauthInfo).toHaveBeenCalledTimes(1);
|
|
1243
|
-
expect(mockProcessTrigger).toHaveBeenCalledWith(expect.any(Object), HostEvent.InfoSuccess, 'http://tshost', expect.objectContaining({ info: expect.any(Object) }));
|
|
1244
|
+
expect(mockProcessTrigger).toHaveBeenCalledWith(expect.any(Object), HostEvent.InfoSuccess, 'http://tshost', expect.objectContaining({ info: expect.any(Object) }), undefined);
|
|
1244
1245
|
});
|
|
1245
1246
|
});
|
|
1246
1247
|
test('should disable preauth cache for FullAppEmbed with overrideOrgId (combined condition)', async () => {
|
|
@@ -2326,7 +2327,7 @@ describe('Unit test case for ts embed', () => {
|
|
|
2326
2327
|
jest.clearAllMocks();
|
|
2327
2328
|
document.body.innerHTML = getDocumentBody();
|
|
2328
2329
|
mockPort.postMessage.mockClear();
|
|
2329
|
-
jest.spyOn(authToken, 'getAuthenticationToken').mockResolvedValue('test-token');
|
|
2330
|
+
jest.spyOn(authToken, 'getAuthenticationToken').mockResolvedValue('mock-test-token-placeholder');
|
|
2330
2331
|
jest.spyOn(baseInstance, 'handleAuth').mockImplementation(() => Promise.resolve(true));
|
|
2331
2332
|
jest.spyOn(baseInstance, 'notifyAuthFailure').mockImplementation(() => { });
|
|
2332
2333
|
});
|
|
@@ -2350,7 +2351,7 @@ describe('Unit test case for ts embed', () => {
|
|
|
2350
2351
|
expect(baseInstance.handleAuth).toHaveBeenCalledTimes(1);
|
|
2351
2352
|
expect(mockPort.postMessage).toHaveBeenCalledWith({
|
|
2352
2353
|
type: EmbedEvent.AuthExpire,
|
|
2353
|
-
data: { authToken: 'test-token' },
|
|
2354
|
+
data: { authToken: 'mock-test-token-placeholder' },
|
|
2354
2355
|
});
|
|
2355
2356
|
});
|
|
2356
2357
|
});
|
|
@@ -2379,7 +2380,7 @@ describe('Unit test case for ts embed', () => {
|
|
|
2379
2380
|
expect(baseInstance.handleAuth).toHaveBeenCalledTimes(1);
|
|
2380
2381
|
expect(mockPort.postMessage).toHaveBeenCalledWith({
|
|
2381
2382
|
type: EmbedEvent.AuthExpire,
|
|
2382
|
-
data: { authToken: 'test-token' },
|
|
2383
|
+
data: { authToken: 'mock-test-token-placeholder' },
|
|
2383
2384
|
});
|
|
2384
2385
|
});
|
|
2385
2386
|
});
|
|
@@ -2423,6 +2424,83 @@ describe('Unit test case for ts embed', () => {
|
|
|
2423
2424
|
expect(baseInstance.notifyAuthFailure).toHaveBeenCalledWith(authInstance.AuthFailureType.EXPIRY);
|
|
2424
2425
|
});
|
|
2425
2426
|
});
|
|
2427
|
+
describe('AutoLogin behavior in tokenRefresh', () => {
|
|
2428
|
+
const mockPort = { postMessage: jest.fn() };
|
|
2429
|
+
const mockEmbedEventPayload = { type: EmbedEvent.RefreshAuthToken, data: {} };
|
|
2430
|
+
beforeEach(() => {
|
|
2431
|
+
jest.clearAllMocks();
|
|
2432
|
+
document.body.innerHTML = getDocumentBody();
|
|
2433
|
+
mockPort.postMessage.mockClear();
|
|
2434
|
+
jest.spyOn(authToken, 'getAuthenticationToken').mockResolvedValue('mock-test-token-placeholder');
|
|
2435
|
+
jest.spyOn(processData, 'processAuthFailure').mockImplementation(() => ({}));
|
|
2436
|
+
jest.spyOn(logger, 'error').mockImplementation(() => { });
|
|
2437
|
+
});
|
|
2438
|
+
const renderAndTriggerRefreshAuthToken = async () => {
|
|
2439
|
+
const spotterEmbed = new SpotterEmbed(getRootEl(), {
|
|
2440
|
+
worksheetId: 'test-worksheet',
|
|
2441
|
+
searchOptions: {
|
|
2442
|
+
searchQuery: 'test query',
|
|
2443
|
+
},
|
|
2444
|
+
});
|
|
2445
|
+
await spotterEmbed.render();
|
|
2446
|
+
await executeAfterWait(() => {
|
|
2447
|
+
const iframe = getIFrameEl();
|
|
2448
|
+
postMessageToParent(iframe.contentWindow, mockEmbedEventPayload, mockPort);
|
|
2449
|
+
});
|
|
2450
|
+
};
|
|
2451
|
+
test('Cookieless with autoLogin undefined should default to true and refresh token', async () => {
|
|
2452
|
+
init({
|
|
2453
|
+
thoughtSpotHost: 'tshost',
|
|
2454
|
+
authType: AuthType.TrustedAuthTokenCookieless,
|
|
2455
|
+
// autoLogin undefined
|
|
2456
|
+
});
|
|
2457
|
+
await renderAndTriggerRefreshAuthToken();
|
|
2458
|
+
await executeAfterWait(() => {
|
|
2459
|
+
expect(authToken.getAuthenticationToken).toHaveBeenCalledWith(expect.any(Object), true);
|
|
2460
|
+
});
|
|
2461
|
+
});
|
|
2462
|
+
test('Cookieless with autoLogin true should refresh token', async () => {
|
|
2463
|
+
init({
|
|
2464
|
+
thoughtSpotHost: 'tshost',
|
|
2465
|
+
authType: AuthType.TrustedAuthTokenCookieless,
|
|
2466
|
+
autoLogin: true,
|
|
2467
|
+
});
|
|
2468
|
+
await renderAndTriggerRefreshAuthToken();
|
|
2469
|
+
await executeAfterWait(() => {
|
|
2470
|
+
expect(authToken.getAuthenticationToken).toHaveBeenCalledWith(expect.any(Object), true);
|
|
2471
|
+
});
|
|
2472
|
+
});
|
|
2473
|
+
test('Cookieless with autoLogin false should not refresh token', async () => {
|
|
2474
|
+
init({
|
|
2475
|
+
thoughtSpotHost: 'tshost',
|
|
2476
|
+
authType: AuthType.TrustedAuthTokenCookieless,
|
|
2477
|
+
autoLogin: false,
|
|
2478
|
+
});
|
|
2479
|
+
await renderAndTriggerRefreshAuthToken();
|
|
2480
|
+
await executeAfterWait(() => {
|
|
2481
|
+
expect(authToken.getAuthenticationToken).not.toHaveBeenCalled();
|
|
2482
|
+
expect(mockPort.postMessage).not.toHaveBeenCalled();
|
|
2483
|
+
});
|
|
2484
|
+
});
|
|
2485
|
+
test('Should handle error when getAuthenticationToken fails', async () => {
|
|
2486
|
+
const error = new Error('Token fetch failed');
|
|
2487
|
+
jest.spyOn(authToken, 'getAuthenticationToken').mockRejectedValue(error);
|
|
2488
|
+
init({
|
|
2489
|
+
thoughtSpotHost: 'tshost',
|
|
2490
|
+
authType: AuthType.TrustedAuthTokenCookieless,
|
|
2491
|
+
autoLogin: true,
|
|
2492
|
+
});
|
|
2493
|
+
await renderAndTriggerRefreshAuthToken();
|
|
2494
|
+
await executeAfterWait(() => {
|
|
2495
|
+
expect(authToken.getAuthenticationToken).toHaveBeenCalledWith(expect.any(Object), true);
|
|
2496
|
+
// Check that logger.error was called with the token refresh error
|
|
2497
|
+
const errorCalls = logger.error.mock.calls.filter((call) => { var _a, _b; return ((_a = call[0]) === null || _a === void 0 ? void 0 : _a.includes(ERROR_MESSAGE.INVALID_TOKEN_ERROR)) && ((_b = call[0]) === null || _b === void 0 ? void 0 : _b.includes('Token fetch failed')); });
|
|
2498
|
+
expect(errorCalls.length).toBeGreaterThan(0);
|
|
2499
|
+
expect(processData.processAuthFailure).toHaveBeenCalledWith(error, expect.any(Element));
|
|
2500
|
+
expect(mockPort.postMessage).not.toHaveBeenCalled();
|
|
2501
|
+
});
|
|
2502
|
+
});
|
|
2503
|
+
});
|
|
2426
2504
|
describe('Fullscreen Change Handler', () => {
|
|
2427
2505
|
beforeEach(() => {
|
|
2428
2506
|
document.body.innerHTML = getDocumentBody();
|
|
@@ -2610,6 +2688,47 @@ describe('Unit test case for ts embed', () => {
|
|
|
2610
2688
|
searchEmbed['executeAfterEmbedContainerLoaded'](callback3);
|
|
2611
2689
|
expect(callback3).toHaveBeenCalledTimes(1);
|
|
2612
2690
|
});
|
|
2691
|
+
describe('getCurrentContext', () => {
|
|
2692
|
+
const mockContext = {
|
|
2693
|
+
stack: [
|
|
2694
|
+
{
|
|
2695
|
+
name: 'Liveboard',
|
|
2696
|
+
type: 'Liveboard',
|
|
2697
|
+
objectIds: { liveboardId: 'lb-123' },
|
|
2698
|
+
},
|
|
2699
|
+
],
|
|
2700
|
+
currentContext: {
|
|
2701
|
+
name: 'Liveboard',
|
|
2702
|
+
type: 'Liveboard',
|
|
2703
|
+
objectIds: { liveboardId: 'lb-123' },
|
|
2704
|
+
},
|
|
2705
|
+
};
|
|
2706
|
+
test('should return context when embed container is already loaded', async () => {
|
|
2707
|
+
const searchEmbed = new SearchEmbed(getRootEl(), defaultViewConfig);
|
|
2708
|
+
searchEmbed.isEmbedContainerLoaded = true;
|
|
2709
|
+
const triggerSpy = jest.spyOn(searchEmbed, 'trigger')
|
|
2710
|
+
.mockResolvedValue(mockContext);
|
|
2711
|
+
const context = await searchEmbed.getCurrentContext();
|
|
2712
|
+
expect(context).toEqual(mockContext);
|
|
2713
|
+
expect(triggerSpy).toHaveBeenCalledWith(HostEvent.GetPageContext, {});
|
|
2714
|
+
});
|
|
2715
|
+
test('should wait for embed container to load before returning context', async () => {
|
|
2716
|
+
const searchEmbed = new SearchEmbed(getRootEl(), defaultViewConfig);
|
|
2717
|
+
searchEmbed.isEmbedContainerLoaded = false;
|
|
2718
|
+
const triggerSpy = jest.spyOn(searchEmbed, 'trigger')
|
|
2719
|
+
.mockResolvedValue(mockContext);
|
|
2720
|
+
const contextPromise = searchEmbed.getCurrentContext();
|
|
2721
|
+
// Context should not be resolved yet
|
|
2722
|
+
await executeAfterWait(() => {
|
|
2723
|
+
expect(triggerSpy).not.toHaveBeenCalled();
|
|
2724
|
+
}, 10);
|
|
2725
|
+
// Simulate embed container becoming ready
|
|
2726
|
+
searchEmbed['executeEmbedContainerReadyCallbacks']();
|
|
2727
|
+
const context = await contextPromise;
|
|
2728
|
+
expect(context).toEqual(mockContext);
|
|
2729
|
+
expect(triggerSpy).toHaveBeenCalledWith(HostEvent.GetPageContext, {});
|
|
2730
|
+
});
|
|
2731
|
+
});
|
|
2613
2732
|
test('should register embed container event handlers during construction', () => {
|
|
2614
2733
|
const searchEmbed = new SearchEmbed(getRootEl(), defaultViewConfig);
|
|
2615
2734
|
// Check that the event handlers are registered
|
|
@@ -3324,7 +3443,7 @@ describe('Destroy error handling', () => {
|
|
|
3324
3443
|
appEmbed.destroy();
|
|
3325
3444
|
}).not.toThrow();
|
|
3326
3445
|
expect(logSpy).toHaveBeenCalledWith('Error destroying TS Embed', expect.any(Error));
|
|
3327
|
-
logSpy.
|
|
3446
|
+
logSpy.mockReset();
|
|
3328
3447
|
});
|
|
3329
3448
|
});
|
|
3330
3449
|
describe('Fullscreen change handler behavior', () => {
|
|
@@ -3358,7 +3477,7 @@ describe('Fullscreen change handler behavior', () => {
|
|
|
3358
3477
|
const event = new Event('fullscreenchange');
|
|
3359
3478
|
document.dispatchEvent(event);
|
|
3360
3479
|
await executeAfterWait(() => {
|
|
3361
|
-
expect(mockProcessTrigger).
|
|
3480
|
+
expect(mockProcessTrigger).toHaveBeenLastCalledWith(expect.any(Object), HostEvent.ExitPresentMode, expect.any(String), expect.any(Object), undefined);
|
|
3362
3481
|
});
|
|
3363
3482
|
});
|
|
3364
3483
|
test('should not trigger ExitPresentMode when entering fullscreen', async () => {
|
|
@@ -3425,9 +3544,9 @@ describe('ShowPreRender with UpdateEmbedParams', () => {
|
|
|
3425
3544
|
});
|
|
3426
3545
|
embed2.showPreRender();
|
|
3427
3546
|
await executeAfterWait(() => {
|
|
3428
|
-
expect(mockProcessTrigger).
|
|
3547
|
+
expect(mockProcessTrigger).toHaveBeenLastCalledWith(expect.any(Object), HostEvent.UpdateEmbedParams, expect.any(String), expect.objectContaining({
|
|
3429
3548
|
liveboardId: 'updated-lb',
|
|
3430
|
-
}));
|
|
3549
|
+
}), undefined);
|
|
3431
3550
|
});
|
|
3432
3551
|
});
|
|
3433
3552
|
test('should trigger UpdateEmbedParams with runtime filters and visible vizs', async () => {
|
|
@@ -3451,7 +3570,7 @@ describe('ShowPreRender with UpdateEmbedParams', () => {
|
|
|
3451
3570
|
});
|
|
3452
3571
|
embed2.showPreRender();
|
|
3453
3572
|
await executeAfterWait(() => {
|
|
3454
|
-
expect(mockProcessTrigger).
|
|
3573
|
+
expect(mockProcessTrigger).toHaveBeenLastCalledWith(expect.any(Object), HostEvent.UpdateEmbedParams, expect.any(String), expect.objectContaining({
|
|
3455
3574
|
liveboardId: 'original-lb',
|
|
3456
3575
|
visibleVizs: ['viz-1'],
|
|
3457
3576
|
runtimeFilters: [
|
|
@@ -3466,7 +3585,7 @@ describe('ShowPreRender with UpdateEmbedParams', () => {
|
|
|
3466
3585
|
values: ['North'],
|
|
3467
3586
|
},
|
|
3468
3587
|
],
|
|
3469
|
-
}));
|
|
3588
|
+
}), undefined);
|
|
3470
3589
|
});
|
|
3471
3590
|
});
|
|
3472
3591
|
test('should trigger UpdateEmbedParams with updated config', async () => {
|
|
@@ -3494,7 +3613,7 @@ describe('ShowPreRender with UpdateEmbedParams', () => {
|
|
|
3494
3613
|
});
|
|
3495
3614
|
embed2.showPreRender();
|
|
3496
3615
|
await executeAfterWait(() => {
|
|
3497
|
-
expect(mockProcessTrigger).
|
|
3616
|
+
expect(mockProcessTrigger).toHaveBeenLastCalledWith(expect.any(Object), HostEvent.UpdateEmbedParams, expect.any(String), expect.objectContaining({
|
|
3498
3617
|
liveboardId: 'original-lb',
|
|
3499
3618
|
visibleVizs: ['viz-1', 'viz-2'],
|
|
3500
3619
|
runtimeFilters: [
|
|
@@ -3504,7 +3623,7 @@ describe('ShowPreRender with UpdateEmbedParams', () => {
|
|
|
3504
3623
|
values: ['North'],
|
|
3505
3624
|
},
|
|
3506
3625
|
],
|
|
3507
|
-
}));
|
|
3626
|
+
}), undefined);
|
|
3508
3627
|
});
|
|
3509
3628
|
});
|
|
3510
3629
|
test('should handle error when getUpdateEmbedParamsObject fails during showPreRender', async () => {
|