Skip to content

Commit

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

* chore(): add a11y test

* chore(): fix a11y test

* chore(): add changeset

* chore(): trigger build

* chore(): trigger build

* chore(): improve changeset

---------

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 Feb 13, 2024
1 parent 819fe72 commit b363ad9
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/spicy-pumas-do.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@baloise/design-system-components': patch
---

**tabs**: Removed `role="region"` to improve semantic HTML and accessibility, ensuring ARIA roles are used correctly and only where they provide clear benefits.
1 change: 0 additions & 1 deletion packages/components/src/components/bal-tabs/bal-tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,6 @@ export class Tabs
></TabNav>
)}
<div
role="region"
part={contentPart}
ref={contentEl => (this.contentEl = contentEl)}
class={{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<!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" />
<title>a11y</title>
<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">
<h1>a11y</h1>
<section data-testid="basic">
<bal-tabs value="tab-c" border>
<bal-tab-item value="tab-a" label="Tab A">Content of Tab A</bal-tab-item>
<bal-tab-item value="tab-b" label="Tab B">Content of Tab B</bal-tab-item>
<bal-tab-item value="tab-c" label="Tab C" bubble>Content of Tab C</bal-tab-item>
<bal-tab-item value="tab-d" label="Tab D" disabled>Content of Tab D</bal-tab-item>
<bal-tab-item
value="tab-link"
label="Tab link"
href="https://github.com/baloise/design-system"
target="_blank"
>Content of Tab link</bal-tab-item
>
<bal-tab-item value="tab-a" label="Tab A" icon="account">Content of Tab A</bal-tab-item>
</bal-tabs>
</section>

<bal-heading>Vertical</bal-heading>
<section data-testid="vertical">
<bal-tabs value="tab-a" vertical border>
<bal-tab-item value="tab-a" label="Tab A" icon="account">Content of Tab A</bal-tab-item>
<bal-tab-item value="tab-b" label="Tab B" icon="account">Content of Tab B</bal-tab-item>
<bal-tab-item value="tab-c" label="Tab C" icon="account" bubble>Content of Tab C</bal-tab-item>
<bal-tab-item value="tab-d" label="Tab D" icon="account" disabled>Content of Tab D</bal-tab-item>
</bal-tabs>
</section>
</main>
</bal-doc-app>
</body>
</html>
15 changes: 15 additions & 0 deletions test/cypress/e2e/a11y/bal-tabs.a11y.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
describe('bal-tabs', () => {
context('a11y', () => {
beforeEach(() => cy.platform('desktop').pageA11y('/components/bal-tabs/test/bal-tabs.a11y.html'))

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

it('tabs vertical', () => {
cy.getByTestId('vertical').testA11y()
})
})
})
})

0 comments on commit b363ad9

Please sign in to comment.