Skip to content

Commit 35bdb74

Browse files
committed
test: fix test of PackageVersions
1 parent 067ef44 commit 35bdb74

1 file changed

Lines changed: 44 additions & 9 deletions

File tree

test/nuxt/components/PackageVersions.spec.ts

Lines changed: 44 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,15 @@ describe('PackageVersions', () => {
7272
},
7373
})
7474

75-
// Find version links (exclude anchor links that start with # and external links)
75+
// Find version links (exclude anchor links, external links, and action buttons like "View all versions")
7676
const versionLinks = component
7777
.findAll('a')
78-
.filter(a => !a.attributes('href')?.startsWith('#') && a.attributes('target') !== '_blank')
78+
.filter(
79+
a =>
80+
!a.attributes('href')?.startsWith('#') &&
81+
a.attributes('target') !== '_blank' &&
82+
a.attributes('title') !== 'View all versions',
83+
)
7984
expect(versionLinks.length).toBeGreaterThan(0)
8085
expect(versionLinks[0]?.text()).toBe('2.0.0')
8186
})
@@ -92,10 +97,15 @@ describe('PackageVersions', () => {
9297
},
9398
})
9499

95-
// Find version links (exclude anchor links that start with # and external links)
100+
// Find version links (exclude anchor links, external links, and action buttons like "View all versions")
96101
const versionLinks = component
97102
.findAll('a')
98-
.filter(a => !a.attributes('href')?.startsWith('#') && a.attributes('target') !== '_blank')
103+
.filter(
104+
a =>
105+
!a.attributes('href')?.startsWith('#') &&
106+
a.attributes('target') !== '_blank' &&
107+
a.attributes('title') !== 'View all versions',
108+
)
99109
expect(versionLinks.length).toBeGreaterThan(0)
100110
expect(versionLinks[0]?.text()).toBe('1.0.0')
101111
})
@@ -234,7 +244,12 @@ describe('PackageVersions', () => {
234244
// Find version links (exclude anchor links that start with # and external links)
235245
const versionLinks = component
236246
.findAll('a')
237-
.filter(a => !a.attributes('href')?.startsWith('#') && a.attributes('target') !== '_blank')
247+
.filter(
248+
a =>
249+
!a.attributes('href')?.startsWith('#') &&
250+
a.attributes('target') !== '_blank' &&
251+
a.attributes('title') !== 'View all versions',
252+
)
238253
const versions = versionLinks.map(l => l.text())
239254
// Should be sorted by version descending
240255
expect(versions[0]).toBe('2.0.0')
@@ -257,7 +272,12 @@ describe('PackageVersions', () => {
257272
// Find version links (exclude anchor links that start with # and external links)
258273
const versionLinks = component
259274
.findAll('a')
260-
.filter(a => !a.attributes('href')?.startsWith('#') && a.attributes('target') !== '_blank')
275+
.filter(
276+
a =>
277+
!a.attributes('href')?.startsWith('#') &&
278+
a.attributes('target') !== '_blank' &&
279+
a.attributes('title') !== 'View all versions',
280+
)
261281
expect(versionLinks.length).toBeGreaterThan(0)
262282
expect(versionLinks[0]?.classes()).toContain('text-red-800')
263283
})
@@ -277,7 +297,12 @@ describe('PackageVersions', () => {
277297
// Find version links (exclude anchor links that start with # and external links)
278298
const versionLinks = component
279299
.findAll('a')
280-
.filter(a => !a.attributes('href')?.startsWith('#') && a.attributes('target') !== '_blank')
300+
.filter(
301+
a =>
302+
!a.attributes('href')?.startsWith('#') &&
303+
a.attributes('target') !== '_blank' &&
304+
a.attributes('title') !== 'View all versions',
305+
)
281306
expect(versionLinks.length).toBeGreaterThan(0)
282307
expect(versionLinks[0]?.attributes('title')).toContain('deprecated')
283308
})
@@ -609,7 +634,12 @@ describe('PackageVersions', () => {
609634
// Count visible version links (excluding anchor links that start with # and external links)
610635
const visibleLinks = component
611636
.findAll('a')
612-
.filter(a => !a.attributes('href')?.startsWith('#') && a.attributes('target') !== '_blank')
637+
.filter(
638+
a =>
639+
!a.attributes('href')?.startsWith('#') &&
640+
a.attributes('target') !== '_blank' &&
641+
a.attributes('title') !== 'View all versions',
642+
)
613643
// Should have max 10 visible links in the main section
614644
expect(visibleLinks.length).toBeLessThanOrEqual(10)
615645
})
@@ -1015,7 +1045,12 @@ describe('PackageVersions', () => {
10151045
// Find version links (exclude anchor and external links)
10161046
const versionLinks = component
10171047
.findAll('a')
1018-
.filter(a => !a.attributes('href')?.startsWith('#') && a.attributes('target') !== '_blank')
1048+
.filter(
1049+
a =>
1050+
!a.attributes('href')?.startsWith('#') &&
1051+
a.attributes('target') !== '_blank' &&
1052+
a.attributes('title') !== 'View all versions',
1053+
)
10191054
const versions = versionLinks.map(l => l.text())
10201055
expect(versions).not.toContain('3.0.0')
10211056
})

0 commit comments

Comments
 (0)