@@ -222,14 +222,14 @@ jest.mock('../RewardItem/RewardItem', () => {
222222 isEndOfSeasonReward ?: boolean ;
223223 isLast ?: boolean ;
224224 compact ?: boolean ;
225- onPress ?: ( rewardId : string ) => void ;
225+ onPress ?: ( rewardId : string , sr : SeasonRewardDto ) => void ;
226226 } ) =>
227227 ReactActual . createElement (
228228 TouchableOpacity ,
229229 {
230230 testID : testID || `reward-item-${ reward . id } ` ,
231231 accessibilityLabel : `isLocked:${ isLocked } ,isEndOfSeasonReward:${ isEndOfSeasonReward } ,isLast:${ isLast } ,compact:${ compact } ` ,
232- onPress : ( ) => onPress ?.( reward . id ) ,
232+ onPress : ( ) => onPress ?.( reward . id , seasonReward ) ,
233233 } ,
234234 ReactActual . createElement ( Text , { } , seasonReward . name ) ,
235235 ) ,
@@ -335,6 +335,18 @@ describe('PreviousSeasonUnlockedRewards', () => {
335335 isEndOfSeasonReward : false ,
336336 } ;
337337
338+ const mockMetalCardSeasonReward : SeasonRewardDto = {
339+ id : 'season-reward-metal-card' ,
340+ name : 'Metal Card Reward' ,
341+ shortDescription : 'Metal card description' ,
342+ longDescription : 'Metal card long description' ,
343+ shortUnlockedDescription : 'Metal card short unlocked' ,
344+ longUnlockedDescription : 'Metal card long unlocked' ,
345+ iconName : 'Card' ,
346+ rewardType : SeasonRewardType . METAL_CARD ,
347+ isEndOfSeasonReward : true ,
348+ } ;
349+
338350 const mockUnlockedReward1 : RewardDto = {
339351 id : 'reward-1' ,
340352 seasonRewardId : 'season-reward-1' ,
@@ -353,6 +365,12 @@ describe('PreviousSeasonUnlockedRewards', () => {
353365 claimStatus : RewardClaimStatus . UNCLAIMED ,
354366 } ;
355367
368+ const mockMetalCardUnlockedReward : RewardDto = {
369+ id : 'reward-metal-card' ,
370+ seasonRewardId : 'season-reward-metal-card' ,
371+ claimStatus : RewardClaimStatus . UNCLAIMED ,
372+ } ;
373+
356374 const mockSeasonTiers = [
357375 {
358376 id : 'tier-1' ,
@@ -363,7 +381,12 @@ describe('PreviousSeasonUnlockedRewards', () => {
363381 darkModeUrl : 'https://example.com/dark.png' ,
364382 } ,
365383 levelNumber : 'Level 1' ,
366- rewards : [ mockSeasonReward1 , mockSeasonReward2 , mockRegularSeasonReward ] ,
384+ rewards : [
385+ mockSeasonReward1 ,
386+ mockSeasonReward2 ,
387+ mockRegularSeasonReward ,
388+ mockMetalCardSeasonReward ,
389+ ] ,
367390 } ,
368391 ] ;
369392
@@ -563,7 +586,7 @@ describe('PreviousSeasonUnlockedRewards', () => {
563586 expect ( queryByTestId ( 'rewards-error-banner' ) ) . not . toBeOnTheScreen ( ) ;
564587 } ) ;
565588
566- it ( 'passes isLocked=false to RewardItem for end of season rewards' , ( ) => {
589+ it ( 'passes isLocked=true for non-METAL_CARD end of season rewards' , ( ) => {
567590 mockUseSelector . mockImplementation ( ( selector ) => {
568591 if ( selector === selectUnlockedRewards ) return [ mockUnlockedReward1 ] ;
569592 if ( selector === selectUnlockedRewardLoading ) return false ;
@@ -576,6 +599,23 @@ describe('PreviousSeasonUnlockedRewards', () => {
576599 const { getByTestId } = render ( < PreviousSeasonUnlockedRewards /> ) ;
577600
578601 const rewardItem = getByTestId ( 'reward-item-reward-1' ) ;
602+ expect ( rewardItem . props . accessibilityLabel ) . toContain ( 'isLocked:true' ) ;
603+ } ) ;
604+
605+ it ( 'passes isLocked=false for METAL_CARD end of season rewards' , ( ) => {
606+ mockUseSelector . mockImplementation ( ( selector ) => {
607+ if ( selector === selectUnlockedRewards )
608+ return [ mockMetalCardUnlockedReward ] ;
609+ if ( selector === selectUnlockedRewardLoading ) return false ;
610+ if ( selector === selectUnlockedRewardError ) return false ;
611+ if ( selector === selectSeasonTiers ) return mockSeasonTiers ;
612+ if ( selector === selectCurrentTier ) return { pointsNeeded : 100 } ;
613+ return undefined ;
614+ } ) ;
615+
616+ const { getByTestId } = render ( < PreviousSeasonUnlockedRewards /> ) ;
617+
618+ const rewardItem = getByTestId ( 'reward-item-reward-metal-card' ) ;
579619 expect ( rewardItem . props . accessibilityLabel ) . toContain ( 'isLocked:false' ) ;
580620 } ) ;
581621
@@ -632,4 +672,44 @@ describe('PreviousSeasonUnlockedRewards', () => {
632672 expect ( firstRewardItem . props . accessibilityLabel ) . toContain ( 'isLast:false' ) ;
633673 expect ( lastRewardItem . props . accessibilityLabel ) . toContain ( 'isLast:true' ) ;
634674 } ) ;
675+
676+ it ( 'navigates to metal card claim sheet when METAL_CARD reward is pressed' , ( ) => {
677+ mockUseSelector . mockImplementation ( ( selector ) => {
678+ if ( selector === selectUnlockedRewards )
679+ return [ mockMetalCardUnlockedReward ] ;
680+ if ( selector === selectUnlockedRewardLoading ) return false ;
681+ if ( selector === selectUnlockedRewardError ) return false ;
682+ if ( selector === selectSeasonTiers ) return mockSeasonTiers ;
683+ if ( selector === selectCurrentTier ) return { pointsNeeded : 100 } ;
684+ return undefined ;
685+ } ) ;
686+
687+ const { getByTestId } = render ( < PreviousSeasonUnlockedRewards /> ) ;
688+
689+ const rewardItem = getByTestId ( 'reward-item-reward-metal-card' ) ;
690+ rewardItem . props . onPress ( ) ;
691+
692+ expect ( mockNavigate ) . toHaveBeenCalledWith ( 'MetalCardClaimBottomSheet' , {
693+ rewardId : 'reward-metal-card' ,
694+ seasonRewardId : 'season-reward-metal-card' ,
695+ } ) ;
696+ } ) ;
697+
698+ it ( 'does not pass onPress handler for non-METAL_CARD rewards' , ( ) => {
699+ mockUseSelector . mockImplementation ( ( selector ) => {
700+ if ( selector === selectUnlockedRewards ) return [ mockUnlockedReward1 ] ;
701+ if ( selector === selectUnlockedRewardLoading ) return false ;
702+ if ( selector === selectUnlockedRewardError ) return false ;
703+ if ( selector === selectSeasonTiers ) return mockSeasonTiers ;
704+ if ( selector === selectCurrentTier ) return { pointsNeeded : 100 } ;
705+ return undefined ;
706+ } ) ;
707+
708+ const { getByTestId } = render ( < PreviousSeasonUnlockedRewards /> ) ;
709+
710+ const rewardItem = getByTestId ( 'reward-item-reward-1' ) ;
711+ rewardItem . props . onPress ( ) ;
712+
713+ expect ( mockNavigate ) . not . toHaveBeenCalled ( ) ;
714+ } ) ;
635715} ) ;
0 commit comments