Skip to content

Commit 0d59ba1

Browse files
committed
test: move axe test to mandated test suite
1 parent 9fb8bf3 commit 0d59ba1

File tree

2 files changed

+38
-30
lines changed

2 files changed

+38
-30
lines changed

test/nuxt/a11y.spec.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ import {
140140
CodeFileTree,
141141
CodeMobileTreeDrawer,
142142
CodeViewer,
143+
CommandPalette,
143144
CopyToClipboardButton,
144145
CollapsibleSection,
145146
ColumnPicker,
@@ -455,6 +456,43 @@ describe('component accessibility audits', () => {
455456
})
456457
})
457458

459+
describe('CommandPalette', () => {
460+
let commandPalette: ReturnType<typeof useCommandPalette> | null = null
461+
462+
const CommandPaletteHarness = defineComponent({
463+
name: 'CommandPaletteHarness',
464+
setup() {
465+
commandPalette = useCommandPalette()
466+
467+
onMounted(() => {
468+
commandPalette?.open()
469+
})
470+
471+
onBeforeUnmount(() => {
472+
commandPalette?.close()
473+
commandPalette?.clearPackageContext()
474+
})
475+
476+
return () => h('div', [h(CommandPalette)])
477+
},
478+
})
479+
480+
afterEach(() => {
481+
commandPalette?.close()
482+
commandPalette?.clearPackageContext()
483+
commandPalette = null
484+
})
485+
486+
it('should have no accessibility violations when open', async () => {
487+
const component = await mountSuspended(CommandPaletteHarness)
488+
await nextTick()
489+
await nextTick()
490+
491+
const results = await runAxe(component)
492+
expect(results.violations).toEqual([])
493+
})
494+
})
495+
458496
describe('TagStatic', () => {
459497
it('should have no accessibility violations', async () => {
460498
const component = await mountSuspended(TagStatic, {

test/nuxt/components/CommandPalette.spec.ts

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,7 @@
11
import { mountSuspended } from '@nuxt/test-utils/runtime'
2-
import 'axe-core'
3-
import type { AxeResults, RunOptions } from 'axe-core'
42
import { afterEach, describe, expect, it } from 'vitest'
53
import { CommandPalette } from '#components'
64

7-
declare const axe: {
8-
run: (context: Element, options?: RunOptions) => Promise<AxeResults>
9-
}
10-
11-
const axeRunOptions: RunOptions = {
12-
resultTypes: ['violations'],
13-
rules: {
14-
'landmark-one-main': { enabled: false },
15-
'region': { enabled: false },
16-
'page-has-heading-one': { enabled: false },
17-
'landmark-no-duplicate-banner': { enabled: false },
18-
'landmark-no-duplicate-contentinfo': { enabled: false },
19-
'landmark-no-duplicate-main': { enabled: false },
20-
},
21-
}
22-
235
let commandPalette: ReturnType<typeof useCommandPalette> | null = null
246

257
const CommandPaletteHarness = defineComponent({
@@ -47,18 +29,6 @@ afterEach(() => {
4729
})
4830

4931
describe('CommandPalette', () => {
50-
it('has no accessibility violations when open', async () => {
51-
await mountSuspended(CommandPaletteHarness)
52-
await nextTick()
53-
await nextTick()
54-
55-
const dialog = document.getElementById('command-palette-modal')
56-
expect(dialog).not.toBeNull()
57-
58-
const results = await axe.run(dialog!, axeRunOptions)
59-
expect(results.violations).toEqual([])
60-
})
61-
6232
it('connects the input to an existing description, live status, and results region', async () => {
6333
await mountSuspended(CommandPaletteHarness)
6434
await nextTick()

0 commit comments

Comments
 (0)