test: add player accessibility assertion

This commit is contained in:
2026-07-06 07:10:02 +02:00
parent 61900a508c
commit 5a3797b5df

View File

@@ -307,6 +307,25 @@ func TestWatchTemplateEscapesJSONDataAttributes(t *testing.T) {
if got != label { if got != label {
t.Fatalf("subtitle label mismatch\nwant: %q\ngot: %q", label, got) t.Fatalf("subtitle label mismatch\nwant: %q\ngot: %q", label, got)
} }
assertPlayerAccessibility(t, player)
}
func assertPlayerAccessibility(t *testing.T, player *goquery.Selection) {
t.Helper()
for selector, want := range map[string]string{
"[data-play-pause]": "Play",
"[data-mute]": "Mute",
"[data-fullscreen]": "Enter fullscreen",
"[data-backward]": "Seek backward 10 seconds",
"[data-forward]": "Seek forward 10 seconds",
} {
if accessibleName, _ := player.Find(selector).Attr("aria-label"); accessibleName != want {
t.Fatalf("%s aria-label = %q, want %q", selector, accessibleName, want)
}
}
if got := player.Find(`[data-loading-context], [data-loading-message]`).Length(); got != 0 {
t.Fatalf("player loading copy count = %d, want 0", got)
}
} }
func TestExecuteFragmentValid(t *testing.T) { func TestExecuteFragmentValid(t *testing.T) {