Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions src/utils/processData.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
});
11 changes: 11 additions & 0 deletions src/utils/processData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -26,6 +27,14 @@ function processExitPresentMode(e: any) {
}
}

/**
*
* @param e
*/
function processClearInfoCache(e: any) {
resetCachedPreauthInfo();
resetCachedSessionInfo();
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The JSDoc for processClearInfoCache is incomplete, and the function accepts a parameter e which is not used. For better code clarity and maintainability, it's best to provide a proper description of the function's purpose and remove the unused parameter.

/**
 * Clears the cached pre-authentication and session information.
 */
function processClearInfoCache() {
    resetCachedPreauthInfo();
    resetCachedSessionInfo();
}

/**
*
* @param e
Expand Down Expand Up @@ -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);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To align with the removal of the unused parameter from processClearInfoCache (as suggested in another comment), this call should be updated to not pass any arguments.

            return processClearInfoCache();

default:
}
return e;
Expand Down
Loading