fix(a11y): give the supported-agent icons an exposed role

aria-label on a bare span maps to the generic role, where ARIA does not
support it, so screen readers could drop the only label these icons have.
role="img" exposes it; the test now asserts it.
This commit is contained in:
Brennan Benson
2026-08-27 15:10:56 -07:00
parent 64d3ca3978
commit b4a28178d0
2 changed files with 5 additions and 3 deletions
@@ -20,13 +20,14 @@ const EXPECTED_SUPPORTED_AGENTS = [
] as const satisfies readonly TuiAgent[]
const SUPPORTED_AGENTS_LABEL_KEY = 'auto.components.settings.NativeChatSupportedAgents.label'
function getRenderedChips(): { agent: string; label: string }[] {
function getRenderedChips(): { agent: string; label: string; role: string }[] {
const markup = renderToStaticMarkup(<NativeChatSupportedAgents />)
const container = document.createElement('div')
container.innerHTML = markup
return Array.from(container.querySelectorAll('[data-agent]')).map((node) => ({
agent: node.getAttribute('data-agent') ?? '',
label: node.getAttribute('aria-label') ?? ''
label: node.getAttribute('aria-label') ?? '',
role: node.getAttribute('role') ?? ''
}))
}
@@ -52,6 +53,7 @@ describe('NativeChatSupportedAgents', () => {
for (const chip of getRenderedChips()) {
const entry = getAgentCatalog().find((candidate) => candidate.id === chip.agent)
expect(chip.label).toBe(entry?.label)
expect(chip.role).toBe('img')
}
})
@@ -19,7 +19,7 @@ export function NativeChatSupportedAgents(): React.JSX.Element {
return (
<Tooltip key={agent}>
<TooltipTrigger asChild>
<span data-agent={agent} aria-label={label}>
<span data-agent={agent} role="img" aria-label={label}>
<AgentIcon agent={agent} size={13} />
</span>
</TooltipTrigger>