mirror of
https://github.com/priyanshujain/sanderling.git
synced 2026-10-02 19:17:10 +00:00
test(browser): tap a role-based control end to end
every control on the page is an <li role="option">, the shape the replay ui gives its step rows, and the spec carries no action of its own: the property firing is the evidence the default enumeration offered a tap on one.
This commit is contained in:
1 parent
a460eba3db
commit
f3096d195b
3 files changed
+57
No files matched your search
+29
@@ -0,0 +1,29 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>aria roles</title>
|
||||
</head>
|
||||
<body>
|
||||
<!-- Shaped like the replay UI's step list: the rows are the only controls on
|
||||
the page, and they are plain <li> elements carrying role="option". A tap
|
||||
target set that reads element names and role="button" alone sees nothing
|
||||
here at all. -->
|
||||
<ol id="steps" role="listbox" aria-label="Steps">
|
||||
<li id="step-1" role="option">step 1</li>
|
||||
<li id="step-2" role="option">step 2</li>
|
||||
<li id="step-3" role="option">step 3</li>
|
||||
</ol>
|
||||
<div id="selected">0</div>
|
||||
<script>
|
||||
let selections = 0;
|
||||
const display = document.getElementById("selected");
|
||||
for (const row of document.querySelectorAll('[role="option"]')) {
|
||||
row.addEventListener("click", function () {
|
||||
selections += 1;
|
||||
display.textContent = String(selections);
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
import { always, extract, taps } from "@sanderling/spec";
|
||||
|
||||
const selections = extract((s) => {
|
||||
const el = s.ax.find({ id: "selected" });
|
||||
return el ? parseInt(el.text, 10) || 0 : 0;
|
||||
}).named("selections");
|
||||
|
||||
// Every control on the page is an <li role="option">, the shape the replay UI
|
||||
// gives its own step rows. Nothing else can move this counter, so the spec
|
||||
// carries no action of its own: this property firing IS the evidence that the
|
||||
// default enumeration offered a tap on a role-based control.
|
||||
const noRowWasEverSelected = always(() => selections.current === 0);
|
||||
|
||||
export const properties = { noRowWasEverSelected };
|
||||
|
||||
export const actionsRoot = taps;
|
||||
Reference in new issue
Block a user