diff --git a/src/embed/app.spec.ts b/src/embed/app.spec.ts index 146232f6..425a968f 100644 --- a/src/embed/app.spec.ts +++ b/src/embed/app.spec.ts @@ -37,6 +37,72 @@ const defaultViewConfig = { 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({ @@ -827,7 +893,7 @@ describe('App embed tests', () => { await executeAfterWait(() => { expectUrlMatchesWithParams( getIFrameSrc(), - `http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&modularHomeExperience=false&hideHomepageLeftNav=false${defaultParams}${defaultParamsPost}#/home`, + `http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&hideHomepageLeftNav=false${defaultParams}${defaultParamsPost}#/home`, ); }); }); @@ -844,7 +910,7 @@ describe('App embed tests', () => { await executeAfterWait(() => { expectUrlMatchesWithParams( getIFrameSrc(), - `http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&modularHomeExperience=false&hideHamburger=true&hideObjectSearch=true&hideNotification=true${defaultParams}${defaultParamsPost}#/home`, + `http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&hideHamburger=true&hideObjectSearch=true&hideNotification=true${defaultParams}${defaultParamsPost}#/home`, ); }); }); @@ -861,198 +927,153 @@ describe('App embed tests', () => { await executeAfterWait(() => { expectUrlMatchesWithParams( getIFrameSrc(), - `http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&modularHomeExperience=false${defaultParams}${defaultParamsPost}#/home`, + `http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false${defaultParams}${defaultParamsPost}#/home`, ); }); }); test('Should add navigationVersion=v3 when primaryNavbarVersion is Sliding to the iframe src', async () => { - const appEmbed = new AppEmbed(getRootEl(), { - ...defaultViewConfig, - discoveryExperience: { - primaryNavbarVersion: PrimaryNavbarVersion.Sliding, - homePage: HomePage.Modular, - }, - } as AppViewConfig); - - appEmbed.render(); - await executeAfterWait(() => { - expectUrlMatchesWithParams( - getIFrameSrc(), - `http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&modularHomeExperience=true&navigationVersion=v3${defaultParams}${defaultParamsPost}#/home`, - ); - }); + 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 () => { - const appEmbed = new AppEmbed(getRootEl(), { - ...defaultViewConfig, - discoveryExperience: { - homePage: HomePage.Modular, - }, - } as AppViewConfig); - - appEmbed.render(); - await executeAfterWait(() => { - expectUrlMatchesWithParams( - getIFrameSrc(), - `http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&modularHomeExperience=true${defaultParams}${defaultParamsPost}#/home`, - ); - }); + 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 () => { - const appEmbed = new AppEmbed(getRootEl(), { - ...defaultViewConfig, - // Not included the homePage v2 config under discoveryExperience. - discoveryExperience: { - primaryNavbarVersion: PrimaryNavbarVersion.Sliding, - }, - } as AppViewConfig); - - appEmbed.render(); - await executeAfterWait(() => { - expectUrlMatchesWithParams( - getIFrameSrc(), - `http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&modularHomeExperience=true&navigationVersion=v3${defaultParams}${defaultParamsPost}#/home`, - ); - }); + 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 () => { - const appEmbed = new AppEmbed(getRootEl(), { - ...defaultViewConfig, - discoveryExperience: { - primaryNavbarVersion: PrimaryNavbarVersion.Sliding, - homePage: HomePage.ModularWithStylingChanges, - }, - } as AppViewConfig); - - appEmbed.render(); - await executeAfterWait(() => { - expectUrlMatchesWithParams( - getIFrameSrc(), - `http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&modularHomeExperience=true&navigationVersion=v3&homepageVersion=v3${defaultParams}${defaultParamsPost}#/home`, - ); - }); + 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 () => { - const appEmbed = new AppEmbed(getRootEl(), { - ...defaultViewConfig, - // primaryNavbarVersion is not included under discoveryExperience, - // then it set navigationVersion=v2 and modularHomeExperience=false. - discoveryExperience: { - homePage: HomePage.ModularWithStylingChanges, - }, - } as AppViewConfig); - - appEmbed.render(); - await executeAfterWait(() => { - expectUrlMatchesWithParams( - getIFrameSrc(), - `http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&modularHomeExperience=false&navigationVersion=v2&homepageVersion=v3${defaultParams}${defaultParamsPost}#/home`, - ); - }); + 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&navigationVersion=v2&homepageVersion=v3${defaultParams}${defaultParamsPost}#/home` + ); }); test('Should add navigationVersion=v2 when primaryNavbarVersion is not added 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&modularHomeExperience=false&navigationVersion=v2${defaultParams}${defaultParamsPost}#/home`, - ); - }); + await testUrlParams( + { + ...defaultViewConfig, + } as AppViewConfig, + `http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&navigationVersion=v2${defaultParams}${defaultParamsPost}#/home` + ); }); test('Should add enableAskSage flag to the iframe src', async () => { - const appEmbed = new AppEmbed(getRootEl(), { - ...defaultViewConfig, - enableAskSage: true, - } as AppViewConfig); - - appEmbed.render(); - await executeAfterWait(() => { - expectUrlMatchesWithParams( - getIFrameSrc(), - `http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&modularHomeExperience=false&enableAskSage=true${defaultParams}${defaultParamsPost}#/home`, - ); - }); + await testUrlParams( + { + ...defaultViewConfig, + enableAskSage: true, + } as AppViewConfig, + `http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&enableAskSage=true${defaultParams}${defaultParamsPost}#/home` + ); }); test('Should add listpageVersion=v3 when listPageVersion is ListWithUXChanges to the iframe src', async () => { - const appEmbed = new AppEmbed(getRootEl(), { - ...defaultViewConfig, - discoveryExperience: { - listPageVersion: ListPage.ListWithUXChanges, - }, - } as AppViewConfig); - - appEmbed.render(); - await executeAfterWait(() => { - expectUrlMatchesWithParams( - getIFrameSrc(), - `http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&modularHomeExperience=false&listpageVersion=v3${defaultParams}${defaultParamsPost}#/home`, - ); - }); + await testUrlParams( + { + ...defaultViewConfig, + discoveryExperience: { + listPageVersion: ListPage.ListWithUXChanges, + }, + } as AppViewConfig, + `http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&listpageVersion=v3${defaultParams}${defaultParamsPost}#/home` + ); }); - test('Should add listpageVersion=v2 by default when no discoveryExperience is provided', async () => { - const appEmbed = new AppEmbed(getRootEl(), { - ...defaultViewConfig, - } as AppViewConfig); - - appEmbed.render(); - await executeAfterWait(() => { - expectUrlMatchesWithParams( - getIFrameSrc(), - `http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&modularHomeExperience=false&navigationVersion=v2&listpageVersion=v2${defaultParams}${defaultParamsPost}#/home`, - ); - }); + await testUrlParams( + { + ...defaultViewConfig, + } as AppViewConfig, + `http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&navigationVersion=v2${defaultParams}${defaultParamsPost}#/home` + ); }); test('Should add listpageVersion=v2 by default when discoveryExperience is provided but listPageVersion is not specified', async () => { - const appEmbed = new AppEmbed(getRootEl(), { - ...defaultViewConfig, - discoveryExperience: { - primaryNavbarVersion: PrimaryNavbarVersion.Sliding, - homePage: HomePage.Modular, - }, - } as AppViewConfig); + 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` + ); + }); - appEmbed.render(); - await executeAfterWait(() => { - expectUrlMatchesWithParams( - getIFrameSrc(), - `http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&modularHomeExperience=true&navigationVersion=v3&listpageVersion=v2${defaultParams}${defaultParamsPost}#/home`, - ); - }); + test('Should add listpageVersion=v2 when modularHomeExperience is explicitly false', async () => { + await testUrlParams( + { + ...defaultViewConfig, + modularHomeExperience: false, + } as AppViewConfig, + `http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&modularHomeExperience=false&navigationVersion=v2&listpageVersion=v2${defaultParams}${defaultParamsPost}#/home` + ); }); test('Should add listpageVersion=v3 combined with other discoveryExperience options to the iframe src', async () => { - const appEmbed = new AppEmbed(getRootEl(), { - ...defaultViewConfig, - discoveryExperience: { - primaryNavbarVersion: PrimaryNavbarVersion.Sliding, - homePage: HomePage.Modular, - listPageVersion: ListPage.ListWithUXChanges, - }, - } as AppViewConfig); - - appEmbed.render(); - await executeAfterWait(() => { - expectUrlMatchesWithParams( - getIFrameSrc(), - `http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&modularHomeExperience=true&navigationVersion=v3&listpageVersion=v3${defaultParams}${defaultParamsPost}#/home`, - ); - }); + await testUrlParams( + { + ...defaultViewConfig, + discoveryExperience: { + primaryNavbarVersion: PrimaryNavbarVersion.Sliding, + homePage: HomePage.Modular, + listPageVersion: ListPage.ListWithUXChanges, + }, + } as AppViewConfig, + `http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&modularHomeExperience=true&navigationVersion=v3&listpageVersion=v3${defaultParams}${defaultParamsPost}#/home` + ); }); test('Should add enablePendoHelp flag to the iframe src conditional on navbar', async () => { @@ -1064,7 +1085,7 @@ describe('App embed tests', () => { await executeAfterWait(() => { expectUrlMatchesWithParams( getIFrameSrc(), - `http://${thoughtSpotHost}/?enablePendoHelp=true&embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&modularHomeExperience=false${defaultParams}${defaultParamsPost}#/home`, + `http://${thoughtSpotHost}/?enablePendoHelp=true&embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false${defaultParams}${defaultParamsPost}#/home`, ); }); @@ -1077,7 +1098,7 @@ describe('App embed tests', () => { await executeAfterWait(() => { expectUrlMatchesWithParams( getIFrameSrc(), - `http://${thoughtSpotHost}/?enablePendoHelp=false&embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&modularHomeExperience=false${defaultParams}${defaultParamsPost}#/home`, + `http://${thoughtSpotHost}/?enablePendoHelp=false&embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false${defaultParams}${defaultParamsPost}#/home`, ); }); }); @@ -1092,7 +1113,7 @@ describe('App embed tests', () => { await executeAfterWait(() => { expectUrlMatchesWithParams( getIFrameSrc(), - `http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&modularHomeExperience=false&homePageSearchBarMode=objectSearch${defaultParams}${defaultParamsPost}#/home`, + `http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&homePageSearchBarMode=objectSearch${defaultParams}${defaultParamsPost}#/home`, ); }); }); @@ -1107,7 +1128,7 @@ describe('App embed tests', () => { await executeAfterWait(() => { expectUrlMatchesWithParams( getIFrameSrc(), - `http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&modularHomeExperience=false&homePageSearchBarMode=aiAnswer${defaultParams}${defaultParamsPost}#/home`, + `http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&homePageSearchBarMode=aiAnswer${defaultParams}${defaultParamsPost}#/home`, ); }); }); @@ -1122,7 +1143,7 @@ describe('App embed tests', () => { await executeAfterWait(() => { expectUrlMatchesWithParams( getIFrameSrc(), - `http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&modularHomeExperience=false&homePageSearchBarMode=none${defaultParams}${defaultParamsPost}#/home`, + `http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&homePageSearchBarMode=none${defaultParams}${defaultParamsPost}#/home`, ); }); }); @@ -1139,7 +1160,7 @@ describe('App embed tests', () => { await executeAfterWait(() => { expectUrlMatchesWithParams( getIFrameSrc(), - `http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&modularHomeExperience=false&dataPanelCustomGroupsAccordionInitialState=EXPAND_FIRST${defaultParams}${defaultParamsPost}#/home`, + `http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&dataPanelCustomGroupsAccordionInitialState=EXPAND_FIRST${defaultParams}${defaultParamsPost}#/home`, ); }); }); @@ -1273,21 +1294,8 @@ describe('App embed tests', () => { let mockIFrame: HTMLIFrameElement; beforeEach(() => { - mockIFrame = document.createElement('iframe'); - mockIFrame.getBoundingClientRect = jest.fn().mockReturnValue({ - top: 100, - left: 150, - bottom: 600, - right: 800, - width: 650, - height: 500, - }); - jest.spyOn(document, 'createElement').mockImplementation((tagName) => { - if (tagName === 'iframe') { - return mockIFrame; - } - return document.createElement(tagName); - }); + mockIFrame = createMockIFrame(); + setupIFrameCreationSpy(mockIFrame); }); afterEach(() => { @@ -1564,53 +1572,15 @@ describe('App embed tests', () => { }); test('should not call setIFrameHeight if currentPath starts with "/embed/viz/"', () => { - const appEmbed = new AppEmbed(getRootEl(), { - ...defaultViewConfig, - fullHeight: true, - } as AppViewConfig) as any; - const spySetIFrameHeight = jest.spyOn(appEmbed, 'setIFrameHeight'); - - appEmbed.render(); - appEmbed.setIframeHeightForNonEmbedLiveboard({ - data: { currentPath: '/embed/viz/' }, - type: 'Route', - }); - - expect(spySetIFrameHeight).not.toHaveBeenCalled(); + testSetIframeHeightBehavior('/embed/viz/', false); }); test('should not call setIFrameHeight if currentPath starts with "/embed/insights/viz/"', () => { - const appEmbed = new AppEmbed(getRootEl(), { - ...defaultViewConfig, - fullHeight: true, - } as AppViewConfig) as any; - const spySetIFrameHeight = jest.spyOn(appEmbed, 'setIFrameHeight'); - - appEmbed.render(); - appEmbed.setIframeHeightForNonEmbedLiveboard({ - data: { currentPath: '/embed/insights/viz/' }, - type: 'Route', - }); - - expect(spySetIFrameHeight).not.toHaveBeenCalled(); + testSetIframeHeightBehavior('/embed/insights/viz/', false); }); test('should call setIFrameHeight if currentPath starts with "/some/other/path/"', () => { - const appEmbed = new AppEmbed(getRootEl(), { - ...defaultViewConfig, - fullHeight: true, - } as AppViewConfig) as any; - const spySetIFrameHeight = jest - .spyOn(appEmbed, 'setIFrameHeight') - .mockImplementation(jest.fn()); - - appEmbed.render(); - appEmbed.setIframeHeightForNonEmbedLiveboard({ - data: { currentPath: '/some/other/path/' }, - type: 'Route', - }); - - expect(spySetIFrameHeight).toHaveBeenCalled(); + testSetIframeHeightBehavior('/some/other/path/', true); }); test('should update iframe height correctly', async () => { diff --git a/src/embed/app.ts b/src/embed/app.ts index 452422cf..772d2ab9 100644 --- a/src/embed/app.ts +++ b/src/embed/app.ts @@ -738,7 +738,7 @@ export class AppEmbed extends V1Embed { showMaskedFilterChip = false, isLiveboardMasterpiecesEnabled = false, hideHomepageLeftNav = false, - modularHomeExperience = false, + modularHomeExperience, isLiveboardHeaderSticky = true, enableAskSage, collapseSearchBarInitially = false, @@ -878,7 +878,6 @@ export class AppEmbed extends V1Embed { params[Param.DataPanelV2Enabled] = dataPanelV2; params[Param.HideHomepageLeftNav] = hideHomepageLeftNav; - params[Param.ModularHomeExperienceEnabled] = modularHomeExperience; params[Param.CollapseSearchBarInitially] = collapseSearchBarInitially || collapseSearchBar; params[Param.EnableCustomColumnGroups] = enableCustomColumnGroups; if (dataPanelCustomGroupsAccordionInitialState @@ -895,6 +894,10 @@ export class AppEmbed extends V1Embed { params[Param.DataPanelCustomGroupsAccordionInitialState] = DataPanelCustomColumnGroupsAccordionState.EXPAND_ALL; } + if (modularHomeExperience !== undefined) { + params[Param.ModularHomeExperienceEnabled] = modularHomeExperience; + } + // Set navigation to v2 by default to avoid problems like the app // switcher (9-dot menu) not showing when v3 navigation is turned on // at the cluster level. @@ -904,9 +907,6 @@ export class AppEmbed extends V1Embed { // Set homePageVersion to v2 by default to reset the LD flag value // for the homepageVersion. params[Param.HomepageVersion] = 'v2'; - // Set listpageVersion to v2 by default to reset the LD flag value - // for the listpageVersion. - params[Param.ListPageVersion] = ListPage.List; if (discoveryExperience) { // primaryNavbarVersion v3 will enabled the new left navigation if (discoveryExperience.primaryNavbarVersion === PrimaryNavbarVersion.Sliding) { @@ -928,12 +928,19 @@ export class AppEmbed extends V1Embed { params[Param.HomepageVersion] = HomePage.ModularWithStylingChanges; } - // listPageVersion v3 will enable the new list page - if (discoveryExperience.listPageVersion === ListPage.ListWithUXChanges) { + // listPageVersion can be changed to v2 or v3 + if (discoveryExperience.listPageVersion !== undefined + && Object.values(ListPage).includes(discoveryExperience.listPageVersion)) { params[Param.ListPageVersion] = discoveryExperience.listPageVersion; } } + // If modularHomeExperience is false, set listPageVersion to v2 to + // avoid homepage library loading issue + if (modularHomeExperience === false) { + params[Param.ListPageVersion] = ListPage.List; + } + const queryParams = getQueryParamString(params, true); return queryParams; @@ -1014,7 +1021,7 @@ export class AppEmbed extends V1Embed { * @param pageId The identifier for a page in the ThoughtSpot app. * @param modularHomeExperience */ - private getPageRoute(pageId: Page, modularHomeExperience = false) { + private getPageRoute(pageId: Page, modularHomeExperience = true) { switch (pageId) { case Page.Search: return 'answer';