-
Notifications
You must be signed in to change notification settings - Fork 466
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ByRole doesn't find SVG's graphics-document role #1295
Comments
Agreed, testing in the latest v10 alpha channel for
The changes to Relevant specifications:
It's worth noting that specifications such as SVG-AAM are still W3C Working Draft so are far from stable - e.g. the first Web Platform Tests to cover the GRAPHICS-ARIA and SVG-AAM specifications were only added last year (2023) in May and November respectively, and are fairly sparse due to lots of specification issues not yet decided/resolved (see https://github.com/web-platform-tests/wpt/blob/master/svg-aam/role/roles.html). There currently isn't a Web Platform Test to cover the implicit role of As an aside, explicit roles appear to work fine - see example test cases taken loosely from https://github.com/web-platform-tests/wpt/tree/master/graphics-aam using import { screen } from "@testing-library/react";
describe("explicit graphics roles support", () => {
afterEach(() => {
document.body.innerHTML = "";
});
test("should support an explicit `graphics-document` on a `svg` and an explicit `graphics-symbol` role on a `g` element", () => {
document.body.innerHTML = `
<svg xmlns="http://www.w3.org/2000/svg" role="graphics-document">
<g id="test" role="graphics-symbol" aria-label="lightbulb">
<circle r="10" />
</g>
</svg>`;
expect(screen.getByRole("graphics-document")).toBeInTheDocument();
expect(
screen.getByRole("graphics-symbol", { name: "lightbulb" })
).toBeInTheDocument();
});
test("should support an explicit `graphics-document` on a `svg` and an explicit `graphics-object` role on a `g` element", () => {
document.body.innerHTML = `
<svg xmlns="http://www.w3.org/2000/svg" role="graphics-document">
<g id="test" role="graphics-object" aria-label="door">
<rect fill="darkKhaki" stroke="#632" width="50" height="90" />
<circle fill="gray" stroke="#444" stroke-width="0.7" cx="10" cy="50" r="4" />
</g>
</svg>`;
expect(screen.getByRole("graphics-document")).toBeInTheDocument();
expect(
screen.getByRole("graphics-object", { name: "door" })
).toBeInTheDocument();
});
test("should support an explicit `graphics-document` on a `svg` and an explicit `graphics-symbol` role on a `g` element", () => {
document.body.innerHTML = `
<svg xmlns="http://www.w3.org/2000/svg" role="graphics-document">
<g id="test" role="graphics-symbol" aria-label="lightbulb">
<circle r="10" />
</g>
</svg>`;
expect(screen.getByRole("graphics-document")).toBeInTheDocument();
expect(
screen.getByRole("graphics-symbol", { name: "lightbulb" })
).toBeInTheDocument();
});
}); |
Thank you for your comment, @jlp-craigmorten ! I also noticed that testing library seems to not take the I think this test should work: test("should support an implicit `graphics-document` on a `svg` and an explicit `graphics-symbol` role on a `g` element + using `title` tags for lables", () => {
document.body.innerHTML = `
<svg xmlns="http://www.w3.org/2000/svg">
<title>room layout</title>
<g id="test" role="graphics-symbol">
<title>lightbulb</title>
<circle r="10" />
</g>
</svg>`;
// ✅ this works
expect(screen.getByRole("graphics-document", { name: "room layout" })).toBeInTheDocument();
// ⚠️ this doesn't
expect(
screen.getByRole("graphics-symbol", { name: "lightbulb" })
).toBeInTheDocument();
}); However, this seems not to work for me in @testing-library/dom v9.3.4 Note that it works if you specify test("should support an implicit `graphics-document` on a `svg` and an explicit `graphics-symbol` role on a `g` element + using `title` tags for lables", () => {
document.body.innerHTML = `
<svg xmlns="http://www.w3.org/2000/svg">
<title>room layout</title>
<g id="test" role="graphics-symbol" aria-labelledby="lightbulb-id">
<title id="lightbulb-id">lightbulb</title>
<circle r="10" />
</g>
</svg>`;
expect(screen.getByRole("graphics-document", { name: "room layout" })).toBeInTheDocument();
expect(
screen.getByRole("graphics-symbol", { name: "lightbulb" })
).toBeInTheDocument();
}); I don't know if this is related or not, but it feels like it is. |
When it comes to accname extensions with the likes of For example, tests in WPT for browsers were only added 5 months ago to the SVG-AAM test suite, see https://github.com/web-platform-tests/wpt/blob/master/svg-aam/name/comp_host_language_label.html. Would recommend raising an issue against |
@testing-library/dom
9.3.4 version:Basically, it's still this Bug: #1131
The upstream issue was closed more than 1.5 years ago, yet the bug still persists. Is there a possibility that this can be fixed?
The text was updated successfully, but these errors were encountered: