Skip to content

Commit 4c602f1

Browse files
test(a11y): add accessibility tests for BackButton component and normalize file paths
1 parent 63eb4e9 commit 4c602f1

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

test/nuxt/a11y.spec.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ import {
124124
AboutLogoList,
125125
AuthorAvatar,
126126
AuthorList,
127+
BackButton,
127128
BlogPostFederatedArticles,
128129
BlogPostListCard,
129130
BlogPostWrapper,
@@ -449,6 +450,14 @@ describe('component accessibility audits', () => {
449450
})
450451
})
451452

453+
describe('BackButton', () => {
454+
it('should have no accessibility violations', async () => {
455+
const component = await mountSuspended(BackButton)
456+
const results = await runAxe(component)
457+
expect(results.violations).toEqual([])
458+
})
459+
})
460+
452461
describe('TagStatic', () => {
453462
it('should have no accessibility violations', async () => {
454463
const component = await mountSuspended(TagStatic, {

test/unit/a11y-component-coverage.spec.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ const SKIPPED_COMPONENTS: Record<string, string> = {
4949
'Button/Group.vue': "Wrapper component, tests wouldn't make much sense here",
5050
}
5151

52+
function normalizeComponentPath(filePath: string): string {
53+
return filePath.replaceAll('\\', '/')
54+
}
55+
5256
/**
5357
* Recursively get all Vue component files in a directory.
5458
*/
@@ -62,7 +66,7 @@ function getVueFiles(dir: string, baseDir: string = dir): string[] {
6266
files.push(...getVueFiles(fullPath, baseDir))
6367
} else if (entry.isFile() && entry.name.endsWith('.vue')) {
6468
// Get relative path from base components directory
65-
files.push(path.relative(baseDir, fullPath))
69+
files.push(normalizeComponentPath(path.relative(baseDir, fullPath)))
6670
}
6771
}
6872

@@ -87,7 +91,7 @@ function parseComponentsDeclaration(dtsPath: string): Map<string, string[]> {
8791
let match
8892
while ((match = exportRegex.exec(content)) !== null) {
8993
const componentName = match[1]!
90-
const filePath = match[2]!
94+
const filePath = normalizeComponentPath(match[2]!)
9195

9296
const existing = componentMap.get(componentName) || []
9397
if (!existing.includes(filePath)) {
@@ -116,7 +120,7 @@ function getTestedComponents(
116120
let match
117121

118122
while ((match = directImportRegex.exec(testFileContent)) !== null) {
119-
tested.add(match[1]!)
123+
tested.add(normalizeComponentPath(match[1]!))
120124
}
121125

122126
// Match #components imports like:

0 commit comments

Comments
 (0)