@@ -232,6 +232,43 @@ describe('usePackageComparison', () => {
232232 expect ( issues ) . toMatchObject ( { raw : 50 , status : 'neutral' } )
233233 } )
234234
235+ it ( 'returns null for missing or non-numeric github metrics' , async ( ) => {
236+ const pkgName = 'missing-metrics-pkg'
237+ vi . stubGlobal (
238+ '$fetch' ,
239+ vi . fn ( ) . mockImplementation ( ( url : string , options ?: { baseURL ?: string } ) => {
240+ const fullUrl = options ?. baseURL ? `${ options . baseURL } ${ url } ` : url
241+ if ( fullUrl . startsWith ( 'https://registry.npmjs.org/' ) ) {
242+ return Promise . resolve ( {
243+ 'name' : pkgName ,
244+ 'dist-tags' : { latest : '1.0.0' } ,
245+ 'repository' : { type : 'git' , url : 'https://github.com/owner/repo' } ,
246+ 'versions' : {
247+ '1.0.0' : { dist : { unpackedSize : 1000 } } ,
248+ } ,
249+ } )
250+ }
251+ if ( fullUrl . includes ( 'ungh.cc/repos/owner/repo' ) ) {
252+ // Return malformed data (stars missing)
253+ return Promise . resolve ( { repo : { } } )
254+ }
255+ if ( fullUrl . includes ( '/api/github/issues/owner/repo' ) ) {
256+ // Return non-numeric data
257+ return Promise . resolve ( { issues : 'not-a-number' } )
258+ }
259+ return Promise . resolve ( null )
260+ } ) ,
261+ )
262+
263+ const { status, getFacetValues } = await usePackageComparisonInComponent ( [ pkgName ] )
264+ await vi . waitFor ( ( ) => {
265+ expect ( status . value ) . toBe ( 'success' )
266+ } )
267+
268+ expect ( getFacetValues ( 'githubStars' ) [ 0 ] ) . toBeNull ( )
269+ expect ( getFacetValues ( 'githubIssues' ) [ 0 ] ) . toBeNull ( )
270+ } )
271+
235272 it ( 'skips github fetches for non-github repositories' , async ( ) => {
236273 const pkgName = 'gitlab-pkg'
237274 const fetchMock = vi
0 commit comments