From 106879a872a835ea8b16c8dcf5f1f6b8f04806f8 Mon Sep 17 00:00:00 2001 From: Mohammed Ashad MM Date: Thu, 22 Jan 2026 14:05:06 +0530 Subject: [PATCH 1/7] SCAL-291789 Remove listpageVersion parameter from embed app URL --- src/embed/app.spec.ts | 8 ++++---- src/embed/app.ts | 3 --- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/embed/app.spec.ts b/src/embed/app.spec.ts index 146232f6..588246c0 100644 --- a/src/embed/app.spec.ts +++ b/src/embed/app.spec.ts @@ -1012,7 +1012,7 @@ describe('App embed tests', () => { await executeAfterWait(() => { expectUrlMatchesWithParams( getIFrameSrc(), - `http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&modularHomeExperience=false&navigationVersion=v2&listpageVersion=v2${defaultParams}${defaultParamsPost}#/home`, + `http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&modularHomeExperience=false&navigationVersion=v2${defaultParams}${defaultParamsPost}#/home`, ); }); }); @@ -1030,7 +1030,7 @@ describe('App embed tests', () => { await executeAfterWait(() => { expectUrlMatchesWithParams( getIFrameSrc(), - `http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&modularHomeExperience=true&navigationVersion=v3&listpageVersion=v2${defaultParams}${defaultParamsPost}#/home`, + `http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&modularHomeExperience=true&navigationVersion=v3${defaultParams}${defaultParamsPost}#/home`, ); }); }); @@ -1246,7 +1246,7 @@ describe('App embed tests', () => { }, }); await appEmbed.render(); - jest.spyOn(logger, 'warn').mockImplementation(() => {}); + jest.spyOn(logger, 'warn').mockImplementation(() => { }); appEmbed.navigateToPage(-1); expect(logger.warn).toHaveBeenCalledWith( 'Path can only by a string when triggered without noReload', @@ -1254,7 +1254,7 @@ describe('App embed tests', () => { }); test('navigateToPage function use before render', async () => { - jest.spyOn(logger, 'log').mockImplementation(() => {}); + jest.spyOn(logger, 'log').mockImplementation(() => { }); const appEmbed = new AppEmbed(getRootEl(), { frameParams: { width: '100%', diff --git a/src/embed/app.ts b/src/embed/app.ts index 452422cf..15ab4b8c 100644 --- a/src/embed/app.ts +++ b/src/embed/app.ts @@ -904,9 +904,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) { From 645f43ad16cfd0d6374ac5d080a7e35569e63c80 Mon Sep 17 00:00:00 2001 From: Mohammed Ashad MM Date: Thu, 22 Jan 2026 14:08:06 +0530 Subject: [PATCH 2/7] SCAL-291789Remove unnecessary whitespace --- src/embed/app.spec.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/embed/app.spec.ts b/src/embed/app.spec.ts index 588246c0..39772d37 100644 --- a/src/embed/app.spec.ts +++ b/src/embed/app.spec.ts @@ -1246,7 +1246,7 @@ describe('App embed tests', () => { }, }); await appEmbed.render(); - jest.spyOn(logger, 'warn').mockImplementation(() => { }); + jest.spyOn(logger, 'warn').mockImplementation(() => {}); appEmbed.navigateToPage(-1); expect(logger.warn).toHaveBeenCalledWith( 'Path can only by a string when triggered without noReload', @@ -1254,7 +1254,7 @@ describe('App embed tests', () => { }); test('navigateToPage function use before render', async () => { - jest.spyOn(logger, 'log').mockImplementation(() => { }); + jest.spyOn(logger, 'log').mockImplementation(() => {}); const appEmbed = new AppEmbed(getRootEl(), { frameParams: { width: '100%', From 939de9c603d5125379da896757f5e9e795e121c0 Mon Sep 17 00:00:00 2001 From: mohammed-ashad Date: Fri, 30 Jan 2026 09:46:31 +0530 Subject: [PATCH 3/7] SCAL-291789 changed modularHomeExperience and discoveryExperience.listPageVersion default hardcoded values --- src/embed/app.spec.ts | 71 ++++++++++++++++++++++++++----------------- src/embed/app.ts | 14 ++++++--- 2 files changed, 52 insertions(+), 33 deletions(-) diff --git a/src/embed/app.spec.ts b/src/embed/app.spec.ts index 39772d37..5be382c2 100644 --- a/src/embed/app.spec.ts +++ b/src/embed/app.spec.ts @@ -131,7 +131,6 @@ describe('App embed tests', () => { }); describe('should render the correct routes for pages', () => { - const pageRouteMap = { [Page.Search]: 'answer', [Page.Answers]: 'answers', @@ -181,7 +180,10 @@ describe('App embed tests', () => { const pageIdsForModularHome = pageIdsForModularHomes[i]; test(`${pageIdsForModularHome}`, async () => { - const route = pageRouteMapForModularHome[pageIdsForModularHome as keyof typeof pageRouteMapForModularHome]; + const route = + pageRouteMapForModularHome[ + pageIdsForModularHome as keyof typeof pageRouteMapForModularHome + ]; const appEmbed = new AppEmbed(getRootEl(), { ...defaultViewConfig, modularHomeExperience: true, @@ -827,7 +829,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 +846,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,7 +863,7 @@ 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`, ); }); }); @@ -951,7 +953,7 @@ describe('App embed tests', () => { await executeAfterWait(() => { expectUrlMatchesWithParams( getIFrameSrc(), - `http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&modularHomeExperience=false&navigationVersion=v2&homepageVersion=v3${defaultParams}${defaultParamsPost}#/home`, + `http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&navigationVersion=v2&homepageVersion=v3${defaultParams}${defaultParamsPost}#/home`, ); }); }); @@ -965,7 +967,7 @@ describe('App embed tests', () => { await executeAfterWait(() => { expectUrlMatchesWithParams( getIFrameSrc(), - `http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&modularHomeExperience=false&navigationVersion=v2${defaultParams}${defaultParamsPost}#/home`, + `http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&navigationVersion=v2${defaultParams}${defaultParamsPost}#/home`, ); }); }); @@ -980,7 +982,7 @@ describe('App embed tests', () => { await executeAfterWait(() => { expectUrlMatchesWithParams( getIFrameSrc(), - `http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&modularHomeExperience=false&enableAskSage=true${defaultParams}${defaultParamsPost}#/home`, + `http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&enableAskSage=true${defaultParams}${defaultParamsPost}#/home`, ); }); }); @@ -997,12 +999,11 @@ describe('App embed tests', () => { await executeAfterWait(() => { expectUrlMatchesWithParams( getIFrameSrc(), - `http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&modularHomeExperience=false&listpageVersion=v3${defaultParams}${defaultParamsPost}#/home`, + `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, @@ -1012,7 +1013,7 @@ describe('App embed tests', () => { await executeAfterWait(() => { expectUrlMatchesWithParams( getIFrameSrc(), - `http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&modularHomeExperience=false&navigationVersion=v2${defaultParams}${defaultParamsPost}#/home`, + `http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&navigationVersion=v2${defaultParams}${defaultParamsPost}#/home`, ); }); }); @@ -1035,7 +1036,6 @@ describe('App embed tests', () => { }); }); - test('Should add listpageVersion=v3 combined with other discoveryExperience options to the iframe src', async () => { const appEmbed = new AppEmbed(getRootEl(), { ...defaultViewConfig, @@ -1064,7 +1064,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 +1077,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 +1092,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 +1107,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 +1122,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,16 +1139,19 @@ 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`, ); }); }); test('should register event handlers to adjust iframe height', async () => { - let embedHeightCallback: any = () => { }; + let embedHeightCallback: any = () => {}; const onSpy = jest.spyOn(AppEmbed.prototype, 'on').mockImplementation((event, callback) => { if (event === EmbedEvent.RouteChange) { - callback({ type: EmbedEvent.RouteChange, data: { currentPath: '/answers' } } as any, jest.fn()); + callback( + { type: EmbedEvent.RouteChange, data: { currentPath: '/answers' } } as any, + jest.fn(), + ); } if (event === EmbedEvent.EmbedHeight) { embedHeightCallback = callback; @@ -1179,7 +1182,10 @@ describe('App embed tests', () => { expect(onSpy).toHaveBeenCalledWith(EmbedEvent.EmbedHeight, expect.anything()); expect(onSpy).toHaveBeenCalledWith(EmbedEvent.RouteChange, expect.anything()); expect(onSpy).toHaveBeenCalledWith(EmbedEvent.EmbedIframeCenter, expect.anything()); - expect(onSpy).toHaveBeenCalledWith(EmbedEvent.RequestVisibleEmbedCoordinates, expect.anything()); + expect(onSpy).toHaveBeenCalledWith( + EmbedEvent.RequestVisibleEmbedCoordinates, + expect.anything(), + ); }, 100); }); @@ -1325,9 +1331,11 @@ describe('App embed tests', () => { Object.defineProperty(mockIFrame, 'scrollHeight', { value: 500 }); // Mock the event handlers - const onSpy = jest.spyOn(AppEmbed.prototype, 'on').mockImplementation((event, callback) => { - return null; - }); + const onSpy = jest + .spyOn(AppEmbed.prototype, 'on') + .mockImplementation((event, callback) => { + return null; + }); jest.spyOn(TsEmbed.prototype as any, 'getIframeCenter').mockReturnValue({}); jest.spyOn(TsEmbed.prototype as any, 'setIFrameHeight').mockReturnValue({}); @@ -1403,7 +1411,10 @@ describe('App embed tests', () => { await appEmbed.render(); - expect(onSpy).toHaveBeenCalledWith(EmbedEvent.RequestVisibleEmbedCoordinates, expect.any(Function)); + expect(onSpy).toHaveBeenCalledWith( + EmbedEvent.RequestVisibleEmbedCoordinates, + expect.any(Function), + ); onSpy.mockRestore(); }); @@ -1457,9 +1468,9 @@ describe('App embed tests', () => { (appEmbed as any).sendFullHeightLazyLoadData(); expect(mockTrigger).toHaveBeenCalledWith(HostEvent.VisibleEmbedCoordinates, { - top: 50, // 50px clipped from top + top: 50, // 50px clipped from top height: 700, // visible height (from 0 to 700) - left: 30, // 30px clipped from left + left: 30, // 30px clipped from left width: 1024, // visible width (from 0 to 1024) }); }); @@ -1479,7 +1490,11 @@ describe('App embed tests', () => { // Wait for the post-render events to be registered await executeAfterWait(() => { expect(addEventListenerSpy).toHaveBeenCalledWith('resize', expect.any(Function)); - expect(addEventListenerSpy).toHaveBeenCalledWith('scroll', expect.any(Function), true); + expect(addEventListenerSpy).toHaveBeenCalledWith( + 'scroll', + expect.any(Function), + true, + ); }, 100); addEventListenerSpy.mockRestore(); diff --git a/src/embed/app.ts b/src/embed/app.ts index 15ab4b8c..492f7055 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. @@ -925,8 +928,9 @@ 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; } } @@ -1011,7 +1015,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'; From 2a373808e8bf9ca62009729670dc90a47add8a21 Mon Sep 17 00:00:00 2001 From: mohammed-ashad Date: Fri, 30 Jan 2026 09:56:41 +0530 Subject: [PATCH 4/7] SCAL-291789 removed prettier changes --- src/embed/app.spec.ts | 40 ++++++++++++---------------------------- 1 file changed, 12 insertions(+), 28 deletions(-) diff --git a/src/embed/app.spec.ts b/src/embed/app.spec.ts index 5be382c2..b4b11e1a 100644 --- a/src/embed/app.spec.ts +++ b/src/embed/app.spec.ts @@ -131,6 +131,7 @@ describe('App embed tests', () => { }); describe('should render the correct routes for pages', () => { + const pageRouteMap = { [Page.Search]: 'answer', [Page.Answers]: 'answers', @@ -180,10 +181,7 @@ describe('App embed tests', () => { const pageIdsForModularHome = pageIdsForModularHomes[i]; test(`${pageIdsForModularHome}`, async () => { - const route = - pageRouteMapForModularHome[ - pageIdsForModularHome as keyof typeof pageRouteMapForModularHome - ]; + const route = pageRouteMapForModularHome[pageIdsForModularHome as keyof typeof pageRouteMapForModularHome]; const appEmbed = new AppEmbed(getRootEl(), { ...defaultViewConfig, modularHomeExperience: true, @@ -1036,6 +1034,7 @@ describe('App embed tests', () => { }); }); + test('Should add listpageVersion=v3 combined with other discoveryExperience options to the iframe src', async () => { const appEmbed = new AppEmbed(getRootEl(), { ...defaultViewConfig, @@ -1148,10 +1147,7 @@ describe('App embed tests', () => { let embedHeightCallback: any = () => {}; const onSpy = jest.spyOn(AppEmbed.prototype, 'on').mockImplementation((event, callback) => { if (event === EmbedEvent.RouteChange) { - callback( - { type: EmbedEvent.RouteChange, data: { currentPath: '/answers' } } as any, - jest.fn(), - ); + callback({ type: EmbedEvent.RouteChange, data: { currentPath: '/answers' } } as any, jest.fn()); } if (event === EmbedEvent.EmbedHeight) { embedHeightCallback = callback; @@ -1182,10 +1178,7 @@ describe('App embed tests', () => { expect(onSpy).toHaveBeenCalledWith(EmbedEvent.EmbedHeight, expect.anything()); expect(onSpy).toHaveBeenCalledWith(EmbedEvent.RouteChange, expect.anything()); expect(onSpy).toHaveBeenCalledWith(EmbedEvent.EmbedIframeCenter, expect.anything()); - expect(onSpy).toHaveBeenCalledWith( - EmbedEvent.RequestVisibleEmbedCoordinates, - expect.anything(), - ); + expect(onSpy).toHaveBeenCalledWith(EmbedEvent.RequestVisibleEmbedCoordinates, expect.anything()); }, 100); }); @@ -1331,11 +1324,9 @@ describe('App embed tests', () => { Object.defineProperty(mockIFrame, 'scrollHeight', { value: 500 }); // Mock the event handlers - const onSpy = jest - .spyOn(AppEmbed.prototype, 'on') - .mockImplementation((event, callback) => { - return null; - }); + const onSpy = jest.spyOn(AppEmbed.prototype, 'on').mockImplementation((event, callback) => { + return null; + }); jest.spyOn(TsEmbed.prototype as any, 'getIframeCenter').mockReturnValue({}); jest.spyOn(TsEmbed.prototype as any, 'setIFrameHeight').mockReturnValue({}); @@ -1411,10 +1402,7 @@ describe('App embed tests', () => { await appEmbed.render(); - expect(onSpy).toHaveBeenCalledWith( - EmbedEvent.RequestVisibleEmbedCoordinates, - expect.any(Function), - ); + expect(onSpy).toHaveBeenCalledWith(EmbedEvent.RequestVisibleEmbedCoordinates, expect.any(Function)); onSpy.mockRestore(); }); @@ -1468,9 +1456,9 @@ describe('App embed tests', () => { (appEmbed as any).sendFullHeightLazyLoadData(); expect(mockTrigger).toHaveBeenCalledWith(HostEvent.VisibleEmbedCoordinates, { - top: 50, // 50px clipped from top + top: 50, // 50px clipped from top height: 700, // visible height (from 0 to 700) - left: 30, // 30px clipped from left + left: 30, // 30px clipped from left width: 1024, // visible width (from 0 to 1024) }); }); @@ -1490,11 +1478,7 @@ describe('App embed tests', () => { // Wait for the post-render events to be registered await executeAfterWait(() => { expect(addEventListenerSpy).toHaveBeenCalledWith('resize', expect.any(Function)); - expect(addEventListenerSpy).toHaveBeenCalledWith( - 'scroll', - expect.any(Function), - true, - ); + expect(addEventListenerSpy).toHaveBeenCalledWith('scroll', expect.any(Function), true); }, 100); addEventListenerSpy.mockRestore(); From 9f67279322bcbb3b78ed0addf7cecc28efcb59fa Mon Sep 17 00:00:00 2001 From: mohammed-ashad Date: Fri, 30 Jan 2026 10:27:51 +0530 Subject: [PATCH 5/7] SCAL-291789 fixed listPageVersion in old home page --- src/embed/app.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/embed/app.ts b/src/embed/app.ts index 492f7055..772d2ab9 100644 --- a/src/embed/app.ts +++ b/src/embed/app.ts @@ -935,6 +935,12 @@ export class AppEmbed extends V1Embed { } } + // 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; From e1c972e6a31bd285461e79490a43f5138e962b4b Mon Sep 17 00:00:00 2001 From: mohammed-ashad Date: Fri, 30 Jan 2026 12:54:01 +0530 Subject: [PATCH 6/7] SCAL-291789 fix sonar cube duplicate code issues --- src/embed/app.spec.ts | 383 +++++++++++++++++++----------------------- 1 file changed, 172 insertions(+), 211 deletions(-) diff --git a/src/embed/app.spec.ts b/src/embed/app.spec.ts index b4b11e1a..3facbc2e 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({ @@ -867,191 +933,137 @@ describe('App embed tests', () => { }); 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&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&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&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&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&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 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); - - 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 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 () => { @@ -1144,7 +1156,7 @@ describe('App embed tests', () => { }); test('should register event handlers to adjust iframe height', async () => { - let embedHeightCallback: any = () => {}; + let embedHeightCallback: any = () => { }; const onSpy = jest.spyOn(AppEmbed.prototype, 'on').mockImplementation((event, callback) => { if (event === EmbedEvent.RouteChange) { callback({ type: EmbedEvent.RouteChange, data: { currentPath: '/answers' } } as any, jest.fn()); @@ -1272,21 +1284,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(() => { @@ -1563,53 +1562,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 () => { From bbc4e57514bdec0b77a0e9e7cc33560c4ddc0f7f Mon Sep 17 00:00:00 2001 From: mohammed-ashad Date: Fri, 30 Jan 2026 13:03:11 +0530 Subject: [PATCH 7/7] SCAL-291789 test added to cover the listPageVersion v2 when modularHomeExperiance = false scenario --- src/embed/app.spec.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/embed/app.spec.ts b/src/embed/app.spec.ts index 3facbc2e..425a968f 100644 --- a/src/embed/app.spec.ts +++ b/src/embed/app.spec.ts @@ -1051,6 +1051,16 @@ describe('App embed tests', () => { ); }); + 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 () => { await testUrlParams(