@thoughtspot/visual-embed-sdk 1.45.1 → 1.45.3
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 +1 -1
- 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/css-variables.d.ts +48 -0
- package/cjs/src/css-variables.d.ts.map +1 -1
- package/cjs/src/embed/app.d.ts +37 -0
- package/cjs/src/embed/app.d.ts.map +1 -1
- package/cjs/src/embed/app.js +37 -1
- package/cjs/src/embed/app.js.map +1 -1
- package/cjs/src/embed/app.spec.js +24 -0
- package/cjs/src/embed/app.spec.js.map +1 -1
- package/cjs/src/embed/conversation.d.ts +127 -9
- package/cjs/src/embed/conversation.d.ts.map +1 -1
- package/cjs/src/embed/conversation.js +41 -18
- package/cjs/src/embed/conversation.js.map +1 -1
- package/cjs/src/embed/conversation.spec.js +96 -3
- package/cjs/src/embed/conversation.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 +40 -3
- package/cjs/src/embed/liveboard.d.ts.map +1 -1
- package/cjs/src/embed/liveboard.js +40 -12
- package/cjs/src/embed/liveboard.js.map +1 -1
- package/cjs/src/embed/liveboard.spec.js +180 -8
- 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/errors.d.ts +1 -0
- package/cjs/src/errors.d.ts.map +1 -1
- package/cjs/src/errors.js +1 -0
- package/cjs/src/errors.js.map +1 -1
- package/cjs/src/index.d.ts +3 -3
- 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 +356 -42
- package/cjs/src/types.d.ts.map +1 -1
- package/cjs/src/types.js +227 -20
- package/cjs/src/types.js.map +1 -1
- package/cjs/src/utils/graphql/answerService/answer-queries.d.ts +1 -0
- package/cjs/src/utils/graphql/answerService/answer-queries.d.ts.map +1 -1
- package/cjs/src/utils/graphql/answerService/answer-queries.js +23 -1
- package/cjs/src/utils/graphql/answerService/answer-queries.js.map +1 -1
- package/cjs/src/utils/graphql/answerService/answerService.d.ts +2 -1
- package/cjs/src/utils/graphql/answerService/answerService.d.ts.map +1 -1
- package/cjs/src/utils/graphql/answerService/answerService.js +9 -1
- package/cjs/src/utils/graphql/answerService/answerService.js.map +1 -1
- package/cjs/src/utils/graphql/answerService/answerService.spec.js +73 -0
- package/cjs/src/utils/graphql/answerService/answerService.spec.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 +20 -1
- package/cjs/src/utils.d.ts.map +1 -1
- package/cjs/src/utils.js +40 -1
- package/cjs/src/utils.js.map +1 -1
- package/cjs/src/utils.spec.js +49 -0
- package/cjs/src/utils.spec.js.map +1 -1
- package/dist/{index-Dgzjq7qH.js → index-BuwECGdm.js} +1 -1
- package/dist/src/authToken.d.ts +1 -1
- package/dist/src/authToken.d.ts.map +1 -1
- package/dist/src/css-variables.d.ts +48 -0
- package/dist/src/css-variables.d.ts.map +1 -1
- package/dist/src/embed/app.d.ts +37 -0
- package/dist/src/embed/app.d.ts.map +1 -1
- package/dist/src/embed/conversation.d.ts +127 -9
- package/dist/src/embed/conversation.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 +40 -3
- 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/errors.d.ts +1 -0
- package/dist/src/errors.d.ts.map +1 -1
- package/dist/src/index.d.ts +3 -3
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/types.d.ts +356 -42
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/utils/graphql/answerService/answer-queries.d.ts +1 -0
- package/dist/src/utils/graphql/answerService/answer-queries.d.ts.map +1 -1
- package/dist/src/utils/graphql/answerService/answerService.d.ts +2 -1
- package/dist/src/utils/graphql/answerService/answerService.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 +20 -1
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/tsembed-react.es.js +501 -98
- package/dist/tsembed-react.js +500 -97
- package/dist/tsembed.es.js +516 -113
- package/dist/tsembed.js +29956 -29553
- package/dist/visual-embed-sdk-react-full.d.ts +819 -282
- package/dist/visual-embed-sdk-react.d.ts +818 -281
- package/dist/visual-embed-sdk.d.ts +882 -321
- package/lib/package.json +1 -1
- 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/css-variables.d.ts +48 -0
- package/lib/src/css-variables.d.ts.map +1 -1
- package/lib/src/embed/app.d.ts +37 -0
- package/lib/src/embed/app.d.ts.map +1 -1
- package/lib/src/embed/app.js +39 -3
- package/lib/src/embed/app.js.map +1 -1
- package/lib/src/embed/app.spec.js +24 -0
- package/lib/src/embed/app.spec.js.map +1 -1
- package/lib/src/embed/conversation.d.ts +127 -9
- package/lib/src/embed/conversation.d.ts.map +1 -1
- package/lib/src/embed/conversation.js +42 -19
- package/lib/src/embed/conversation.js.map +1 -1
- package/lib/src/embed/conversation.spec.js +96 -3
- package/lib/src/embed/conversation.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 +40 -3
- package/lib/src/embed/liveboard.d.ts.map +1 -1
- package/lib/src/embed/liveboard.js +41 -13
- package/lib/src/embed/liveboard.js.map +1 -1
- package/lib/src/embed/liveboard.spec.js +180 -8
- 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/errors.d.ts +1 -0
- package/lib/src/errors.d.ts.map +1 -1
- package/lib/src/errors.js +1 -0
- package/lib/src/errors.js.map +1 -1
- package/lib/src/index.d.ts +3 -3
- package/lib/src/index.d.ts.map +1 -1
- package/lib/src/index.js +2 -2
- package/lib/src/index.js.map +1 -1
- package/lib/src/types.d.ts +356 -42
- package/lib/src/types.d.ts.map +1 -1
- package/lib/src/types.js +226 -19
- package/lib/src/types.js.map +1 -1
- package/lib/src/utils/graphql/answerService/answer-queries.d.ts +1 -0
- package/lib/src/utils/graphql/answerService/answer-queries.d.ts.map +1 -1
- package/lib/src/utils/graphql/answerService/answer-queries.js +22 -0
- package/lib/src/utils/graphql/answerService/answer-queries.js.map +1 -1
- package/lib/src/utils/graphql/answerService/answerService.d.ts +2 -1
- package/lib/src/utils/graphql/answerService/answerService.d.ts.map +1 -1
- package/lib/src/utils/graphql/answerService/answerService.js +9 -1
- package/lib/src/utils/graphql/answerService/answerService.js.map +1 -1
- package/lib/src/utils/graphql/answerService/answerService.spec.js +73 -0
- package/lib/src/utils/graphql/answerService/answerService.spec.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 +20 -1
- package/lib/src/utils.d.ts.map +1 -1
- package/lib/src/utils.js +36 -0
- package/lib/src/utils.js.map +1 -1
- package/lib/src/utils.spec.js +50 -1
- package/lib/src/utils.spec.js.map +1 -1
- package/package.json +1 -1
- package/src/authToken.spec.ts +91 -2
- package/src/authToken.ts +2 -2
- package/src/css-variables.ts +60 -0
- package/src/embed/app.spec.ts +32 -0
- package/src/embed/app.ts +97 -1
- package/src/embed/conversation.spec.ts +117 -3
- package/src/embed/conversation.ts +188 -29
- 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 +264 -10
- package/src/embed/liveboard.ts +105 -14
- package/src/embed/ts-embed.spec.ts +184 -8
- package/src/embed/ts-embed.ts +81 -24
- package/src/errors.ts +1 -0
- package/src/index.ts +7 -1
- package/src/types.ts +364 -40
- package/src/utils/graphql/answerService/answer-queries.ts +23 -0
- package/src/utils/graphql/answerService/answerService.spec.ts +87 -0
- package/src/utils/graphql/answerService/answerService.ts +13 -1
- package/src/utils/processTrigger.ts +6 -3
- package/src/utils.spec.ts +56 -0
- package/src/utils.ts +44 -0
|
@@ -24,6 +24,7 @@ const contracts_1 = require("./hostEventClient/contracts");
|
|
|
24
24
|
const sessionInfoService = tslib_1.__importStar(require("../utils/sessionInfoService"));
|
|
25
25
|
const authToken = tslib_1.__importStar(require("../authToken"));
|
|
26
26
|
const apiIntercept = tslib_1.__importStar(require("../api-intercept"));
|
|
27
|
+
const processData = tslib_1.__importStar(require("../utils/processData"));
|
|
27
28
|
jest.mock('../utils/processTrigger');
|
|
28
29
|
const mockProcessTrigger = processTrigger_1.processTrigger;
|
|
29
30
|
const mockHandleInterceptEvent = jest.spyOn(apiIntercept, 'handleInterceptEvent');
|
|
@@ -140,7 +141,7 @@ describe('Unit test case for ts embed', () => {
|
|
|
140
141
|
expect(mockProcessTrigger).toHaveBeenCalledWith((0, test_utils_1.getIFrameEl)(), types_1.HostEvent.UIPassthrough, 'http://tshost', {
|
|
141
142
|
parameters: payload,
|
|
142
143
|
type: contracts_1.UIPassthroughEvent.PinAnswerToLiveboard,
|
|
143
|
-
});
|
|
144
|
+
}, undefined);
|
|
144
145
|
});
|
|
145
146
|
});
|
|
146
147
|
test('Host event with empty param', async () => {
|
|
@@ -152,7 +153,7 @@ describe('Unit test case for ts embed', () => {
|
|
|
152
153
|
mockProcessTrigger.mockResolvedValue({ session: 'test' });
|
|
153
154
|
await (0, test_utils_1.executeAfterWait)(async () => {
|
|
154
155
|
await liveboardEmbed.trigger(types_1.HostEvent.Save);
|
|
155
|
-
expect(mockProcessTrigger).toHaveBeenCalledWith((0, test_utils_1.getIFrameEl)(), types_1.HostEvent.Save, 'http://tshost', {});
|
|
156
|
+
expect(mockProcessTrigger).toHaveBeenCalledWith((0, test_utils_1.getIFrameEl)(), types_1.HostEvent.Save, 'http://tshost', {}, undefined);
|
|
156
157
|
});
|
|
157
158
|
});
|
|
158
159
|
test('Host event with falsy param', async () => {
|
|
@@ -164,7 +165,7 @@ describe('Unit test case for ts embed', () => {
|
|
|
164
165
|
mockProcessTrigger.mockResolvedValue({ session: 'test' });
|
|
165
166
|
await (0, test_utils_1.executeAfterWait)(async () => {
|
|
166
167
|
await liveboardEmbed.trigger(types_1.HostEvent.Save, false);
|
|
167
|
-
expect(mockProcessTrigger).toHaveBeenCalledWith((0, test_utils_1.getIFrameEl)(), types_1.HostEvent.Save, 'http://tshost', false);
|
|
168
|
+
expect(mockProcessTrigger).toHaveBeenCalledWith((0, test_utils_1.getIFrameEl)(), types_1.HostEvent.Save, 'http://tshost', false, undefined);
|
|
168
169
|
});
|
|
169
170
|
});
|
|
170
171
|
test('should set proper height, width and min-height to iframe', async () => {
|
|
@@ -1120,7 +1121,7 @@ describe('Unit test case for ts embed', () => {
|
|
|
1120
1121
|
const { mockPreauthInfoFetch, iFrame, } = await setup(true);
|
|
1121
1122
|
expect(mockPreauthInfoFetch).toHaveBeenCalledTimes(1);
|
|
1122
1123
|
await (0, test_utils_1.executeAfterWait)(() => {
|
|
1123
|
-
expect(mockProcessTrigger).toHaveBeenCalledWith(iFrame, types_1.HostEvent.InfoSuccess, 'http://tshost', expect.objectContaining({ info: expect.any(Object) }));
|
|
1124
|
+
expect(mockProcessTrigger).toHaveBeenCalledWith(iFrame, types_1.HostEvent.InfoSuccess, 'http://tshost', expect.objectContaining({ info: expect.any(Object) }), undefined);
|
|
1124
1125
|
});
|
|
1125
1126
|
});
|
|
1126
1127
|
test('should not call InfoSuccess Event if overrideOrgId is true', async () => {
|
|
@@ -1223,28 +1224,28 @@ describe('Unit test case for ts embed', () => {
|
|
|
1223
1224
|
const { mockGetPreauthInfo } = await setupPreauthTest('AppEmbed', undefined);
|
|
1224
1225
|
await (0, test_utils_1.executeAfterWait)(() => {
|
|
1225
1226
|
expect(mockGetPreauthInfo).toHaveBeenCalledTimes(1);
|
|
1226
|
-
expect(mockProcessTrigger).toHaveBeenCalledWith(expect.any(Object), types_1.HostEvent.InfoSuccess, 'http://tshost', expect.objectContaining({ info: expect.any(Object) }));
|
|
1227
|
+
expect(mockProcessTrigger).toHaveBeenCalledWith(expect.any(Object), types_1.HostEvent.InfoSuccess, 'http://tshost', expect.objectContaining({ info: expect.any(Object) }), undefined);
|
|
1227
1228
|
});
|
|
1228
1229
|
});
|
|
1229
1230
|
test('should enable preauth cache for FullAppEmbed with showPrimaryNavbar = false', async () => {
|
|
1230
1231
|
const { mockGetPreauthInfo } = await setupPreauthTest('AppEmbed', false);
|
|
1231
1232
|
await (0, test_utils_1.executeAfterWait)(() => {
|
|
1232
1233
|
expect(mockGetPreauthInfo).toHaveBeenCalledTimes(1);
|
|
1233
|
-
expect(mockProcessTrigger).toHaveBeenCalledWith(expect.any(Object), types_1.HostEvent.InfoSuccess, 'http://tshost', expect.objectContaining({ info: expect.any(Object) }));
|
|
1234
|
+
expect(mockProcessTrigger).toHaveBeenCalledWith(expect.any(Object), types_1.HostEvent.InfoSuccess, 'http://tshost', expect.objectContaining({ info: expect.any(Object) }), undefined);
|
|
1234
1235
|
});
|
|
1235
1236
|
});
|
|
1236
1237
|
test('should enable preauth cache for SearchEmbed regardless of showPrimaryNavbar', async () => {
|
|
1237
1238
|
const { mockGetPreauthInfo } = await setupPreauthTest('SearchEmbed', true);
|
|
1238
1239
|
await (0, test_utils_1.executeAfterWait)(() => {
|
|
1239
1240
|
expect(mockGetPreauthInfo).toHaveBeenCalledTimes(1);
|
|
1240
|
-
expect(mockProcessTrigger).toHaveBeenCalledWith(expect.any(Object), types_1.HostEvent.InfoSuccess, 'http://tshost', expect.objectContaining({ info: expect.any(Object) }));
|
|
1241
|
+
expect(mockProcessTrigger).toHaveBeenCalledWith(expect.any(Object), types_1.HostEvent.InfoSuccess, 'http://tshost', expect.objectContaining({ info: expect.any(Object) }), undefined);
|
|
1241
1242
|
});
|
|
1242
1243
|
});
|
|
1243
1244
|
test('should enable preauth cache for SearchEmbed (verifies fix for embed type regression)', async () => {
|
|
1244
1245
|
const { mockGetPreauthInfo } = await setupPreauthTest('SearchEmbed', false);
|
|
1245
1246
|
await (0, test_utils_1.executeAfterWait)(() => {
|
|
1246
1247
|
expect(mockGetPreauthInfo).toHaveBeenCalledTimes(1);
|
|
1247
|
-
expect(mockProcessTrigger).toHaveBeenCalledWith(expect.any(Object), types_1.HostEvent.InfoSuccess, 'http://tshost', expect.objectContaining({ info: expect.any(Object) }));
|
|
1248
|
+
expect(mockProcessTrigger).toHaveBeenCalledWith(expect.any(Object), types_1.HostEvent.InfoSuccess, 'http://tshost', expect.objectContaining({ info: expect.any(Object) }), undefined);
|
|
1248
1249
|
});
|
|
1249
1250
|
});
|
|
1250
1251
|
test('should disable preauth cache for FullAppEmbed with overrideOrgId (combined condition)', async () => {
|
|
@@ -2330,7 +2331,7 @@ describe('Unit test case for ts embed', () => {
|
|
|
2330
2331
|
jest.clearAllMocks();
|
|
2331
2332
|
document.body.innerHTML = (0, test_utils_1.getDocumentBody)();
|
|
2332
2333
|
mockPort.postMessage.mockClear();
|
|
2333
|
-
jest.spyOn(authToken, 'getAuthenticationToken').mockResolvedValue('test-token');
|
|
2334
|
+
jest.spyOn(authToken, 'getAuthenticationToken').mockResolvedValue('mock-test-token-placeholder');
|
|
2334
2335
|
jest.spyOn(baseInstance, 'handleAuth').mockImplementation(() => Promise.resolve(true));
|
|
2335
2336
|
jest.spyOn(baseInstance, 'notifyAuthFailure').mockImplementation(() => { });
|
|
2336
2337
|
});
|
|
@@ -2354,7 +2355,7 @@ describe('Unit test case for ts embed', () => {
|
|
|
2354
2355
|
expect(baseInstance.handleAuth).toHaveBeenCalledTimes(1);
|
|
2355
2356
|
expect(mockPort.postMessage).toHaveBeenCalledWith({
|
|
2356
2357
|
type: index_1.EmbedEvent.AuthExpire,
|
|
2357
|
-
data: { authToken: 'test-token' },
|
|
2358
|
+
data: { authToken: 'mock-test-token-placeholder' },
|
|
2358
2359
|
});
|
|
2359
2360
|
});
|
|
2360
2361
|
});
|
|
@@ -2383,7 +2384,7 @@ describe('Unit test case for ts embed', () => {
|
|
|
2383
2384
|
expect(baseInstance.handleAuth).toHaveBeenCalledTimes(1);
|
|
2384
2385
|
expect(mockPort.postMessage).toHaveBeenCalledWith({
|
|
2385
2386
|
type: index_1.EmbedEvent.AuthExpire,
|
|
2386
|
-
data: { authToken: 'test-token' },
|
|
2387
|
+
data: { authToken: 'mock-test-token-placeholder' },
|
|
2387
2388
|
});
|
|
2388
2389
|
});
|
|
2389
2390
|
});
|
|
@@ -2427,6 +2428,83 @@ describe('Unit test case for ts embed', () => {
|
|
|
2427
2428
|
expect(baseInstance.notifyAuthFailure).toHaveBeenCalledWith(authInstance.AuthFailureType.EXPIRY);
|
|
2428
2429
|
});
|
|
2429
2430
|
});
|
|
2431
|
+
describe('AutoLogin behavior in tokenRefresh', () => {
|
|
2432
|
+
const mockPort = { postMessage: jest.fn() };
|
|
2433
|
+
const mockEmbedEventPayload = { type: index_1.EmbedEvent.RefreshAuthToken, data: {} };
|
|
2434
|
+
beforeEach(() => {
|
|
2435
|
+
jest.clearAllMocks();
|
|
2436
|
+
document.body.innerHTML = (0, test_utils_1.getDocumentBody)();
|
|
2437
|
+
mockPort.postMessage.mockClear();
|
|
2438
|
+
jest.spyOn(authToken, 'getAuthenticationToken').mockResolvedValue('mock-test-token-placeholder');
|
|
2439
|
+
jest.spyOn(processData, 'processAuthFailure').mockImplementation(() => ({}));
|
|
2440
|
+
jest.spyOn(logger_1.logger, 'error').mockImplementation(() => { });
|
|
2441
|
+
});
|
|
2442
|
+
const renderAndTriggerRefreshAuthToken = async () => {
|
|
2443
|
+
const spotterEmbed = new index_1.SpotterEmbed((0, test_utils_1.getRootEl)(), {
|
|
2444
|
+
worksheetId: 'test-worksheet',
|
|
2445
|
+
searchOptions: {
|
|
2446
|
+
searchQuery: 'test query',
|
|
2447
|
+
},
|
|
2448
|
+
});
|
|
2449
|
+
await spotterEmbed.render();
|
|
2450
|
+
await (0, test_utils_1.executeAfterWait)(() => {
|
|
2451
|
+
const iframe = (0, test_utils_1.getIFrameEl)();
|
|
2452
|
+
(0, test_utils_1.postMessageToParent)(iframe.contentWindow, mockEmbedEventPayload, mockPort);
|
|
2453
|
+
});
|
|
2454
|
+
};
|
|
2455
|
+
test('Cookieless with autoLogin undefined should default to true and refresh token', async () => {
|
|
2456
|
+
(0, index_1.init)({
|
|
2457
|
+
thoughtSpotHost: 'tshost',
|
|
2458
|
+
authType: index_1.AuthType.TrustedAuthTokenCookieless,
|
|
2459
|
+
// autoLogin undefined
|
|
2460
|
+
});
|
|
2461
|
+
await renderAndTriggerRefreshAuthToken();
|
|
2462
|
+
await (0, test_utils_1.executeAfterWait)(() => {
|
|
2463
|
+
expect(authToken.getAuthenticationToken).toHaveBeenCalledWith(expect.any(Object), true);
|
|
2464
|
+
});
|
|
2465
|
+
});
|
|
2466
|
+
test('Cookieless with autoLogin true should refresh token', async () => {
|
|
2467
|
+
(0, index_1.init)({
|
|
2468
|
+
thoughtSpotHost: 'tshost',
|
|
2469
|
+
authType: index_1.AuthType.TrustedAuthTokenCookieless,
|
|
2470
|
+
autoLogin: true,
|
|
2471
|
+
});
|
|
2472
|
+
await renderAndTriggerRefreshAuthToken();
|
|
2473
|
+
await (0, test_utils_1.executeAfterWait)(() => {
|
|
2474
|
+
expect(authToken.getAuthenticationToken).toHaveBeenCalledWith(expect.any(Object), true);
|
|
2475
|
+
});
|
|
2476
|
+
});
|
|
2477
|
+
test('Cookieless with autoLogin false should not refresh token', async () => {
|
|
2478
|
+
(0, index_1.init)({
|
|
2479
|
+
thoughtSpotHost: 'tshost',
|
|
2480
|
+
authType: index_1.AuthType.TrustedAuthTokenCookieless,
|
|
2481
|
+
autoLogin: false,
|
|
2482
|
+
});
|
|
2483
|
+
await renderAndTriggerRefreshAuthToken();
|
|
2484
|
+
await (0, test_utils_1.executeAfterWait)(() => {
|
|
2485
|
+
expect(authToken.getAuthenticationToken).not.toHaveBeenCalled();
|
|
2486
|
+
expect(mockPort.postMessage).not.toHaveBeenCalled();
|
|
2487
|
+
});
|
|
2488
|
+
});
|
|
2489
|
+
test('Should handle error when getAuthenticationToken fails', async () => {
|
|
2490
|
+
const error = new Error('Token fetch failed');
|
|
2491
|
+
jest.spyOn(authToken, 'getAuthenticationToken').mockRejectedValue(error);
|
|
2492
|
+
(0, index_1.init)({
|
|
2493
|
+
thoughtSpotHost: 'tshost',
|
|
2494
|
+
authType: index_1.AuthType.TrustedAuthTokenCookieless,
|
|
2495
|
+
autoLogin: true,
|
|
2496
|
+
});
|
|
2497
|
+
await renderAndTriggerRefreshAuthToken();
|
|
2498
|
+
await (0, test_utils_1.executeAfterWait)(() => {
|
|
2499
|
+
expect(authToken.getAuthenticationToken).toHaveBeenCalledWith(expect.any(Object), true);
|
|
2500
|
+
// Check that logger.error was called with the token refresh error
|
|
2501
|
+
const errorCalls = logger_1.logger.error.mock.calls.filter((call) => { var _a, _b; return ((_a = call[0]) === null || _a === void 0 ? void 0 : _a.includes(errors_1.ERROR_MESSAGE.INVALID_TOKEN_ERROR)) && ((_b = call[0]) === null || _b === void 0 ? void 0 : _b.includes('Token fetch failed')); });
|
|
2502
|
+
expect(errorCalls.length).toBeGreaterThan(0);
|
|
2503
|
+
expect(processData.processAuthFailure).toHaveBeenCalledWith(error, expect.any(Element));
|
|
2504
|
+
expect(mockPort.postMessage).not.toHaveBeenCalled();
|
|
2505
|
+
});
|
|
2506
|
+
});
|
|
2507
|
+
});
|
|
2430
2508
|
describe('Fullscreen Change Handler', () => {
|
|
2431
2509
|
beforeEach(() => {
|
|
2432
2510
|
document.body.innerHTML = (0, test_utils_1.getDocumentBody)();
|
|
@@ -2614,6 +2692,47 @@ describe('Unit test case for ts embed', () => {
|
|
|
2614
2692
|
searchEmbed['executeAfterEmbedContainerLoaded'](callback3);
|
|
2615
2693
|
expect(callback3).toHaveBeenCalledTimes(1);
|
|
2616
2694
|
});
|
|
2695
|
+
describe('getCurrentContext', () => {
|
|
2696
|
+
const mockContext = {
|
|
2697
|
+
stack: [
|
|
2698
|
+
{
|
|
2699
|
+
name: 'Liveboard',
|
|
2700
|
+
type: 'Liveboard',
|
|
2701
|
+
objectIds: { liveboardId: 'lb-123' },
|
|
2702
|
+
},
|
|
2703
|
+
],
|
|
2704
|
+
currentContext: {
|
|
2705
|
+
name: 'Liveboard',
|
|
2706
|
+
type: 'Liveboard',
|
|
2707
|
+
objectIds: { liveboardId: 'lb-123' },
|
|
2708
|
+
},
|
|
2709
|
+
};
|
|
2710
|
+
test('should return context when embed container is already loaded', async () => {
|
|
2711
|
+
const searchEmbed = new index_1.SearchEmbed((0, test_utils_1.getRootEl)(), defaultViewConfig);
|
|
2712
|
+
searchEmbed.isEmbedContainerLoaded = true;
|
|
2713
|
+
const triggerSpy = jest.spyOn(searchEmbed, 'trigger')
|
|
2714
|
+
.mockResolvedValue(mockContext);
|
|
2715
|
+
const context = await searchEmbed.getCurrentContext();
|
|
2716
|
+
expect(context).toEqual(mockContext);
|
|
2717
|
+
expect(triggerSpy).toHaveBeenCalledWith(types_1.HostEvent.GetPageContext, {});
|
|
2718
|
+
});
|
|
2719
|
+
test('should wait for embed container to load before returning context', async () => {
|
|
2720
|
+
const searchEmbed = new index_1.SearchEmbed((0, test_utils_1.getRootEl)(), defaultViewConfig);
|
|
2721
|
+
searchEmbed.isEmbedContainerLoaded = false;
|
|
2722
|
+
const triggerSpy = jest.spyOn(searchEmbed, 'trigger')
|
|
2723
|
+
.mockResolvedValue(mockContext);
|
|
2724
|
+
const contextPromise = searchEmbed.getCurrentContext();
|
|
2725
|
+
// Context should not be resolved yet
|
|
2726
|
+
await (0, test_utils_1.executeAfterWait)(() => {
|
|
2727
|
+
expect(triggerSpy).not.toHaveBeenCalled();
|
|
2728
|
+
}, 10);
|
|
2729
|
+
// Simulate embed container becoming ready
|
|
2730
|
+
searchEmbed['executeEmbedContainerReadyCallbacks']();
|
|
2731
|
+
const context = await contextPromise;
|
|
2732
|
+
expect(context).toEqual(mockContext);
|
|
2733
|
+
expect(triggerSpy).toHaveBeenCalledWith(types_1.HostEvent.GetPageContext, {});
|
|
2734
|
+
});
|
|
2735
|
+
});
|
|
2617
2736
|
test('should register embed container event handlers during construction', () => {
|
|
2618
2737
|
const searchEmbed = new index_1.SearchEmbed((0, test_utils_1.getRootEl)(), defaultViewConfig);
|
|
2619
2738
|
// Check that the event handlers are registered
|
|
@@ -3328,7 +3447,7 @@ describe('Destroy error handling', () => {
|
|
|
3328
3447
|
appEmbed.destroy();
|
|
3329
3448
|
}).not.toThrow();
|
|
3330
3449
|
expect(logSpy).toHaveBeenCalledWith('Error destroying TS Embed', expect.any(Error));
|
|
3331
|
-
logSpy.
|
|
3450
|
+
logSpy.mockReset();
|
|
3332
3451
|
});
|
|
3333
3452
|
});
|
|
3334
3453
|
describe('Fullscreen change handler behavior', () => {
|
|
@@ -3362,7 +3481,7 @@ describe('Fullscreen change handler behavior', () => {
|
|
|
3362
3481
|
const event = new Event('fullscreenchange');
|
|
3363
3482
|
document.dispatchEvent(event);
|
|
3364
3483
|
await (0, test_utils_1.executeAfterWait)(() => {
|
|
3365
|
-
expect(mockProcessTrigger).
|
|
3484
|
+
expect(mockProcessTrigger).toHaveBeenLastCalledWith(expect.any(Object), types_1.HostEvent.ExitPresentMode, expect.any(String), expect.any(Object), undefined);
|
|
3366
3485
|
});
|
|
3367
3486
|
});
|
|
3368
3487
|
test('should not trigger ExitPresentMode when entering fullscreen', async () => {
|
|
@@ -3429,9 +3548,9 @@ describe('ShowPreRender with UpdateEmbedParams', () => {
|
|
|
3429
3548
|
});
|
|
3430
3549
|
embed2.showPreRender();
|
|
3431
3550
|
await (0, test_utils_1.executeAfterWait)(() => {
|
|
3432
|
-
expect(mockProcessTrigger).
|
|
3551
|
+
expect(mockProcessTrigger).toHaveBeenLastCalledWith(expect.any(Object), types_1.HostEvent.UpdateEmbedParams, expect.any(String), expect.objectContaining({
|
|
3433
3552
|
liveboardId: 'updated-lb',
|
|
3434
|
-
}));
|
|
3553
|
+
}), undefined);
|
|
3435
3554
|
});
|
|
3436
3555
|
});
|
|
3437
3556
|
test('should trigger UpdateEmbedParams with runtime filters and visible vizs', async () => {
|
|
@@ -3455,7 +3574,7 @@ describe('ShowPreRender with UpdateEmbedParams', () => {
|
|
|
3455
3574
|
});
|
|
3456
3575
|
embed2.showPreRender();
|
|
3457
3576
|
await (0, test_utils_1.executeAfterWait)(() => {
|
|
3458
|
-
expect(mockProcessTrigger).
|
|
3577
|
+
expect(mockProcessTrigger).toHaveBeenLastCalledWith(expect.any(Object), types_1.HostEvent.UpdateEmbedParams, expect.any(String), expect.objectContaining({
|
|
3459
3578
|
liveboardId: 'original-lb',
|
|
3460
3579
|
visibleVizs: ['viz-1'],
|
|
3461
3580
|
runtimeFilters: [
|
|
@@ -3470,7 +3589,7 @@ describe('ShowPreRender with UpdateEmbedParams', () => {
|
|
|
3470
3589
|
values: ['North'],
|
|
3471
3590
|
},
|
|
3472
3591
|
],
|
|
3473
|
-
}));
|
|
3592
|
+
}), undefined);
|
|
3474
3593
|
});
|
|
3475
3594
|
});
|
|
3476
3595
|
test('should trigger UpdateEmbedParams with updated config', async () => {
|
|
@@ -3498,7 +3617,7 @@ describe('ShowPreRender with UpdateEmbedParams', () => {
|
|
|
3498
3617
|
});
|
|
3499
3618
|
embed2.showPreRender();
|
|
3500
3619
|
await (0, test_utils_1.executeAfterWait)(() => {
|
|
3501
|
-
expect(mockProcessTrigger).
|
|
3620
|
+
expect(mockProcessTrigger).toHaveBeenLastCalledWith(expect.any(Object), types_1.HostEvent.UpdateEmbedParams, expect.any(String), expect.objectContaining({
|
|
3502
3621
|
liveboardId: 'original-lb',
|
|
3503
3622
|
visibleVizs: ['viz-1', 'viz-2'],
|
|
3504
3623
|
runtimeFilters: [
|
|
@@ -3508,7 +3627,7 @@ describe('ShowPreRender with UpdateEmbedParams', () => {
|
|
|
3508
3627
|
values: ['North'],
|
|
3509
3628
|
},
|
|
3510
3629
|
],
|
|
3511
|
-
}));
|
|
3630
|
+
}), undefined);
|
|
3512
3631
|
});
|
|
3513
3632
|
});
|
|
3514
3633
|
test('should handle error when getUpdateEmbedParamsObject fails during showPreRender', async () => {
|