11import { describe , it , expect , vi , beforeEach } from 'vitest' ;
2- import { render , screen } from '@testing-library/react' ;
2+ import { render , screen , fireEvent } from '@testing-library/react' ;
33import { ProfileTabs } from '@/components/profile-tabs' ;
44
55// Mock framer-motion to avoid animation issues in tests
@@ -53,7 +53,7 @@ describe('ProfileTabs', () => {
5353 amount : '100' ,
5454 assetCode : 'XLM' ,
5555 createdAt : '2026-03-01T00:00:00Z' ,
56- status : 'verified ' ,
56+ status : 'SUCCESS ' ,
5757 } ,
5858 ] ,
5959 } ) ,
@@ -63,5 +63,83 @@ describe('ProfileTabs', () => {
6363
6464 expect ( await screen . findByText ( '100 XLM' ) ) . toBeInTheDocument ( ) ;
6565 expect ( screen . queryByText ( 'No support yet' ) ) . not . toBeInTheDocument ( ) ;
66+
67+ // Check that status is rendered as a badge
68+ expect ( screen . getByText ( 'SUCCESS' ) ) . toBeInTheDocument ( ) ;
69+ } ) ;
70+
71+ it ( 'renders status badges with correct colors' , async ( ) => {
72+ vi . stubGlobal ( 'fetch' , vi . fn ( ) . mockResolvedValue ( {
73+ json : async ( ) => ( {
74+ transactions : [
75+ {
76+ id : '1' ,
77+ txHash : 'abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890' ,
78+ amount : '100' ,
79+ assetCode : 'XLM' ,
80+ createdAt : '2026-03-01T00:00:00Z' ,
81+ status : 'SUCCESS' ,
82+ } ,
83+ {
84+ id : '2' ,
85+ txHash : 'fedcba0987654321fedcba0987654321fedcba0987654321fedcba0987654321' ,
86+ amount : '50' ,
87+ assetCode : 'USDC' ,
88+ createdAt : '2026-03-02T00:00:00Z' ,
89+ status : 'PENDING' ,
90+ } ,
91+ {
92+ id : '3' ,
93+ txHash : '1111111111111111111111111111111111111111111111111111111111111111' ,
94+ amount : '25' ,
95+ assetCode : 'XLM' ,
96+ createdAt : '2026-03-03T00:00:00Z' ,
97+ status : 'FAILED' ,
98+ } ,
99+ {
100+ id : '4' ,
101+ txHash : '2222222222222222222222222222222222222222222222222222222222222222' ,
102+ amount : '75' ,
103+ assetCode : 'XLM' ,
104+ createdAt : '2026-03-04T00:00:00Z' ,
105+ status : 'UNKNOWN' ,
106+ } ,
107+ ] ,
108+ } ) ,
109+ } ) ) ;
110+
111+ render ( < ProfileTabs username = "stellar-dev" /> ) ;
112+
113+ // Check that all status badges are rendered
114+ expect ( await screen . findByText ( 'SUCCESS' ) ) . toBeInTheDocument ( ) ;
115+ expect ( screen . getByText ( 'PENDING' ) ) . toBeInTheDocument ( ) ;
116+ expect ( screen . getByText ( 'FAILED' ) ) . toBeInTheDocument ( ) ;
117+ expect ( screen . getByText ( 'UNKNOWN' ) ) . toBeInTheDocument ( ) ;
118+
119+ // Check that badges have correct CSS classes for colors
120+ const successBadge = screen . getByText ( 'SUCCESS' ) ;
121+ const pendingBadge = screen . getByText ( 'PENDING' ) ;
122+ const failedBadge = screen . getByText ( 'FAILED' ) ;
123+ const unknownBadge = screen . getByText ( 'UNKNOWN' ) ;
124+
125+ expect ( successBadge ) . toHaveClass ( 'bg-green-100' , 'text-green-800' ) ;
126+ expect ( pendingBadge ) . toHaveClass ( 'bg-yellow-100' , 'text-yellow-800' ) ;
127+ expect ( failedBadge ) . toHaveClass ( 'bg-red-100' , 'text-red-800' ) ;
128+ expect ( unknownBadge ) . toHaveClass ( 'bg-gray-100' , 'text-gray-800' ) ;
129+ } ) ;
130+
131+ it ( 'renders badges coming soon empty state' , ( ) => {
132+ vi . stubGlobal ( 'fetch' , vi . fn ( ) . mockResolvedValue ( {
133+ json : async ( ) => ( { transactions : [ ] } ) ,
134+ } ) ) ;
135+
136+ render ( < ProfileTabs username = "stellar-dev" /> ) ;
137+
138+ // Click on the badges tab
139+ const badgesTab = screen . getByText ( 'Badges' ) ;
140+ fireEvent . click ( badgesTab ) ;
141+
142+ expect ( screen . getByText ( 'Badges coming soon' ) ) . toBeInTheDocument ( ) ;
143+ expect ( screen . getByText ( 'Achievement badges will appear here once earned.' ) ) . toBeInTheDocument ( ) ;
66144 } ) ;
67145} ) ;
0 commit comments