Skip to content

Commit 183b6ff

Browse files
test(validation): add accessibility tests for CertificateChain component
- Test aria-expanded state on header (true/false) - Test aria-label on each certificate item - Test dl/dt/dd semantic structure for certificate fields - Test toggle button aria-label changes with open/close state Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent 81cf6e6 commit 183b6ff

1 file changed

Lines changed: 96 additions & 0 deletions

File tree

src/tests/components/validation/CertificateChain.spec.ts

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,79 @@ describe('CertificateChain', () => {
430430
const chainWrapper = wrapper.find('.chain-wrapper')
431431
expect(chainWrapper.attributes('aria-label')).toContain('Certificate chain')
432432
})
433+
434+
it('header has aria-expanded false when closed', () => {
435+
wrapper = createWrapper({
436+
chain: [
437+
{ subject: { CN: 'Signer' } },
438+
],
439+
})
440+
441+
const header = wrapper.find('.extra')
442+
expect(header.attributes('aria-expanded')).toBe('false')
443+
})
444+
445+
it('header has aria-expanded true when open', async () => {
446+
wrapper = createWrapper({
447+
chain: [
448+
{ subject: { CN: 'Signer' } },
449+
],
450+
})
451+
452+
wrapper.vm.chainOpen = true
453+
await wrapper.vm.$nextTick()
454+
455+
const header = wrapper.find('.extra')
456+
expect(header.attributes('aria-expanded')).toBe('true')
457+
})
458+
459+
it('certificate items have aria-label', async () => {
460+
wrapper = createWrapper({
461+
chain: [
462+
{ subject: { CN: 'Signer' }, issuer: { CN: 'CA' } },
463+
{ subject: { CN: 'CA' }, issuer: { CN: 'Root' } },
464+
],
465+
})
466+
467+
wrapper.vm.chainOpen = true
468+
await wrapper.vm.$nextTick()
469+
470+
const items = wrapper.findAll('.certificate-item')
471+
expect(items.at(0)!.attributes('aria-label')).toContain('Signer certificate')
472+
expect(items.at(1)!.attributes('aria-label')).toBeTruthy()
473+
})
474+
475+
it('uses dl/dt/dd structure for certificate fields', async () => {
476+
wrapper = createWrapper({
477+
chain: [
478+
{ subject: { CN: 'Signer' }, issuer: { CN: 'CA' }, serialNumber: '123' },
479+
],
480+
})
481+
482+
wrapper.vm.chainOpen = true
483+
await wrapper.vm.$nextTick()
484+
485+
expect(wrapper.find('dl.cert-details').exists()).toBe(true)
486+
expect(wrapper.find('dt').exists()).toBe(true)
487+
expect(wrapper.find('dd').exists()).toBe(true)
488+
})
489+
490+
it('each field has dt label and dd value', async () => {
491+
wrapper = createWrapper({
492+
chain: [
493+
{ subject: { CN: 'Leon Green' }, issuer: { CN: 'LibreSign Test' } },
494+
],
495+
})
496+
497+
wrapper.vm.chainOpen = true
498+
await wrapper.vm.$nextTick()
499+
500+
const dts = wrapper.findAll('dt')
501+
const dds = wrapper.findAll('dd')
502+
503+
expect(dts.length).toBeGreaterThan(0)
504+
expect(dds.length).toBe(dts.length)
505+
})
433506
})
434507

435508
describe('RULE: certificate items maintain order in chain', () => {
@@ -518,6 +591,29 @@ describe('CertificateChain', () => {
518591

519592
expect(wrapper.vm.chainOpen).toBe(false)
520593
})
594+
595+
it('toggle button has aria-label when closed', () => {
596+
wrapper = createWrapper({
597+
chain: [
598+
{ subject: { CN: 'Signer' } },
599+
],
600+
})
601+
602+
expect(wrapper.html()).toContain('Expand certificate chain')
603+
})
604+
605+
it('toggle button has aria-label when open', async () => {
606+
wrapper = createWrapper({
607+
chain: [
608+
{ subject: { CN: 'Signer' } },
609+
],
610+
})
611+
612+
wrapper.vm.chainOpen = true
613+
await wrapper.vm.$nextTick()
614+
615+
expect(wrapper.html()).toContain('Collapse certificate chain')
616+
})
521617
})
522618

523619
describe('RULE: empty chain displays nothing', () => {

0 commit comments

Comments
 (0)