mirror of
https://github.com/stablyai/orca.git
synced 2026-10-25 00:03:59 +00:00
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:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user