@thoughtspot/visual-embed-sdk 1.44.1 → 1.44.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 +6 -5
- package/cjs/src/api-intercept.d.ts.map +1 -1
- package/cjs/src/api-intercept.js +8 -3
- package/cjs/src/api-intercept.js.map +1 -1
- package/cjs/src/api-intercept.spec.js +19 -3
- package/cjs/src/api-intercept.spec.js.map +1 -1
- package/cjs/src/auth.spec.js +43 -42
- package/cjs/src/auth.spec.js.map +1 -1
- package/cjs/src/authToken.spec.js +3 -3
- package/cjs/src/authToken.spec.js.map +1 -1
- package/cjs/src/embed/app.d.ts +17 -0
- package/cjs/src/embed/app.d.ts.map +1 -1
- package/cjs/src/embed/app.js +9 -5
- package/cjs/src/embed/app.js.map +1 -1
- package/cjs/src/embed/app.spec.js +96 -6
- package/cjs/src/embed/app.spec.js.map +1 -1
- package/cjs/src/embed/base.spec.js +11 -15
- package/cjs/src/embed/base.spec.js.map +1 -1
- package/cjs/src/embed/bodyless-conversation.spec.js +2 -2
- package/cjs/src/embed/bodyless-conversation.spec.js.map +1 -1
- package/cjs/src/embed/conversation.d.ts.map +1 -1
- package/cjs/src/embed/conversation.js +6 -1
- package/cjs/src/embed/conversation.js.map +1 -1
- package/cjs/src/embed/conversation.spec.js +8 -3
- package/cjs/src/embed/conversation.spec.js.map +1 -1
- package/cjs/src/embed/embed.spec.js +101 -2
- package/cjs/src/embed/embed.spec.js.map +1 -1
- package/cjs/src/embed/events.spec.js +2 -2
- package/cjs/src/embed/events.spec.js.map +1 -1
- package/cjs/src/embed/hostEventClient/host-event-client.spec.js +1 -1
- package/cjs/src/embed/hostEventClient/host-event-client.spec.js.map +1 -1
- package/cjs/src/embed/liveboard.d.ts +18 -0
- package/cjs/src/embed/liveboard.d.ts.map +1 -1
- package/cjs/src/embed/liveboard.js +13 -6
- package/cjs/src/embed/liveboard.js.map +1 -1
- package/cjs/src/embed/liveboard.spec.js +114 -26
- package/cjs/src/embed/liveboard.spec.js.map +1 -1
- package/cjs/src/embed/pinboard.spec.js +1 -1
- package/cjs/src/embed/pinboard.spec.js.map +1 -1
- package/cjs/src/embed/sage.spec.js +2 -2
- package/cjs/src/embed/sage.spec.js.map +1 -1
- package/cjs/src/embed/search.spec.js +118 -2
- package/cjs/src/embed/search.spec.js.map +1 -1
- package/cjs/src/embed/ts-embed-trigger.spec.js +2 -3
- package/cjs/src/embed/ts-embed-trigger.spec.js.map +1 -1
- package/cjs/src/embed/ts-embed.d.ts +3 -2
- package/cjs/src/embed/ts-embed.d.ts.map +1 -1
- package/cjs/src/embed/ts-embed.js +51 -17
- 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 +335 -71
- package/cjs/src/embed/ts-embed.spec.js.map +1 -1
- package/cjs/src/errors.d.ts +7 -0
- package/cjs/src/errors.d.ts.map +1 -1
- package/cjs/src/errors.js +7 -0
- package/cjs/src/errors.js.map +1 -1
- package/cjs/src/mixpanel-service.spec.js +1 -1
- package/cjs/src/mixpanel-service.spec.js.map +1 -1
- package/cjs/src/react/index.spec.js +3 -4
- package/cjs/src/react/index.spec.js.map +1 -1
- package/cjs/src/test/test-utils.js +1 -1
- package/cjs/src/test/test-utils.js.map +1 -1
- package/cjs/src/types.d.ts +194 -1
- package/cjs/src/types.d.ts.map +1 -1
- package/cjs/src/types.js +94 -2
- package/cjs/src/types.js.map +1 -1
- package/cjs/src/utils/authService/authService.spec.js +8 -8
- package/cjs/src/utils/authService/authService.spec.js.map +1 -1
- package/cjs/src/utils/authService/tokenizedAuthService.spec.js.map +1 -1
- package/cjs/src/utils/graphql/answerService/answerService.spec.js +1 -1
- package/cjs/src/utils/graphql/answerService/answerService.spec.js.map +1 -1
- package/cjs/src/utils/graphql/graphql-request.spec.js +1 -1
- package/cjs/src/utils/graphql/graphql-request.spec.js.map +1 -1
- package/cjs/src/utils/graphql/sourceService.spec.js +1 -1
- package/cjs/src/utils/graphql/sourceService.spec.js.map +1 -1
- package/cjs/src/utils/logger.spec.d.ts +5 -20
- package/cjs/src/utils/logger.spec.d.ts.map +1 -1
- package/cjs/src/utils/processData.spec.js +17 -17
- package/cjs/src/utils/processData.spec.js.map +1 -1
- package/cjs/src/utils/processTrigger.spec.js +8 -8
- package/cjs/src/utils/processTrigger.spec.js.map +1 -1
- package/cjs/src/utils.d.ts +6 -0
- package/cjs/src/utils.d.ts.map +1 -1
- package/cjs/src/utils.js +32 -1
- package/cjs/src/utils.js.map +1 -1
- package/cjs/src/utils.spec.js +19 -10
- package/cjs/src/utils.spec.js.map +1 -1
- package/dist/{index-BE9gGzRX.js → index-CSFjfTVk.js} +1 -1
- package/dist/src/api-intercept.d.ts.map +1 -1
- package/dist/src/embed/app.d.ts +17 -0
- package/dist/src/embed/app.d.ts.map +1 -1
- package/dist/src/embed/conversation.d.ts.map +1 -1
- package/dist/src/embed/liveboard.d.ts +18 -0
- package/dist/src/embed/liveboard.d.ts.map +1 -1
- package/dist/src/embed/ts-embed.d.ts +3 -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/errors.d.ts +7 -0
- package/dist/src/errors.d.ts.map +1 -1
- package/dist/src/types.d.ts +194 -1
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/utils/logger.spec.d.ts +5 -20
- package/dist/src/utils/logger.spec.d.ts.map +1 -1
- package/dist/src/utils.d.ts +6 -0
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/tsembed-react.es.js +219 -36
- package/dist/tsembed-react.js +218 -35
- package/dist/tsembed.es.js +219 -36
- package/dist/tsembed.js +218 -35
- package/dist/visual-embed-sdk-react-full.d.ts +184 -2
- package/dist/visual-embed-sdk-react.d.ts +184 -2
- package/dist/visual-embed-sdk.d.ts +184 -2
- package/lib/package.json +6 -5
- package/lib/src/api-intercept.d.ts.map +1 -1
- package/lib/src/api-intercept.js +9 -4
- package/lib/src/api-intercept.js.map +1 -1
- package/lib/src/api-intercept.spec.js +20 -4
- package/lib/src/api-intercept.spec.js.map +1 -1
- package/lib/src/auth.spec.js +43 -42
- package/lib/src/auth.spec.js.map +1 -1
- package/lib/src/authToken.spec.js +3 -3
- package/lib/src/authToken.spec.js.map +1 -1
- package/lib/src/embed/app.d.ts +17 -0
- package/lib/src/embed/app.d.ts.map +1 -1
- package/lib/src/embed/app.js +10 -6
- package/lib/src/embed/app.js.map +1 -1
- package/lib/src/embed/app.spec.js +96 -6
- package/lib/src/embed/app.spec.js.map +1 -1
- package/lib/src/embed/base.spec.js +11 -15
- package/lib/src/embed/base.spec.js.map +1 -1
- package/lib/src/embed/bodyless-conversation.spec.js +2 -2
- package/lib/src/embed/bodyless-conversation.spec.js.map +1 -1
- package/lib/src/embed/conversation.d.ts.map +1 -1
- package/lib/src/embed/conversation.js +7 -2
- package/lib/src/embed/conversation.js.map +1 -1
- package/lib/src/embed/conversation.spec.js +9 -4
- package/lib/src/embed/conversation.spec.js.map +1 -1
- package/lib/src/embed/embed.spec.js +103 -4
- package/lib/src/embed/embed.spec.js.map +1 -1
- package/lib/src/embed/events.spec.js +2 -2
- package/lib/src/embed/events.spec.js.map +1 -1
- package/lib/src/embed/hostEventClient/host-event-client.spec.js +2 -2
- package/lib/src/embed/hostEventClient/host-event-client.spec.js.map +1 -1
- package/lib/src/embed/liveboard.d.ts +18 -0
- package/lib/src/embed/liveboard.d.ts.map +1 -1
- package/lib/src/embed/liveboard.js +15 -8
- package/lib/src/embed/liveboard.js.map +1 -1
- package/lib/src/embed/liveboard.spec.js +114 -26
- package/lib/src/embed/liveboard.spec.js.map +1 -1
- package/lib/src/embed/pinboard.spec.js +1 -1
- package/lib/src/embed/pinboard.spec.js.map +1 -1
- package/lib/src/embed/sage.spec.js +2 -2
- package/lib/src/embed/sage.spec.js.map +1 -1
- package/lib/src/embed/search.spec.js +118 -2
- package/lib/src/embed/search.spec.js.map +1 -1
- package/lib/src/embed/ts-embed-trigger.spec.js +2 -3
- package/lib/src/embed/ts-embed-trigger.spec.js.map +1 -1
- package/lib/src/embed/ts-embed.d.ts +3 -2
- package/lib/src/embed/ts-embed.d.ts.map +1 -1
- package/lib/src/embed/ts-embed.js +52 -18
- 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 +336 -72
- package/lib/src/embed/ts-embed.spec.js.map +1 -1
- package/lib/src/errors.d.ts +7 -0
- package/lib/src/errors.d.ts.map +1 -1
- package/lib/src/errors.js +7 -0
- package/lib/src/errors.js.map +1 -1
- package/lib/src/mixpanel-service.spec.js +1 -1
- package/lib/src/mixpanel-service.spec.js.map +1 -1
- package/lib/src/react/index.spec.js +3 -4
- package/lib/src/react/index.spec.js.map +1 -1
- package/lib/src/test/test-utils.js +1 -1
- package/lib/src/test/test-utils.js.map +1 -1
- package/lib/src/types.d.ts +194 -1
- package/lib/src/types.d.ts.map +1 -1
- package/lib/src/types.js +93 -1
- package/lib/src/types.js.map +1 -1
- package/lib/src/utils/authService/authService.spec.js +8 -8
- package/lib/src/utils/authService/authService.spec.js.map +1 -1
- package/lib/src/utils/authService/tokenizedAuthService.spec.js.map +1 -1
- package/lib/src/utils/graphql/answerService/answerService.spec.js +1 -1
- package/lib/src/utils/graphql/answerService/answerService.spec.js.map +1 -1
- package/lib/src/utils/graphql/graphql-request.spec.js +1 -1
- package/lib/src/utils/graphql/graphql-request.spec.js.map +1 -1
- package/lib/src/utils/graphql/sourceService.spec.js +1 -1
- package/lib/src/utils/graphql/sourceService.spec.js.map +1 -1
- package/lib/src/utils/logger.spec.d.ts +5 -20
- package/lib/src/utils/logger.spec.d.ts.map +1 -1
- package/lib/src/utils/processData.spec.js +17 -17
- package/lib/src/utils/processData.spec.js.map +1 -1
- package/lib/src/utils/processTrigger.spec.js +8 -8
- package/lib/src/utils/processTrigger.spec.js.map +1 -1
- package/lib/src/utils.d.ts +6 -0
- package/lib/src/utils.d.ts.map +1 -1
- package/lib/src/utils.js +30 -0
- package/lib/src/utils.js.map +1 -1
- package/lib/src/utils.spec.js +20 -11
- package/lib/src/utils.spec.js.map +1 -1
- package/package.json +6 -5
- package/src/api-intercept.spec.ts +23 -10
- package/src/api-intercept.ts +9 -4
- package/src/auth.spec.ts +53 -51
- package/src/authToken.spec.ts +3 -3
- package/src/embed/app.spec.ts +128 -7
- package/src/embed/app.ts +30 -4
- package/src/embed/base.spec.ts +16 -20
- package/src/embed/bodyless-conversation.spec.ts +2 -2
- package/src/embed/conversation.spec.ts +9 -4
- package/src/embed/conversation.ts +7 -2
- package/src/embed/embed.spec.ts +122 -2
- package/src/embed/events.spec.ts +2 -2
- package/src/embed/hostEventClient/host-event-client.spec.ts +2 -2
- package/src/embed/liveboard.spec.ts +137 -29
- package/src/embed/liveboard.ts +36 -6
- package/src/embed/pinboard.spec.ts +1 -1
- package/src/embed/sage.spec.ts +2 -2
- package/src/embed/search.spec.ts +133 -2
- package/src/embed/ts-embed-trigger.spec.ts +2 -3
- package/src/embed/ts-embed.spec.ts +424 -91
- package/src/embed/ts-embed.ts +56 -19
- package/src/errors.ts +7 -0
- package/src/mixpanel-service.spec.ts +1 -1
- package/src/react/index.spec.tsx +4 -5
- package/src/test/test-utils.ts +2 -2
- package/src/types.ts +206 -1
- package/src/utils/authService/authService.spec.ts +17 -17
- package/src/utils/authService/tokenizedAuthService.spec.ts +4 -4
- package/src/utils/graphql/answerService/answerService.spec.ts +3 -3
- package/src/utils/graphql/graphql-request.spec.ts +2 -2
- package/src/utils/graphql/sourceService.spec.ts +1 -1
- package/src/utils/processData.spec.ts +26 -26
- package/src/utils/processTrigger.spec.ts +8 -8
- package/src/utils.spec.ts +22 -11
- package/src/utils.ts +34 -0
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import * as apiIntercept from './api-intercept';
|
|
2
2
|
import * as config from './config';
|
|
3
3
|
import * as embedConfig from './embed/embedConfig';
|
|
4
|
-
import {
|
|
4
|
+
import { ERROR_MESSAGE } from './errors';
|
|
5
|
+
import { InterceptedApiType, EmbedEvent, BaseViewConfig, EmbedErrorCodes, ErrorDetailsTypes } from './types';
|
|
5
6
|
import { embedEventStatus } from './utils';
|
|
6
7
|
import { logger } from './utils/logger';
|
|
7
8
|
|
|
@@ -354,9 +355,13 @@ describe('api-intercept', () => {
|
|
|
354
355
|
getUnsavedAnswerTml
|
|
355
356
|
});
|
|
356
357
|
|
|
357
|
-
expect(executeEvent).toHaveBeenCalledWith(
|
|
358
|
-
|
|
359
|
-
|
|
358
|
+
expect(executeEvent).toHaveBeenCalledWith(EmbedEvent.Error,
|
|
359
|
+
expect.objectContaining({
|
|
360
|
+
errorType: ErrorDetailsTypes.API,
|
|
361
|
+
message: ERROR_MESSAGE.ERROR_PARSING_API_INTERCEPT_BODY,
|
|
362
|
+
code: EmbedErrorCodes.PARSING_API_INTERCEPT_BODY_ERROR,
|
|
363
|
+
error: ERROR_MESSAGE.ERROR_PARSING_API_INTERCEPT_BODY,
|
|
364
|
+
})
|
|
360
365
|
);
|
|
361
366
|
expect(mockLogger.error).toHaveBeenCalled();
|
|
362
367
|
});
|
|
@@ -414,9 +419,13 @@ describe('api-intercept', () => {
|
|
|
414
419
|
getUnsavedAnswerTml
|
|
415
420
|
});
|
|
416
421
|
|
|
417
|
-
expect(executeEvent).toHaveBeenCalledWith(
|
|
418
|
-
|
|
419
|
-
|
|
422
|
+
expect(executeEvent).toHaveBeenCalledWith(EmbedEvent.Error,
|
|
423
|
+
expect.objectContaining({
|
|
424
|
+
errorType: ErrorDetailsTypes.API,
|
|
425
|
+
message: ERROR_MESSAGE.ERROR_PARSING_API_INTERCEPT_BODY,
|
|
426
|
+
code: EmbedErrorCodes.PARSING_API_INTERCEPT_BODY_ERROR,
|
|
427
|
+
error: ERROR_MESSAGE.ERROR_PARSING_API_INTERCEPT_BODY,
|
|
428
|
+
})
|
|
420
429
|
);
|
|
421
430
|
expect(mockLogger.error).toHaveBeenCalled();
|
|
422
431
|
|
|
@@ -485,9 +494,13 @@ describe('api-intercept', () => {
|
|
|
485
494
|
});
|
|
486
495
|
|
|
487
496
|
// When init is missing, accessing init.body throws an error
|
|
488
|
-
expect(executeEvent).toHaveBeenCalledWith(
|
|
489
|
-
|
|
490
|
-
|
|
497
|
+
expect(executeEvent).toHaveBeenCalledWith(EmbedEvent.Error,
|
|
498
|
+
expect.objectContaining({
|
|
499
|
+
errorType: ErrorDetailsTypes.API,
|
|
500
|
+
message: ERROR_MESSAGE.ERROR_PARSING_API_INTERCEPT_BODY,
|
|
501
|
+
code: EmbedErrorCodes.PARSING_API_INTERCEPT_BODY_ERROR,
|
|
502
|
+
error: ERROR_MESSAGE.ERROR_PARSING_API_INTERCEPT_BODY,
|
|
503
|
+
})
|
|
491
504
|
);
|
|
492
505
|
});
|
|
493
506
|
|
package/src/api-intercept.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { getThoughtSpotHost } from "./config";
|
|
2
2
|
import { getEmbedConfig } from "./embed/embedConfig";
|
|
3
|
-
import {
|
|
3
|
+
import { ERROR_MESSAGE } from "./errors";
|
|
4
|
+
import { InterceptedApiType, BaseViewConfig, ApiInterceptFlags, EmbedEvent, EmbedErrorCodes, ErrorDetailsTypes, EmbedErrorDetailsEvent } from "./types";
|
|
4
5
|
import { embedEventStatus } from "./utils";
|
|
5
6
|
import { logger } from "./utils/logger";
|
|
6
7
|
|
|
@@ -129,9 +130,13 @@ export const handleInterceptEvent = async (params: {
|
|
|
129
130
|
const [interceptData, bodyParseError] = parseInterceptData(eventData.data);
|
|
130
131
|
|
|
131
132
|
if (bodyParseError) {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
133
|
+
const errorDetails: EmbedErrorDetailsEvent = {
|
|
134
|
+
errorType: ErrorDetailsTypes.API,
|
|
135
|
+
message: ERROR_MESSAGE.ERROR_PARSING_API_INTERCEPT_BODY,
|
|
136
|
+
code: EmbedErrorCodes.PARSING_API_INTERCEPT_BODY_ERROR,
|
|
137
|
+
error: ERROR_MESSAGE.ERROR_PARSING_API_INTERCEPT_BODY,
|
|
138
|
+
};
|
|
139
|
+
executeEvent(EmbedEvent.Error, errorDetails);
|
|
135
140
|
logger.error('Error parsing request body', bodyParseError);
|
|
136
141
|
return;
|
|
137
142
|
}
|
package/src/auth.spec.ts
CHANGED
|
@@ -145,20 +145,20 @@ describe('Unit test for auth', () => {
|
|
|
145
145
|
|
|
146
146
|
test('Disable mixpanel when disableSDKTracking flag is set', () => {
|
|
147
147
|
jest.spyOn(mixPanelService, 'initMixpanel');
|
|
148
|
-
jest.spyOn(SessionService, 'getSessionInfo').mockReturnValue(mockSessionInfo);
|
|
149
|
-
jest.spyOn(EmbedConfig, 'getEmbedConfig').mockReturnValue({ disableSDKTracking: true });
|
|
148
|
+
jest.spyOn(SessionService, 'getSessionInfo').mockReturnValue(mockSessionInfo as any);
|
|
149
|
+
jest.spyOn(EmbedConfig, 'getEmbedConfig').mockReturnValue({ disableSDKTracking: true } as any);
|
|
150
150
|
authInstance.postLoginService();
|
|
151
|
-
expect(mixPanelService.initMixpanel).not.
|
|
151
|
+
expect(mixPanelService.initMixpanel).not.toHaveBeenCalled();
|
|
152
152
|
});
|
|
153
153
|
|
|
154
154
|
test('Log error is postLogin faild', async () => {
|
|
155
155
|
jest.spyOn(mixPanelService, 'initMixpanel');
|
|
156
156
|
jest.spyOn(SessionService, 'getSessionInfo').mockRejectedValueOnce(mockSessionInfo);
|
|
157
|
-
jest.spyOn(EmbedConfig, 'getEmbedConfig').mockReturnValue({ disableSDKTracking: true });
|
|
158
|
-
jest.spyOn(logger, 'error').
|
|
157
|
+
jest.spyOn(EmbedConfig, 'getEmbedConfig').mockReturnValue({ disableSDKTracking: true } as any);
|
|
158
|
+
jest.spyOn(logger, 'error').mockImplementation(() => {});
|
|
159
159
|
await authInstance.postLoginService();
|
|
160
|
-
expect(mixPanelService.initMixpanel).not.
|
|
161
|
-
expect(logger.error).
|
|
160
|
+
expect(mixPanelService.initMixpanel).not.toHaveBeenCalled();
|
|
161
|
+
expect(logger.error).toHaveBeenCalled();
|
|
162
162
|
});
|
|
163
163
|
|
|
164
164
|
test('doCookielessTokenAuth: when authEndpoint and getAuthToken are not there, it throw error', async () => {
|
|
@@ -187,7 +187,7 @@ describe('Unit test for auth', () => {
|
|
|
187
187
|
const getAuthenticationTokenMock = jest.spyOn(authTokenService, 'getAuthenticationToken');
|
|
188
188
|
jest.spyOn(tokenAuthService, 'isActiveService').mockImplementation(async () => true);
|
|
189
189
|
await authInstance.doTokenAuth(embedConfig.doTokenAuthSuccess('authToken'));
|
|
190
|
-
expect(authTokenService.getAuthenticationToken).not.
|
|
190
|
+
expect(authTokenService.getAuthenticationToken).not.toHaveBeenCalled();
|
|
191
191
|
expect(authInstance.loggedInStatus).toBe(true);
|
|
192
192
|
getAuthenticationTokenMock.mockRestore();
|
|
193
193
|
});
|
|
@@ -200,7 +200,7 @@ describe('Unit test for auth', () => {
|
|
|
200
200
|
}));
|
|
201
201
|
jest.spyOn(authService, 'verifyTokenService').mockResolvedValueOnce(true);
|
|
202
202
|
await authInstance.doTokenAuth(embedConfig.doTokenAuthSuccess('authToken2'));
|
|
203
|
-
expect(authService.fetchAuthService).
|
|
203
|
+
expect(authService.fetchAuthService).toHaveBeenCalledWith(
|
|
204
204
|
thoughtSpotHost,
|
|
205
205
|
username,
|
|
206
206
|
'authToken2',
|
|
@@ -212,17 +212,17 @@ describe('Unit test for auth', () => {
|
|
|
212
212
|
jest.spyOn(tokenAuthService, 'isActiveService').mockImplementation(async () => false);
|
|
213
213
|
jest.spyOn(authService, 'fetchAuthTokenService').mockImplementation(() => ({
|
|
214
214
|
text: () => Promise.resolve('abc'),
|
|
215
|
-
}));
|
|
215
|
+
} as any));
|
|
216
216
|
jest.spyOn(authService, 'fetchAuthService').mockImplementation(() => Promise.resolve({
|
|
217
217
|
status: 200,
|
|
218
218
|
ok: true,
|
|
219
219
|
}));
|
|
220
220
|
jest.spyOn(authService, 'verifyTokenService').mockResolvedValueOnce(true);
|
|
221
221
|
await authInstance.doTokenAuth(embedConfig.doTokenAuthFailureWithoutGetAuthToken);
|
|
222
|
-
expect(authService.fetchAuthTokenService).
|
|
222
|
+
expect(authService.fetchAuthTokenService).toHaveBeenCalledWith('auth');
|
|
223
223
|
await executeAfterWait(() => {
|
|
224
224
|
expect(authInstance.loggedInStatus).toBe(true);
|
|
225
|
-
expect(authService.fetchAuthService).
|
|
225
|
+
expect(authService.fetchAuthService).toHaveBeenCalledWith(thoughtSpotHost, username, 'abc');
|
|
226
226
|
});
|
|
227
227
|
});
|
|
228
228
|
|
|
@@ -250,7 +250,7 @@ describe('Unit test for auth', () => {
|
|
|
250
250
|
}
|
|
251
251
|
await executeAfterWait(() => {
|
|
252
252
|
expect(authInstance.loggedInStatus).toBe(false);
|
|
253
|
-
expect(window.alert).
|
|
253
|
+
expect(window.alert).toHaveBeenCalled();
|
|
254
254
|
expect(authService.fetchAuthService).toHaveBeenCalledTimes(1);
|
|
255
255
|
});
|
|
256
256
|
});
|
|
@@ -263,7 +263,7 @@ describe('Unit test for auth', () => {
|
|
|
263
263
|
.mockClear();
|
|
264
264
|
jest.spyOn(authService, 'fetchAuthTokenService').mockImplementation(() => ({
|
|
265
265
|
text: () => Promise.resolve('abc'),
|
|
266
|
-
}));
|
|
266
|
+
} as any));
|
|
267
267
|
jest.spyOn(authService, 'fetchAuthService').mockImplementation(() => Promise.resolve({
|
|
268
268
|
status: 200,
|
|
269
269
|
ok: true,
|
|
@@ -278,10 +278,10 @@ describe('Unit test for auth', () => {
|
|
|
278
278
|
|
|
279
279
|
test('doTokenAuth: when user is not loggedIn & fetchAuthPostService failed than fetchAuthService should call', async () => {
|
|
280
280
|
jest.spyOn(window, 'alert').mockImplementation(() => undefined);
|
|
281
|
-
jest.spyOn(tokenAuthService, 'fetchSessionInfoService').mockImplementation(() => false);
|
|
281
|
+
jest.spyOn(tokenAuthService, 'fetchSessionInfoService').mockImplementation(() => Promise.resolve(false));
|
|
282
282
|
jest.spyOn(authService, 'fetchAuthTokenService').mockImplementation(() => ({
|
|
283
283
|
text: () => Promise.resolve('abc'),
|
|
284
|
-
}));
|
|
284
|
+
} as any));
|
|
285
285
|
jest.spyOn(authService, 'fetchAuthPostService').mockImplementation(() =>
|
|
286
286
|
// eslint-disable-next-line prefer-promise-reject-errors, implicit-arrow-linebreak
|
|
287
287
|
Promise.reject({
|
|
@@ -295,12 +295,12 @@ describe('Unit test for auth', () => {
|
|
|
295
295
|
expect(await authInstance.doTokenAuth(embedConfig.doTokenAuthSuccess('authToken2'))).toBe(
|
|
296
296
|
true,
|
|
297
297
|
);
|
|
298
|
-
expect(authService.fetchAuthPostService).
|
|
298
|
+
expect(authService.fetchAuthPostService).toHaveBeenCalledWith(
|
|
299
299
|
thoughtSpotHost,
|
|
300
300
|
username,
|
|
301
301
|
'authToken2',
|
|
302
302
|
);
|
|
303
|
-
expect(authService.fetchAuthService).
|
|
303
|
+
expect(authService.fetchAuthService).toHaveBeenCalledWith(
|
|
304
304
|
thoughtSpotHost,
|
|
305
305
|
username,
|
|
306
306
|
'authToken2',
|
|
@@ -323,11 +323,11 @@ describe('Unit test for auth', () => {
|
|
|
323
323
|
jest.spyOn(authService, 'fetchBasicAuthService').mockImplementation(() => ({
|
|
324
324
|
status: 200,
|
|
325
325
|
ok: true,
|
|
326
|
-
}));
|
|
326
|
+
} as any));
|
|
327
327
|
|
|
328
328
|
await authInstance.doBasicAuth(embedConfig.doBasicAuth);
|
|
329
|
-
// expect(tokenAuthService.fetchSessionInfoService).
|
|
330
|
-
expect(authService.fetchBasicAuthService).
|
|
329
|
+
// expect(tokenAuthService.fetchSessionInfoService).toHaveBeenCalled();
|
|
330
|
+
expect(authService.fetchBasicAuthService).toHaveBeenCalled();
|
|
331
331
|
expect(authInstance.loggedInStatus).toBe(true);
|
|
332
332
|
});
|
|
333
333
|
});
|
|
@@ -341,7 +341,7 @@ describe('Unit test for auth', () => {
|
|
|
341
341
|
});
|
|
342
342
|
|
|
343
343
|
it('when user is loggedIn & isAtSSORedirectUrl is true', async () => {
|
|
344
|
-
spyOn(checkReleaseVersionInBetaInstance, 'checkReleaseVersionInBeta');
|
|
344
|
+
jest.spyOn(checkReleaseVersionInBetaInstance, 'checkReleaseVersionInBeta');
|
|
345
345
|
Object.defineProperty(window, 'location', {
|
|
346
346
|
value: {
|
|
347
347
|
href: `asd.com#?tsSSOMarker=${authInstance.SSO_REDIRECTION_MARKER_GUID}`,
|
|
@@ -354,7 +354,7 @@ describe('Unit test for auth', () => {
|
|
|
354
354
|
status: 200,
|
|
355
355
|
}),
|
|
356
356
|
);
|
|
357
|
-
jest.spyOn(tokenAuthService, 'isActiveService').mockReturnValue(true);
|
|
357
|
+
jest.spyOn(tokenAuthService, 'isActiveService').mockReturnValue(Promise.resolve(true));
|
|
358
358
|
await authInstance.doSamlAuth(embedConfig.doSamlAuth);
|
|
359
359
|
expect(window.location.hash).toBe('');
|
|
360
360
|
expect(authInstance.loggedInStatus).toBe(true);
|
|
@@ -399,7 +399,7 @@ describe('Unit test for auth', () => {
|
|
|
399
399
|
hash: '',
|
|
400
400
|
},
|
|
401
401
|
});
|
|
402
|
-
|
|
402
|
+
(authInstance as any).samlCompletionPromise = Promise.resolve(false);
|
|
403
403
|
const emitSpy = jest.fn();
|
|
404
404
|
const mockEventEmitter = {
|
|
405
405
|
emit: emitSpy,
|
|
@@ -408,8 +408,8 @@ describe('Unit test for auth', () => {
|
|
|
408
408
|
};
|
|
409
409
|
authInstance.setAuthEE(mockEventEmitter as any);
|
|
410
410
|
jest.spyOn(tokenAuthService, 'isActiveService')
|
|
411
|
-
.mockReturnValueOnce(false)
|
|
412
|
-
.mockReturnValueOnce(true);
|
|
411
|
+
.mockReturnValueOnce(Promise.resolve(false))
|
|
412
|
+
.mockReturnValueOnce(Promise.resolve(true));
|
|
413
413
|
expect(
|
|
414
414
|
await authInstance.doSamlAuth({
|
|
415
415
|
...embedConfig.doSamlAuthNoRedirect,
|
|
@@ -431,11 +431,11 @@ describe('Unit test for auth', () => {
|
|
|
431
431
|
hash: '',
|
|
432
432
|
},
|
|
433
433
|
});
|
|
434
|
-
|
|
434
|
+
(authInstance as any).samlCompletionPromise = Promise.resolve();
|
|
435
435
|
global.window.open = jest.fn();
|
|
436
436
|
jest.spyOn(tokenAuthService, 'isActiveService')
|
|
437
|
-
.mockReturnValueOnce(false)
|
|
438
|
-
.mockReturnValueOnce(true);
|
|
437
|
+
.mockReturnValueOnce(Promise.resolve(false))
|
|
438
|
+
.mockReturnValueOnce(Promise.resolve(true));
|
|
439
439
|
expect(await authInstance.samlCompletionPromise).not.toBe(null);
|
|
440
440
|
expect(
|
|
441
441
|
await authInstance.doSamlAuth({
|
|
@@ -489,42 +489,42 @@ describe('Unit test for auth', () => {
|
|
|
489
489
|
jest.spyOn(authInstance, 'doSamlAuth');
|
|
490
490
|
await authInstance.authenticate(embedConfig.SSOAuth);
|
|
491
491
|
expect(window.location.hash).toBe('');
|
|
492
|
-
expect(authInstance.doSamlAuth).
|
|
492
|
+
expect(authInstance.doSamlAuth).toHaveBeenCalled();
|
|
493
493
|
});
|
|
494
494
|
|
|
495
495
|
it('authenticate: when authType is SMAL', async () => {
|
|
496
496
|
jest.spyOn(authInstance, 'doSamlAuth');
|
|
497
497
|
await authInstance.authenticate(embedConfig.SAMLAuth);
|
|
498
498
|
expect(window.location.hash).toBe('');
|
|
499
|
-
expect(authInstance.doSamlAuth).
|
|
499
|
+
expect(authInstance.doSamlAuth).toHaveBeenCalled();
|
|
500
500
|
});
|
|
501
501
|
|
|
502
502
|
it('authenticate: when authType is OIDC', async () => {
|
|
503
503
|
jest.spyOn(authInstance, 'doOIDCAuth');
|
|
504
504
|
await authInstance.authenticate(embedConfig.OIDCAuth);
|
|
505
505
|
expect(window.location.hash).toBe('');
|
|
506
|
-
expect(authInstance.doOIDCAuth).
|
|
506
|
+
expect(authInstance.doOIDCAuth).toHaveBeenCalled();
|
|
507
507
|
});
|
|
508
508
|
|
|
509
509
|
it('authenticate: when authType is AuthServer', async () => {
|
|
510
|
-
spyOn(authInstance, 'doTokenAuth');
|
|
510
|
+
jest.spyOn(authInstance, 'doTokenAuth').mockReturnValue(Promise.resolve(true) as any);
|
|
511
511
|
await authInstance.authenticate(embedConfig.authServerFailure);
|
|
512
512
|
expect(window.location.hash).toBe('');
|
|
513
|
-
expect(authInstance.doTokenAuth).
|
|
513
|
+
expect(authInstance.doTokenAuth).toHaveBeenCalled();
|
|
514
514
|
});
|
|
515
515
|
|
|
516
516
|
it('authenticate: when authType is AuthServerCookieless', async () => {
|
|
517
|
-
spyOn(authInstance, 'doCookielessTokenAuth');
|
|
517
|
+
jest.spyOn(authInstance, 'doCookielessTokenAuth').mockReturnValue(Promise.resolve(true) as any);
|
|
518
518
|
await authInstance.authenticate(embedConfig.authServerCookielessFailure);
|
|
519
519
|
expect(window.location.hash).toBe('');
|
|
520
|
-
expect(authInstance.doCookielessTokenAuth).
|
|
520
|
+
expect(authInstance.doCookielessTokenAuth).toHaveBeenCalled();
|
|
521
521
|
});
|
|
522
522
|
|
|
523
523
|
it('authenticate: when authType is Basic', async () => {
|
|
524
524
|
jest.spyOn(authInstance, 'doBasicAuth');
|
|
525
525
|
jest.spyOn(authService, 'fetchBasicAuthService').mockImplementation(() => Promise.resolve({ status: 200, ok: true }));
|
|
526
526
|
await authInstance.authenticate(embedConfig.basicAuthSuccess);
|
|
527
|
-
expect(authInstance.doBasicAuth).
|
|
527
|
+
expect(authInstance.doBasicAuth).toHaveBeenCalled();
|
|
528
528
|
expect(authInstance.loggedInStatus).toBe(true);
|
|
529
529
|
});
|
|
530
530
|
|
|
@@ -540,7 +540,7 @@ describe('Unit test for auth', () => {
|
|
|
540
540
|
|
|
541
541
|
it('doCookielessTokenAuth should resolve to true if valid token is passed', async () => {
|
|
542
542
|
jest.clearAllMocks();
|
|
543
|
-
jest.spyOn(
|
|
543
|
+
jest.spyOn(authInstance, 'doCookielessTokenAuth').mockReturnValue(Promise.resolve(true) as any);
|
|
544
544
|
const isLoggedIn = await authInstance.doCookielessTokenAuth(
|
|
545
545
|
embedConfig.doCookielessAuth('testToken'),
|
|
546
546
|
);
|
|
@@ -548,6 +548,7 @@ describe('Unit test for auth', () => {
|
|
|
548
548
|
});
|
|
549
549
|
|
|
550
550
|
it('doCookielessTokenAuth should resolve to false if valid token is not passed', async () => {
|
|
551
|
+
jest.restoreAllMocks();
|
|
551
552
|
jest.spyOn(authService, 'verifyTokenService').mockResolvedValueOnce(false);
|
|
552
553
|
const isLoggedIn = await authInstance.doCookielessTokenAuth(
|
|
553
554
|
embedConfig.doCookielessAuth('testToken'),
|
|
@@ -563,17 +564,18 @@ describe('Unit test for auth', () => {
|
|
|
563
564
|
jest.clearAllMocks();
|
|
564
565
|
jest.restoreAllMocks();
|
|
565
566
|
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
releaseVersion: '1',
|
|
567
|
+
const devMockResponse = {
|
|
568
|
+
...mockSessionInfoApiResponse,
|
|
569
569
|
configInfo: {
|
|
570
|
+
...mockSessionInfoApiResponse.configInfo,
|
|
570
571
|
mixpanelConfig: {
|
|
571
|
-
|
|
572
|
-
prodSdkKey: 'prodKey',
|
|
572
|
+
...mockSessionInfoApiResponse.configInfo.mixpanelConfig,
|
|
573
573
|
production: false,
|
|
574
574
|
},
|
|
575
575
|
},
|
|
576
|
-
}
|
|
576
|
+
};
|
|
577
|
+
|
|
578
|
+
jest.spyOn(tokenAuthService, 'fetchSessionInfoService').mockReturnValue(Promise.resolve(devMockResponse));
|
|
577
579
|
const details = await SessionService.getSessionInfo();
|
|
578
580
|
expect(details).toEqual(
|
|
579
581
|
expect.objectContaining({
|
|
@@ -589,7 +591,7 @@ describe('Unit test for auth', () => {
|
|
|
589
591
|
production: true,
|
|
590
592
|
},
|
|
591
593
|
},
|
|
592
|
-
});
|
|
594
|
+
} as any);
|
|
593
595
|
|
|
594
596
|
SessionService.resetCachedSessionInfo();
|
|
595
597
|
const details2 = await SessionService.getSessionInfo();
|
|
@@ -602,13 +604,13 @@ describe('Unit test for auth', () => {
|
|
|
602
604
|
|
|
603
605
|
test('notifyAuthSuccess if getSessionInfo returns data', async () => {
|
|
604
606
|
const dummyInfo = { test: 'dummy' };
|
|
605
|
-
jest.spyOn(SessionService, 'getSessionInfo').mockResolvedValueOnce(dummyInfo);
|
|
606
|
-
jest.spyOn(logger, 'error').
|
|
607
|
+
jest.spyOn(SessionService, 'getSessionInfo').mockResolvedValueOnce(dummyInfo as any);
|
|
608
|
+
jest.spyOn(logger, 'error').mockImplementation(() => {});
|
|
607
609
|
const emitSpy = jest.fn();
|
|
608
610
|
authInstance.setAuthEE({ emit: emitSpy } as any);
|
|
609
611
|
await authInstance.notifyAuthSuccess();
|
|
610
|
-
expect(logger.error).not.
|
|
611
|
-
expect(emitSpy).
|
|
612
|
+
expect(logger.error).not.toHaveBeenCalled();
|
|
613
|
+
expect(emitSpy).toHaveBeenCalledWith(authInstance.AuthStatus.SUCCESS, dummyInfo);
|
|
612
614
|
authInstance.setAuthEE(null);
|
|
613
615
|
});
|
|
614
616
|
|
|
@@ -620,8 +622,8 @@ describe('Unit test for auth', () => {
|
|
|
620
622
|
const emitSpy = jest.fn();
|
|
621
623
|
authInstance.setAuthEE({ emit: emitSpy } as any);
|
|
622
624
|
await authInstance.notifyAuthSuccess();
|
|
623
|
-
expect(logger.error).
|
|
624
|
-
expect(emitSpy).not.
|
|
625
|
+
expect(logger.error).toHaveBeenCalled();
|
|
626
|
+
expect(emitSpy).not.toHaveBeenCalled();
|
|
625
627
|
authInstance.setAuthEE(null);
|
|
626
628
|
});
|
|
627
629
|
});
|
package/src/authToken.spec.ts
CHANGED
|
@@ -15,13 +15,13 @@ describe('AuthToken Unit tests', () => {
|
|
|
15
15
|
} as EmbedConfig);
|
|
16
16
|
|
|
17
17
|
expect(token).toBe('abc3');
|
|
18
|
-
expect(authServiceInstance.verifyTokenService).not.
|
|
18
|
+
expect(authServiceInstance.verifyTokenService).not.toHaveBeenCalled();
|
|
19
19
|
});
|
|
20
20
|
|
|
21
21
|
test('getAuthenticationToken: When verification is enabled', async () => {
|
|
22
22
|
resetCachedAuthToken();
|
|
23
23
|
jest.clearAllMocks();
|
|
24
|
-
jest.spyOn(authServiceInstance, 'verifyTokenService').mockImplementation(() => true);
|
|
24
|
+
jest.spyOn(authServiceInstance, 'verifyTokenService').mockImplementation(() => Promise.resolve(true));
|
|
25
25
|
const token = await getAuthenticationToken({
|
|
26
26
|
thoughtSpotHost: 'test',
|
|
27
27
|
getAuthToken: async () => 'abc2',
|
|
@@ -29,7 +29,7 @@ describe('AuthToken Unit tests', () => {
|
|
|
29
29
|
} as EmbedConfig);
|
|
30
30
|
|
|
31
31
|
expect(token).toBe('abc2');
|
|
32
|
-
expect(authServiceInstance.verifyTokenService).
|
|
32
|
+
expect(authServiceInstance.verifyTokenService).toHaveBeenCalledWith('test', 'abc2');
|
|
33
33
|
});
|
|
34
34
|
|
|
35
35
|
test('validateAuthToken : When token is invalid by type number', async () => {
|
package/src/embed/app.spec.ts
CHANGED
|
@@ -43,7 +43,7 @@ beforeAll(() => {
|
|
|
43
43
|
thoughtSpotHost,
|
|
44
44
|
authType: AuthType.None,
|
|
45
45
|
});
|
|
46
|
-
jest.spyOn(auth, 'postLoginService').mockImplementation(() => Promise.resolve(
|
|
46
|
+
jest.spyOn(auth, 'postLoginService').mockImplementation(() => Promise.resolve(undefined));
|
|
47
47
|
(window as any).ResizeObserver =
|
|
48
48
|
window.ResizeObserver ||
|
|
49
49
|
jest.fn().mockImplementation(() => ({
|
|
@@ -542,6 +542,100 @@ describe('App embed tests', () => {
|
|
|
542
542
|
});
|
|
543
543
|
});
|
|
544
544
|
|
|
545
|
+
test('Should add showMaskedFilterChip true to the iframe src', async () => {
|
|
546
|
+
const appEmbed = new AppEmbed(getRootEl(), {
|
|
547
|
+
...defaultViewConfig,
|
|
548
|
+
showPrimaryNavbar: false,
|
|
549
|
+
showMaskedFilterChip: true,
|
|
550
|
+
} as AppViewConfig);
|
|
551
|
+
|
|
552
|
+
appEmbed.render();
|
|
553
|
+
await executeAfterWait(() => {
|
|
554
|
+
expectUrlMatchesWithParams(
|
|
555
|
+
getIFrameSrc(),
|
|
556
|
+
`http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&showMaskedFilterChip=true${defaultParams}${defaultParamsPost}#/home`,
|
|
557
|
+
);
|
|
558
|
+
});
|
|
559
|
+
});
|
|
560
|
+
|
|
561
|
+
test('Should add showMaskedFilterChip false to the iframe src', async () => {
|
|
562
|
+
const appEmbed = new AppEmbed(getRootEl(), {
|
|
563
|
+
...defaultViewConfig,
|
|
564
|
+
showPrimaryNavbar: false,
|
|
565
|
+
showMaskedFilterChip: false,
|
|
566
|
+
} as AppViewConfig);
|
|
567
|
+
|
|
568
|
+
appEmbed.render();
|
|
569
|
+
await executeAfterWait(() => {
|
|
570
|
+
expectUrlMatchesWithParams(
|
|
571
|
+
getIFrameSrc(),
|
|
572
|
+
`http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&showMaskedFilterChip=false${defaultParams}${defaultParamsPost}#/home`,
|
|
573
|
+
);
|
|
574
|
+
});
|
|
575
|
+
});
|
|
576
|
+
|
|
577
|
+
test('Should add default showMaskedFilterChip false when not specified', async () => {
|
|
578
|
+
const appEmbed = new AppEmbed(getRootEl(), {
|
|
579
|
+
...defaultViewConfig,
|
|
580
|
+
showPrimaryNavbar: false,
|
|
581
|
+
} as AppViewConfig);
|
|
582
|
+
|
|
583
|
+
appEmbed.render();
|
|
584
|
+
await executeAfterWait(() => {
|
|
585
|
+
expectUrlMatchesWithParams(
|
|
586
|
+
getIFrameSrc(),
|
|
587
|
+
`http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&showMaskedFilterChip=false${defaultParams}${defaultParamsPost}#/home`,
|
|
588
|
+
);
|
|
589
|
+
});
|
|
590
|
+
});
|
|
591
|
+
|
|
592
|
+
test('Should add isLiveboardMasterpiecesEnabled true to the iframe src', async () => {
|
|
593
|
+
const appEmbed = new AppEmbed(getRootEl(), {
|
|
594
|
+
...defaultViewConfig,
|
|
595
|
+
showPrimaryNavbar: false,
|
|
596
|
+
isLiveboardMasterpiecesEnabled: true,
|
|
597
|
+
} as AppViewConfig);
|
|
598
|
+
|
|
599
|
+
appEmbed.render();
|
|
600
|
+
await executeAfterWait(() => {
|
|
601
|
+
expectUrlMatchesWithParams(
|
|
602
|
+
getIFrameSrc(),
|
|
603
|
+
`http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&isLiveboardMasterpiecesEnabled=true${defaultParams}${defaultParamsPost}#/home`,
|
|
604
|
+
);
|
|
605
|
+
});
|
|
606
|
+
});
|
|
607
|
+
|
|
608
|
+
test('Should add isLiveboardMasterpiecesEnabled false to the iframe src', async () => {
|
|
609
|
+
const appEmbed = new AppEmbed(getRootEl(), {
|
|
610
|
+
...defaultViewConfig,
|
|
611
|
+
showPrimaryNavbar: false,
|
|
612
|
+
isLiveboardMasterpiecesEnabled: false,
|
|
613
|
+
} as AppViewConfig);
|
|
614
|
+
|
|
615
|
+
appEmbed.render();
|
|
616
|
+
await executeAfterWait(() => {
|
|
617
|
+
expectUrlMatchesWithParams(
|
|
618
|
+
getIFrameSrc(),
|
|
619
|
+
`http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&isLiveboardMasterpiecesEnabled=false${defaultParams}${defaultParamsPost}#/home`,
|
|
620
|
+
);
|
|
621
|
+
});
|
|
622
|
+
});
|
|
623
|
+
|
|
624
|
+
test('Should add default isLiveboardMasterpiecesEnabled false when not specified', async () => {
|
|
625
|
+
const appEmbed = new AppEmbed(getRootEl(), {
|
|
626
|
+
...defaultViewConfig,
|
|
627
|
+
showPrimaryNavbar: false,
|
|
628
|
+
} as AppViewConfig);
|
|
629
|
+
|
|
630
|
+
appEmbed.render();
|
|
631
|
+
await executeAfterWait(() => {
|
|
632
|
+
expectUrlMatchesWithParams(
|
|
633
|
+
getIFrameSrc(),
|
|
634
|
+
`http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&isLiveboardMasterpiecesEnabled=false${defaultParams}${defaultParamsPost}#/home`,
|
|
635
|
+
);
|
|
636
|
+
});
|
|
637
|
+
});
|
|
638
|
+
|
|
545
639
|
test('Should add enableSearchAssist flagto the iframe src', async () => {
|
|
546
640
|
const appEmbed = new AppEmbed(getRootEl(), {
|
|
547
641
|
...defaultViewConfig,
|
|
@@ -1036,13 +1130,13 @@ describe('App embed tests', () => {
|
|
|
1036
1130
|
let embedHeightCallback: any = () => { };
|
|
1037
1131
|
const onSpy = jest.spyOn(AppEmbed.prototype, 'on').mockImplementation((event, callback) => {
|
|
1038
1132
|
if (event === EmbedEvent.RouteChange) {
|
|
1039
|
-
callback({ data: { currentPath: '/answers' } }, jest.fn());
|
|
1133
|
+
callback({ type: EmbedEvent.RouteChange, data: { currentPath: '/answers' } } as any, jest.fn());
|
|
1040
1134
|
}
|
|
1041
1135
|
if (event === EmbedEvent.EmbedHeight) {
|
|
1042
1136
|
embedHeightCallback = callback;
|
|
1043
1137
|
}
|
|
1044
1138
|
if (event === EmbedEvent.EmbedIframeCenter) {
|
|
1045
|
-
callback({}, jest.fn());
|
|
1139
|
+
callback({ type: EmbedEvent.EmbedIframeCenter, data: {} } as any, jest.fn());
|
|
1046
1140
|
}
|
|
1047
1141
|
return null;
|
|
1048
1142
|
});
|
|
@@ -1052,6 +1146,7 @@ describe('App embed tests', () => {
|
|
|
1052
1146
|
...defaultViewConfig,
|
|
1053
1147
|
fullHeight: true,
|
|
1054
1148
|
lazyLoadingForFullHeight: true,
|
|
1149
|
+
lazyLoadingMargin: '10px',
|
|
1055
1150
|
} as AppViewConfig);
|
|
1056
1151
|
|
|
1057
1152
|
// Set the iframe before render
|
|
@@ -1133,7 +1228,7 @@ describe('App embed tests', () => {
|
|
|
1133
1228
|
},
|
|
1134
1229
|
});
|
|
1135
1230
|
await appEmbed.render();
|
|
1136
|
-
spyOn(logger, 'warn');
|
|
1231
|
+
jest.spyOn(logger, 'warn').mockImplementation(() => {});
|
|
1137
1232
|
appEmbed.navigateToPage(-1);
|
|
1138
1233
|
expect(logger.warn).toHaveBeenCalledWith(
|
|
1139
1234
|
'Path can only by a string when triggered without noReload',
|
|
@@ -1141,7 +1236,7 @@ describe('App embed tests', () => {
|
|
|
1141
1236
|
});
|
|
1142
1237
|
|
|
1143
1238
|
test('navigateToPage function use before render', async () => {
|
|
1144
|
-
spyOn(logger, 'log');
|
|
1239
|
+
jest.spyOn(logger, 'log').mockImplementation(() => {});
|
|
1145
1240
|
const appEmbed = new AppEmbed(getRootEl(), {
|
|
1146
1241
|
frameParams: {
|
|
1147
1242
|
width: '100%',
|
|
@@ -1223,6 +1318,7 @@ describe('App embed tests', () => {
|
|
|
1223
1318
|
...defaultViewConfig,
|
|
1224
1319
|
fullHeight: true,
|
|
1225
1320
|
lazyLoadingForFullHeight: true,
|
|
1321
|
+
lazyLoadingMargin: '10px',
|
|
1226
1322
|
} as AppViewConfig);
|
|
1227
1323
|
|
|
1228
1324
|
// Set the iframe before render
|
|
@@ -1299,6 +1395,7 @@ describe('App embed tests', () => {
|
|
|
1299
1395
|
...defaultViewConfig,
|
|
1300
1396
|
fullHeight: true,
|
|
1301
1397
|
lazyLoadingForFullHeight: true,
|
|
1398
|
+
lazyLoadingMargin: '10px',
|
|
1302
1399
|
} as AppViewConfig);
|
|
1303
1400
|
|
|
1304
1401
|
const mockTrigger = jest.spyOn(appEmbed, 'trigger');
|
|
@@ -1331,6 +1428,7 @@ describe('App embed tests', () => {
|
|
|
1331
1428
|
...defaultViewConfig,
|
|
1332
1429
|
fullHeight: true,
|
|
1333
1430
|
lazyLoadingForFullHeight: true,
|
|
1431
|
+
lazyLoadingMargin: '10px',
|
|
1334
1432
|
} as AppViewConfig);
|
|
1335
1433
|
|
|
1336
1434
|
const mockTrigger = jest.spyOn(appEmbed, 'trigger');
|
|
@@ -1355,6 +1453,7 @@ describe('App embed tests', () => {
|
|
|
1355
1453
|
...defaultViewConfig,
|
|
1356
1454
|
fullHeight: true,
|
|
1357
1455
|
lazyLoadingForFullHeight: true,
|
|
1456
|
+
lazyLoadingMargin: '10px',
|
|
1358
1457
|
} as AppViewConfig);
|
|
1359
1458
|
|
|
1360
1459
|
await appEmbed.render();
|
|
@@ -1375,6 +1474,7 @@ describe('App embed tests', () => {
|
|
|
1375
1474
|
...defaultViewConfig,
|
|
1376
1475
|
fullHeight: true,
|
|
1377
1476
|
lazyLoadingForFullHeight: true,
|
|
1477
|
+
lazyLoadingMargin: '10px',
|
|
1378
1478
|
} as AppViewConfig);
|
|
1379
1479
|
|
|
1380
1480
|
await appEmbed.render();
|
|
@@ -1402,6 +1502,7 @@ describe('App embed tests', () => {
|
|
|
1402
1502
|
...defaultViewConfig,
|
|
1403
1503
|
fullHeight: true,
|
|
1404
1504
|
lazyLoadingForFullHeight: true,
|
|
1505
|
+
lazyLoadingMargin: '10px',
|
|
1405
1506
|
} as AppViewConfig);
|
|
1406
1507
|
|
|
1407
1508
|
// Set the iframe before render
|
|
@@ -1527,13 +1628,33 @@ describe('App embed tests', () => {
|
|
|
1527
1628
|
|
|
1528
1629
|
await appEmbed.render();
|
|
1529
1630
|
const mockEvent = {
|
|
1530
|
-
data: 0, // This will make it use the
|
|
1631
|
+
data: 0, // This will make it use the default height
|
|
1531
1632
|
type: EmbedEvent.EmbedHeight,
|
|
1532
1633
|
};
|
|
1533
1634
|
appEmbed.updateIFrameHeight(mockEvent);
|
|
1534
1635
|
|
|
1535
|
-
// Should use the
|
|
1636
|
+
// Should use the default height
|
|
1536
1637
|
expect(mockIFrame.style.height).toBe('500px');
|
|
1537
1638
|
});
|
|
1538
1639
|
});
|
|
1539
1640
|
});
|
|
1641
|
+
|
|
1642
|
+
describe('App Embed Default Height and Minimum Height Handling', () => {
|
|
1643
|
+
test('should set default height to 500 when neither default height nor minimum height is provided', async () => {
|
|
1644
|
+
const appEmbed = new AppEmbed(getRootEl(), {
|
|
1645
|
+
...defaultViewConfig,
|
|
1646
|
+
fullHeight: true,
|
|
1647
|
+
} as AppViewConfig);
|
|
1648
|
+
await appEmbed.render();
|
|
1649
|
+
expect(appEmbed['defaultHeight']).toBe(500);
|
|
1650
|
+
});
|
|
1651
|
+
test('should set default height to 700 when default height is provided', async () => {
|
|
1652
|
+
const appEmbed = new AppEmbed(getRootEl(), {
|
|
1653
|
+
...defaultViewConfig,
|
|
1654
|
+
fullHeight: true,
|
|
1655
|
+
minimumHeight: 700,
|
|
1656
|
+
} as AppViewConfig);
|
|
1657
|
+
await appEmbed.render();
|
|
1658
|
+
expect(appEmbed['defaultHeight']).toBe(700);
|
|
1659
|
+
});
|
|
1660
|
+
});
|