Skip to content

Commit cf61533

Browse files
committed
test: fix and upfate tests
1 parent d69d11e commit cf61533

4 files changed

Lines changed: 109 additions & 8 deletions

File tree

app/assets/logos/oss-partners/index.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,14 @@ export const OSS_PARTNERS = [
5353
logo: LogoNuxt,
5454
url: 'https://nuxt.com/',
5555
},
56-
{
57-
name: 'Storybook',
58-
logo: LogoStorybook,
59-
url: 'https://storybook.js.org/',
60-
},
6156
{
6257
name: 'Vue',
6358
logo: LogoVue,
6459
url: 'https://vuejs.org/',
6560
},
61+
{
62+
name: 'Storybook',
63+
logo: LogoStorybook,
64+
url: 'https://storybook.js.org/',
65+
},
6666
]

app/components/About/LogoImg.vue

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,36 @@ const props = defineProps<{
66
dark: string
77
light: string
88
}
9+
alt: string
910
}>()
1011
</script>
1112
<template>
1213
<div v-if="typeof src === 'string'">
13-
<img :src="src" loading="lazy" height="36" class="w-auto block h-9" />
14+
<img :src="src" loading="lazy" height="36" class="w-auto block h-9" :alt="alt" />
1415
</div>
1516
<div v-else-if="src.light === 'auto'">
1617
<img
1718
:src="src.dark"
1819
loading="lazy"
1920
height="36"
2021
class="w-auto block light:invert light:grayscale h-9"
22+
:alt="alt"
2123
/>
2224
</div>
2325
<div v-else>
24-
<img :src="src.dark" loading="lazy" height="36" class="w-auto block light:hidden h-9" />
25-
<img :src="src.light" loading="lazy" height="36" class="w-auto block hidden light:block h-9" />
26+
<img
27+
:src="src.dark"
28+
loading="lazy"
29+
height="36"
30+
class="w-auto block light:hidden h-9"
31+
:alt="alt"
32+
/>
33+
<img
34+
:src="src.light"
35+
loading="lazy"
36+
height="36"
37+
class="w-auto block hidden light:block h-9"
38+
:alt="alt"
39+
/>
2640
</div>
2741
</template>

app/components/About/LogoList.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ const props = defineProps<{
2929
target="_blank"
3030
rel="noopener noreferrer"
3131
class="flex items-center justify-center h-full min-w-11 rounded-md hover:bg-fg/10 transition-colors p-1"
32+
:aria-label="item.name"
3233
>
3334
<AboutLogoImg :src="item.logo" :alt="item.name" />
3435
</a>
@@ -53,6 +54,7 @@ const props = defineProps<{
5354
target="_blank"
5455
rel="noopener noreferrer"
5556
class="flex items-center justify-center h-full min-w-10 rounded-md hover:bg-fg/10 transition-colors p-0.5"
57+
:aria-label="groupItem.name"
5658
>
5759
<AboutLogoImg :src="groupItem.logo" :alt="groupItem.name" />
5860
</a>

test/nuxt/a11y.spec.ts

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@ import {
114114
AppFooter,
115115
AppHeader,
116116
AppLogo,
117+
AboutLogoImg,
118+
AboutLogoList,
117119
BaseCard,
118120
BlueskyPostEmbed,
119121
BuildEnvironment,
@@ -197,6 +199,7 @@ import {
197199

198200
// Server variant components must be imported directly to test the server-side render
199201
// The #components import automatically provides the client variant
202+
import LogoNuxt from '~/assets/logos/oss-partners/nuxt.svg'
200203
import HeaderAccountMenuServer from '~/components/Header/AccountMenu.server.vue'
201204
import ToggleServer from '~/components/Settings/Toggle.server.vue'
202205
import SearchProviderToggleServer from '~/components/SearchProviderToggle.server.vue'
@@ -304,6 +307,88 @@ describe('component accessibility audits', () => {
304307
})
305308
})
306309

310+
describe('AboutLogoImg', () => {
311+
it('should have no accessibility violations with string src', async () => {
312+
const component = await mountSuspended(AboutLogoImg, {
313+
props: {
314+
src: LogoNuxt,
315+
alt: 'Nuxt logo',
316+
},
317+
})
318+
const results = await runAxe(component)
319+
expect(results.violations).toEqual([])
320+
})
321+
322+
it('should have no accessibility violations with dark/light src', async () => {
323+
const component = await mountSuspended(AboutLogoImg, {
324+
props: {
325+
src: {
326+
dark: LogoNuxt,
327+
light: 'auto',
328+
},
329+
alt: 'Nuxt logo',
330+
},
331+
})
332+
const results = await runAxe(component)
333+
expect(results.violations).toEqual([])
334+
})
335+
})
336+
337+
describe('AboutLogoList', () => {
338+
it('should have no accessibility violations with direct logo items', async () => {
339+
const component = await mountSuspended(AboutLogoList, {
340+
props: {
341+
list: [
342+
{
343+
name: 'Nuxt',
344+
url: 'https://nuxt.com',
345+
logo: LogoNuxt,
346+
},
347+
{
348+
name: 'Nuxt',
349+
url: 'https://nuxt.com',
350+
logo: {
351+
dark: LogoNuxt,
352+
light: 'auto',
353+
},
354+
},
355+
],
356+
},
357+
})
358+
const results = await runAxe(component)
359+
expect(results.violations).toEqual([])
360+
})
361+
362+
it('should have no accessibility violations with grouped items', async () => {
363+
const component = await mountSuspended(AboutLogoList, {
364+
props: {
365+
list: [
366+
{
367+
name: 'OSS Partners',
368+
items: [
369+
{
370+
name: 'Nuxt',
371+
url: 'https://nuxt.com',
372+
logo: LogoNuxt,
373+
},
374+
{
375+
name: 'Nuxt',
376+
url: 'https://nuxt.com',
377+
logo: {
378+
dark: LogoNuxt,
379+
light: 'auto',
380+
},
381+
},
382+
],
383+
},
384+
],
385+
},
386+
})
387+
const results = await runAxe(component)
388+
expect(results.violations).toEqual([])
389+
})
390+
})
391+
307392
describe('BaseCard', () => {
308393
it('should have no accessibility violations', async () => {
309394
const component = await mountSuspended(BaseCard, {

0 commit comments

Comments
 (0)