@thoughtspot/visual-embed-sdk
Version:
ThoughtSpot Embed SDK
1,237 lines (1,112 loc) • 78.5 kB
text/typescript
import {
AppEmbed,
AppViewConfig,
DataPanelCustomColumnGroupsAccordionState,
Page,
HomePageSearchBarMode,
PrimaryNavbarVersion,
HomePage,
ListPage,
} from './app';
import { init } from '../index';
import { Action, AuthType, EmbedEvent, HostEvent, RuntimeFilterOp } from '../types';
import {
executeAfterWait,
getDocumentBody,
getIFrameSrc,
getRootEl,
getIFrameEl,
mockMessageChannel,
defaultParams,
defaultParamsForPinboardEmbed,
defaultParamsWithoutHiddenActions,
expectUrlMatchesWithParams,
postMessageToParent,
testVisualOverridesInEmbed,
} from '../test/test-utils';
import { version } from '../../package.json';
import * as config from '../config';
import { TsEmbed, V1Embed } from './ts-embed';
import { logger } from '../utils/logger';
import * as auth from '../auth';
const defaultViewConfig = {
frameParams: {
width: 1280,
height: 720,
},
};
const thoughtSpotHost = 'tshost';
const defaultParamsPost = '';
// Helper function to create and render AppEmbed with config
const createAndRenderAppEmbed = async (viewConfig: AppViewConfig) => {
const appEmbed = new AppEmbed(getRootEl(), viewConfig);
appEmbed.render();
return appEmbed;
};
// Helper function to test URL parameters
const testUrlParams = async (viewConfig: AppViewConfig, expectedUrl: string) => {
await createAndRenderAppEmbed(viewConfig);
await executeAfterWait(() => {
expectUrlMatchesWithParams(getIFrameSrc(), expectedUrl);
});
};
// Helper function to test setIframeHeightForNonEmbedLiveboard behavior
const testSetIframeHeightBehavior = (
currentPath: string,
shouldBeCalled: boolean
) => {
const appEmbed = new AppEmbed(getRootEl(), {
...defaultViewConfig,
fullHeight: true,
} as AppViewConfig) as any;
const spySetIFrameHeight = shouldBeCalled
? jest.spyOn(appEmbed, 'setIFrameHeight').mockImplementation(jest.fn())
: jest.spyOn(appEmbed, 'setIFrameHeight');
appEmbed.render();
appEmbed.setIframeHeightForNonEmbedLiveboard({
data: { currentPath },
type: 'Route',
});
if (shouldBeCalled) {
expect(spySetIFrameHeight).toHaveBeenCalled();
} else {
expect(spySetIFrameHeight).not.toHaveBeenCalled();
}
};
// Helper function to create mock iframe with default getBoundingClientRect
const createMockIFrame = (rect = {
top: 100,
left: 150,
bottom: 600,
right: 800,
width: 650,
height: 500,
}): HTMLIFrameElement => {
const mockIFrame = document.createElement('iframe');
mockIFrame.getBoundingClientRect = jest.fn().mockReturnValue(rect);
return mockIFrame;
};
// Helper function to setup iframe creation spy
const setupIFrameCreationSpy = (mockIFrame: HTMLIFrameElement) => {
jest.spyOn(document, 'createElement').mockImplementation((tagName) => {
if (tagName === 'iframe') {
return mockIFrame;
}
return document.createElement(tagName);
});
};
const originalResizeObserver = window.ResizeObserver;
beforeAll(() => {
init({
thoughtSpotHost,
authType: AuthType.None,
});
jest.spyOn(auth, 'postLoginService').mockImplementation(() => Promise.resolve(undefined));
(window as any).ResizeObserver =
window.ResizeObserver ||
jest.fn().mockImplementation(() => ({
disconnect: jest.fn(),
observe: jest.fn(),
unobserve: jest.fn(),
}));
});
const cleanUp = () => {
document.body.innerHTML = getDocumentBody();
window.ResizeObserver = originalResizeObserver;
};
describe('App embed tests', () => {
beforeEach(() => {
cleanUp();
});
test('should render home page by default', async () => {
const appEmbed = new AppEmbed(getRootEl(), defaultViewConfig);
appEmbed.render();
await executeAfterWait(() => {
expectUrlMatchesWithParams(
getIFrameSrc(),
`http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false${defaultParams}${defaultParamsPost}#/home`,
);
});
});
test('should hide the primary nav bar', async () => {
const appEmbed = new AppEmbed(getRootEl(), {
...defaultViewConfig,
showPrimaryNavbar: false,
} as AppViewConfig);
appEmbed.render();
await executeAfterWait(() => {
expectUrlMatchesWithParams(
getIFrameSrc(),
`http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false${defaultParams}${defaultParamsPost}#/home`,
);
});
});
test('should hide the help and profile buttons from nav bar', async () => {
const appEmbed = new AppEmbed(getRootEl(), {
...defaultViewConfig,
disableProfileAndHelp: true,
} as AppViewConfig);
appEmbed.render();
await executeAfterWait(() => {
expectUrlMatchesWithParams(
getIFrameSrc(),
`http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=true${defaultParams}${defaultParamsPost}#/home`,
);
});
});
test('should hide the application switcher button from nav bar', async () => {
const appEmbed = new AppEmbed(getRootEl(), {
...defaultViewConfig,
hideApplicationSwitcher: true,
} as AppViewConfig);
appEmbed.render();
await executeAfterWait(() => {
expectUrlMatchesWithParams(
getIFrameSrc(),
`http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&applicationSwitcherHidden=true${defaultParams}${defaultParamsPost}#/home`,
);
});
});
test('should hide the org switcher button from nav bar', async () => {
const appEmbed = new AppEmbed(getRootEl(), {
...defaultViewConfig,
hideOrgSwitcher: true,
} as AppViewConfig);
appEmbed.render();
await executeAfterWait(() => {
expectUrlMatchesWithParams(
getIFrameSrc(),
`http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&orgSwitcherHidden=true${defaultParams}${defaultParamsPost}#/home`,
);
});
});
describe('should render the correct routes for pages', () => {
const pageRouteMap = {
[Page.Search]: 'answer',
[Page.Answers]: 'answers',
[Page.Pinboards]: 'pinboards',
[Page.Liveboards]: 'pinboards',
[Page.Data]: 'data/tables',
[Page.Home]: 'home',
[Page.SpotIQ]: 'insights/results',
[Page.Monitor]: 'insights/monitor-alerts',
};
const pageIds = Object.keys(pageRouteMap);
for (let i = 0; i < pageIds.length; i++) {
const pageId = pageIds[i];
test(`${pageId}`, async () => {
const route = pageRouteMap[pageId as keyof typeof pageRouteMap];
const appEmbed = new AppEmbed(getRootEl(), {
...defaultViewConfig,
pageId: pageId as Page,
} as AppViewConfig);
appEmbed.render();
await executeAfterWait(() => {
expectUrlMatchesWithParams(
getIFrameSrc(),
`http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false${defaultParams}${defaultParamsPost}#/${route}`,
);
cleanUp();
});
});
}
const pageRouteMapForModularHome = {
[Page.Search]: 'answer',
[Page.Answers]: 'home/answers',
[Page.Pinboards]: 'home/liveboards',
[Page.Liveboards]: 'home/liveboards',
[Page.Data]: 'data/tables',
[Page.Home]: 'home',
[Page.SpotIQ]: 'home/spotiq-analysis',
[Page.Monitor]: 'home/monitor-alerts',
};
const pageIdsForModularHomes = Object.keys(pageRouteMapForModularHome);
for (let i = 0; i < pageIdsForModularHomes.length; i++) {
const pageIdsForModularHome = pageIdsForModularHomes[i];
test(`${pageIdsForModularHome}`, async () => {
const route = pageRouteMapForModularHome[pageIdsForModularHome as keyof typeof pageRouteMapForModularHome];
const appEmbed = new AppEmbed(getRootEl(), {
...defaultViewConfig,
modularHomeExperience: true,
pageId: pageIdsForModularHome as Page,
} as AppViewConfig);
appEmbed.render();
await executeAfterWait(() => {
expectUrlMatchesWithParams(
getIFrameSrc(),
`http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false${defaultParams}${defaultParamsPost}#/${route}`,
);
cleanUp();
});
});
}
});
test('should navigate to a path', async () => {
const appEmbed = new AppEmbed(getRootEl(), {
...defaultViewConfig,
path: 'foo/bar',
} as AppViewConfig);
appEmbed.render();
await executeAfterWait(() => {
expectUrlMatchesWithParams(
getIFrameSrc(),
`http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false${defaultParams}${defaultParamsPost}#/foo/bar`,
);
});
});
test('should apply runtime filters', async () => {
const appEmbed = new AppEmbed(getRootEl(), {
...defaultViewConfig,
showPrimaryNavbar: true,
runtimeFilters: [
{
columnName: 'sales',
operator: RuntimeFilterOp.EQ,
values: [1000],
},
],
excludeRuntimeFiltersfromURL: false,
} as AppViewConfig);
appEmbed.render();
await executeAfterWait(() => {
expectUrlMatchesWithParams(
getIFrameSrc(),
`http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=false&profileAndHelpInNavBarHidden=false&col1=sales&op1=EQ&val1=1000${defaultParams}${defaultParamsPost}#/home`,
);
});
});
test('should not append runtime filters in URL if excludeRuntimeFiltersfromURL is true', async () => {
const appEmbed = new AppEmbed(getRootEl(), {
...defaultViewConfig,
showPrimaryNavbar: true,
runtimeFilters: [
{
columnName: 'sales',
operator: RuntimeFilterOp.EQ,
values: [1000],
},
],
excludeRuntimeFiltersfromURL: true,
} as AppViewConfig);
appEmbed.render();
await executeAfterWait(() => {
expectUrlMatchesWithParams(
getIFrameSrc(),
`http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=false&profileAndHelpInNavBarHidden=false${defaultParams}${defaultParamsPost}#/home`,
);
});
});
test('should append runtime filters in URL if excludeRuntimeFiltersfromURL is undefined', async () => {
const appEmbed = new AppEmbed(getRootEl(), {
...defaultViewConfig,
showPrimaryNavbar: true,
runtimeFilters: [
{
columnName: 'sales',
operator: RuntimeFilterOp.EQ,
values: [1000],
},
],
excludeRuntimeFiltersfromURL: undefined,
} as AppViewConfig);
appEmbed.render();
const runtimeFilter = 'col1=sales&op1=EQ&val1=1000';
await executeAfterWait(() => {
expectUrlMatchesWithParams(
getIFrameSrc(),
`http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=false&profileAndHelpInNavBarHidden=false${defaultParams}${defaultParamsPost}&${runtimeFilter}#/home`,
);
});
});
test('should disable and hide actions', async () => {
const appEmbed = new AppEmbed(getRootEl(), {
...defaultViewConfig,
showPrimaryNavbar: true,
disabledActions: [Action.Save, Action.Update],
disabledActionReason: 'Access denied',
hiddenActions: [Action.Download],
} as AppViewConfig);
appEmbed.render();
await executeAfterWait(() => {
expectUrlMatchesWithParams(
getIFrameSrc(),
`http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=false&profileAndHelpInNavBarHidden=false&${defaultParamsWithoutHiddenActions}&disableAction=[%22save%22,%22update%22]&disableHint=Access%20denied&hideAction=[%22${Action.ReportError}%22,%22download%22]${defaultParamsPost}#/home`,
);
});
});
test('should set enable2ColumnLayout to true in url', async () => {
const appEmbed = new AppEmbed(getRootEl(), {
...defaultViewConfig,
enable2ColumnLayout: true,
} as AppViewConfig);
appEmbed.render();
await executeAfterWait(() => {
expectUrlMatchesWithParams(
getIFrameSrc(),
`http://${thoughtSpotHost}/?embedApp=true&profileAndHelpInNavBarHidden=false&enable2ColumnLayout=true${defaultParamsPost}#/home`,
);
});
});
test('should set coverAndFilterOptionInPDF to false in url', async () => {
const appEmbed = new AppEmbed(getRootEl(), {
...defaultViewConfig,
coverAndFilterOptionInPDF: false,
} as AppViewConfig);
appEmbed.render();
await executeAfterWait(() => {
expectUrlMatchesWithParams(
getIFrameSrc(),
`http://${thoughtSpotHost}/?embedApp=true&profileAndHelpInNavBarHidden=false&arePdfCoverFilterPageCheckboxesEnabled=false${defaultParamsPost}#/home`,
);
});
});
test('should set isLiveboardStylingAndGroupingEnabled to true in url (deprecated, use isLiveboardMasterpiecesEnabled)', async () => {
const appEmbed = new AppEmbed(getRootEl(), {
...defaultViewConfig,
isLiveboardStylingAndGroupingEnabled: true,
} as AppViewConfig);
appEmbed.render();
await executeAfterWait(() => {
expectUrlMatchesWithParams(
getIFrameSrc(),
`http://${thoughtSpotHost}/?embedApp=true&profileAndHelpInNavBarHidden=false&isLiveboardStylingAndGroupingEnabled=true${defaultParamsPost}#/home`,
);
});
});
test('should set isThisPeriodInDateFiltersEnabled to true in url', async () => {
const appEmbed = new AppEmbed(getRootEl(), {
...defaultViewConfig,
isThisPeriodInDateFiltersEnabled: true,
} as AppViewConfig);
appEmbed.render();
await executeAfterWait(() => {
expectUrlMatchesWithParams(
getIFrameSrc(),
`http://${thoughtSpotHost}/?embedApp=true&profileAndHelpInNavBarHidden=false&isThisPeriodInDateFiltersEnabled=true${defaultParamsPost}#/home`,
);
});
});
test('should set enableHomepageAnnouncement to true in url', async () => {
const appEmbed = new AppEmbed(getRootEl(), {
...defaultViewConfig,
enableHomepageAnnouncement: true,
} as AppViewConfig);
appEmbed.render();
await executeAfterWait(() => {
expectUrlMatchesWithParams(
getIFrameSrc(),
`http://${thoughtSpotHost}/?embedApp=true&profileAndHelpInNavBarHidden=false&enableHomepageAnnouncement=true${defaultParamsPost}#/home`,
);
});
});
test('should set enableHomepageAnnouncement to false in url when not provided in AppViewConfig', async () => {
const appEmbed = new AppEmbed(getRootEl(), defaultViewConfig);
appEmbed.render();
await executeAfterWait(() => {
expectUrlMatchesWithParams(
getIFrameSrc(),
`http://${thoughtSpotHost}/?embedApp=true&profileAndHelpInNavBarHidden=false&enableHomepageAnnouncement=false${defaultParamsPost}#/home`,
);
});
});
test('should set isPNGInScheduledEmailsEnabled to true in url', async () => {
const appEmbed = new AppEmbed(getRootEl(), {
...defaultViewConfig,
isPNGInScheduledEmailsEnabled: true,
} as AppViewConfig);
appEmbed.render();
await executeAfterWait(() => {
expectUrlMatchesWithParams(
getIFrameSrc(),
`http://${thoughtSpotHost}/?embedApp=true&profileAndHelpInNavBarHidden=false&isPNGInScheduledEmailsEnabled=true${defaultParamsPost}#/home`,
);
});
});
test('should set isWYSIWYGLiveboardPDFEnabled to true in url', async () => {
const appEmbed = new AppEmbed(getRootEl(), {
...defaultViewConfig,
isContinuousLiveboardPDFEnabled: true,
} as AppViewConfig);
appEmbed.render();
await executeAfterWait(() => {
expectUrlMatchesWithParams(
getIFrameSrc(),
`http://${thoughtSpotHost}/?embedApp=true&profileAndHelpInNavBarHidden=false&isWYSIWYGLiveboardPDFEnabled=true${defaultParamsPost}#/home`,
);
});
});
test('should disable isWYSIWYGLiveboardPDFEnabled by default in url', async () => {
const appEmbed = new AppEmbed(getRootEl(), {
...defaultViewConfig,
} as AppViewConfig);
appEmbed.render();
await executeAfterWait(() => {
expectUrlMatchesWithParams(
getIFrameSrc(),
`http://${thoughtSpotHost}/?embedApp=true&profileAndHelpInNavBarHidden=false&isWYSIWYGLiveboardPDFEnabled=false${defaultParamsPost}#/home`,
);
});
});
test('should set isLinkParametersEnabled to true in url', async () => {
const appEmbed = new AppEmbed(getRootEl(), {
...defaultViewConfig,
isLinkParametersEnabled: true,
} as AppViewConfig);
appEmbed.render();
await executeAfterWait(() => {
expectUrlMatchesWithParams(
getIFrameSrc(),
`http://${thoughtSpotHost}/?embedApp=true&profileAndHelpInNavBarHidden=false&isLinkParametersEnabled=true${defaultParamsPost}#/home`,
);
});
});
test('should set isLinkParametersEnabled to false in url', async () => {
const appEmbed = new AppEmbed(getRootEl(), {
...defaultViewConfig,
isLinkParametersEnabled: false,
} as AppViewConfig);
appEmbed.render();
await executeAfterWait(() => {
expectUrlMatchesWithParams(
getIFrameSrc(),
`http://${thoughtSpotHost}/?embedApp=true&profileAndHelpInNavBarHidden=false&isLinkParametersEnabled=false${defaultParamsPost}#/home`,
);
});
});
test('should set isLiveboardXLSXCSVDownloadEnabled to true in url', async () => {
const appEmbed = new AppEmbed(getRootEl(), {
...defaultViewConfig,
isLiveboardXLSXCSVDownloadEnabled: true,
} as AppViewConfig);
appEmbed.render();
await executeAfterWait(() => {
expectUrlMatchesWithParams(
getIFrameSrc(),
`http://${thoughtSpotHost}/?embedApp=true&profileAndHelpInNavBarHidden=false&isLiveboardXLSXCSVDownloadEnabled=true${defaultParamsPost}#/home`,
);
});
});
test('should set updatedSpotterChatPrompt to true in url', async () => {
const appEmbed = new AppEmbed(getRootEl(), {
...defaultViewConfig,
updatedSpotterChatPrompt: true,
} as AppViewConfig);
appEmbed.render();
await executeAfterWait(() => {
expectUrlMatchesWithParams(
getIFrameSrc(),
`http://${thoughtSpotHost}/?embedApp=true&profileAndHelpInNavBarHidden=false&updatedSpotterChatPrompt=true${defaultParamsPost}#/home`,
);
});
});
test('should set updatedSpotterChatPrompt to false in url', async () => {
const appEmbed = new AppEmbed(getRootEl(), {
...defaultViewConfig,
updatedSpotterChatPrompt: false,
} as AppViewConfig);
appEmbed.render();
await executeAfterWait(() => {
expectUrlMatchesWithParams(
getIFrameSrc(),
`http://${thoughtSpotHost}/?embedApp=true&profileAndHelpInNavBarHidden=false&updatedSpotterChatPrompt=false${defaultParamsPost}#/home`,
);
});
});
test('should set hideToolResponseCardBranding to true in url via spotterChatConfig', async () => {
const appEmbed = new AppEmbed(getRootEl(), {
...defaultViewConfig,
spotterChatConfig: {
hideToolResponseCardBranding: true,
},
} as AppViewConfig);
appEmbed.render();
await executeAfterWait(() => {
expectUrlMatchesWithParams(
getIFrameSrc(),
`http://${thoughtSpotHost}/?embedApp=true&profileAndHelpInNavBarHidden=false&hideToolResponseCardBranding=true${defaultParamsPost}#/home`,
);
});
});
test('should set toolResponseCardBrandingLabel in url via spotterChatConfig', async () => {
const appEmbed = new AppEmbed(getRootEl(), {
...defaultViewConfig,
spotterChatConfig: {
toolResponseCardBrandingLabel: 'MyBrand',
},
} as AppViewConfig);
appEmbed.render();
await executeAfterWait(() => {
expectUrlMatchesWithParams(
getIFrameSrc(),
`http://${thoughtSpotHost}/?embedApp=true&profileAndHelpInNavBarHidden=false&toolResponseCardBrandingLabel=MyBrand${defaultParamsPost}#/home`,
);
});
});
test('should set isLiveboardXLSXCSVDownloadEnabled to false in url', async () => {
const appEmbed = new AppEmbed(getRootEl(), {
...defaultViewConfig,
isLiveboardXLSXCSVDownloadEnabled: false,
} as AppViewConfig);
appEmbed.render();
await executeAfterWait(() => {
expectUrlMatchesWithParams(
getIFrameSrc(),
`http://${thoughtSpotHost}/?embedApp=true&profileAndHelpInNavBarHidden=false&isLiveboardXLSXCSVDownloadEnabled=false${defaultParamsPost}#/home`,
);
});
});
test('should set isGranularXLSXCSVSchedulesEnabled to true in url', async () => {
const appEmbed = new AppEmbed(getRootEl(), {
...defaultViewConfig,
isGranularXLSXCSVSchedulesEnabled: true,
} as AppViewConfig);
appEmbed.render();
await executeAfterWait(() => {
expectUrlMatchesWithParams(
getIFrameSrc(),
`http://${thoughtSpotHost}/?embedApp=true&profileAndHelpInNavBarHidden=false&isGranularXLSXCSVSchedulesEnabled=true${defaultParamsPost}#/home`,
);
});
});
test('should set isGranularXLSXCSVSchedulesEnabled to false in url', async () => {
const appEmbed = new AppEmbed(getRootEl(), {
...defaultViewConfig,
isGranularXLSXCSVSchedulesEnabled: false,
} as AppViewConfig);
appEmbed.render();
await executeAfterWait(() => {
expectUrlMatchesWithParams(
getIFrameSrc(),
`http://${thoughtSpotHost}/?embedApp=true&profileAndHelpInNavBarHidden=false&isGranularXLSXCSVSchedulesEnabled=false${defaultParamsPost}#/home`,
);
});
});
test('should set isCentralizedLiveboardFilterUXEnabled to true in url', async () => {
const appEmbed = new AppEmbed(getRootEl(), {
...defaultViewConfig,
isCentralizedLiveboardFilterUXEnabled: true,
} as AppViewConfig);
appEmbed.render();
await executeAfterWait(() => {
expectUrlMatchesWithParams(
getIFrameSrc(),
`http://${thoughtSpotHost}/?embedApp=true&profileAndHelpInNavBarHidden=false&isCentralizedLiveboardFilterUXEnabled=true${defaultParamsPost}#/home`,
);
});
});
test('should set isCentralizedLiveboardFilterUXEnabled to false in url', async () => {
const appEmbed = new AppEmbed(getRootEl(), {
...defaultViewConfig,
isCentralizedLiveboardFilterUXEnabled: false,
} as AppViewConfig);
appEmbed.render();
await executeAfterWait(() => {
expectUrlMatchesWithParams(
getIFrameSrc(),
`http://${thoughtSpotHost}/?embedApp=true&profileAndHelpInNavBarHidden=false&isCentralizedLiveboardFilterUXEnabled=false${defaultParamsPost}#/home`,
);
});
});
test('Should add the tag to the iframe src', async () => {
const appEmbed = new AppEmbed(getRootEl(), {
...defaultViewConfig,
showPrimaryNavbar: false,
tag: 'Finance',
} as AppViewConfig);
appEmbed.render();
await executeAfterWait(() => {
expectUrlMatchesWithParams(
getIFrameSrc(),
`http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false${defaultParams}&tag=Finance${defaultParamsPost}#/home`,
);
});
});
test('Should add the hideTagFilterChips true to the iframe src', async () => {
const appEmbed = new AppEmbed(getRootEl(), {
...defaultViewConfig,
showPrimaryNavbar: false,
hideTagFilterChips: true,
} as AppViewConfig);
appEmbed.render();
await executeAfterWait(() => {
expectUrlMatchesWithParams(
getIFrameSrc(),
`http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false${defaultParams}&hideTagFilterChips=true${defaultParamsPost}#/home`,
);
});
});
test('Should add the hideTagFilterChips false to the iframe src', async () => {
const appEmbed = new AppEmbed(getRootEl(), {
...defaultViewConfig,
showPrimaryNavbar: false,
hideTagFilterChips: false,
} as AppViewConfig);
appEmbed.render();
await executeAfterWait(() => {
expectUrlMatchesWithParams(
getIFrameSrc(),
`http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false${defaultParams}&hideTagFilterChips=false${defaultParamsPost}#/home`,
);
});
});
test('Should not add hideTagFilterChips if it is undefined', async () => {
const appEmbed = new AppEmbed(getRootEl(), {
...defaultViewConfig,
showPrimaryNavbar: false,
} as AppViewConfig);
appEmbed.render();
await executeAfterWait(() => {
expectUrlMatchesWithParams(
getIFrameSrc(),
`http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false${defaultParams}${defaultParamsPost}#/home`,
);
});
});
test('Should add showMaskedFilterChip true to the iframe src', async () => {
const appEmbed = new AppEmbed(getRootEl(), {
...defaultViewConfig,
showPrimaryNavbar: false,
showMaskedFilterChip: true,
} as AppViewConfig);
appEmbed.render();
await executeAfterWait(() => {
expectUrlMatchesWithParams(
getIFrameSrc(),
`http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&showMaskedFilterChip=true${defaultParams}${defaultParamsPost}#/home`,
);
});
});
test('Should add showMaskedFilterChip false to the iframe src', async () => {
const appEmbed = new AppEmbed(getRootEl(), {
...defaultViewConfig,
showPrimaryNavbar: false,
showMaskedFilterChip: false,
} as AppViewConfig);
appEmbed.render();
await executeAfterWait(() => {
expectUrlMatchesWithParams(
getIFrameSrc(),
`http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&showMaskedFilterChip=false${defaultParams}${defaultParamsPost}#/home`,
);
});
});
test('Should add default showMaskedFilterChip false when not specified', async () => {
const appEmbed = new AppEmbed(getRootEl(), {
...defaultViewConfig,
showPrimaryNavbar: false,
} as AppViewConfig);
appEmbed.render();
await executeAfterWait(() => {
expectUrlMatchesWithParams(
getIFrameSrc(),
`http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&showMaskedFilterChip=false${defaultParams}${defaultParamsPost}#/home`,
);
});
});
test('Should add isLiveboardMasterpiecesEnabled true to the iframe src', async () => {
const appEmbed = new AppEmbed(getRootEl(), {
...defaultViewConfig,
showPrimaryNavbar: false,
isLiveboardMasterpiecesEnabled: true,
} as AppViewConfig);
appEmbed.render();
await executeAfterWait(() => {
expectUrlMatchesWithParams(
getIFrameSrc(),
`http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&isLiveboardMasterpiecesEnabled=true${defaultParams}${defaultParamsPost}#/home`,
);
});
});
test('Should add isLiveboardMasterpiecesEnabled false to the iframe src', async () => {
const appEmbed = new AppEmbed(getRootEl(), {
...defaultViewConfig,
showPrimaryNavbar: false,
isLiveboardMasterpiecesEnabled: false,
} as AppViewConfig);
appEmbed.render();
await executeAfterWait(() => {
expectUrlMatchesWithParams(
getIFrameSrc(),
`http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&isLiveboardMasterpiecesEnabled=false${defaultParams}${defaultParamsPost}#/home`,
);
});
});
test('Should add default isLiveboardMasterpiecesEnabled false when not specified', async () => {
const appEmbed = new AppEmbed(getRootEl(), {
...defaultViewConfig,
showPrimaryNavbar: false,
} as AppViewConfig);
appEmbed.render();
await executeAfterWait(() => {
expectUrlMatchesWithParams(
getIFrameSrc(),
`http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&isLiveboardMasterpiecesEnabled=false${defaultParams}${defaultParamsPost}#/home`,
);
});
});
test('Should add newChartsLibrary true to the iframe src', async () => {
const appEmbed = new AppEmbed(getRootEl(), {
...defaultViewConfig,
showPrimaryNavbar: false,
newChartsLibrary: true,
} as AppViewConfig);
appEmbed.render();
await executeAfterWait(() => {
expectUrlMatchesWithParams(
getIFrameSrc(),
`http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&muzeChartPhase1EnabledGA=true${defaultParams}${defaultParamsPost}#/home`,
);
});
});
test('Should add newChartsLibrary false to the iframe src', async () => {
const appEmbed = new AppEmbed(getRootEl(), {
...defaultViewConfig,
showPrimaryNavbar: false,
newChartsLibrary: false,
} as AppViewConfig);
appEmbed.render();
await executeAfterWait(() => {
expectUrlMatchesWithParams(
getIFrameSrc(),
`http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&muzeChartPhase1EnabledGA=false${defaultParams}${defaultParamsPost}#/home`,
);
});
});
test('Should not add newChartsLibrary to the iframe src when not specified', async () => {
const appEmbed = new AppEmbed(getRootEl(), {
...defaultViewConfig,
showPrimaryNavbar: false,
} as AppViewConfig);
appEmbed.render();
await executeAfterWait(() => {
expectUrlMatchesWithParams(
getIFrameSrc(),
`http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false${defaultParams}${defaultParamsPost}#/home`,
);
});
});
test('Should add enableSearchAssist flagto the iframe src', async () => {
const appEmbed = new AppEmbed(getRootEl(), {
...defaultViewConfig,
enableSearchAssist: true,
} as AppViewConfig);
appEmbed.render();
await executeAfterWait(() => {
expectUrlMatchesWithParams(
getIFrameSrc(),
`http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&enableSearchAssist=true${defaultParams}${defaultParamsPost}#/home`,
);
});
});
test('Should add enableDataPanelV2 flag to the iframe src', async () => {
const appEmbed = new AppEmbed(getRootEl(), {
...defaultViewConfig,
dataPanelV2: true,
} as AppViewConfig);
appEmbed.render();
await executeAfterWait(() => {
expectUrlMatchesWithParams(
getIFrameSrc(),
`http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&enableDataPanelV2=true${defaultParams}${defaultParamsPost}#/home`,
);
});
});
test('Should add isLiveboardHeaderSticky flag to the iframe src', async () => {
const appEmbed = new AppEmbed(getRootEl(), {
...defaultViewConfig,
isLiveboardHeaderSticky: false,
} as AppViewConfig);
appEmbed.render();
await executeAfterWait(() => {
expectUrlMatchesWithParams(
getIFrameSrc(),
`http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&isLiveboardHeaderSticky=false${defaultParams}${defaultParamsPost}#/home`,
);
});
});
test('Should add isLiveboardCompactHeaderEnabled flag to the iframe src', async () => {
const appEmbed = new AppEmbed(getRootEl(), {
...defaultViewConfig,
isLiveboardCompactHeaderEnabled: false,
} as AppViewConfig);
appEmbed.render();
await executeAfterWait(() => {
expectUrlMatchesWithParams(
getIFrameSrc(),
`http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&isLiveboardHeaderV2Enabled=false${defaultParams}${defaultParamsPost}#/home`,
);
});
});
test('Should add showLiveboardReverifyBanner flag to the iframe src', async () => {
const appEmbed = new AppEmbed(getRootEl(), {
...defaultViewConfig,
showLiveboardReverifyBanner: false,
} as AppViewConfig);
appEmbed.render();
await executeAfterWait(() => {
expectUrlMatchesWithParams(
getIFrameSrc(),
`http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&showLiveboardReverifyBanner=false${defaultParams}${defaultParamsPost}#/home`,
);
});
});
test('Should add isUnifiedSearchExperienceEnabled flag to the iframe src', async () => {
// Case 1: explicitly true
const appEmbedTrue = new AppEmbed(getRootEl(), {
...defaultViewConfig,
isUnifiedSearchExperienceEnabled: true,
} as AppViewConfig);
appEmbedTrue.render();
await executeAfterWait(() => {
expectUrlMatchesWithParams(
getIFrameSrc(),
`http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&isUnifiedSearchExperienceEnabled=true${defaultParams}${defaultParamsPost}#/home`,
);
});
appEmbedTrue.destroy();
// Case 2: explicitly false
const appEmbedFalse = new AppEmbed(getRootEl(), {
...defaultViewConfig,
isUnifiedSearchExperienceEnabled: false,
} as AppViewConfig);
appEmbedFalse.render();
await executeAfterWait(() => {
expectUrlMatchesWithParams(
getIFrameSrc(),
`http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&isUnifiedSearchExperienceEnabled=false${defaultParams}${defaultParamsPost}#/home`,
);
});
appEmbedFalse.destroy();
// Case 3: not provided — defaults to false
const appEmbedDefault = new AppEmbed(getRootEl(), {
...defaultViewConfig,
} as AppViewConfig);
appEmbedDefault.render();
await executeAfterWait(() => {
expectUrlMatchesWithParams(
getIFrameSrc(),
`http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&isUnifiedSearchExperienceEnabled=true${defaultParams}${defaultParamsPost}#/home`,
);
});
});
test('Should add hideIrrelevantFiltersAtTabLevel flag to the iframe src', async () => {
const appEmbed = new AppEmbed(getRootEl(), {
...defaultViewConfig,
hideIrrelevantChipsInLiveboardTabs: false,
} as AppViewConfig);
appEmbed.render();
await executeAfterWait(() => {
expectUrlMatchesWithParams(
getIFrameSrc(),
`http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&hideIrrelevantFiltersAtTabLevel=false${defaultParams}${defaultParamsPost}#/home`,
);
});
});
test('Should add showLiveboardVerifiedBadge flag to the iframe src', async () => {
const appEmbed = new AppEmbed(getRootEl(), {
...defaultViewConfig,
showLiveboardVerifiedBadge: false,
} as AppViewConfig);
appEmbed.render();
await executeAfterWait(() => {
expectUrlMatchesWithParams(
getIFrameSrc(),
`http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&showLiveboardVerifiedBadge=false${defaultParams}${defaultParamsPost}#/home`,
);
});
});
test('Should add isLiveboardPermissionV2Enabled flag to the iframe src', async () => {
const appEmbed = new AppEmbed(getRootEl(), {
...defaultViewConfig,
isEnhancedFilterInteractivityEnabled: false,
} as AppViewConfig);
appEmbed.render();
await executeAfterWait(() => {
expectUrlMatchesWithParams(
getIFrameSrc(),
`http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&isLiveboardPermissionV2Enabled=false${defaultParams}${defaultParamsPost}#/home`,
);
});
});
test('Should add default values of flags to the iframe src', async () => {
const appEmbed = new AppEmbed(getRootEl(), {
...defaultViewConfig,
} as AppViewConfig);
appEmbed.render();
await executeAfterWait(() => {
expectUrlMatchesWithParams(
getIFrameSrc(),
`http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&isLiveboardHeaderSticky=true&hideLiveboardHeader=false&showLiveboardDescription=true&showLiveboardTitle=true${defaultParams}${defaultParamsPost}#/home`,
);
});
});
test('Should add modularHomeExperience flag to the iframe src', async () => {
const appEmbed = new AppEmbed(getRootEl(), {
...defaultViewConfig,
modularHomeExperience: true,
} as AppViewConfig);
appEmbed.render();
await executeAfterWait(() => {
expectUrlMatchesWithParams(
getIFrameSrc(),
`http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&modularHomeExperience=true${defaultParams}${defaultParamsPost}#/home`,
);
});
});
test('Should add hideHomepageLeftNav flag to the iframe src', async () => {
const appEmbed = new AppEmbed(getRootEl(), {
...defaultViewConfig,
hideHomepageLeftNav: false,
} as AppViewConfig);
appEmbed.render();
await executeAfterWait(() => {
expectUrlMatchesWithParams(
getIFrameSrc(),
`http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&modularHomeExperience=false&hideHomepageLeftNav=false${defaultParams}${defaultParamsPost}#/home`,
);
});
});
test('Should add hideHamburger, hideObjectSearch, hideNotification flags to the iframe src', async () => {
const appEmbed = new AppEmbed(getRootEl(), {
...defaultViewConfig,
hideHamburger: true,
hideObjectSearch: true,
hideNotification: true,
} as AppViewConfig);
appEmbed.render();
await executeAfterWait(() => {
expectUrlMatchesWithParams(
getIFrameSrc(),
`http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&modularHomeExperience=false&hideHamburger=true&hideObjectSearch=true&hideNotification=true${defaultParams}${defaultParamsPost}#/home`,
);
});
});
test('Should not add when hideHamburger, hideObjectSearch, hideNotification values are not true to the iframe src', async () => {
const appEmbed = new AppEmbed(getRootEl(), {
...defaultViewConfig,
hideHamburger: false,
hideObjectSearch: undefined,
hideNotification: null,
} as AppViewConfig);
appEmbed.render();
await executeAfterWait(() => {
expectUrlMatchesWithParams(
getIFrameSrc(),
`http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&modularHomeExperience=false${defaultParams}${defaultParamsPost}#/home`,
);
});
});
test('Should add navigationVersion=v3 when primaryNavbarVersion is Sliding to the iframe src', async () => {
await testUrlParams(
{
...defaultViewConfig,
discoveryExperience: {
primaryNavbarVersion: PrimaryNavbarVersion.Sliding,
homePage: HomePage.Modular,
},
} as AppViewConfig,
`http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&modularHomeExperience=true&navigationVersion=v3${defaultParams}${defaultParamsPost}#/home`
);
});
test('Should not add navigationVersion=v3 when primaryNavbarVersion is not added to the iframe src', async () => {
await testUrlParams(
{
...defaultViewConfig,
discoveryExperience: {
homePage: HomePage.Modular,
},
} as AppViewConfig,
`http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&modularHomeExperience=true${defaultParams}${defaultParamsPost}#/home`
);
});
test('Should add navigationVersion=v3 & modularHomeExperience=true when primaryNavbarVersion is Sliding to the iframe src', async () => {
await testUrlParams(
{
...defaultViewConfig,
// homePage v2 config not included under discoveryExperience
discoveryExperience: {
primaryNavbarVersion: PrimaryNavbarVersion.Sliding,
},
} as AppViewConfig,
`http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&modularHomeExperience=true&navigationVersion=v3${defaultParams}${defaultParamsPost}#/home`
);
});
test('Should add homepageVersion=v3 & navigationVersion=v3 & modularHomeExperience=true when Sliding and ModularWithStylingChanges configured in the iframe src', async () => {
await testUrlParams(
{
...defaultViewConfig,
discoveryExperience: {
primaryNavbarVersion: PrimaryNavbarVersion.Sliding,
homePage: HomePage.ModularWithStylingChanges,
},
} as AppViewConfig,
`http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&modularHomeExperience=true&navigationVersion=v3&homepageVersion=v3${defaultParams}${defaultParamsPost}#/home`
);
});
test('Should add homepageVersion=v3 & navigationVersion=v3 & modularHomeExperience=true when homePage is ModularWithStylingChanges to the iframe src', async () => {
await testUrlParams(
{
...defaultViewConfig,
// primaryNavbarVersion is not included under
// discoveryExperience, then it set navigationVersion=v2 and
// modularHomeExperience=false.
discoveryExperience: {
homePage: HomePage.ModularWithStylingChanges,
},
} as AppViewConfig,
`http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&modularHomeExperience=false&navigationVersion=v2&homepageVersion=v3${defaultParams}${defaultParamsPost}#/home`
);
});
test('Should add navigationVersion=v2 when primaryNavbarVersion is not added to the iframe src', async () => {
await testUrlParams(
{
...defaultViewConfig,
} as AppViewConfig,
`http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&modularHomeExperience=false&navigationVersion=v2${defaultParams}${defaultParamsPost}#/home`
);
});
test('Should add enableAskSage flag to the iframe src', async () => {
await testUrlParams(
{
...defaultViewConfig,
enableAskSage: true,
} as AppViewConfig,
`http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&modularHomeExperience=false&enableAskSage=true${defaultParams}${defaultParamsPost}#/home`
);
});
test('Should add listpageVersion=v3 when listPageVersion is ListWithUXChanges to the iframe src', async () => {
await testUrlParams(
{
...defaultViewConfig,
discoveryExperience: {
listPageVersion: ListPage.ListWithUXChanges,
},
} as AppViewConfig,
`http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&modularHomeExperience=false&listpageVersion=v3${defaultParams}${defaultParamsPost}#/home`
);
});
test('Should add listpageVersion=v2 by default when no discoveryExperience is provided', async () => {
await testUrlParams(
{
...defaultViewConfig,
} as AppViewConfig,
`http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&modularHomeExperience=false&navigationVersion=v2${defaultParams}${defaultParamsPost}#/home`
);
});
test('Should add listpageVersion=v2 by default when discoveryExperience is provided but listPageVersion is not specified', async () => {
await testUrlParams(
{
...defaultViewConfig,
discoveryExperience: {
primaryNavbarVersion: PrimaryNavbarVersion.Sliding,
homePage: HomePage.Modular,
},
} as AppViewConfig,
`http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&modularHomeExperience=true&navigationVersion=v3${defaultParams}${defaultParamsPost}#/home`
);
});
test('Should add listpageVersion=v3 combined with other discoveryExperience options to the iframe src', async () => {
await testUrlParams(
{
...defaultViewConfig,
discoveryExperience: {