Closed tracy-french closed 5 months ago
Thanks for creating this issue @tracy-french!
The intent of this method is to provide a safe way to use grafana/e2e-selectors
. These selectors were initially using aria-label
attribute, but to improve accessibility most of them have been migrated to use data-testid
instead. For legacy reasons, the selector value had to be prefixed with data-testid
so that the resolver would know what attribute to look for. So the purpose of the getByTestIdOrAriaLabel
method is to provide a safe way to find locators based on a Grafana e2e selector. You can find more information about this in the plugin-e2e docs.
If you have defined data-testid
attributes to elements in your plugin, I suggest you use page.getByTestId
to access them.
The method name getByTestIdOrAriaLabel
is a bit misleading since there's more to it. I'll definitely add a more explanatory comment. I'm also considering changing the method name entirely to something like getByGrafanaSelector
. Thoughts on that @mckn?
Thanks for creating this issue @tracy-french!
The intent of this method is to provide a safe way to use
grafana/e2e-selectors
. These selectors were initially usingaria-label
attribute, but to improve accessibility most of them have been migrated to usedata-testid
instead. For legacy reasons, the selector value had to be prefixed withdata-testid
so that the resolver would know what attribute to look for. So the purpose of thegetByTestIdOrAriaLabel
method is to provide a safe way to find locators based on a Grafana e2e selector. You can find more information about this in the plugin-e2e docs.If you have defined
data-testid
attributes to elements in your plugin, I suggest you usepage.getByTestId
to access them.The get that the method name
getByTestIdOrAriaLabel
is a bit misleading since there's more to it. I'll definitely add a more explanatory comment. I'm also considering changing the method name entirely to something likegetByGrafanaSelector
. Thoughts on that @mckn?
I think the getByGrafanaSelector
is a better name for this method since it reflects a bit more what it does.
Great, I'll put up a PR that changes the name. We can mark getByTestIdOrAriaLabel
as deprecated, but still support it until we release 1.0.0.
IMHO whilst the package is on a major zero I don't think there's a need to deprecate things, rather I'd vote to rip it out now. Major zero signifies that the package is in active development and breaking changes can and will happen. This allows us to remove any cruft as it evolves into the api we want to give to consumers without the risk of something deprecated arriving in the 1.0.0 release.
IMHO whilst the package is on a major zero I don't think there's a need to deprecate things, rather I'd vote to rip it out now. Major zero signifies that the package is in active development and breaking changes can and will happen. This allows us to remove any cruft as it evolves into the api we want to give to consumers without the risk of something deprecated arriving in the 1.0.0 release.
Yes let's do it! I'm updating the PR.
Which package(s) does this bug affect?
Package versions
What happened?
It's not possible to use
getByTestIdOrAriaLabel
with adata-testid
. The method requires you to call it likegetByTestIdOrAriaLabel('data-testid="my-id"')
to usedata-testid
, but the method incorrectly creates the selector as[data-testid="data-testid="my-id""]
.You can see the bug at https://github.com/grafana/plugin-tools/blob/8be2f927615c2e5a5d21a2b27398122dbe22bdfe/packages/plugin-e2e/src/models/pages/GrafanaPage.ts#L30.
What you expected to happen
The method should create the selector as
[data-testid="my-id"]
.How to reproduce it (as minimally and precisely as possible)
Use the method with a
data-testid
.Environment
Additional context
No response