Repository navigation
Plugin E2E: Allow overriding grafanaAPICredentials - #930
Conversation
3fd6964 to
799875f
Compare
| await expect(annotationEditPage.getByGrafanaSelector('Select option')).toContainText(REDSHIFT_SCHEMAS); | ||
| await expect(annotationEditPage.getByGrafanaSelector(selectors.components.Select.option)).toContainText( | ||
| REDSHIFT_SCHEMAS | ||
| ); |
There was a problem hiding this comment.
This change (and the next file) is unrelated, but needed to get others tests to pass as this selector was recently changed in the main branch of Grafana.
| /** | ||
| * Set this to true if the user already exist in the database. If omitted or set to false, the user will be created. | ||
| */ | ||
| skipCreateUser?: boolean; |
There was a problem hiding this comment.
This prop name is a bit weird - would have been better to reverse the condition and call this createUser, but that would have been a breaking change.
jackw
left a comment
There was a problem hiding this comment.
LGTM! 🚀
Left a couple of nits. Could we add something to the docs about this?
|
|
||
| /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ | ||
| trace: 'on-first-retry', | ||
| grafanaAPIUser: { |
There was a problem hiding this comment.
nit: Besides a user account are there other ways to auth with the API? Maybe grafanaAPIAuth or grafanaAPICredentials would work rather than mentioning user?
|
|
||
| setup('authenticate', async ({ login, createUser, user }) => { | ||
| if (user) { | ||
| if (user && !user.skipCreateUser) { |
There was a problem hiding this comment.
Not sure I'm understanding the skipCreateUser. Doesn't createUser already handle cases where the user already exists?
There was a problem hiding this comment.
No that's right, user is only created if it doesn't exist, so this is not entirely necessary. I guess I thought this would make this more clear from an end-user standpoint, but that's not the case so I'll remote this prop. Thanks for feedback.
|
🚀 PR was released in |
What this PR does / why we need it:
In a few places in the code, plugin-e2e uses the Grafana API to administrate users, data sources etc. Before this PR, the Grafana API was always called on behalf of the admin:admin user (the default server admin account) as it has all the necessary permissions. This is working fine in most cases, but in the test environment for the SLO app, this account doesn't exist so they're getting 401 errors when setting up users (more details on how to create users here).
With this PR, the Grafana API is still called on behalf of the admin:admin user by default. However, consumers now have the option to override this user by providing a
grafanaAPIUserin the playwright config.grafanaAPIUseris a Playwright option, meaning it can be defined on a global level and on a project level. Also, when specifying the user to use when running the e2e test (not the same thing as thegrafanaAPIUser), it's now possible to setskipCreateUserprop. This gives the consumer the option to not create the user in the database.This is an example where one user is being used when calling the Grafana API and another one is being used when running the e2e tests.
Which issue(s) this PR fixes:
Fixes #934
Special notes for your reviewer:
📦 Published PR as canary version:
Canary Versions✨ Test out this PR locally via:
npm install @grafana/plugin-e2e@1.3.0-canary.930.a85b4bb.0 # or yarn add @grafana/plugin-e2e@1.3.0-canary.930.a85b4bb.0