From 8d7c09ef76db66b09bc04473a83f35b893a0dc0d Mon Sep 17 00:00:00 2001 From: jlp-craigmorten Date: Sun, 25 Jun 2023 12:03:02 +0100 Subject: [PATCH 1/5] feat: upgrade aria-query to 5.3.0 --- package.json | 2 +- .../__snapshots__/role-helpers.js.snap | 26 ------------------- src/__tests__/role-helpers.js | 20 ++++---------- src/__tests__/role.js | 18 +++++++++++++ src/__tests__/suggestions.js | 6 ++--- 5 files changed, 27 insertions(+), 45 deletions(-) diff --git a/package.json b/package.json index 55f7b49e..dd189543 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/__tests__/__snapshots__/role-helpers.js.snap b/src/__tests__/__snapshots__/role-helpers.js.snap index 4a8a1f2f..a917f225 100644 --- a/src/__tests__/__snapshots__/role-helpers.js.snap +++ b/src/__tests__/__snapshots__/role-helpers.js.snap @@ -52,32 +52,6 @@ Name "": data-testid="a-article" /> --------------------------------------------------- -command: - -Name "": - - -Name "": - - --------------------------------------------------- -menuitem: - -Name "": - - -Name "": - - -------------------------------------------------- list: diff --git a/src/__tests__/role-helpers.js b/src/__tests__/role-helpers.js index aadc1dc2..5d60f55b 100644 --- a/src/__tests__/role-helpers.js +++ b/src/__tests__/role-helpers.js @@ -19,7 +19,7 @@ function setup() {
Banner header
link - invalid link + invalid link
`) @@ -70,7 +74,6 @@ function setup() { unnamedSection: getByTestId('a-section'), namedSection: getByTestId('named-section'), anchor: getByTestId('a-link'), - invalidAnchor: getByTestId('invalid-link'), h1: getByTestId('a-h1'), h2: getByTestId('a-h2'), h3: getByTestId('a-h3'), @@ -98,14 +101,16 @@ 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'), } } test('getRoles returns expected roles for various dom nodes', () => { const { - unnamedSection, anchor, - invalidAnchor, h1, h2, h3, @@ -133,11 +138,15 @@ test('getRoles returns expected roles for various dom nodes', () => { dd, dt, header, + invalidAnchor, + unnamedSection, + unnamedImg, + presentationImg, + namedImg, } = setup() expect(getRoles(namedSection)).toEqual({ link: [anchor], - generic: [invalidAnchor, unnamedSection], heading: [h1, h2, h3], navigation: [nav], radio: [radio, radio2], @@ -153,6 +162,9 @@ test('getRoles returns expected roles for various dom nodes', () => { region: [namedSection], term: [dt], definition: [dd], + generic: [invalidAnchor, unnamedSection], + img: [unnamedImg, namedImg], + presentation: [presentationImg], }) expect(getRoles(header)).toEqual({ banner: [header], diff --git a/src/role-helpers.js b/src/role-helpers.js index bc134f27..8d7e7cb0 100644 --- a/src/role-helpers.js +++ b/src/role-helpers.js @@ -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('')}` } From 47511c69766c89ae4806272ca260699173faad60 Mon Sep 17 00:00:00 2001 From: jlp-craigmorten Date: Wed, 9 Aug 2023 09:29:59 +0100 Subject: [PATCH 3/5] feat: pin `aria-query` version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index fcf04ae8..3803ac7b 100644 --- a/package.json +++ b/package.json @@ -62,7 +62,7 @@ "@babel/code-frame": "^7.10.4", "@babel/runtime": "^7.12.5", "@types/aria-query": "^5.0.1", - "aria-query": "^5.3.0", + "aria-query": "5.3.0", "chalk": "^4.1.0", "dom-accessibility-api": "^0.5.9", "lz-string": "^1.5.0", From 336152be6670d40509f35043e661cde14e4b30ba Mon Sep 17 00:00:00 2001 From: Matan Borenkraout Date: Sun, 10 Sep 2023 10:33:20 +0300 Subject: [PATCH 4/5] chore: add accessibility-alt-text-bot (#1240) * chore: add accessibility-alt-text-bot * fix formatting issues --- .github/workflows/accessibility-alt-text.yml | 28 ++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 .github/workflows/accessibility-alt-text.yml diff --git a/.github/workflows/accessibility-alt-text.yml b/.github/workflows/accessibility-alt-text.yml new file mode 100644 index 00000000..2b8ea3f1 --- /dev/null +++ b/.github/workflows/accessibility-alt-text.yml @@ -0,0 +1,28 @@ +name: Accessibility-alt-text-bot +on: + issues: + types: [opened, edited] + pull_request: + types: [opened, edited] + issue_comment: + types: [created, edited] + discussion: + types: [created, edited] + discussion_comment: + types: [created, edited] + +permissions: + issues: write + pull-requests: write + discussions: write + +jobs: + accessibility_alt_text_bot: + name: Check alt text is set on issue or pull requests + runs-on: ubuntu-latest + if: + ${{ github.event.issue || github.event.pull_request || + github.event.discussion }} + steps: + - name: Get action 'github/accessibility-alt-text-bot' + uses: github/accessibility-alt-text-bot@v1.2.0 # Set to latest From 4a6b5958bd9f46de900177a88164a3894e582167 Mon Sep 17 00:00:00 2001 From: jlp-craigmorten Date: Sun, 10 Sep 2023 17:57:06 +0100 Subject: [PATCH 5/5] test: add coverage for footer to confirm it's expected implicit role as contentinfo --- src/__tests__/role-helpers.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/__tests__/role-helpers.js b/src/__tests__/role-helpers.js index 0cec4ea6..1ed32464 100644 --- a/src/__tests__/role-helpers.js +++ b/src/__tests__/role-helpers.js @@ -68,6 +68,7 @@ function setup() { a meaningful description + `) return { @@ -105,6 +106,7 @@ function setup() { unnamedImg: getByTestId('a-img-1'), presentationImg: getByTestId('a-img-2'), namedImg: getByTestId('a-img-3'), + footer: getByTestId('a-footer'), } } @@ -143,6 +145,7 @@ test('getRoles returns expected roles for various dom nodes', () => { unnamedImg, presentationImg, namedImg, + footer, } = setup() expect(getRoles(namedSection)).toEqual({ @@ -169,6 +172,9 @@ test('getRoles returns expected roles for various dom nodes', () => { expect(getRoles(header)).toEqual({ banner: [header], }) + expect(getRoles(footer)).toEqual({ + contentinfo: [footer], + }) }) test('logRoles calls console.log with output from prettyRoles', () => {