@@ -28,6 +28,7 @@ import {
2828 ContextMenuTriggerOptions ,
2929 CustomActionTarget ,
3030 CustomActionsPosition ,
31+ ListPageColumns ,
3132} from '../types' ;
3233import {
3334 executeAfterWait ,
@@ -3456,4 +3457,74 @@ describe('Unit test case for ts embed', () => {
34563457 triggerSpy . mockReset ( ) ;
34573458 } ) ;
34583459 } ) ;
3460+
3461+ describe ( 'hideTagFilterChips functionality' , ( ) => {
3462+ beforeAll ( ( ) => {
3463+ init ( {
3464+ thoughtSpotHost : 'tshost' ,
3465+ authType : AuthType . None ,
3466+ } ) ;
3467+ } ) ;
3468+ test ( 'when hideTagFilterChips is true should automatically add Action.ManageTags to hiddenActions for AppEmbed' , async ( ) => {
3469+ const appEmbed = new AppEmbed ( getRootEl ( ) , {
3470+ frameParams : {
3471+ width : '100%' ,
3472+ height : '100%' ,
3473+ } ,
3474+ hideTagFilterChips : true ,
3475+ } ) ;
3476+ appEmbed . render ( ) ;
3477+ await waitFor ( ( ) => ! ! getIFrameEl ( ) ) . then ( ( ) => {
3478+ const iframeSrc = getIFrameSrc ( ) ;
3479+ expect ( iframeSrc ) . toContain ( encodeURIComponent ( `"${ Action . ManageTags } "` ) ) ;
3480+ expect ( iframeSrc ) . toContain ( 'hideAction=' ) ;
3481+ } ) ;
3482+ } ) ;
3483+
3484+ test ( 'when hideTagFilterChips is false should not add Action.ManageTags to hiddenActions for AppEmbed' , async ( ) => {
3485+ const appEmbed = new AppEmbed ( getRootEl ( ) , {
3486+ frameParams : {
3487+ width : '100%' ,
3488+ height : '100%' ,
3489+ } ,
3490+ } ) ;
3491+ appEmbed . render ( ) ;
3492+ await waitFor ( ( ) => ! ! getIFrameEl ( ) ) . then ( ( ) => {
3493+ const iframeSrc = getIFrameSrc ( ) ;
3494+ expect ( iframeSrc ) . not . toContain ( encodeURIComponent ( `"${ Action . ManageTags } "` ) ) ;
3495+ expect ( iframeSrc ) . toContain ( 'hideAction=' ) ;
3496+ } ) ;
3497+ } ) ;
3498+
3499+ test ( 'should work with existing hiddenListColumns without duplicates' , async ( ) => {
3500+ const appEmbed = new AppEmbed ( getRootEl ( ) , {
3501+ ...defaultViewConfig ,
3502+ hideTagFilterChips : true ,
3503+ hiddenListColumns : [ ListPageColumns . Author , ListPageColumns . Favourite ] ,
3504+ } as AppViewConfig ) ;
3505+
3506+ const appInitData = await ( appEmbed as any ) . getDefaultAppInitData ( ) ;
3507+
3508+ expect ( appInitData . hiddenListColumns ) . toContain ( ListPageColumns . Author ) ;
3509+ expect ( appInitData . hiddenListColumns ) . toContain ( ListPageColumns . Favourite ) ;
3510+ expect ( appInitData . hiddenListColumns ) . toContain ( ListPageColumns . Tags ) ;
3511+
3512+ const tagsCount = appInitData . hiddenListColumns . filter (
3513+ ( col : ListPageColumns ) => col === ListPageColumns . Tags
3514+ ) . length ;
3515+ expect ( tagsCount ) . toBe ( 1 ) ;
3516+ } ) ;
3517+
3518+ test ( 'should not automatically add ListPageColumns.Tags to hiddenListColumns' , async ( ) => {
3519+ const appEmbed = new AppEmbed ( getRootEl ( ) , {
3520+ ...defaultViewConfig ,
3521+ hideTagFilterChips : false ,
3522+ } as AppViewConfig ) ;
3523+
3524+ const appInitData = await ( appEmbed as any ) . getDefaultAppInitData ( ) ;
3525+
3526+ expect ( appInitData . hiddenListColumns ) . not . toContain ( ListPageColumns . Tags ) ;
3527+ expect ( appInitData . hiddenListColumns ) . toEqual ( [ ] ) ;
3528+ } ) ;
3529+ } ) ;
34593530} ) ;
0 commit comments