@@ -3,7 +3,7 @@ import { mountSuspended } from '@nuxt/test-utils/runtime'
33import type { VueWrapper } from '@vue/test-utils'
44import 'axe-core'
55import type { AxeResults , RunOptions } from 'axe-core'
6- import { afterEach , describe , expect , it } from 'vitest'
6+ import { afterEach , describe , expect , it , vi } from 'vitest'
77
88// axe-core is a UMD module that exposes itself as window.axe in the browser
99declare const axe : {
@@ -56,6 +56,23 @@ afterEach(() => {
5656 mountedContainers . length = 0
5757} )
5858
59+ // VueUiXy is imported directly in <script setup>, so global stubs cannot override it.
60+ // We mock the module itself to prevent vue-data-ui from mounting charts during tests
61+ // (it relies on DOM measurements and causes runtime errors in Vitest / Playwright).
62+ // This render-function stub avoids the Vue runtime-compiler warning and keeps slots working.
63+ vi . mock ( 'vue-data-ui/vue-ui-xy' , ( ) => {
64+ return {
65+ VueUiXy : defineComponent ( {
66+ name : 'VueUiXy' ,
67+ inheritAttrs : false ,
68+ setup ( _ , { attrs, slots } ) {
69+ return ( ) =>
70+ h ( 'div' , { ...attrs , 'data-test-id' : 'vue-ui-xy-stub' } , slots . default ?.( ) ?? [ ] )
71+ } ,
72+ } ) ,
73+ }
74+ } )
75+
5976// Import components from #components where possible
6077// For server/client variants, we need to import directly to test the specific variant
6178import {
@@ -95,7 +112,6 @@ import {
95112 PackageCompatibility ,
96113 PackageDependencies ,
97114 PackageDeprecatedTree ,
98- PackageDownloadAnalytics ,
99115 PackageInstallScripts ,
100116 PackageKeywords ,
101117 PackageList ,
@@ -138,6 +154,7 @@ import {
138154// The #components import automatically provides the client variant
139155import HeaderAccountMenuServer from '~/components/Header/AccountMenu.server.vue'
140156import ToggleServer from '~/components/Settings/Toggle.server.vue'
157+ import PackageDownloadAnalytics from '~/components/Package/DownloadAnalytics.vue'
141158
142159describe ( 'component accessibility audits' , ( ) => {
143160 describe ( 'DateTime' , ( ) => {
@@ -518,34 +535,32 @@ describe('component accessibility audits', () => {
518535 ]
519536
520537 it ( 'should have no accessibility violations (non-modal)' , async ( ) => {
521- // Test only non-modal mode to avoid vue-data-ui chart rendering issues
522- const component = await mountSuspended ( PackageDownloadAnalytics , {
538+ const wrapper = await mountSuspended ( PackageDownloadAnalytics , {
523539 props : {
524540 weeklyDownloads : mockWeeklyDownloads ,
525541 packageName : 'vue' ,
526542 createdIso : '2020-01-01T00:00:00.000Z' ,
527543 inModal : false ,
528544 } ,
529545 } )
530- const results = await runAxe ( component )
546+
547+ const results = await runAxe ( wrapper )
531548 expect ( results . violations ) . toEqual ( [ ] )
532549 } )
533550
534551 it ( 'should have no accessibility violations with empty data' , async ( ) => {
535- const component = await mountSuspended ( PackageDownloadAnalytics , {
552+ const wrapper = await mountSuspended ( PackageDownloadAnalytics , {
536553 props : {
537554 weeklyDownloads : [ ] ,
538555 packageName : 'vue' ,
539556 createdIso : null ,
540557 inModal : false ,
541558 } ,
542559 } )
543- const results = await runAxe ( component )
560+
561+ const results = await runAxe ( wrapper )
544562 expect ( results . violations ) . toEqual ( [ ] )
545563 } )
546-
547- // Note: Modal mode tests with inModal: true are skipped because vue-data-ui VueUiXy
548- // component has issues in the test environment (requires DOM measurements).
549564 } )
550565
551566 describe ( 'PackagePlaygrounds' , ( ) => {
@@ -1452,6 +1467,13 @@ describe('component accessibility audits', () => {
14521467 it ( 'should have no accessibility violations with no packages' , async ( ) => {
14531468 const component = await mountSuspended ( CompareLineChart , {
14541469 props : { packages : [ ] } ,
1470+ global : {
1471+ stubs : {
1472+ DownloadAnalytics : {
1473+ template : '<div data-test-id="download-analytics-stub"></div>' ,
1474+ } ,
1475+ } ,
1476+ } ,
14551477 } )
14561478 const results = await runAxe ( component )
14571479 expect ( results . violations ) . toEqual ( [ ] )
@@ -1460,6 +1482,13 @@ describe('component accessibility audits', () => {
14601482 it ( 'should have no accessibility violations with packages selected' , async ( ) => {
14611483 const component = await mountSuspended ( CompareLineChart , {
14621484 props : { packages : [ 'vue' , 'react' ] } ,
1485+ global : {
1486+ stubs : {
1487+ DownloadAnalytics : {
1488+ template : '<div data-test-id="download-analytics-stub"></div>' ,
1489+ } ,
1490+ } ,
1491+ } ,
14631492 } )
14641493 const results = await runAxe ( component )
14651494 expect ( results . violations ) . toEqual ( [ ] )
0 commit comments