fix(replay-ui): read data-* attributes by their markup names

The web runtime now publishes raw markup attribute names, so attrs["step"]
read nothing where the markup writes data-step. Three properties went
vacuous and exactlyOneStepIsSelected reported false against a UI that was
fine.

The test also fails if a dataOf key gains no matching attribute, or if an
attribute it derives is rendered nowhere.
This commit is contained in:
pj committed 2026-08-17 23:45:33 +05:30
1 parent 5651adb439
commit e432af7828
3 files changed
+69 -1

No files matched your search

+7
View File
@@ -0,0 +1,7 @@
// attrs is keyed by the names the markup writes (rawAttributes in
// pkg/spec/src/web-runtime.ts), and the goja host the properties run in exposes
// attrs and nothing else (internal/verifier/marshal.go): there is no dataset
// field to read a camelCased key off, so the spec converts the key itself.
export function attributeOf(key: string): string {
return `data-${key.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`)}`;
}
+2 -1
View File
@@ -12,6 +12,7 @@
import { type AccessibilityElement, type Key, PressKey, Tap, actions, always, extract, from, next, weighted } from "@sanderling/spec";
import { defaultActions, noUncaughtExceptions } from "@sanderling/spec/defaults";
import { attributeOf } from "./data-attributes";
function numberOf(value: string | undefined): number | null {
if (value === undefined || value === "") return null;
@@ -21,7 +22,7 @@ function numberOf(value: string | undefined): number | null {
function dataOf(element: AccessibilityElement | undefined, key: string): string | undefined {
const attrs = (element as unknown as { attrs?: Record<string, string> } | undefined)?.attrs;
return attrs ? attrs[key] : undefined;
return attrs ? attrs[attributeOf(key)] : undefined;
}
// The toolbar's own claim about which step is on screen, and how many there are.