From cd73626970593c9d4b3284ffaf191de48f0d9a11 Mon Sep 17 00:00:00 2001 From: Tim Paine <3105306+timkpaine@users.noreply.github.com> Date: Fri, 23 Oct 2026 11:06:37 -0400 Subject: [PATCH] Check accessible names for theme navigation links Signed-off-by: Tim Paine <3105306+timkpaine@users.noreply.github.com> --- yardang/tests/test_themes.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/yardang/tests/test_themes.py b/yardang/tests/test_themes.py index e425be9f..b0b45ef8 100644 --- a/yardang/tests/test_themes.py +++ b/yardang/tests/test_themes.py @@ -1,5 +1,6 @@ import ast import os +import re from pathlib import Path from unittest.mock import patch @@ -213,8 +214,11 @@ def test_inferred_urls_render_project_links(self, project, tmp_path): assert "Test Project" in html assert 'href="https://github.com/owner/repo"' in html assert 'href="https://github.com/owner/repo/edit/HEAD/index.md"' in html - assert html.count('href="https://example.com" target="_blank" rel="noopener">Home</a>') == 2 - assert html.count('href="https://docs.example.com" target="_blank" rel="noopener">Docs</a>') == 2 + for url, title in (("https://example.com", "Home"), ("https://docs.example.com", "Docs")): + links = re.findall(r'<a\b([^>]*href="' + re.escape(url) + r'"[^>]*)>(.*?)</a>', html, re.DOTALL) + assert len(links) == 2 + assert all('target="_blank"' in attrs and 'rel="noopener"' in attrs for attrs, _ in links) + assert all(f'aria-label="{title}"' in attrs or text == title for attrs, text in links) class TestResolveCustomAsset: