@thoughtspot/visual-embed-sdk 1.35.11 → 1.35.13
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/auth.d.ts +2 -1
- package/cjs/src/auth.d.ts.map +1 -1
- package/cjs/src/auth.js +3 -1
- package/cjs/src/auth.js.map +1 -1
- package/cjs/src/embed/app.d.ts.map +1 -1
- package/cjs/src/embed/app.js +2 -0
- package/cjs/src/embed/app.js.map +1 -1
- package/cjs/src/embed/conversation.d.ts +44 -0
- package/cjs/src/embed/conversation.d.ts.map +1 -1
- package/cjs/src/embed/conversation.js +10 -1
- package/cjs/src/embed/conversation.js.map +1 -1
- package/cjs/src/embed/conversation.spec.js +36 -0
- 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/host-event-client.d.ts.map +1 -1
- package/cjs/src/embed/hostEventClient/host-event-client.js +6 -1
- package/cjs/src/embed/hostEventClient/host-event-client.js.map +1 -1
- package/cjs/src/embed/liveboard.d.ts +5 -4
- package/cjs/src/embed/liveboard.d.ts.map +1 -1
- package/cjs/src/embed/liveboard.js +11 -4
- package/cjs/src/embed/liveboard.js.map +1 -1
- package/cjs/src/embed/liveboard.spec.js +1 -1
- package/cjs/src/embed/liveboard.spec.js.map +1 -1
- package/cjs/src/embed/search-bar.d.ts.map +1 -1
- package/cjs/src/embed/search-bar.js +4 -2
- package/cjs/src/embed/search-bar.js.map +1 -1
- package/cjs/src/embed/search.d.ts.map +1 -1
- package/cjs/src/embed/search.js +4 -2
- package/cjs/src/embed/search.js.map +1 -1
- package/cjs/src/embed/search.spec.js +56 -3
- package/cjs/src/embed/search.spec.js.map +1 -1
- package/cjs/src/embed/ts-embed.d.ts +6 -0
- package/cjs/src/embed/ts-embed.d.ts.map +1 -1
- package/cjs/src/embed/ts-embed.js +43 -15
- 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 +193 -81
- package/cjs/src/embed/ts-embed.spec.js.map +1 -1
- package/cjs/src/types.d.ts +85 -20
- package/cjs/src/types.d.ts.map +1 -1
- package/cjs/src/types.js +80 -9
- package/cjs/src/types.js.map +1 -1
- package/cjs/src/utils/processData.d.ts.map +1 -1
- package/cjs/src/utils/processData.js +9 -2
- package/cjs/src/utils/processData.js.map +1 -1
- package/cjs/src/utils/processData.spec.js +51 -0
- package/cjs/src/utils/processData.spec.js.map +1 -1
- package/dist/index-B3hd6DTM.js +7370 -0
- package/dist/index-D-9WUCUl.js +7370 -0
- package/dist/src/auth.d.ts +2 -1
- package/dist/src/auth.d.ts.map +1 -1
- package/dist/src/embed/app.d.ts.map +1 -1
- package/dist/src/embed/conversation.d.ts +44 -0
- 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.map +1 -1
- package/dist/src/embed/liveboard.d.ts +5 -4
- package/dist/src/embed/liveboard.d.ts.map +1 -1
- package/dist/src/embed/search-bar.d.ts.map +1 -1
- package/dist/src/embed/search.d.ts.map +1 -1
- package/dist/src/embed/ts-embed.d.ts +6 -0
- 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/types.d.ts +85 -20
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/utils/processData.d.ts.map +1 -1
- package/dist/tsembed-react.es.js +175 -40
- package/dist/tsembed-react.js +174 -39
- package/dist/tsembed.es.js +175 -40
- package/dist/tsembed.js +174 -39
- package/dist/visual-embed-sdk-react-full.d.ts +138 -27
- package/dist/visual-embed-sdk-react.d.ts +138 -27
- package/dist/visual-embed-sdk.d.ts +138 -27
- package/lib/package.json +1 -1
- package/lib/src/auth.d.ts +2 -1
- package/lib/src/auth.d.ts.map +1 -1
- package/lib/src/auth.js +3 -1
- package/lib/src/auth.js.map +1 -1
- package/lib/src/embed/app.d.ts.map +1 -1
- package/lib/src/embed/app.js +2 -0
- package/lib/src/embed/app.js.map +1 -1
- package/lib/src/embed/conversation.d.ts +44 -0
- package/lib/src/embed/conversation.d.ts.map +1 -1
- package/lib/src/embed/conversation.js +10 -1
- package/lib/src/embed/conversation.js.map +1 -1
- package/lib/src/embed/conversation.spec.js +36 -0
- 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/host-event-client.d.ts.map +1 -1
- package/lib/src/embed/hostEventClient/host-event-client.js +6 -1
- package/lib/src/embed/hostEventClient/host-event-client.js.map +1 -1
- package/lib/src/embed/liveboard.d.ts +5 -4
- package/lib/src/embed/liveboard.d.ts.map +1 -1
- package/lib/src/embed/liveboard.js +11 -4
- package/lib/src/embed/liveboard.js.map +1 -1
- package/lib/src/embed/liveboard.spec.js +1 -1
- package/lib/src/embed/liveboard.spec.js.map +1 -1
- package/lib/src/embed/search-bar.d.ts.map +1 -1
- package/lib/src/embed/search-bar.js +4 -2
- package/lib/src/embed/search-bar.js.map +1 -1
- package/lib/src/embed/search.d.ts.map +1 -1
- package/lib/src/embed/search.js +4 -2
- package/lib/src/embed/search.js.map +1 -1
- package/lib/src/embed/search.spec.js +56 -3
- package/lib/src/embed/search.spec.js.map +1 -1
- package/lib/src/embed/ts-embed.d.ts +6 -0
- package/lib/src/embed/ts-embed.d.ts.map +1 -1
- package/lib/src/embed/ts-embed.js +43 -15
- 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 +195 -83
- package/lib/src/embed/ts-embed.spec.js.map +1 -1
- package/lib/src/types.d.ts +85 -20
- package/lib/src/types.d.ts.map +1 -1
- package/lib/src/types.js +80 -9
- package/lib/src/types.js.map +1 -1
- package/lib/src/utils/processData.d.ts.map +1 -1
- package/lib/src/utils/processData.js +9 -2
- package/lib/src/utils/processData.js.map +1 -1
- package/lib/src/utils/processData.spec.js +51 -0
- package/lib/src/utils/processData.spec.js.map +1 -1
- package/lib/src/visual-embed-sdk.d.ts +139 -28
- package/package.json +1 -1
- package/src/auth.ts +3 -1
- package/src/embed/app.ts +2 -0
- package/src/embed/conversation.spec.ts +52 -3
- package/src/embed/conversation.ts +60 -1
- package/src/embed/hostEventClient/contracts.ts +3 -3
- package/src/embed/hostEventClient/host-event-client.ts +7 -1
- package/src/embed/liveboard.spec.ts +1 -1
- package/src/embed/liveboard.ts +18 -12
- package/src/embed/search-bar.tsx +6 -4
- package/src/embed/search.spec.ts +71 -3
- package/src/embed/search.ts +6 -5
- package/src/embed/ts-embed.spec.ts +234 -102
- package/src/embed/ts-embed.ts +50 -34
- package/src/types.ts +89 -16
- package/src/utils/processData.spec.ts +63 -0
- package/src/utils/processData.ts +12 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* eslint-disable dot-notation */
|
|
2
2
|
import { resetCachedAuthToken } from '../authToken';
|
|
3
|
-
import { AuthType, init, EmbedEvent, SearchEmbed, PinboardEmbed, AppEmbed, LiveboardEmbed, SageEmbed,
|
|
4
|
-
import { Action, HomeLeftNavItem, RuntimeFilterOp, HomepageModule, HostEvent, } from '../types';
|
|
3
|
+
import { AuthType, init, EmbedEvent, SearchEmbed, PinboardEmbed, AppEmbed, LiveboardEmbed, SageEmbed, AnswerService, } from '../index';
|
|
4
|
+
import { Action, HomeLeftNavItem, RuntimeFilterOp, HomepageModule, HostEvent, ContextMenuTriggerOptions, } from '../types';
|
|
5
5
|
import { executeAfterWait, getDocumentBody, getIFrameEl, getIFrameSrc, getRootEl, postMessageToParent, defaultParamsForPinboardEmbed, waitFor, expectUrlMatchesWithParams, expectUrlToHaveParamsWithValues, mockMessageChannel, createRootEleForEmbed, expectUrlMatch, fixedEncodeURI, } from '../test/test-utils';
|
|
6
6
|
import * as config from '../config';
|
|
7
7
|
import * as tsEmbedInstance from './ts-embed';
|
|
@@ -182,6 +182,38 @@ describe('Unit test case for ts embed', () => {
|
|
|
182
182
|
});
|
|
183
183
|
});
|
|
184
184
|
});
|
|
185
|
+
test('check for new authToken based on getAuthToken function', async () => {
|
|
186
|
+
init({
|
|
187
|
+
thoughtSpotHost: 'tshost',
|
|
188
|
+
customizations: customisations,
|
|
189
|
+
authType: AuthType.TrustedAuthToken,
|
|
190
|
+
getAuthToken: () => Promise.resolve('test_auth_token2'),
|
|
191
|
+
autoLogin: true,
|
|
192
|
+
});
|
|
193
|
+
const mockEmbedEventPayload = {
|
|
194
|
+
type: EmbedEvent.AuthExpire,
|
|
195
|
+
data: {},
|
|
196
|
+
};
|
|
197
|
+
const searchEmbed = new SearchEmbed(getRootEl(), defaultViewConfig);
|
|
198
|
+
jest.spyOn(baseInstance, 'notifyAuthFailure');
|
|
199
|
+
jest.spyOn(baseInstance, 'handleAuth');
|
|
200
|
+
searchEmbed.render();
|
|
201
|
+
const mockPort = {
|
|
202
|
+
postMessage: jest.fn(),
|
|
203
|
+
};
|
|
204
|
+
await executeAfterWait(() => {
|
|
205
|
+
const iframe = getIFrameEl();
|
|
206
|
+
postMessageToParent(iframe.contentWindow, mockEmbedEventPayload, mockPort);
|
|
207
|
+
});
|
|
208
|
+
await executeAfterWait(() => {
|
|
209
|
+
expect(baseInstance.notifyAuthFailure).toBeCalledWith(authInstance.AuthFailureType.EXPIRY);
|
|
210
|
+
expect(mockPort.postMessage).not.toHaveBeenCalledWith({
|
|
211
|
+
type: EmbedEvent.AuthExpire,
|
|
212
|
+
data: { authToken: 'test_auth_token2' },
|
|
213
|
+
});
|
|
214
|
+
expect(baseInstance.handleAuth).toHaveBeenCalled();
|
|
215
|
+
});
|
|
216
|
+
});
|
|
185
217
|
});
|
|
186
218
|
describe('Called Embed event status for start and end', () => {
|
|
187
219
|
beforeAll(() => {
|
|
@@ -1415,49 +1447,15 @@ describe('Unit test case for ts embed', () => {
|
|
|
1415
1447
|
orgId: overrideOrgId,
|
|
1416
1448
|
});
|
|
1417
1449
|
});
|
|
1418
|
-
it('
|
|
1419
|
-
const
|
|
1420
|
-
...defaultViewConfig,
|
|
1421
|
-
enableFlipTooltipToContextMenu: true,
|
|
1422
|
-
});
|
|
1423
|
-
appEmbed.render();
|
|
1424
|
-
await executeAfterWait(() => {
|
|
1425
|
-
expectUrlMatchesWithParams(getIFrameSrc(), `http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&flipTooltipToContextMenuEnabled=true${defaultParams}${defaultParamsPost}#/home`);
|
|
1426
|
-
});
|
|
1427
|
-
});
|
|
1428
|
-
it('AppEmbed: Should not add flipTooltipToContextMenuEnabled flag to the iframe src when if false', async () => {
|
|
1429
|
-
const appEmbed = new AppEmbed(getRootEl(), {
|
|
1430
|
-
...defaultViewConfig,
|
|
1431
|
-
enableFlipTooltipToContextMenu: false,
|
|
1432
|
-
});
|
|
1433
|
-
appEmbed.render();
|
|
1434
|
-
await executeAfterWait(() => {
|
|
1435
|
-
expectUrlMatchesWithParams(getIFrameSrc(), `http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false${defaultParams}${defaultParamsPost}#/home`);
|
|
1436
|
-
});
|
|
1437
|
-
});
|
|
1438
|
-
it('LiveboardEmbed: Should add flipTooltipToContextMenuEnabled flag to the iframe src', async () => {
|
|
1439
|
-
const appEmbed = new LiveboardEmbed(getRootEl(), {
|
|
1440
|
-
...defaultViewConfig,
|
|
1441
|
-
liveboardId,
|
|
1442
|
-
enableFlipTooltipToContextMenu: true,
|
|
1443
|
-
});
|
|
1444
|
-
appEmbed.render();
|
|
1445
|
-
await executeAfterWait(() => {
|
|
1446
|
-
expectUrlMatchesWithParams(getIFrameSrc(), `http://${thoughtSpotHost}/?embedApp=true&flipTooltipToContextMenuEnabled=true${defaultParams}#/embed/viz/${liveboardId}`);
|
|
1447
|
-
});
|
|
1448
|
-
});
|
|
1449
|
-
it('LiveboardEmbed: Should not add flipTooltipToContextMenuEnabled flag to the iframe src when if false', async () => {
|
|
1450
|
-
const appEmbed = new LiveboardEmbed(getRootEl(), {
|
|
1450
|
+
it('Should not add contextMenuEnabledOnWhichClick flag to the iframe src when it is not passed', async () => {
|
|
1451
|
+
const liveboardEmbed = new LiveboardEmbed(getRootEl(), {
|
|
1451
1452
|
...defaultViewConfig,
|
|
1452
1453
|
liveboardId,
|
|
1453
|
-
enableFlipTooltipToContextMenu: false,
|
|
1454
1454
|
});
|
|
1455
|
-
|
|
1455
|
+
liveboardEmbed.render();
|
|
1456
1456
|
await executeAfterWait(() => {
|
|
1457
1457
|
expectUrlMatchesWithParams(getIFrameSrc(), `http://${thoughtSpotHost}/?embedApp=true${defaultParams}#/embed/viz/${liveboardId}`);
|
|
1458
1458
|
});
|
|
1459
|
-
});
|
|
1460
|
-
it('SageViewConfig: Should add flipTooltipToContextMenuEnabled flag to the iframe src', async () => {
|
|
1461
1459
|
const defaultConfig = {
|
|
1462
1460
|
disableWorksheetChange: false,
|
|
1463
1461
|
hideWorksheetSelector: false,
|
|
@@ -1467,16 +1465,24 @@ describe('Unit test case for ts embed', () => {
|
|
|
1467
1465
|
isProductTour: false,
|
|
1468
1466
|
dataPanelV2: false,
|
|
1469
1467
|
};
|
|
1470
|
-
const
|
|
1468
|
+
const sageEmbed = new SageEmbed(getRootEl(), {
|
|
1471
1469
|
...defaultConfig,
|
|
1472
|
-
enableFlipTooltipToContextMenu: true,
|
|
1473
1470
|
});
|
|
1474
|
-
|
|
1471
|
+
sageEmbed.render();
|
|
1475
1472
|
await executeAfterWait(() => {
|
|
1476
|
-
expectUrlMatch(getIFrameSrc(), `http://${thoughtSpotHost}/?embedApp=true&enableDataPanelV2=false&isSageEmbed=true&disableWorksheetChange=false&hideWorksheetSelector=false&hideEurekaSuggestions=false&isProductTour=false&hideSageAnswerHeader=false&hideAction=%5B%22reportError%22%5D
|
|
1473
|
+
expectUrlMatch(getIFrameSrc(), `http://${thoughtSpotHost}/?embedApp=true&enableDataPanelV2=false&isSageEmbed=true&disableWorksheetChange=false&hideWorksheetSelector=false&hideEurekaSuggestions=false&isProductTour=false&hideSageAnswerHeader=false&hideAction=%5B%22reportError%22%5D#/embed/eureka`);
|
|
1477
1474
|
});
|
|
1478
1475
|
});
|
|
1479
|
-
it('
|
|
1476
|
+
it('Should add contextMenuEnabledOnWhichClick flag to the iframe with left value', async () => {
|
|
1477
|
+
const liveboardEmbed = new LiveboardEmbed(getRootEl(), {
|
|
1478
|
+
...defaultViewConfig,
|
|
1479
|
+
liveboardId,
|
|
1480
|
+
contextMenuTrigger: ContextMenuTriggerOptions.LEFT_CLICK,
|
|
1481
|
+
});
|
|
1482
|
+
liveboardEmbed.render();
|
|
1483
|
+
await executeAfterWait(() => {
|
|
1484
|
+
expectUrlMatchesWithParams(getIFrameSrc(), `http://${thoughtSpotHost}/?embedApp=true${defaultParams}&contextMenuEnabledOnWhichClick=left#/embed/viz/${liveboardId}`);
|
|
1485
|
+
});
|
|
1480
1486
|
const defaultConfig = {
|
|
1481
1487
|
disableWorksheetChange: false,
|
|
1482
1488
|
hideWorksheetSelector: false,
|
|
@@ -1486,63 +1492,69 @@ describe('Unit test case for ts embed', () => {
|
|
|
1486
1492
|
isProductTour: false,
|
|
1487
1493
|
dataPanelV2: false,
|
|
1488
1494
|
};
|
|
1489
|
-
const
|
|
1495
|
+
const sageEmbed = new SageEmbed(getRootEl(), {
|
|
1490
1496
|
...defaultConfig,
|
|
1491
|
-
|
|
1497
|
+
contextMenuTrigger: ContextMenuTriggerOptions.LEFT_CLICK,
|
|
1492
1498
|
});
|
|
1493
|
-
|
|
1499
|
+
sageEmbed.render();
|
|
1494
1500
|
await executeAfterWait(() => {
|
|
1495
|
-
expectUrlMatch(getIFrameSrc(), `http://${thoughtSpotHost}/?embedApp=true&enableDataPanelV2=false&isSageEmbed=true&disableWorksheetChange=false&hideWorksheetSelector=false&hideEurekaSuggestions=false&isProductTour=false&hideSageAnswerHeader=false&hideAction=%5B%22reportError%22%5D#/embed/eureka`);
|
|
1501
|
+
expectUrlMatch(getIFrameSrc(), `http://${thoughtSpotHost}/?embedApp=true&enableDataPanelV2=false&contextMenuEnabledOnWhichClick=left&isSageEmbed=true&disableWorksheetChange=false&hideWorksheetSelector=false&hideEurekaSuggestions=false&isProductTour=false&hideSageAnswerHeader=false&hideAction=%5B%22reportError%22%5D#/embed/eureka`);
|
|
1496
1502
|
});
|
|
1497
1503
|
});
|
|
1498
|
-
it('
|
|
1499
|
-
const
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
},
|
|
1504
|
-
enableFlipTooltipToContextMenu: true,
|
|
1504
|
+
it('Should add contextMenuEnabledOnWhichClick flag to the iframe with right value', async () => {
|
|
1505
|
+
const livebaordEmbed = new LiveboardEmbed(getRootEl(), {
|
|
1506
|
+
...defaultViewConfig,
|
|
1507
|
+
liveboardId,
|
|
1508
|
+
contextMenuTrigger: ContextMenuTriggerOptions.RIGHT_CLICK,
|
|
1505
1509
|
});
|
|
1506
|
-
|
|
1510
|
+
livebaordEmbed.render();
|
|
1507
1511
|
await executeAfterWait(() => {
|
|
1508
|
-
expectUrlMatchesWithParams(getIFrameSrc(), `http://${thoughtSpotHost}
|
|
1512
|
+
expectUrlMatchesWithParams(getIFrameSrc(), `http://${thoughtSpotHost}/?embedApp=true${defaultParams}&contextMenuEnabledOnWhichClick=right#/embed/viz/${liveboardId}`);
|
|
1509
1513
|
});
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1514
|
+
const defaultConfig = {
|
|
1515
|
+
disableWorksheetChange: false,
|
|
1516
|
+
hideWorksheetSelector: false,
|
|
1517
|
+
hideSageAnswerHeader: false,
|
|
1518
|
+
hideAutocompleteSuggestions: false,
|
|
1519
|
+
hideSampleQuestions: false,
|
|
1520
|
+
isProductTour: false,
|
|
1521
|
+
dataPanelV2: false,
|
|
1522
|
+
};
|
|
1523
|
+
const sageEmbed = new SageEmbed(getRootEl(), {
|
|
1524
|
+
...defaultConfig,
|
|
1525
|
+
contextMenuTrigger: ContextMenuTriggerOptions.RIGHT_CLICK,
|
|
1518
1526
|
});
|
|
1519
|
-
|
|
1527
|
+
sageEmbed.render();
|
|
1520
1528
|
await executeAfterWait(() => {
|
|
1521
|
-
|
|
1529
|
+
expectUrlMatch(getIFrameSrc(), `http://${thoughtSpotHost}/?embedApp=true&enableDataPanelV2=false&contextMenuEnabledOnWhichClick=right&isSageEmbed=true&disableWorksheetChange=false&hideWorksheetSelector=false&hideEurekaSuggestions=false&isProductTour=false&hideSageAnswerHeader=false&hideAction=%5B%22reportError%22%5D#/embed/eureka`);
|
|
1522
1530
|
});
|
|
1523
1531
|
});
|
|
1524
|
-
it('
|
|
1525
|
-
const
|
|
1526
|
-
const appEmbed = new SearchEmbed(getRootEl(), {
|
|
1532
|
+
it('Should add contextMenuEnabledOnWhichClick flag to the iframe with both value', async () => {
|
|
1533
|
+
const livebaordEmbed = new LiveboardEmbed(getRootEl(), {
|
|
1527
1534
|
...defaultViewConfig,
|
|
1528
|
-
|
|
1529
|
-
|
|
1535
|
+
liveboardId,
|
|
1536
|
+
contextMenuTrigger: ContextMenuTriggerOptions.BOTH_CLICKS,
|
|
1530
1537
|
});
|
|
1531
|
-
|
|
1538
|
+
livebaordEmbed.render();
|
|
1532
1539
|
await executeAfterWait(() => {
|
|
1533
|
-
expectUrlMatchesWithParams(getIFrameSrc(), `http://${thoughtSpotHost}
|
|
1540
|
+
expectUrlMatchesWithParams(getIFrameSrc(), `http://${thoughtSpotHost}/?embedApp=true${defaultParams}&contextMenuEnabledOnWhichClick=both#/embed/viz/${liveboardId}`);
|
|
1534
1541
|
});
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
+
const defaultConfig = {
|
|
1543
|
+
disableWorksheetChange: false,
|
|
1544
|
+
hideWorksheetSelector: false,
|
|
1545
|
+
hideSageAnswerHeader: false,
|
|
1546
|
+
hideAutocompleteSuggestions: false,
|
|
1547
|
+
hideSampleQuestions: false,
|
|
1548
|
+
isProductTour: false,
|
|
1549
|
+
dataPanelV2: false,
|
|
1550
|
+
};
|
|
1551
|
+
const sageEmbed = new SageEmbed(getRootEl(), {
|
|
1552
|
+
...defaultConfig,
|
|
1553
|
+
contextMenuTrigger: ContextMenuTriggerOptions.BOTH_CLICKS,
|
|
1542
1554
|
});
|
|
1543
|
-
|
|
1555
|
+
sageEmbed.render();
|
|
1544
1556
|
await executeAfterWait(() => {
|
|
1545
|
-
|
|
1557
|
+
expectUrlMatch(getIFrameSrc(), `http://${thoughtSpotHost}/?embedApp=true&enableDataPanelV2=false&contextMenuEnabledOnWhichClick=both&isSageEmbed=true&disableWorksheetChange=false&hideWorksheetSelector=false&hideEurekaSuggestions=false&isProductTour=false&hideSageAnswerHeader=false&hideAction=%5B%22reportError%22%5D#/embed/eureka`);
|
|
1546
1558
|
});
|
|
1547
1559
|
});
|
|
1548
1560
|
});
|
|
@@ -1816,5 +1828,105 @@ describe('Unit test case for ts embed', () => {
|
|
|
1816
1828
|
logger.error.mockClear();
|
|
1817
1829
|
});
|
|
1818
1830
|
});
|
|
1831
|
+
describe('IdleSessionTimeout embedEvent for TrustedAuthTokenCookieless authType with autoLogin true', () => {
|
|
1832
|
+
beforeAll(() => {
|
|
1833
|
+
jest.spyOn(authInstance, 'doCookielessTokenAuth').mockResolvedValueOnce(true);
|
|
1834
|
+
jest.spyOn(authService, 'verifyTokenService').mockResolvedValueOnce(true);
|
|
1835
|
+
init({
|
|
1836
|
+
thoughtSpotHost: 'tshost',
|
|
1837
|
+
customizations: customisations,
|
|
1838
|
+
authType: AuthType.TrustedAuthTokenCookieless,
|
|
1839
|
+
getAuthToken: () => Promise.resolve('test_auth_token2'),
|
|
1840
|
+
autoLogin: true,
|
|
1841
|
+
});
|
|
1842
|
+
});
|
|
1843
|
+
test('should handle idle session timeout and send updated auth token', async () => {
|
|
1844
|
+
const mockEmbedEventPayload = {
|
|
1845
|
+
type: EmbedEvent.IdleSessionTimeout,
|
|
1846
|
+
data: {},
|
|
1847
|
+
};
|
|
1848
|
+
const searchEmbed = new SearchEmbed(getRootEl(), defaultViewConfig);
|
|
1849
|
+
jest.spyOn(baseInstance, 'handleAuth');
|
|
1850
|
+
jest.spyOn(baseInstance, 'notifyAuthFailure');
|
|
1851
|
+
searchEmbed.render();
|
|
1852
|
+
const mockPort = {
|
|
1853
|
+
postMessage: jest.fn(),
|
|
1854
|
+
};
|
|
1855
|
+
await executeAfterWait(() => {
|
|
1856
|
+
const iframe = getIFrameEl();
|
|
1857
|
+
postMessageToParent(iframe.contentWindow, mockEmbedEventPayload, mockPort);
|
|
1858
|
+
});
|
|
1859
|
+
await executeAfterWait(() => {
|
|
1860
|
+
expect(baseInstance.notifyAuthFailure).toBeCalledWith(authInstance.AuthFailureType.IDLE_SESSION_TIMEOUT);
|
|
1861
|
+
expect(baseInstance.handleAuth).toHaveBeenCalled();
|
|
1862
|
+
expect(mockPort.postMessage).toHaveBeenCalledWith({
|
|
1863
|
+
type: EmbedEvent.IdleSessionTimeout,
|
|
1864
|
+
data: { authToken: 'test_auth_token2' },
|
|
1865
|
+
});
|
|
1866
|
+
});
|
|
1867
|
+
});
|
|
1868
|
+
test('should handle idle session timeout and show login failure message if token fetch fails', async () => {
|
|
1869
|
+
init({
|
|
1870
|
+
thoughtSpotHost: 'tshost',
|
|
1871
|
+
customizations: customisations,
|
|
1872
|
+
authType: AuthType.TrustedAuthTokenCookieless,
|
|
1873
|
+
getAuthToken: () => Promise.reject(),
|
|
1874
|
+
autoLogin: true,
|
|
1875
|
+
});
|
|
1876
|
+
const mockEmbedEventPayload = {
|
|
1877
|
+
type: EmbedEvent.IdleSessionTimeout,
|
|
1878
|
+
data: {},
|
|
1879
|
+
};
|
|
1880
|
+
const searchEmbed = new SearchEmbed(getRootEl(), defaultViewConfig);
|
|
1881
|
+
jest.spyOn(baseInstance, 'notifyAuthFailure');
|
|
1882
|
+
searchEmbed.render();
|
|
1883
|
+
const mockPort = {
|
|
1884
|
+
postMessage: jest.fn(),
|
|
1885
|
+
};
|
|
1886
|
+
const loggerSpy = jest.spyOn(logger, 'error').mockResolvedValueOnce(true);
|
|
1887
|
+
await executeAfterWait(() => {
|
|
1888
|
+
const iframe = getIFrameEl();
|
|
1889
|
+
postMessageToParent(iframe.contentWindow, mockEmbedEventPayload, mockPort);
|
|
1890
|
+
});
|
|
1891
|
+
await executeAfterWait(() => {
|
|
1892
|
+
expect(getRootEl().innerHTML).toContain('Not logged in');
|
|
1893
|
+
expect(baseInstance.notifyAuthFailure).toBeCalledWith(authInstance.AuthFailureType.IDLE_SESSION_TIMEOUT);
|
|
1894
|
+
expect(loggerSpy).toHaveBeenCalledTimes(1);
|
|
1895
|
+
});
|
|
1896
|
+
jest.spyOn(authService, 'verifyTokenService').mockClear();
|
|
1897
|
+
jest.spyOn(baseInstance, 'notifyAuthFailure').mockClear();
|
|
1898
|
+
});
|
|
1899
|
+
test('should handle idle session timeout and show login failure message if handleAuth fails', async () => {
|
|
1900
|
+
init({
|
|
1901
|
+
thoughtSpotHost: 'tshost',
|
|
1902
|
+
customizations: customisations,
|
|
1903
|
+
authType: AuthType.TrustedAuthTokenCookieless,
|
|
1904
|
+
getAuthToken: () => Promise.resolve('test_auth_token2'),
|
|
1905
|
+
autoLogin: true,
|
|
1906
|
+
});
|
|
1907
|
+
const mockEmbedEventPayload = {
|
|
1908
|
+
type: EmbedEvent.IdleSessionTimeout,
|
|
1909
|
+
data: {},
|
|
1910
|
+
};
|
|
1911
|
+
const searchEmbed = new SearchEmbed(getRootEl(), defaultViewConfig);
|
|
1912
|
+
jest.spyOn(baseInstance, 'notifyAuthFailure');
|
|
1913
|
+
jest.spyOn(authInstance, 'authenticate').mockResolvedValue(false);
|
|
1914
|
+
searchEmbed.render();
|
|
1915
|
+
const mockPort = {
|
|
1916
|
+
postMessage: jest.fn(),
|
|
1917
|
+
};
|
|
1918
|
+
const loggerSpy = jest.spyOn(logger, 'error').mockResolvedValueOnce(true);
|
|
1919
|
+
await executeAfterWait(() => {
|
|
1920
|
+
const iframe = getIFrameEl();
|
|
1921
|
+
postMessageToParent(iframe.contentWindow, mockEmbedEventPayload, mockPort);
|
|
1922
|
+
});
|
|
1923
|
+
await executeAfterWait(() => {
|
|
1924
|
+
expect(baseInstance.notifyAuthFailure).toBeCalledWith(authInstance.AuthFailureType.IDLE_SESSION_TIMEOUT);
|
|
1925
|
+
expect(loggerSpy).toHaveBeenCalledTimes(0);
|
|
1926
|
+
});
|
|
1927
|
+
jest.spyOn(authService, 'verifyTokenService').mockClear();
|
|
1928
|
+
jest.spyOn(baseInstance, 'notifyAuthFailure').mockClear();
|
|
1929
|
+
});
|
|
1930
|
+
});
|
|
1819
1931
|
});
|
|
1820
1932
|
//# sourceMappingURL=ts-embed.spec.js.map
|