Skip to content

Commit 6f5c1b8

Browse files
committed
test: use data-testid
1 parent f069028 commit 6f5c1b8

2 files changed

Lines changed: 10 additions & 9 deletions

File tree

app/components/Package/Versions.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,7 @@ function majorGroupContainsCurrent(group: (typeof otherMajorGroups.value)[0]): b
536536
class="text-fg-subtle hover:text-fg transition-colors min-w-6 min-h-6 p-1 rounded"
537537
:title="$t('package.versions.view_all_versions')"
538538
classicon="i-lucide:history"
539+
data-testid="view-all-versions-link"
539540
>
540541
<span class="sr-only">{{ $t('package.versions.view_all_versions') }}</span>
541542
</LinkBase>

test/nuxt/components/PackageVersions.spec.ts

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

75-
// Find version links (exclude anchor links, external links, and action buttons like "View all versions")
75+
// Find version links (exclude anchor links, external links, and action buttons)
7676
const versionLinks = component
7777
.findAll('a')
7878
.filter(
7979
a =>
8080
!a.attributes('href')?.startsWith('#') &&
8181
a.attributes('target') !== '_blank' &&
82-
a.attributes('title') !== 'View all versions',
82+
!a.attributes('data-testid')?.includes('view-all-versions'),
8383
)
8484
expect(versionLinks.length).toBeGreaterThan(0)
8585
expect(versionLinks[0]?.text()).toBe('2.0.0')
@@ -97,14 +97,14 @@ describe('PackageVersions', () => {
9797
},
9898
})
9999

100-
// Find version links (exclude anchor links, external links, and action buttons like "View all versions")
100+
// Find version links (exclude anchor links, external links, and action buttons)
101101
const versionLinks = component
102102
.findAll('a')
103103
.filter(
104104
a =>
105105
!a.attributes('href')?.startsWith('#') &&
106106
a.attributes('target') !== '_blank' &&
107-
a.attributes('title') !== 'View all versions',
107+
!a.attributes('data-testid')?.includes('view-all-versions'),
108108
)
109109
expect(versionLinks.length).toBeGreaterThan(0)
110110
expect(versionLinks[0]?.text()).toBe('1.0.0')
@@ -248,7 +248,7 @@ describe('PackageVersions', () => {
248248
a =>
249249
!a.attributes('href')?.startsWith('#') &&
250250
a.attributes('target') !== '_blank' &&
251-
a.attributes('title') !== 'View all versions',
251+
!a.attributes('data-testid')?.includes('view-all-versions'),
252252
)
253253
const versions = versionLinks.map(l => l.text())
254254
// Should be sorted by version descending
@@ -276,7 +276,7 @@ describe('PackageVersions', () => {
276276
a =>
277277
!a.attributes('href')?.startsWith('#') &&
278278
a.attributes('target') !== '_blank' &&
279-
a.attributes('title') !== 'View all versions',
279+
!a.attributes('data-testid')?.includes('view-all-versions'),
280280
)
281281
expect(versionLinks.length).toBeGreaterThan(0)
282282
expect(versionLinks[0]?.classes()).toContain('text-red-800')
@@ -301,7 +301,7 @@ describe('PackageVersions', () => {
301301
a =>
302302
!a.attributes('href')?.startsWith('#') &&
303303
a.attributes('target') !== '_blank' &&
304-
a.attributes('title') !== 'View all versions',
304+
!a.attributes('data-testid')?.includes('view-all-versions'),
305305
)
306306
expect(versionLinks.length).toBeGreaterThan(0)
307307
expect(versionLinks[0]?.attributes('title')).toContain('deprecated')
@@ -638,7 +638,7 @@ describe('PackageVersions', () => {
638638
a =>
639639
!a.attributes('href')?.startsWith('#') &&
640640
a.attributes('target') !== '_blank' &&
641-
a.attributes('title') !== 'View all versions',
641+
!a.attributes('data-testid')?.includes('view-all-versions'),
642642
)
643643
// Should have max 10 visible links in the main section
644644
expect(visibleLinks.length).toBeLessThanOrEqual(10)
@@ -1049,7 +1049,7 @@ describe('PackageVersions', () => {
10491049
a =>
10501050
!a.attributes('href')?.startsWith('#') &&
10511051
a.attributes('target') !== '_blank' &&
1052-
a.attributes('title') !== 'View all versions',
1052+
!a.attributes('data-testid')?.includes('view-all-versions'),
10531053
)
10541054
const versions = versionLinks.map(l => l.text())
10551055
expect(versions).not.toContain('3.0.0')

0 commit comments

Comments
 (0)