@@ -82,9 +82,12 @@ describe('PackageVersions', () => {
8282 } ,
8383 } )
8484
85- const link = component . find ( 'a' )
86- expect ( link . exists ( ) ) . toBe ( true )
87- expect ( link . text ( ) ) . toBe ( '2.0.0' )
85+ // Find version links (exclude anchor links that start with #)
86+ const versionLinks = component
87+ . findAll ( 'a' )
88+ . filter ( a => ! a . attributes ( 'href' ) ?. startsWith ( '#' ) )
89+ expect ( versionLinks . length ) . toBeGreaterThan ( 0 )
90+ expect ( versionLinks [ 0 ] ?. text ( ) ) . toBe ( '2.0.0' )
8891 } )
8992
9093 it ( 'renders scoped package version links correctly' , async ( ) => {
@@ -99,9 +102,12 @@ describe('PackageVersions', () => {
99102 } ,
100103 } )
101104
102- const link = component . find ( 'a' )
103- expect ( link . exists ( ) ) . toBe ( true )
104- expect ( link . text ( ) ) . toBe ( '1.0.0' )
105+ // Find version links (exclude anchor links that start with #)
106+ const versionLinks = component
107+ . findAll ( 'a' )
108+ . filter ( a => ! a . attributes ( 'href' ) ?. startsWith ( '#' ) )
109+ expect ( versionLinks . length ) . toBeGreaterThan ( 0 )
110+ expect ( versionLinks [ 0 ] ?. text ( ) ) . toBe ( '1.0.0' )
105111 } )
106112 } )
107113
@@ -190,8 +196,11 @@ describe('PackageVersions', () => {
190196 } ,
191197 } )
192198
193- const links = component . findAll ( 'a' )
194- const versions = links . map ( l => l . text ( ) )
199+ // Find version links (exclude anchor links that start with #)
200+ const versionLinks = component
201+ . findAll ( 'a' )
202+ . filter ( a => ! a . attributes ( 'href' ) ?. startsWith ( '#' ) )
203+ const versions = versionLinks . map ( l => l . text ( ) )
195204 // Should be sorted by version descending
196205 expect ( versions [ 0 ] ) . toBe ( '2.0.0' )
197206 } )
@@ -210,8 +219,12 @@ describe('PackageVersions', () => {
210219 } ,
211220 } )
212221
213- const link = component . find ( 'a' )
214- expect ( link . classes ( ) ) . toContain ( 'text-red-400' )
222+ // Find version links (exclude anchor links that start with #)
223+ const versionLinks = component
224+ . findAll ( 'a' )
225+ . filter ( a => ! a . attributes ( 'href' ) ?. startsWith ( '#' ) )
226+ expect ( versionLinks . length ) . toBeGreaterThan ( 0 )
227+ expect ( versionLinks [ 0 ] ?. classes ( ) ) . toContain ( 'text-red-400' )
215228 } )
216229
217230 it ( 'shows deprecated version in title attribute' , async ( ) => {
@@ -226,8 +239,12 @@ describe('PackageVersions', () => {
226239 } ,
227240 } )
228241
229- const link = component . find ( 'a' )
230- expect ( link . attributes ( 'title' ) ) . toContain ( 'deprecated' )
242+ // Find version links (exclude anchor links that start with #)
243+ const versionLinks = component
244+ . findAll ( 'a' )
245+ . filter ( a => ! a . attributes ( 'href' ) ?. startsWith ( '#' ) )
246+ expect ( versionLinks . length ) . toBeGreaterThan ( 0 )
247+ expect ( versionLinks [ 0 ] ?. attributes ( 'title' ) ) . toContain ( 'deprecated' )
231248 } )
232249
233250 it ( 'filters deprecated tags from visible list when package is not deprecated' , async ( ) => {
@@ -552,9 +569,10 @@ describe('PackageVersions', () => {
552569 } ,
553570 } )
554571
555- // Count visible version links (excluding "Other versions" section)
556- // The first set of links before the "Other versions" button
557- const visibleLinks = component . findAll ( 'a' )
572+ // Count visible version links (excluding anchor links that start with #)
573+ const visibleLinks = component
574+ . findAll ( 'a' )
575+ . filter ( a => ! a . attributes ( 'href' ) ?. startsWith ( '#' ) )
558576 // Should have max 10 visible links in the main section
559577 expect ( visibleLinks . length ) . toBeLessThanOrEqual ( 10 )
560578 } )
0 commit comments