Skip to content

Commit

Permalink
♿ a11y(bal-badge): write test to prove AA-Standard (#1289)
Browse files Browse the repository at this point in the history
* Create PR for #1181

* chore(): add a11y test

* chore(): refactor

* chore(): use util function

* chore(): format

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Mladen Planinicic <[email protected]>
  • Loading branch information
github-actions[bot] and Mladen Planinicic authored Jan 29, 2024
1 parent dd00d94 commit 27bc36c
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!doctype html>
<html dir="ltr" lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=5.0" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />

<script type="module" src="/build/design-system-components.esm.js"></script>
<script nomodule src="/build/design-system-components.js"></script>
</head>

<body>
<bal-doc-app>
<main class="container py-medium">
<section>
<bal-badge data-testid="basic">42</bal-badge>
</section>
</main>
</bal-doc-app>
</body>
</html>
36 changes: 36 additions & 0 deletions test/cypress/e2e/a11y/bal-badge.a11y.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { findPropertyValuesByTag } from '../../support/a11y.utils'

describe('bal-badge', () => {
context('a11y', () => {
beforeEach(() => cy.platform('desktop').pageA11y('/components/bal-badge/test/bal-badge.a11y.html'))

describe('have the AA standard', () => {
it('basic', () => {
cy.getByTestId('basic').testA11y()
})

testColorA11y()
testSizeA11y()
})
})
})

function testColorA11y() {
const colors = findPropertyValuesByTag('bal-badge', 'color')
for (let index = 0; index < colors.length; index++) {
const color = colors[index]
it(`color ${color}`, () => {
cy.getByTestId('basic').setProperty('color', color).testA11y()
})
}
}

function testSizeA11y() {
const sizes = findPropertyValuesByTag('bal-badge', 'size')
for (let index = 0; index < sizes.length; index++) {
const size = sizes[index]
it(`size ${size}`, () => {
cy.getByTestId('basic').setProperty('size', size).testA11y()
})
}
}

0 comments on commit 27bc36c

Please sign in to comment.