-
Notifications
You must be signed in to change notification settings - Fork 31
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
E2E: Improve support to interact with panel edit options #1272
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! I think I prefer option 1 as option 2 would make us slightly more vulnerable to changes in the core Playwright api.
Question: Would it be better to replace input
and switch
with getByRole(role: 'input' | 'switch' | ..., { name: string }: Options)
? This would make our abstraction look closer to the playwright api?
const group = panelEditPage.getOptionsGroup('Clock panel')
await group.getByRole('switch', { name: 'enableClock' }).uncheck()
Yeah, but on the other hand 'input' is not a role. In the scenario where with the switch-bug you would still need to know if you are trying to fetch a |
@sunker I added some more code and tests. Lets have a sync about this before I continue further but it feels kind of OK to work with when writing tests. |
Nice! Great tests! I had a quick look at the helper methods in the panel options API and this is what you can do:
So basically we need to support textbox, textarea, combobox, radiogroup and switch. So I guess we'll have to choose between: group.getByRole(role: textbox | textarea | combobox | radiogroup | switch, options: { ... })
// or implementing each specifically like in this PR. e.g
group.getRadioButtonGroup(label: string) I don't have strong opinions here. The tricky bit will be to get them to work in >= 8.5.0. |
I'm happy with both as well. The only thing I feel is a bit negative with the But I'm happy to proceed with that approach as well. Maybe ask for some more input here? |
You mean because they only make up a subset of all roles that exists?
Sounds good! Maybe Jack? He's affected by the recent change in his traffic light panel. :) |
Yes, and we would need to have custom roles that match to our components. E.g. in the scenario with the recent change the switch got changed from a 'checkbox' to a 'switch' and in those cases we would not want the developer to need to update their tests. In case they have I understood your suggestion as we don't use the default roles but use our own that maps to our components rather than the html roles. Otherwise we don't resolve issues as the one with the switch. |
packages/plugin-e2e/src/models/components/PanelEditOptionsGroup.ts
Outdated
Show resolved
Hide resolved
d073a1d
to
ef666ca
Compare
packages/plugin-e2e/src/models/components/PanelEditOptionsGroup.ts
Outdated
Show resolved
Hide resolved
packages/plugin-e2e/tests/as-admin-user/panel/panelEdit.spec.ts
Outdated
Show resolved
Hide resolved
packages/plugin-e2e/src/models/components/PanelEditOptionsGroup.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great stuff! From my standpoint we're ready to ship this, but I think we should try to add proper selector for a few of the elements in Grafana first.
@@ -25,7 +25,7 @@ jobs: | |||
with: | |||
version-resolver-type: plugin-grafana-dependency | |||
grafana-dependency: '>=8.5.0' | |||
# limit: 0 # Uncomment to test all versions since 8.5.0. Useful when testing compatibility for new APIs. | |||
limit: 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
now that all tests pass, we can revert the change in this file :)
packages/plugin-e2e/tests/as-admin-user/panel/panelEdit.spec.ts
Outdated
Show resolved
Hide resolved
Everything is fixed except that I have not updated the dependency on the canary package and hence not using the selector in the ColorPicker. Will do that asap. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great stuff!! 🕺
I think what's left to do know is:
- update all docs and snippets so that they use the new awesome API
- add api-test in grafana/grafana to verify the new APIs won't break
- update create-plugin scaffolding so that the new APIs are used
- update examples repo to use the new APIs
It's totally fine with me to do this later in follow up PRs, but the docs should probably be addressed quickly after this PR is merged.
Awesome work on this!
🚀 PR was released in |
What this PR does / why we need it:
This PR introduce an abstraction to interact with the panel edit options. This is useful when developing panel plugins and you want to verify that different combinations of settings works as expected. The goal is to make it easier and more robust to write tests that interacts with the panel editor. This will also give us a layer where we can cater for differences in the panel editor between Grafana versions.
One example of this is the recent change of the switch component that changed role from checkbox to switch. Developers writing tests interacting with the switch directly would need to cater for this in the test which will make it harder and more complex to test your plugin against multiple versions of Grafana.
This is how the configuration of the panel edit options map into the test APIs.
Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
This is a suggestion and I would like to get more eyes on this to get better naming, structure and ways to interact with the panel editor in your test.
On thing that isn't that great is that while writing the tests you use the "labels" visible in the UI to select options to interact with. This is great for the options that the plugin adds because the plugin controls the labels that they add. But for the standard options or options that is added by Grafana we can still run into the problem that a plugin developer writes a test and interacts with the
Standard options
label. If we, for some reason, change that in a Grafana version the tests will stop working and the tests will not be able to run across multiple versions of Grafana.📦 Published PR as canary version:
Canary Versions
✨ Test out this PR locally via: