Skip to content

Commit 1e7d6cb

Browse files
committed
test: yet more tests
1 parent 40058f4 commit 1e7d6cb

1 file changed

Lines changed: 234 additions & 0 deletions

File tree

test/nuxt/components.spec.ts

Lines changed: 234 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,18 @@ import CodeViewer from '~/components/CodeViewer.vue'
6868
import CodeDirectoryListing from '~/components/CodeDirectoryListing.vue'
6969
import CodeFileTree from '~/components/CodeFileTree.vue'
7070
import UserCombobox from '~/components/UserCombobox.vue'
71+
import ConnectorModal from '~/components/ConnectorModal.vue'
72+
import ConnectorStatusServer from '~/components/ConnectorStatus.server.vue'
73+
import ConnectorStatusClient from '~/components/ConnectorStatus.client.vue'
74+
import ClaimPackageModal from '~/components/ClaimPackageModal.vue'
75+
import OperationsQueue from '~/components/OperationsQueue.vue'
76+
import PackageList from '~/components/PackageList.vue'
77+
import PackageMetricsBadges from '~/components/PackageMetricsBadges.vue'
78+
import PackageVulnerabilities from '~/components/PackageVulnerabilities.vue'
79+
import PackageAccessControls from '~/components/PackageAccessControls.vue'
80+
import OrgMembersPanel from '~/components/OrgMembersPanel.vue'
81+
import OrgTeamsPanel from '~/components/OrgTeamsPanel.vue'
82+
import CodeMobileTreeDrawer from '~/components/CodeMobileTreeDrawer.vue'
7183

7284
describe('component accessibility audits', () => {
7385
describe('AppHeader', () => {
@@ -565,4 +577,226 @@ describe('component accessibility audits', () => {
565577
expect(results.violations).toEqual([])
566578
})
567579
})
580+
581+
describe('ConnectorModal', () => {
582+
it('should have no accessibility violations when closed', async () => {
583+
const component = await mountSuspended(ConnectorModal, {
584+
props: { open: false },
585+
})
586+
const results = await runAxe(component)
587+
expect(results.violations).toEqual([])
588+
})
589+
590+
it('should have no accessibility violations when open (disconnected)', async () => {
591+
const component = await mountSuspended(ConnectorModal, {
592+
props: { open: true },
593+
})
594+
const results = await runAxe(component)
595+
expect(results.violations).toEqual([])
596+
})
597+
})
598+
599+
describe('ConnectorStatus.server', () => {
600+
it('should have no accessibility violations', async () => {
601+
const component = await mountSuspended(ConnectorStatusServer)
602+
const results = await runAxe(component)
603+
expect(results.violations).toEqual([])
604+
})
605+
})
606+
607+
describe('ConnectorStatus.client', () => {
608+
it('should have no accessibility violations', async () => {
609+
const component = await mountSuspended(ConnectorStatusClient)
610+
const results = await runAxe(component)
611+
expect(results.violations).toEqual([])
612+
})
613+
})
614+
615+
describe('ClaimPackageModal', () => {
616+
it('should have no accessibility violations when closed', async () => {
617+
const component = await mountSuspended(ClaimPackageModal, {
618+
props: {
619+
packageName: 'test-package',
620+
open: false,
621+
},
622+
})
623+
const results = await runAxe(component)
624+
expect(results.violations).toEqual([])
625+
})
626+
627+
it('should have no accessibility violations when open', async () => {
628+
const component = await mountSuspended(ClaimPackageModal, {
629+
props: {
630+
packageName: 'test-package',
631+
open: true,
632+
},
633+
})
634+
const results = await runAxe(component)
635+
expect(results.violations).toEqual([])
636+
})
637+
})
638+
639+
describe('OperationsQueue', () => {
640+
it('should have no accessibility violations', async () => {
641+
const component = await mountSuspended(OperationsQueue)
642+
const results = await runAxe(component)
643+
expect(results.violations).toEqual([])
644+
})
645+
})
646+
647+
describe('PackageList', () => {
648+
const mockResults = [
649+
{
650+
package: {
651+
name: 'vue',
652+
version: '3.5.0',
653+
description: 'The progressive JavaScript framework',
654+
date: '2024-01-15T00:00:00.000Z',
655+
keywords: ['framework'],
656+
links: {},
657+
publisher: { username: 'yyx990803' },
658+
},
659+
score: { final: 0.9, detail: { quality: 0.9, popularity: 0.9, maintenance: 0.9 } },
660+
searchScore: 100000,
661+
},
662+
{
663+
package: {
664+
name: 'react',
665+
version: '18.2.0',
666+
description: 'React is a JavaScript library for building user interfaces.',
667+
date: '2024-01-10T00:00:00.000Z',
668+
keywords: ['react'],
669+
links: {},
670+
publisher: { username: 'fb' },
671+
},
672+
score: { final: 0.9, detail: { quality: 0.9, popularity: 0.9, maintenance: 0.9 } },
673+
searchScore: 90000,
674+
},
675+
]
676+
677+
it('should have no accessibility violations', async () => {
678+
const component = await mountSuspended(PackageList, {
679+
props: { results: mockResults },
680+
})
681+
const results = await runAxe(component)
682+
expect(results.violations).toEqual([])
683+
})
684+
685+
it('should have no accessibility violations with empty results', async () => {
686+
const component = await mountSuspended(PackageList, {
687+
props: { results: [] },
688+
})
689+
const results = await runAxe(component)
690+
expect(results.violations).toEqual([])
691+
})
692+
693+
it('should have no accessibility violations when loading', async () => {
694+
const component = await mountSuspended(PackageList, {
695+
props: {
696+
results: mockResults,
697+
isLoading: true,
698+
hasMore: true,
699+
},
700+
})
701+
const results = await runAxe(component)
702+
expect(results.violations).toEqual([])
703+
})
704+
})
705+
706+
describe('PackageMetricsBadges', () => {
707+
it('should have no accessibility violations', async () => {
708+
const component = await mountSuspended(PackageMetricsBadges, {
709+
props: { packageName: 'vue' },
710+
})
711+
const results = await runAxe(component)
712+
expect(results.violations).toEqual([])
713+
})
714+
715+
it('should have no accessibility violations with version', async () => {
716+
const component = await mountSuspended(PackageMetricsBadges, {
717+
props: {
718+
packageName: 'vue',
719+
version: '3.5.0',
720+
},
721+
})
722+
const results = await runAxe(component)
723+
expect(results.violations).toEqual([])
724+
})
725+
})
726+
727+
describe('PackageVulnerabilities', () => {
728+
it('should have no accessibility violations', async () => {
729+
const component = await mountSuspended(PackageVulnerabilities, {
730+
props: {
731+
packageName: 'lodash',
732+
version: '4.17.21',
733+
},
734+
})
735+
const results = await runAxe(component)
736+
expect(results.violations).toEqual([])
737+
})
738+
})
739+
740+
describe('PackageAccessControls', () => {
741+
it('should have no accessibility violations', async () => {
742+
const component = await mountSuspended(PackageAccessControls, {
743+
props: { packageName: '@nuxt/kit' },
744+
})
745+
const results = await runAxe(component)
746+
expect(results.violations).toEqual([])
747+
})
748+
749+
it('should have no accessibility violations for unscoped package', async () => {
750+
// Unscoped packages don't show the access controls section
751+
const component = await mountSuspended(PackageAccessControls, {
752+
props: { packageName: 'vue' },
753+
})
754+
const results = await runAxe(component)
755+
expect(results.violations).toEqual([])
756+
})
757+
})
758+
759+
describe('OrgMembersPanel', () => {
760+
it('should have no accessibility violations', async () => {
761+
const component = await mountSuspended(OrgMembersPanel, {
762+
props: { orgName: 'nuxt' },
763+
})
764+
const results = await runAxe(component)
765+
expect(results.violations).toEqual([])
766+
})
767+
})
768+
769+
describe('OrgTeamsPanel', () => {
770+
it('should have no accessibility violations', async () => {
771+
const component = await mountSuspended(OrgTeamsPanel, {
772+
props: { orgName: 'nuxt' },
773+
})
774+
const results = await runAxe(component)
775+
expect(results.violations).toEqual([])
776+
})
777+
})
778+
779+
describe('CodeMobileTreeDrawer', () => {
780+
const mockTree = [
781+
{
782+
name: 'src',
783+
type: 'directory' as const,
784+
path: 'src',
785+
children: [{ name: 'index.ts', type: 'file' as const, path: 'src/index.ts' }],
786+
},
787+
{ name: 'package.json', type: 'file' as const, path: 'package.json' },
788+
]
789+
790+
it('should have no accessibility violations when closed', async () => {
791+
const component = await mountSuspended(CodeMobileTreeDrawer, {
792+
props: {
793+
tree: mockTree,
794+
currentPath: '',
795+
baseUrl: '/code/vue',
796+
},
797+
})
798+
const results = await runAxe(component)
799+
expect(results.violations).toEqual([])
800+
})
801+
})
568802
})

0 commit comments

Comments
 (0)