@@ -19,6 +19,11 @@ jest.mock('@hooks/useLocalize', () =>
1919 } ) ) ,
2020) ;
2121
22+ jest . mock ( '@hooks/useResponsiveLayout' , ( ) => jest . fn ( ( ) => ( { shouldUseNarrowLayout : false } ) ) ) ;
23+
24+ jest . mock ( '@userActions/Policy/Category' , ( ) => ( { enablePolicyCategories : jest . fn ( ) } ) ) ;
25+ jest . mock ( '@userActions/Policy/Policy' , ( ) => ( { enableCompanyCards : jest . fn ( ) , enablePolicyConnections : jest . fn ( ) , enablePolicyRules : jest . fn ( ) } ) ) ;
26+
2227const POLICY_ID = '1' ;
2328
2429function buildPolicy ( overrides : Partial < Policy > = { } ) : Policy {
@@ -349,10 +354,10 @@ describe('useGettingStartedItems', () => {
349354 } ) ;
350355
351356 describe ( 'row 3 - Link company cards' , ( ) => {
352- it ( 'should be shown when company cards feature is enabled on the workspace ' , async ( ) => {
357+ it ( 'should always be shown' , async ( ) => {
353358 await setupManageTeamScenario ( {
354359 accounting : CONST . POLICY . CONNECTIONS . NAME . QBO ,
355- policy : { areCompanyCardsEnabled : true } ,
360+ policy : { areCompanyCardsEnabled : false } ,
356361 } ) ;
357362
358363 const { result} = renderHook ( ( ) => useGettingStartedItems ( ) ) ;
@@ -361,7 +366,19 @@ describe('useGettingStartedItems', () => {
361366 expect ( companyCardsItem ) . toBeDefined ( ) ;
362367 } ) ;
363368
364- it ( 'should be hidden when company cards feature is not enabled on the workspace' , async ( ) => {
369+ it ( 'should have isFeatureEnabled=true when company cards feature is enabled' , async ( ) => {
370+ await setupManageTeamScenario ( {
371+ accounting : CONST . POLICY . CONNECTIONS . NAME . QBO ,
372+ policy : { areCompanyCardsEnabled : true } ,
373+ } ) ;
374+
375+ const { result} = renderHook ( ( ) => useGettingStartedItems ( ) ) ;
376+
377+ const companyCardsItem = result . current . items . find ( ( item ) => item . key === 'linkCompanyCards' ) ;
378+ expect ( companyCardsItem ?. isFeatureEnabled ) . toBe ( true ) ;
379+ } ) ;
380+
381+ it ( 'should have isFeatureEnabled=false when company cards feature is not enabled' , async ( ) => {
365382 await setupManageTeamScenario ( {
366383 accounting : CONST . POLICY . CONNECTIONS . NAME . QBO ,
367384 policy : { areCompanyCardsEnabled : false } ,
@@ -370,7 +387,7 @@ describe('useGettingStartedItems', () => {
370387 const { result} = renderHook ( ( ) => useGettingStartedItems ( ) ) ;
371388
372389 const companyCardsItem = result . current . items . find ( ( item ) => item . key === 'linkCompanyCards' ) ;
373- expect ( companyCardsItem ) . toBeUndefined ( ) ;
390+ expect ( companyCardsItem ?. isFeatureEnabled ) . toBe ( false ) ;
374391 } ) ;
375392
376393 it ( 'should navigate to workspace company cards route' , async ( ) => {
@@ -399,10 +416,10 @@ describe('useGettingStartedItems', () => {
399416 } ) ;
400417
401418 describe ( 'row 4 - Set up spend rules' , ( ) => {
402- it ( 'should be shown when rules feature is enabled on the workspace ' , async ( ) => {
419+ it ( 'should always be shown' , async ( ) => {
403420 await setupManageTeamScenario ( {
404421 accounting : CONST . POLICY . CONNECTIONS . NAME . QBO ,
405- policy : { areRulesEnabled : true } ,
422+ policy : { areRulesEnabled : false } ,
406423 } ) ;
407424
408425 const { result} = renderHook ( ( ) => useGettingStartedItems ( ) ) ;
@@ -411,7 +428,19 @@ describe('useGettingStartedItems', () => {
411428 expect ( rulesItem ) . toBeDefined ( ) ;
412429 } ) ;
413430
414- it ( 'should be hidden when rules feature is not enabled on the workspace' , async ( ) => {
431+ it ( 'should have isFeatureEnabled=true when rules feature is enabled' , async ( ) => {
432+ await setupManageTeamScenario ( {
433+ accounting : CONST . POLICY . CONNECTIONS . NAME . QBO ,
434+ policy : { areRulesEnabled : true } ,
435+ } ) ;
436+
437+ const { result} = renderHook ( ( ) => useGettingStartedItems ( ) ) ;
438+
439+ const rulesItem = result . current . items . find ( ( item ) => item . key === 'setupRules' ) ;
440+ expect ( rulesItem ?. isFeatureEnabled ) . toBe ( true ) ;
441+ } ) ;
442+
443+ it ( 'should have isFeatureEnabled=false when rules feature is not enabled' , async ( ) => {
415444 await setupManageTeamScenario ( {
416445 accounting : CONST . POLICY . CONNECTIONS . NAME . QBO ,
417446 policy : { areRulesEnabled : false } ,
@@ -420,7 +449,7 @@ describe('useGettingStartedItems', () => {
420449 const { result} = renderHook ( ( ) => useGettingStartedItems ( ) ) ;
421450
422451 const rulesItem = result . current . items . find ( ( item ) => item . key === 'setupRules' ) ;
423- expect ( rulesItem ) . toBeUndefined ( ) ;
452+ expect ( rulesItem ?. isFeatureEnabled ) . toBe ( false ) ;
424453 } ) ;
425454
426455 it ( 'should navigate to workspace rules route' , async ( ) => {
@@ -511,7 +540,7 @@ describe('useGettingStartedItems', () => {
511540 expect ( keys ) . toEqual ( [ 'createWorkspace' , 'customizeCategories' , 'linkCompanyCards' , 'setupRules' ] ) ;
512541 } ) ;
513542
514- it ( 'should only contain createWorkspace and accounting row when no optional features are enabled ' , async ( ) => {
543+ it ( 'should always contain all four rows even when optional features are disabled ' , async ( ) => {
515544 await setupManageTeamScenario ( {
516545 accounting : CONST . POLICY . CONNECTIONS . NAME . QBO ,
517546 policy : { areCompanyCardsEnabled : false , areRulesEnabled : false } ,
@@ -520,7 +549,7 @@ describe('useGettingStartedItems', () => {
520549 const { result} = renderHook ( ( ) => useGettingStartedItems ( ) ) ;
521550
522551 const keys = result . current . items . map ( ( item ) => item . key ) ;
523- expect ( keys ) . toEqual ( [ 'createWorkspace' , 'connectAccounting' ] ) ;
552+ expect ( keys ) . toEqual ( [ 'createWorkspace' , 'connectAccounting' , 'linkCompanyCards' , 'setupRules' ] ) ;
524553 } ) ;
525554 } ) ;
526555
0 commit comments