@thoughtspot/visual-embed-sdk 1.44.1-test → 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/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.map +1 -1
- package/cjs/src/embed/app.js +3 -1
- package/cjs/src/embed/app.js.map +1 -1
- package/cjs/src/embed/app.spec.js +12 -5
- 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.spec.js +2 -2
- 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.map +1 -1
- package/cjs/src/embed/liveboard.js +3 -1
- package/cjs/src/embed/liveboard.js.map +1 -1
- package/cjs/src/embed/liveboard.spec.js +28 -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.spec.js +242 -66
- package/cjs/src/embed/ts-embed.spec.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/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-BXCUJ09L.js → index-CSFjfTVk.js} +1 -1
- package/dist/src/embed/app.d.ts.map +1 -1
- package/dist/src/embed/liveboard.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 +39 -5
- package/dist/tsembed-react.js +38 -4
- package/dist/tsembed.es.js +39 -5
- package/dist/tsembed.js +38 -4
- package/lib/package.json +6 -5
- 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.map +1 -1
- package/lib/src/embed/app.js +4 -2
- package/lib/src/embed/app.js.map +1 -1
- package/lib/src/embed/app.spec.js +12 -5
- 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.spec.js +2 -2
- 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.map +1 -1
- package/lib/src/embed/liveboard.js +4 -2
- package/lib/src/embed/liveboard.js.map +1 -1
- package/lib/src/embed/liveboard.spec.js +28 -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.spec.js +242 -66
- package/lib/src/embed/ts-embed.spec.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/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/auth.spec.ts +53 -51
- package/src/authToken.spec.ts +3 -3
- package/src/embed/app.spec.ts +12 -5
- package/src/embed/app.ts +4 -2
- package/src/embed/base.spec.ts +16 -20
- package/src/embed/bodyless-conversation.spec.ts +2 -2
- package/src/embed/conversation.spec.ts +2 -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 +30 -29
- package/src/embed/liveboard.ts +4 -2
- 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 +317 -76
- 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/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
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(() => ({
|
|
@@ -1130,13 +1130,13 @@ describe('App embed tests', () => {
|
|
|
1130
1130
|
let embedHeightCallback: any = () => { };
|
|
1131
1131
|
const onSpy = jest.spyOn(AppEmbed.prototype, 'on').mockImplementation((event, callback) => {
|
|
1132
1132
|
if (event === EmbedEvent.RouteChange) {
|
|
1133
|
-
callback({ data: { currentPath: '/answers' } }, jest.fn());
|
|
1133
|
+
callback({ type: EmbedEvent.RouteChange, data: { currentPath: '/answers' } } as any, jest.fn());
|
|
1134
1134
|
}
|
|
1135
1135
|
if (event === EmbedEvent.EmbedHeight) {
|
|
1136
1136
|
embedHeightCallback = callback;
|
|
1137
1137
|
}
|
|
1138
1138
|
if (event === EmbedEvent.EmbedIframeCenter) {
|
|
1139
|
-
callback({}, jest.fn());
|
|
1139
|
+
callback({ type: EmbedEvent.EmbedIframeCenter, data: {} } as any, jest.fn());
|
|
1140
1140
|
}
|
|
1141
1141
|
return null;
|
|
1142
1142
|
});
|
|
@@ -1146,6 +1146,7 @@ describe('App embed tests', () => {
|
|
|
1146
1146
|
...defaultViewConfig,
|
|
1147
1147
|
fullHeight: true,
|
|
1148
1148
|
lazyLoadingForFullHeight: true,
|
|
1149
|
+
lazyLoadingMargin: '10px',
|
|
1149
1150
|
} as AppViewConfig);
|
|
1150
1151
|
|
|
1151
1152
|
// Set the iframe before render
|
|
@@ -1227,7 +1228,7 @@ describe('App embed tests', () => {
|
|
|
1227
1228
|
},
|
|
1228
1229
|
});
|
|
1229
1230
|
await appEmbed.render();
|
|
1230
|
-
spyOn(logger, 'warn');
|
|
1231
|
+
jest.spyOn(logger, 'warn').mockImplementation(() => {});
|
|
1231
1232
|
appEmbed.navigateToPage(-1);
|
|
1232
1233
|
expect(logger.warn).toHaveBeenCalledWith(
|
|
1233
1234
|
'Path can only by a string when triggered without noReload',
|
|
@@ -1235,7 +1236,7 @@ describe('App embed tests', () => {
|
|
|
1235
1236
|
});
|
|
1236
1237
|
|
|
1237
1238
|
test('navigateToPage function use before render', async () => {
|
|
1238
|
-
spyOn(logger, 'log');
|
|
1239
|
+
jest.spyOn(logger, 'log').mockImplementation(() => {});
|
|
1239
1240
|
const appEmbed = new AppEmbed(getRootEl(), {
|
|
1240
1241
|
frameParams: {
|
|
1241
1242
|
width: '100%',
|
|
@@ -1317,6 +1318,7 @@ describe('App embed tests', () => {
|
|
|
1317
1318
|
...defaultViewConfig,
|
|
1318
1319
|
fullHeight: true,
|
|
1319
1320
|
lazyLoadingForFullHeight: true,
|
|
1321
|
+
lazyLoadingMargin: '10px',
|
|
1320
1322
|
} as AppViewConfig);
|
|
1321
1323
|
|
|
1322
1324
|
// Set the iframe before render
|
|
@@ -1393,6 +1395,7 @@ describe('App embed tests', () => {
|
|
|
1393
1395
|
...defaultViewConfig,
|
|
1394
1396
|
fullHeight: true,
|
|
1395
1397
|
lazyLoadingForFullHeight: true,
|
|
1398
|
+
lazyLoadingMargin: '10px',
|
|
1396
1399
|
} as AppViewConfig);
|
|
1397
1400
|
|
|
1398
1401
|
const mockTrigger = jest.spyOn(appEmbed, 'trigger');
|
|
@@ -1425,6 +1428,7 @@ describe('App embed tests', () => {
|
|
|
1425
1428
|
...defaultViewConfig,
|
|
1426
1429
|
fullHeight: true,
|
|
1427
1430
|
lazyLoadingForFullHeight: true,
|
|
1431
|
+
lazyLoadingMargin: '10px',
|
|
1428
1432
|
} as AppViewConfig);
|
|
1429
1433
|
|
|
1430
1434
|
const mockTrigger = jest.spyOn(appEmbed, 'trigger');
|
|
@@ -1449,6 +1453,7 @@ describe('App embed tests', () => {
|
|
|
1449
1453
|
...defaultViewConfig,
|
|
1450
1454
|
fullHeight: true,
|
|
1451
1455
|
lazyLoadingForFullHeight: true,
|
|
1456
|
+
lazyLoadingMargin: '10px',
|
|
1452
1457
|
} as AppViewConfig);
|
|
1453
1458
|
|
|
1454
1459
|
await appEmbed.render();
|
|
@@ -1469,6 +1474,7 @@ describe('App embed tests', () => {
|
|
|
1469
1474
|
...defaultViewConfig,
|
|
1470
1475
|
fullHeight: true,
|
|
1471
1476
|
lazyLoadingForFullHeight: true,
|
|
1477
|
+
lazyLoadingMargin: '10px',
|
|
1472
1478
|
} as AppViewConfig);
|
|
1473
1479
|
|
|
1474
1480
|
await appEmbed.render();
|
|
@@ -1496,6 +1502,7 @@ describe('App embed tests', () => {
|
|
|
1496
1502
|
...defaultViewConfig,
|
|
1497
1503
|
fullHeight: true,
|
|
1498
1504
|
lazyLoadingForFullHeight: true,
|
|
1505
|
+
lazyLoadingMargin: '10px',
|
|
1499
1506
|
} as AppViewConfig);
|
|
1500
1507
|
|
|
1501
1508
|
// Set the iframe before render
|
package/src/embed/app.ts
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
import { logger } from '../utils/logger';
|
|
12
|
-
import { calculateVisibleElementData, getQueryParamString, isUndefined } from '../utils';
|
|
12
|
+
import { calculateVisibleElementData, getQueryParamString, isUndefined, isValidCssMargin } from '../utils';
|
|
13
13
|
import {
|
|
14
14
|
Param,
|
|
15
15
|
DOMSelector,
|
|
@@ -761,7 +761,9 @@ export class AppEmbed extends V1Embed {
|
|
|
761
761
|
params[Param.fullHeight] = true;
|
|
762
762
|
if (this.viewConfig.lazyLoadingForFullHeight) {
|
|
763
763
|
params[Param.IsLazyLoadingForEmbedEnabled] = true;
|
|
764
|
-
|
|
764
|
+
if (isValidCssMargin(this.viewConfig.lazyLoadingMargin)) {
|
|
765
|
+
params[Param.RootMarginForLazyLoad] = this.viewConfig.lazyLoadingMargin;
|
|
766
|
+
}
|
|
765
767
|
}
|
|
766
768
|
}
|
|
767
769
|
|
package/src/embed/base.spec.ts
CHANGED
|
@@ -32,14 +32,14 @@ describe('Base TS Embed', () => {
|
|
|
32
32
|
thoughtSpotHost,
|
|
33
33
|
authType: index.AuthType.None,
|
|
34
34
|
}) as EventEmitter;
|
|
35
|
-
jest.spyOn(auth, 'postLoginService').mockImplementation(() => Promise.resolve(
|
|
35
|
+
jest.spyOn(auth, 'postLoginService').mockImplementation(() => Promise.resolve(undefined));
|
|
36
36
|
});
|
|
37
37
|
|
|
38
38
|
beforeEach(() => {
|
|
39
39
|
document.body.innerHTML = getDocumentBody();
|
|
40
40
|
});
|
|
41
41
|
|
|
42
|
-
test('Should show an alert when third party cookie access is blocked', (
|
|
42
|
+
test('Should show an alert when third party cookie access is blocked', () => {
|
|
43
43
|
const tsEmbed = new index.SearchEmbed(getRootEl(), {});
|
|
44
44
|
const iFrame: any = document.createElement('div');
|
|
45
45
|
iFrame.contentWindow = null;
|
|
@@ -59,18 +59,17 @@ describe('Base TS Embed', () => {
|
|
|
59
59
|
jest.spyOn(window, 'alert').mockImplementation(() => undefined);
|
|
60
60
|
authEE.on(auth.AuthStatus.FAILURE, (reason) => {
|
|
61
61
|
expect(reason).toEqual(auth.AuthFailureType.NO_COOKIE_ACCESS);
|
|
62
|
-
expect(window.alert).
|
|
62
|
+
expect(window.alert).toHaveBeenCalledWith(
|
|
63
63
|
'Third-party cookie access is blocked on this browser. Please allow third-party cookies for this to work properly. \nYou can use `suppressNoCookieAccessAlert` to suppress this message.',
|
|
64
64
|
);
|
|
65
|
-
done();
|
|
66
65
|
});
|
|
67
66
|
});
|
|
68
67
|
|
|
69
|
-
test('Should ignore cookie blocked alert if ignoreNoCookieAccess is true', async (
|
|
68
|
+
test('Should ignore cookie blocked alert if ignoreNoCookieAccess is true', async () => {
|
|
70
69
|
jest.spyOn(window, 'fetch').mockResolvedValue({
|
|
71
70
|
ok: true,
|
|
72
71
|
json: jest.fn().mockResolvedValue({}),
|
|
73
|
-
});
|
|
72
|
+
} as any);
|
|
74
73
|
const authEE = index.init({
|
|
75
74
|
thoughtSpotHost,
|
|
76
75
|
authType: index.AuthType.None,
|
|
@@ -96,7 +95,6 @@ describe('Base TS Embed', () => {
|
|
|
96
95
|
authEE.on(auth.AuthStatus.FAILURE, (reason) => {
|
|
97
96
|
expect(reason).toEqual(auth.AuthFailureType.NO_COOKIE_ACCESS);
|
|
98
97
|
expect(window.alert).not.toHaveBeenCalled();
|
|
99
|
-
done();
|
|
100
98
|
});
|
|
101
99
|
});
|
|
102
100
|
|
|
@@ -104,7 +102,7 @@ describe('Base TS Embed', () => {
|
|
|
104
102
|
jest.spyOn(window, 'fetch').mockResolvedValue({
|
|
105
103
|
ok: true,
|
|
106
104
|
json: jest.fn().mockResolvedValue({}),
|
|
107
|
-
});
|
|
105
|
+
} as any);
|
|
108
106
|
index.init({
|
|
109
107
|
thoughtSpotHost,
|
|
110
108
|
authType: index.AuthType.None,
|
|
@@ -161,7 +159,7 @@ describe('Base TS Embed', () => {
|
|
|
161
159
|
jest.spyOn(tokenizedFetchInstance, 'tokenizedFetch').mockResolvedValueOnce({
|
|
162
160
|
ok: true,
|
|
163
161
|
json: jest.fn().mockResolvedValue({}),
|
|
164
|
-
});
|
|
162
|
+
} as any);
|
|
165
163
|
index.init({
|
|
166
164
|
thoughtSpotHost,
|
|
167
165
|
authType: index.AuthType.TrustedAuthTokenCookieless,
|
|
@@ -229,7 +227,7 @@ describe('Base TS Embed', () => {
|
|
|
229
227
|
jest.spyOn(tokenizedFetchInstance, 'tokenizedFetch').mockResolvedValueOnce({
|
|
230
228
|
ok: true,
|
|
231
229
|
json: jest.fn().mockResolvedValue({}),
|
|
232
|
-
});
|
|
230
|
+
} as any);
|
|
233
231
|
index.init({
|
|
234
232
|
thoughtSpotHost,
|
|
235
233
|
authType: index.AuthType.None,
|
|
@@ -388,7 +386,7 @@ describe('Base TS Embed', () => {
|
|
|
388
386
|
});
|
|
389
387
|
});
|
|
390
388
|
|
|
391
|
-
test('handleAuth notifies for SDK auth failure', (
|
|
389
|
+
test('handleAuth notifies for SDK auth failure', () => {
|
|
392
390
|
jest.spyOn(auth, 'authenticate').mockResolvedValue(false);
|
|
393
391
|
const authEmitter = index.init({
|
|
394
392
|
thoughtSpotHost,
|
|
@@ -398,11 +396,10 @@ describe('Base TS Embed', () => {
|
|
|
398
396
|
});
|
|
399
397
|
authEmitter.on(auth.AuthStatus.FAILURE, (reason) => {
|
|
400
398
|
expect(reason).toBe(auth.AuthFailureType.SDK);
|
|
401
|
-
done();
|
|
402
399
|
});
|
|
403
400
|
});
|
|
404
401
|
|
|
405
|
-
test('handleAuth notifies for SDK auth success', (
|
|
402
|
+
test('handleAuth notifies for SDK auth success', () => {
|
|
406
403
|
jest.spyOn(auth, 'authenticate').mockResolvedValue(true);
|
|
407
404
|
const failureCallback = jest.fn();
|
|
408
405
|
const authEmitter = index.init({
|
|
@@ -414,16 +411,15 @@ describe('Base TS Embed', () => {
|
|
|
414
411
|
|
|
415
412
|
authEmitter.on(auth.AuthStatus.FAILURE, failureCallback);
|
|
416
413
|
authEmitter.on(auth.AuthStatus.SDK_SUCCESS, (...args) => {
|
|
417
|
-
expect(failureCallback).not.
|
|
414
|
+
expect(failureCallback).not.toHaveBeenCalled();
|
|
418
415
|
expect(args.length).toBe(0);
|
|
419
|
-
done();
|
|
420
416
|
});
|
|
421
417
|
});
|
|
422
418
|
|
|
423
419
|
test('Logout method should disable autoLogin', () => {
|
|
424
420
|
jest.spyOn(window, 'fetch').mockResolvedValueOnce({
|
|
425
421
|
type: 'opaque',
|
|
426
|
-
});
|
|
422
|
+
} as any);
|
|
427
423
|
index.init({
|
|
428
424
|
thoughtSpotHost,
|
|
429
425
|
authType: index.AuthType.None,
|
|
@@ -461,7 +457,7 @@ describe('Base TS Embed', () => {
|
|
|
461
457
|
index.init({
|
|
462
458
|
authType: index.AuthType.None,
|
|
463
459
|
} as EmbedConfig);
|
|
464
|
-
}).
|
|
460
|
+
}).toThrow();
|
|
465
461
|
});
|
|
466
462
|
|
|
467
463
|
test('config sanity, no username in trusted auth', () => {
|
|
@@ -470,7 +466,7 @@ describe('Base TS Embed', () => {
|
|
|
470
466
|
authType: index.AuthType.TrustedAuthToken,
|
|
471
467
|
thoughtSpotHost,
|
|
472
468
|
} as EmbedConfig);
|
|
473
|
-
}).
|
|
469
|
+
}).toThrow();
|
|
474
470
|
});
|
|
475
471
|
|
|
476
472
|
test('config sanity, no authEndpoint and getAuthToken', () => {
|
|
@@ -480,7 +476,7 @@ describe('Base TS Embed', () => {
|
|
|
480
476
|
thoughtSpotHost,
|
|
481
477
|
username: 'test',
|
|
482
478
|
});
|
|
483
|
-
}).
|
|
479
|
+
}).toThrow();
|
|
484
480
|
});
|
|
485
481
|
test('config backward compat, should assign inPopup when noRedirect is set', () => {
|
|
486
482
|
index.init({
|
|
@@ -532,6 +528,6 @@ describe('Init tests', () => {
|
|
|
532
528
|
thoughtSpotHost,
|
|
533
529
|
authType: index.AuthType.None,
|
|
534
530
|
});
|
|
535
|
-
expect(resetService.resetAllCachedServices).
|
|
531
|
+
expect(resetService.resetAllCachedServices).toHaveBeenCalled();
|
|
536
532
|
});
|
|
537
533
|
});
|
|
@@ -22,8 +22,8 @@ describe('SpotterAgentEmbed', () => {
|
|
|
22
22
|
thoughtSpotHost,
|
|
23
23
|
authType: AuthType.None,
|
|
24
24
|
});
|
|
25
|
-
jest.spyOn(authInstance, 'postLoginService').mockImplementation(() => Promise.resolve(
|
|
26
|
-
spyOn(window, 'alert');
|
|
25
|
+
jest.spyOn(authInstance, 'postLoginService').mockImplementation(() => Promise.resolve(undefined));
|
|
26
|
+
jest.spyOn(window, 'alert').mockImplementation(() => undefined);
|
|
27
27
|
document.body.innerHTML = getDocumentBody();
|
|
28
28
|
});
|
|
29
29
|
|
|
@@ -19,8 +19,8 @@ beforeAll(() => {
|
|
|
19
19
|
thoughtSpotHost,
|
|
20
20
|
authType: AuthType.None,
|
|
21
21
|
});
|
|
22
|
-
jest.spyOn(authInstance, 'postLoginService').mockImplementation(() => Promise.resolve(
|
|
23
|
-
spyOn(window, 'alert');
|
|
22
|
+
jest.spyOn(authInstance, 'postLoginService').mockImplementation(() => Promise.resolve(undefined));
|
|
23
|
+
jest.spyOn(window, 'alert');
|
|
24
24
|
document.body.innerHTML = getDocumentBody();
|
|
25
25
|
});
|
|
26
26
|
|