Skip to content

Commit 2e2df55

Browse files
committed
feat: add a11y tests
1 parent 0e086e7 commit 2e2df55

1 file changed

Lines changed: 55 additions & 10 deletions

File tree

test/nuxt/a11y.spec.ts

Lines changed: 55 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import type { AxeResults, RunOptions } from 'axe-core'
2-
import type { VueWrapper } from '@vue/test-utils'
31
import type { ColumnConfig, FilterChip } from '#shared/types/preferences'
2+
import { mountSuspended } from '@nuxt/test-utils/runtime'
3+
import type { VueWrapper } from '@vue/test-utils'
44
import 'axe-core'
5+
import type { AxeResults, RunOptions } from 'axe-core'
56
import { afterEach, describe, expect, it } from 'vitest'
6-
import { mountSuspended } from '@nuxt/test-utils/runtime'
77

88
// axe-core is a UMD module that exposes itself as window.axe in the browser
99
declare const axe: {
@@ -58,7 +58,6 @@ import {
5858
AppFooter,
5959
AppHeader,
6060
BaseCard,
61-
UserAvatar,
6261
BuildEnvironment,
6362
CallToAction,
6463
CodeDirectoryListing,
@@ -67,30 +66,33 @@ import {
6766
CodeViewer,
6867
CollapsibleSection,
6968
ColumnPicker,
69+
CompareComparisonGrid,
7070
CompareFacetCard,
7171
CompareFacetRow,
7272
CompareFacetSelector,
73-
CompareComparisonGrid,
7473
ComparePackageSelector,
7574
DateTime,
7675
DependencyPathPopup,
7776
FilterChips,
7877
FilterPanel,
7978
HeaderAccountMenu,
79+
HeaderConnectorModal,
80+
HeaderSearchBox,
8081
LicenseDisplay,
8182
LoadingSpinner,
82-
PackageChartModal,
83-
PackageClaimPackageModal,
84-
HeaderConnectorModal,
8583
OrgMembersPanel,
8684
OrgOperationsQueue,
8785
OrgTeamsPanel,
8886
PackageAccessControls,
8987
PackageCard,
88+
PackageChartModal,
89+
PackageClaimPackageModal,
90+
PackageCompatibility,
9091
PackageDependencies,
9192
PackageDeprecatedTree,
9293
PackageDownloadAnalytics,
9394
PackageInstallScripts,
95+
PackageKeywords,
9496
PackageList,
9597
PackageListControls,
9698
PackageListToolbar,
@@ -108,6 +110,7 @@ import {
108110
PaginationControls,
109111
ProvenanceBadge,
110112
Readme,
113+
SearchSuggestionCard,
111114
SettingsAccentColorPicker,
112115
SettingsBgThemePicker,
113116
SettingsToggle,
@@ -116,8 +119,7 @@ import {
116119
TooltipAnnounce,
117120
TooltipApp,
118121
TooltipBase,
119-
HeaderSearchBox,
120-
SearchSuggestionCard,
122+
UserAvatar,
121123
VersionSelector,
122124
ViewModeToggle,
123125
} from '#components'
@@ -610,6 +612,49 @@ describe('component accessibility audits', () => {
610612
})
611613
})
612614

615+
describe('PackageCompatibility', () => {
616+
it('should have no accessibility violations without engines', async () => {
617+
const component = await mountSuspended(PackageCompatibility, {
618+
props: {},
619+
})
620+
const results = await runAxe(component)
621+
expect(results.violations).toEqual([])
622+
})
623+
624+
it('should have no accessibility violations with engines', async () => {
625+
const component = await mountSuspended(PackageCompatibility, {
626+
props: {
627+
engines: {
628+
node: '>=14',
629+
npm: '>=10',
630+
},
631+
},
632+
})
633+
const results = await runAxe(component)
634+
expect(results.violations).toEqual([])
635+
})
636+
})
637+
638+
describe('PackageKeywords', () => {
639+
it('should have no accessibility violations without keywords', async () => {
640+
const component = await mountSuspended(PackageKeywords, {
641+
props: {},
642+
})
643+
const results = await runAxe(component)
644+
expect(results.violations).toEqual([])
645+
})
646+
647+
it('should have no accessibility violations with keywords', async () => {
648+
const component = await mountSuspended(PackageKeywords, {
649+
props: {
650+
keywords: ['keyword1', 'keyword2'],
651+
},
652+
})
653+
const results = await runAxe(component)
654+
expect(results.violations).toEqual([])
655+
})
656+
})
657+
613658
describe('CodeViewer', () => {
614659
it('should have no accessibility violations', async () => {
615660
const component = await mountSuspended(CodeViewer, {

0 commit comments

Comments
 (0)