From d62677d01ded7dbba19d94b41b01c6ed11882a3f Mon Sep 17 00:00:00 2001 From: "bhanu.jupally" Date: Wed, 3 Sep 2025 19:52:33 -0700 Subject: [PATCH 1/2] SCAL-262099 - Added CLEAR_INFO_CACHE to allow clearing the info cache from app --- src/types.ts | 5 +++++ src/utils/processData.spec.ts | 12 ++++++++++++ src/utils/processData.ts | 11 +++++++++++ 3 files changed, 28 insertions(+) diff --git a/src/types.ts b/src/types.ts index 266aa791..1d754cc0 100644 --- a/src/types.ts +++ b/src/types.ts @@ -2349,6 +2349,11 @@ export enum EmbedEvent { * @hidden */ APP_INIT = 'appInit', + /** + * Internal event to clear the cached info + * @hidden + */ + CLEAR_INFO_CACHE = 'clearInfoCache', /** * Emitted when a user clicks **Show Liveboard details** on a Liveboard * @version SDK: 1.15.0 | ThoughtSpot: 8.7.0.cl, 8.8.1.sw diff --git a/src/utils/processData.spec.ts b/src/utils/processData.spec.ts index a1683bac..beb06d81 100644 --- a/src/utils/processData.spec.ts +++ b/src/utils/processData.spec.ts @@ -279,4 +279,16 @@ describe('Unit test for process data', () => { mockHandleExitPresentMode.mockReset(); }); + + test('should handle ClearInfoCache', () => { + const mockResetCachedPreauthInfo = jest.spyOn(sessionInfoService, 'resetCachedPreauthInfo').mockImplementation(() => {}); + const mockResetCachedSessionInfo = jest.spyOn(sessionInfoService, 'resetCachedSessionInfo').mockImplementation(() => {}); + const processedData = { + type: EmbedEvent.CLEAR_INFO_CACHE, + data: {}, + }; + processDataInstance.processEventData(EmbedEvent.CLEAR_INFO_CACHE, processedData, thoughtSpotHost, null); + expect(mockResetCachedPreauthInfo).toHaveBeenCalled(); + expect(mockResetCachedSessionInfo).toHaveBeenCalled(); + }); }); diff --git a/src/utils/processData.ts b/src/utils/processData.ts index 0be083ef..0ad4e6fe 100644 --- a/src/utils/processData.ts +++ b/src/utils/processData.ts @@ -12,6 +12,7 @@ import { resetCachedAuthToken } from '../authToken'; import { ERROR_MESSAGE } from '../errors'; import { logger } from '../utils/logger'; import { handleExitPresentMode } from '../utils'; +import { resetCachedPreauthInfo, resetCachedSessionInfo } from './sessionInfoService'; /** * Process the ExitPresentMode event and handle default fullscreen exit @@ -26,6 +27,14 @@ function processExitPresentMode(e: any) { } } +/** + * + * @param e + */ +function processClearInfoCache(e: any) { + resetCachedPreauthInfo(); + resetCachedSessionInfo(); +} /** * * @param e @@ -153,6 +162,8 @@ export function processEventData( return processAuthLogout(e, containerEl); case EmbedEvent.ExitPresentMode: return processExitPresentMode(e); + case EmbedEvent.CLEAR_INFO_CACHE: + return processClearInfoCache(e); default: } return e; From 5d33ab701b30f47c26db96c8393b6877f3d6e9bd Mon Sep 17 00:00:00 2001 From: "bhanu.jupally" Date: Wed, 3 Sep 2025 21:18:27 -0700 Subject: [PATCH 2/2] Addressed comments --- src/utils/processData.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/utils/processData.ts b/src/utils/processData.ts index 0ad4e6fe..2d06c5ba 100644 --- a/src/utils/processData.ts +++ b/src/utils/processData.ts @@ -28,10 +28,9 @@ function processExitPresentMode(e: any) { } /** - * - * @param e + * Clears the cached preauth and session info. */ -function processClearInfoCache(e: any) { +function processClearInfoCache() { resetCachedPreauthInfo(); resetCachedSessionInfo(); } @@ -163,7 +162,7 @@ export function processEventData( case EmbedEvent.ExitPresentMode: return processExitPresentMode(e); case EmbedEvent.CLEAR_INFO_CACHE: - return processClearInfoCache(e); + return processClearInfoCache(); default: } return e;