Skip to content

Commit 0819869

Browse files
committed
Improve testing page
1 parent 22eec8b commit 0819869

File tree

4 files changed

+82
-17
lines changed

4 files changed

+82
-17
lines changed

apps/components_guide_web/lib/components_guide_web/templates/accessibility_first/properties-cheatsheet.html.eex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
<p>You can hide using a large range of techniques. What you first want to ask is, from whom do I want to hide the content?
3838

3939
<%= list [
40-
"Hide to **everyone**.",
40+
"Hide from **everyone**.",
4141
"**Screen reader affordance:** hide to sighted users, but show to screen reader users.",
4242
"**Visual affordance:** hide to screen reader users, but show to sighted users."
4343
] %>

apps/components_guide_web/lib/components_guide_web/templates/landing/index.html.eex

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,26 @@ subhead = "Guides to accessibility, TDD, BDD, naming, performance, and the lates
6464
</header>
6565
</div>
6666

67+
<div class="text-white" style="<%= sections_styles(:blue) %>">
68+
<header class="mx-auto max-w-4xl">
69+
<h1 class="pt-8 row space-x-4 text-4xl text-center font-bold leading-tight text-shadow">
70+
<div class="row">
71+
<span class="mr-2 text-4xl">💁🏼‍♀️🥇</span>
72+
</div>
73+
<span><%= "Accessibility-First Development" %></span>
74+
</h1>
75+
<nav class="pt-6 pb-4">
76+
<ul class="list-none row font-bold" style="--link-padding: 0.75em">
77+
<li><%= link("Landmarks", to: '/accessibility-first/landmarks') %>
78+
<li><%= link("Widgets", to: '/accessibility-first/widgets-cheatsheet') %>
79+
<li><%= link("Properties", to: '/accessibility-first/properties-cheatsheet') %>
80+
<li><%= link("Forms", to: '/accessibility-first/forms') %>
81+
<li><%= link("Keyboard Navigation", to: '/accessibility-first/keyboard-navigation') %>
82+
</ul>
83+
</nav>
84+
</header>
85+
</div>
86+
6787
<div class="text-white">
6888
<section class="pt-20 pb-20" style="<%= sections_styles(:dark) %>">
6989
<header class="mb-8 mx-auto max-w-4xl px-2 text-center">

apps/components_guide_web/lib/components_guide_web/templates/react_typescript/index.html.eex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
</div>
1919

2020
<article>
21-
<div class="bg-white">
21+
<div class="text-white bg-gray-900">
2222
<div class="content max-w-4xl mx-auto py-8 text-lg">
2323
<%= render(@view_module, @article <> ".html", conn: @conn) %>
2424
</div>

apps/components_guide_web/lib/components_guide_web/templates/react_typescript/testing.html.md

Lines changed: 60 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,41 @@
1-
## Behavior and markup > implementation details
1+
## Use Roles First
22

3-
## Accessibility-first testing: a standard-based approach
3+
Most semantic HTML elements have an implicit role. This role is used by accessibility tools such as screen readers. But as we’ll explain, ou can also use it to write easy-to-understand tests.
44

5-
- Build components
6-
- Test components work as expected
7-
- Test-drive components
8-
- Learnable & deterministic
5+
Because the ARIA specs are more recent than HTML 1.0, it clarifies HTML and provides improved names for a lot of the traditional HTML elements. The names used are more what everyday users would use too, such as `link` rather than `a`.
6+
7+
### Roles are better than Tag Names
8+
9+
Roles are better than tag names, as they generalize towards the user behaviour not the nitty-gritty of HTML specifics.
10+
11+
As an example, `<input type="text">` and `<textarea></textarea>` both have the role **textbox**. A user probably does not care for the difference — it’s just a text field that they can type into.
12+
13+
These roles allow us to think in the language that our users would use:
14+
15+
- The **save** _button_
16+
- The **email** _text field_
17+
- The **primary** _navigation_
18+
- The **notifications** _icon image_
19+
- The _**search** field_
20+
- The **remember me** _checkbox_
21+
22+
### Roles are better than Test IDs
23+
24+
Test IDs are something that allow us to find specific elements on the page. They can seem especially necessary in a component system, since our component structure is not surfaced if we render our component tree to HTML.
25+
26+
The problem is that Test IDs are _only_ used for automated testing — they don’t affect the user’s experience at all.
27+
28+
So something that relies on Test IDs to work might still pass, but still produce an issue for end users! So using them does not give us that much more confidence that what we are implementing actually works.
29+
30+
It would be better if we could test the same experience as our users. If we could take the same path they use when first coming to a page and they begin to understand what’s there.
31+
32+
A screen reader user has this exact experience. They arrive at a page, and are able to hear what sections and elements are available. They are able to jump to a specific section or element and interact with it. And they get feedback telling them exactly what the state of the world is as they interact.
933

10-
## Build components
34+
This sounds exactly what we would desire for our automated tests! We want to find elements on the page, interact with them, and get feedback that they are working correctly.
1135

12-
Most semantic HTML elements have a role.
36+
This is what accessibility-first testing allows us to achieve. And as a massive bonus, it lets us create an accessible experience from day one. We can be on a path to creating a fantastic user experience too.
37+
38+
## Available Roles
1339

1440
<table class="text-left table-fixed">
1541
<thead>
@@ -18,7 +44,7 @@ Most semantic HTML elements have a role.
1844
<th>HTML element</th>
1945
</tr>
2046
</thead>
21-
<tbody class="border text-white bg-teal-900">
47+
<tbody class="text-white bg-teal-900 border border-teal-700">
2248
<%= table_rows([
2349
["**link**", "`<a href=…>`"],
2450
["_none_", "`<a>`"],
@@ -43,7 +69,7 @@ Most semantic HTML elements have a role.
4369
<th>HTML element</th>
4470
</tr>
4571
</thead>
46-
<tbody class="border text-white bg-teal-900">
72+
<tbody class="text-white bg-teal-900 border border-teal-700">
4773
<%= table_rows([
4874
["**main**", "`<main>`"],
4975
["**navigation**", "`<nav>`"],
@@ -61,7 +87,7 @@ Most semantic HTML elements have a role.
6187
<th>HTML element</th>
6288
</tr>
6389
</thead>
64-
<tbody class="border text-white bg-teal-900">
90+
<tbody class="text-white bg-teal-900 border border-teal-700">
6591
<%= table_rows([
6692
["**link**", "`<a href=…>`"],
6793
["_none_", "`<a>`"],
@@ -90,7 +116,7 @@ Most semantic HTML elements have a role.
90116
<th>HTML element</th>
91117
</tr>
92118
</thead>
93-
<tbody class="border text-white bg-teal-900">
119+
<tbody class="text-white bg-teal-900 border border-teal-700">
94120
<%= table_rows([
95121
["**form**", "`<form>`"],
96122
["**button**", "`<button>`"],
@@ -116,15 +142,15 @@ Most semantic HTML elements have a role.
116142
</tbody>
117143
</table>
118144

119-
<table class="text-left">
145+
<table class="text-left table-fixed">
120146
<caption class="text-2xl">Tables</caption>
121147
<thead>
122148
<tr>
123-
<th>Role name</th>
149+
<th style="width: 12em">Role name</th>
124150
<th>HTML element</th>
125151
</tr>
126152
</thead>
127-
<tbody class="border text-white bg-teal-900">
153+
<tbody class="text-white bg-teal-900 border border-teal-700">
128154
<%= table_rows([
129155
["**table**", "`<table>`"],
130156
["**rowgroup**", "`<tbody>`, `<thead>`, `<tfoot>`"],
@@ -136,6 +162,25 @@ Most semantic HTML elements have a role.
136162
</tbody>
137163
</table>
138164

165+
## Accessible names
166+
167+
Accessible elements don’t just have a role. They have a name too, which differentiates them from things with the same role.
168+
169+
These names are provided by HTML in a number of ways:
170+
171+
- `<label>` relationship
172+
- `aria-labelledby` attribute
173+
- `aria-label` attribute
174+
175+
## Behavior and markup > implementation details
176+
177+
## Accessibility-first testing: a standard-based approach
178+
179+
- Build components
180+
- Test components work as expected
181+
- Test-drive components
182+
- Learnable & deterministic
183+
139184
## Test components work as expected
140185

141186
### Roles > Tag Names

0 commit comments

Comments
 (0)