Skip to content

Commit

Permalink
release: 10.0.0
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Minimum supported Node.js version is 18.0
BREAKING CHANGE: New version of `aria-query` changes various roles. Check out the changed tests in 2c57055 to get an overview about what changed.
  • Loading branch information
eps1lon authored Apr 8, 2024
2 parents bd04cf9 + cb57f99 commit 6ad31ec
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 56 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ jobs:
- name: ⎔ Setup node
uses: actions/setup-node@v3
with:
node-version: 14
node-version: 18

# Ideally done by actions/setup-node: https://github.com/actions/setup-node/issues/213
- name: Setup package manager
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"author": "Kent C. Dodds <me@kentcdodds.com> (https://kentcdodds.com)",
"license": "MIT",
"engines": {
"node": ">=14"
"node": ">=18"
},
"browserslist": [
"and_chr 103",
Expand All @@ -40,7 +40,7 @@
"safari 15.5",
"samsung 17.0",
"samsung 16.0",
"node 14.0"
"node 18.0"
],
"scripts": {
"build": "kcd-scripts build --no-ts-defs --ignore \"**/__tests__/**,**/__node_tests__/**,**/__mocks__/**\" && kcd-scripts build --no-ts-defs --bundle --no-clean",
Expand All @@ -62,7 +62,7 @@
"@babel/code-frame": "^7.10.4",
"@babel/runtime": "^7.12.5",
"@types/aria-query": "^5.0.1",
"aria-query": "5.1.3",
"aria-query": "5.3.0",
"chalk": "^4.1.0",
"dom-accessibility-api": "^0.5.9",
"lz-string": "^1.5.0",
Expand Down
52 changes: 26 additions & 26 deletions src/__tests__/__snapshots__/role-helpers.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -52,32 +52,6 @@ Name "":
data-testid="a-article"
/>
--------------------------------------------------
command:
Name "":
<menuitem
data-testid="a-menuitem-1"
/>
Name "":
<menuitem
data-testid="a-menuitem-2"
/>
--------------------------------------------------
menuitem:
Name "":
<menuitem
data-testid="a-menuitem-1"
/>
Name "":
<menuitem
data-testid="a-menuitem-2"
/>
--------------------------------------------------
list:
Expand Down Expand Up @@ -216,5 +190,31 @@ Name "":
data-testid="a-dd"
/>
--------------------------------------------------
img:
Name "":
<img
data-testid="a-img-1"
src="http://example.com/image.png"
/>
Name "a meaningful description":
<img
alt="a meaningful description"
data-testid="a-img-3"
src="http://example.com/image.png"
/>
--------------------------------------------------
presentation:
Name "":
<img
alt=""
data-testid="a-img-2"
src="http://example.com/image.png"
/>
--------------------------------------------------
`;
44 changes: 26 additions & 18 deletions src/__tests__/role-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function setup() {
<header data-testid="a-header">Banner header</header>
<section aria-label="a region" data-testid='named-section'>
<a href="http://whatever.com" data-testid="a-link">link</a>
<a>invalid link</a>
<a data-testid="invalid-link">invalid link</a>
<nav data-testid='a-nav' />
Expand All @@ -28,14 +28,6 @@ function setup() {
<h3 data-testid='a-h3'>Tertiary Heading</h3>
<article data-testid='a-article'>
<!-- menuitem is currently deprecated, but is the only
tag currently that aria-query returns multiple roles for
(roles: command, menuitem).
It's used here in case a future tag also has multiple
roles -->
<menuitem data-testid='a-menuitem-1'>1</menuitem>
<menuitem data-testid='a-menuitem-2'>2</menuitem>
<ul data-testid='a-list'>
<li data-testid='a-list-item-1'>Item 1</li>
<li data-testid='a-list-item-2'>Item 2</li>
Expand Down Expand Up @@ -66,12 +58,17 @@ function setup() {
<form data-testid="a-form" />
<section data-testid="a-section" />
</article>
<dl>
</article>
<dl>
<dt data-testid="a-dt">Term</dt>
<dd data-testid="a-dd">Definition</dd>
</dl>
</dl>
<img src="http://example.com/image.png" data-testid='a-img-1'/>
<img alt="" src="http://example.com/image.png" data-testid='a-img-2'/>
<img alt="a meaningful description" src="http://example.com/image.png" data-testid='a-img-3'/>
</section>
<footer data-testid="a-footer">Contentinfo footer</footer>
`)

return {
Expand All @@ -83,8 +80,6 @@ function setup() {
h3: getByTestId('a-h3'),
nav: getByTestId('a-nav'),
article: getByTestId('a-article'),
menuItem: getByTestId('a-menuitem-1'),
menuItem2: getByTestId('a-menuitem-2'),
aUl: getByTestId('a-list'),
aLi1: getByTestId('a-list-item-1'),
aLi2: getByTestId('a-list-item-2'),
Expand All @@ -107,6 +102,11 @@ function setup() {
dt: getByTestId('a-dt'),
dd: getByTestId('a-dd'),
header: getByTestId('a-header'),
invalidAnchor: getByTestId('invalid-link'),
unnamedImg: getByTestId('a-img-1'),
presentationImg: getByTestId('a-img-2'),
namedImg: getByTestId('a-img-3'),
footer: getByTestId('a-footer'),
}
}

Expand All @@ -118,8 +118,6 @@ test('getRoles returns expected roles for various dom nodes', () => {
h3,
nav,
article,
menuItem,
menuItem2,
aUl,
aLi1,
aLi2,
Expand All @@ -142,6 +140,12 @@ test('getRoles returns expected roles for various dom nodes', () => {
dd,
dt,
header,
invalidAnchor,
unnamedSection,
unnamedImg,
presentationImg,
namedImg,
footer,
} = setup()

expect(getRoles(namedSection)).toEqual({
Expand All @@ -157,16 +161,20 @@ test('getRoles returns expected roles for various dom nodes', () => {
cell: [td1, td2, td3],
textbox: [input, input2, textarea],
rowgroup: [tbody],
command: [menuItem, menuItem2],
menuitem: [menuItem, menuItem2],
form: [namedForm],
region: [namedSection],
term: [dt],
definition: [dd],
generic: [invalidAnchor, unnamedSection],
img: [unnamedImg, namedImg],
presentation: [presentationImg],
})
expect(getRoles(header)).toEqual({
banner: [header],
})
expect(getRoles(footer)).toEqual({
contentinfo: [footer],
})
})

test('logRoles calls console.log with output from prettyRoles', () => {
Expand Down
18 changes: 18 additions & 0 deletions src/__tests__/role.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,12 @@ test('accessible name comparison is case sensitive', () => {
<h1 />
--------------------------------------------------
emphasis:
Name "":
<em />
--------------------------------------------------
Ignored nodes: comments, script, style
<div>
Expand Down Expand Up @@ -296,6 +302,12 @@ test('TextMatch serialization in error message', () => {
<h1 />
--------------------------------------------------
emphasis:
Name "":
<em />
--------------------------------------------------
Ignored nodes: comments, script, style
<div>
Expand All @@ -320,6 +332,12 @@ test('TextMatch serialization in error message', () => {
<h1 />
--------------------------------------------------
emphasis:
Name "":
<em />
--------------------------------------------------
Ignored nodes: comments, script, style
<div>
Expand Down
6 changes: 3 additions & 3 deletions src/__tests__/suggestions.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,9 @@ test('escapes regular expressions in suggestion', () => {
const {container} = renderIntoDocument(`
<label for="superInput">inp-t lab^l w{th c+ars to esc\\pe</label>
<input id="superInput" type="text" value="my super string +-('{}^$)" placeholder="should escape +-'(/" />
<p>
<span>
Loading ... (1)
</p>
</span>
<img src="foo.png" alt="The Problem (picture of a question mark)" data-testid="foo" />
`)

Expand All @@ -214,7 +214,7 @@ test('escapes regular expressions in suggestion', () => {
).toString(),
).toEqual(`getByAltText(/the problem \\(picture of a question mark\\)/i)`)

expect(getSuggestedQuery(container.querySelector('p')).toString()).toEqual(
expect(getSuggestedQuery(container.querySelector('span')).toString()).toEqual(
`getByText(/loading \\.\\.\\. \\(1\\)/i)`,
)

Expand Down
15 changes: 10 additions & 5 deletions src/role-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,18 @@ function buildElementRoleList(elementRolesMap) {
return `${name}${attributes
.map(({name: attributeName, value, constraints = []}) => {
const shouldNotExist = constraints.indexOf('undefined') !== -1
if (shouldNotExist) {
return `:not([${attributeName}])`
} else if (value) {
const shouldBeNonEmpty = constraints.indexOf('set') !== -1
const hasExplicitValue = typeof value !== 'undefined'
if (hasExplicitValue) {
return `[${attributeName}="${value}"]`
} else {
return `[${attributeName}]`
} else if (shouldNotExist) {
return `:not([${attributeName}])`
} else if (shouldBeNonEmpty) {
return `[${attributeName}]:not([${attributeName}=""])`
}
return `[${attributeName}]`
})
.join('')}`
}
Expand Down

0 comments on commit 6ad31ec

Please sign in to comment.