Skip to content

Commit 0962018

Browse files
feat: show accessibility warning message for inaccessible elements (#270)
* chore: update @testing-library/dom @testing-library/user-event * test: update snapshot after dep update Co-authored-by: Stephan Meijer <[email protected]>
1 parent 4797e03 commit 0962018

File tree

4 files changed

+81
-25
lines changed

4 files changed

+81
-25
lines changed

package-lock.json

Lines changed: 58 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@
4242
"@primer/octicons-react": "^10.0.0",
4343
"@reach/dialog": "^0.10.5",
4444
"@reach/menu-button": "^0.9.1",
45-
"@testing-library/dom": "^7.18.1",
46-
"@testing-library/user-event": "^12.0.11",
45+
"@testing-library/dom": "^7.22.5",
46+
"@testing-library/user-event": "^12.1.2",
4747
"codemirror": "5.54.0",
4848
"crx-bridge": "^2.1.0",
4949
"deep-diff": "^1.0.2",

src/components/ResultSuggestion.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from 'react';
22
import { messages } from '../constants';
33
import CopyButton from './CopyButton';
4+
import { ShieldIcon } from '@primer/octicons-react';
45

56
const colors = ['bg-blue-600', 'bg-yellow-600', 'bg-orange-600', 'bg-red-600'];
67

@@ -125,6 +126,12 @@ function ResultSuggestion({ queries, result, dispatch }) {
125126
)}
126127
</div>
127128
<div className="min-h-8">{message}</div>
129+
{suggestion.warning && (
130+
<div className="min-h-8 text-yellow-700">
131+
<ShieldIcon />
132+
{suggestion.warning}
133+
</div>
134+
)}
128135
</div>
129136
);
130137
}

src/lib/queryAdvise.test.js

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ it('[getAllPossibleQueries] should return an object with all possibile queries',
2121
"queryName": "Role",
2222
"snippet": "screen.getByRole('button')",
2323
"variant": "get",
24+
"warning": "",
2425
},
2526
"Selector": Object {
2627
"excerpt": "querySelector('div > button')",
@@ -65,16 +66,18 @@ it('[getAllPossibleQueries] should return an object with all possibile queries',
6566
"queryName": "AltText",
6667
"snippet": "screen.getByAltText(/enter your username/i)",
6768
"variant": "get",
69+
"warning": "",
6870
},
6971
"DisplayValue": Object {
70-
"excerpt": "getByDisplayValue(/john-doe/i)",
72+
"excerpt": "getByDisplayValue(/john\\\\-doe/i)",
7173
"queryArgs": Array [
72-
/john-doe/i,
74+
/john\\\\-doe/i,
7375
],
7476
"queryMethod": "getByDisplayValue",
7577
"queryName": "DisplayValue",
76-
"snippet": "screen.getByDisplayValue(/john-doe/i)",
78+
"snippet": "screen.getByDisplayValue(/john\\\\-doe/i)",
7779
"variant": "get",
80+
"warning": "",
7881
},
7982
"LabelText": Object {
8083
"excerpt": "getByLabelText(/username/i)",
@@ -85,16 +88,18 @@ it('[getAllPossibleQueries] should return an object with all possibile queries',
8588
"queryName": "LabelText",
8689
"snippet": "screen.getByLabelText(/username/i)",
8790
"variant": "get",
91+
"warning": "",
8892
},
8993
"PlaceholderText": Object {
90-
"excerpt": "getByPlaceholderText(/how should i call you?/i)",
94+
"excerpt": "getByPlaceholderText(/how should i call you\\\\?/i)",
9195
"queryArgs": Array [
92-
/how should i call you\\?/i,
96+
/how should i call you\\\\\\?/i,
9397
],
9498
"queryMethod": "getByPlaceholderText",
9599
"queryName": "PlaceholderText",
96-
"snippet": "screen.getByPlaceholderText(/how should i call you?/i)",
100+
"snippet": "screen.getByPlaceholderText(/how should i call you\\\\?/i)",
97101
"variant": "get",
102+
"warning": "",
98103
},
99104
"Role": Object {
100105
"excerpt": "getByRole('textbox', { name: /username/i })",
@@ -110,6 +115,7 @@ it('[getAllPossibleQueries] should return an object with all possibile queries',
110115
name: /username/i
111116
})",
112117
"variant": "get",
118+
"warning": "",
113119
},
114120
"Selector": Object {
115121
"excerpt": "querySelector('#username')",
@@ -130,6 +136,7 @@ it('[getAllPossibleQueries] should return an object with all possibile queries',
130136
"queryName": "TestId",
131137
"snippet": "screen.getByTestId('uname')",
132138
"variant": "get",
139+
"warning": "",
133140
},
134141
"Text": undefined,
135142
"Title": Object {
@@ -141,6 +148,7 @@ it('[getAllPossibleQueries] should return an object with all possibile queries',
141148
"queryName": "Title",
142149
"snippet": "screen.getByTitle(/enter your username/i)",
143150
"variant": "get",
151+
"warning": "",
144152
},
145153
}
146154
`);

0 commit comments

Comments
 (0)