Skip to content

Commit

Permalink
Begin A11y unit testing integration (#2014)
Browse files Browse the repository at this point in the history
  • Loading branch information
cameron-eyds authored Sep 3, 2024
1 parent 20d75a7 commit 09b967b
Show file tree
Hide file tree
Showing 11 changed files with 62 additions and 10 deletions.
4 changes: 2 additions & 2 deletions ppr-ui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ppr-ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ppr-ui",
"version": "3.2.50",
"version": "3.2.51",
"private": true,
"appName": "Assets UI",
"sbcName": "SBC Common Components",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<tr>
<th
v-for="header in headers"
:key="header.value"
:key="header.value as string"
:class="header.class"
class="pa-2"
>
Expand Down Expand Up @@ -164,8 +164,9 @@
<tr>
<th
v-for="header in headers"
:key="header.value"
:key="header.value as string"
:class="header.class"
:aria-hidden="header.value === 'edit'"
>
{{ header.text }}
</th>
Expand Down
1 change: 1 addition & 0 deletions ppr-ui/src/components/common/InputFieldDatePicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
readonly
variant="filled"
color="primary"
aria-label="date-text-field"
/>
</template>
<v-card
Expand Down
1 change: 1 addition & 0 deletions ppr-ui/src/components/common/Stepper.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
:ripple="false"
:icon="step.icon"
size="56"
:aria-label="step.id"
>
<v-icon
class="step-icon"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<FormCard
id="add-edit-commission-order"
:label="`${addEditLabel} Securities Commission Order`"
role="form"
>
<template #formSlot>
<v-form
Expand All @@ -19,6 +20,7 @@
label="Commission Order Number"
persistentHint
:rules="fileNumberRules"
aria-label="commission-order-number"
/>
</v-col>
</v-row>
Expand Down Expand Up @@ -57,6 +59,7 @@
counter="512"
persistentCounter
:rules="effectOfOrderRules"
aria-label="effect-of-order"
>
<template #counter="{ counter }">
<span>Characters: {{ counter }}</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
<FormCard
id="add-edit-court-order"
:label="`${addEditLabel} Court Order`"
role="form"
aria-label="Add or edit court order"
>
<template #formSlot>
<v-form
Expand All @@ -21,6 +23,7 @@
label="Court Name"
hint="For example: Supreme Court of British Columbia"
persistentHint
aria-label="court-name-text-field"
:rules="nameRules"
/>
</v-col>
Expand All @@ -39,6 +42,7 @@
label="Court Registry"
hint="The location (city) of the court. For example: Richmond"
persistentHint
aria-label="court-registry-text-field"
:rules="registryRules"
/>
</v-col>
Expand All @@ -56,6 +60,7 @@
color="primary"
label="Court File Number"
persistentHint
aria-label="court-file-number-text-field"
:rules="fileNumberRules"
/>
</v-col>
Expand Down Expand Up @@ -98,6 +103,7 @@
label="Effect of Order (Optional)"
counter="512"
persistentCounter
aria-label="effect-of-order-text-area"
:rules="effectOfOrderRules"
>
<template #counter="{ counter }">
Expand Down
12 changes: 9 additions & 3 deletions ppr-ui/src/views/newRegistration/AddCollateral.vue
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
<template>
<v-container
<span
v-if="dataLoaded"
class="footer-view-container pa-0"
>
<div class="py-0">
<div class="container pa-0 pt-4">
<v-row noGutters>
<v-col cols="9">
<v-col
cols="9"
role="region"
>
<v-btn>
Close Button
</v-btn>
<v-row
id="registration-header"
noGutters
Expand Down Expand Up @@ -74,7 +80,7 @@
/>
</v-col>
</v-row>
</v-container>
</span>
</template>

<script lang="ts">
Expand Down
10 changes: 10 additions & 0 deletions ppr-ui/tests/unit/AddCollateral.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import flushPromises from 'flush-promises'
import { LengthTrustIF } from '@/interfaces'
import { RegistrationTypes } from '@/resources'
import { nextTick } from 'vue'
import { expect, it } from 'vitest'
import { axe } from 'vitest-axe'
import { shallowMount } from '@vue/test-utils'

const store = useStore()

Expand Down Expand Up @@ -44,6 +47,13 @@ describe('Add Collateral new registration component', () => {
await nextTick()
})

it('should have no accessibility violations', async () => {
// Run the axe-core accessibility check on the component's HTML
const results = await axe(wrapper.html())
// Use the custom vitest-axe matcher to check for violations
expect(results).toHaveNoViolations()
})

it('renders Add Collateral View with child components when store is set', async () => {
expect(wrapper.vm.$route.name).toBe(RouteNames.ADD_COLLATERAL)
expect(wrapper.vm.appReady).toBe(true)
Expand Down
14 changes: 13 additions & 1 deletion ppr-ui/tests/unit/AddEditCommissionOrder.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { nextTick } from 'vue'
import { createComponent } from './utils'
import { AddEditCommissionOrder } from '@/components/registration'
import { beforeEach } from 'vitest'
import { beforeEach, expect, it } from 'vitest'
import flushPromises from 'flush-promises'
import { axe } from 'vitest-axe'

const mockCommissionOrder = {
courtOrder: false,
Expand All @@ -21,6 +22,17 @@ describe('AddEditCommissionOrder', () => {
})
})

it('should have no accessibility violations', async () => {
// Run the axe-core accessibility check on the component's HTML
const results = await axe(wrapper.element, {
rules: {
'aria-allowed-attr': { enabled: false } // Disabling this rule as it is inheriting an issue from vuetify
}
})
// Use the custom vitest-axe matcher to check for violations
expect(results).toHaveNoViolations()
})

it('renders the form and input fields', () => {
expect(wrapper.findComponent(AddEditCommissionOrder).exists()).toBe(true)
expect(wrapper.find('#commission-order-number').exists()).toBe(true)
Expand Down
14 changes: 13 additions & 1 deletion ppr-ui/tests/unit/AddEditCourtOrder.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { nextTick } from 'vue'
import { createComponent } from './utils'
import { AddEditCourtOrder, AddEditNotice } from '@/components/registration'
import { beforeEach } from 'vitest'
import { beforeEach, expect, it } from 'vitest'
import flushPromises from 'flush-promises'
import { axe } from 'vitest-axe'

const mockCourtOrder = {
courtOrder: true,
Expand All @@ -23,6 +24,17 @@ describe('AddEditCourtOrder', () => {
})
})

it('should have no accessibility violations', async () => {
// Run the axe-core accessibility check on the component's HTML
const results = await axe(wrapper.element, {
rules: {
'aria-allowed-attr': { enabled: false } // Disabling this rule as it is inheriting an issue from vuetify
}
})
// Use the custom vitest-axe matcher to check for violations
expect(results).toHaveNoViolations()
})

it('renders the form and input fields', () => {
expect(wrapper.findComponent(AddEditCourtOrder).exists()).toBe(true)
expect(wrapper.find('#txt-court-name').exists()).toBe(true)
Expand Down

0 comments on commit 09b967b

Please sign in to comment.