-
Notifications
You must be signed in to change notification settings - Fork 3
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
Feat/AN-4120 playwright e2e tests #93
Changes from all commits
5f68c81
90099bc
bbea871
489bfda
255cc8b
3c472c9
3f601ac
9faa6ef
858b01b
35f2660
3a7a57c
5d0230c
3f46673
1516e54
31e0272
a9c7620
6a070fe
8962cba
fbfe079
40e8ae8
453e2ac
c6a8611
028b14e
63bad25
89db892
c1255a0
9921e08
db42354
a5b04b5
9e47d6b
21bd94e
558abcc
53c5c3a
f95514e
17a5001
5ce366a
5fd2f3e
146e89d
2d02409
eef928e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,11 +24,15 @@ coverage | |
artifacts/ | ||
work/ | ||
ci/ | ||
e2e-results/ | ||
**/cypress/videos | ||
**/cypress/report.json | ||
Comment on lines
-27
to
-29
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is "cypress" mentioned in project files ? I thought new plugin has only playwright ? is this just left over from angular grafana plugin ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cypress is mentioned because grafana just recently deprecated cypress in their plugin development (https://grafana.com/docs/grafana/latest/breaking-changes/breaking-changes-v11-0/#the-grafanae2e-testing-tool-is-deprecated) and back in March when I created the plugin with the generator tool, this generator tool was still using cypress. |
||
|
||
# Editor | ||
.idea | ||
|
||
.eslintcache | ||
|
||
# Playwright | ||
/test-results/ | ||
/playwright-report/ | ||
/blob-report/ | ||
/playwright/.cache/ | ||
/playwright/.auth/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -103,7 +103,7 @@ This project was generated with `yarn create @grafana/[email protected]`. | |
yarn run server | ||
``` | ||
|
||
6. Run the E2E tests (using Cypress) | ||
6. Run the E2E tests (using Playwright) | ||
|
||
```bash | ||
# Spins up a Grafana instance first that we tests against | ||
|
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { test, expect } from '@grafana/plugin-e2e'; | ||
import { BitmovinDataSourceOptions } from '../src/types/grafanaTypes'; | ||
|
||
test('should save and test valid configuration', async ({ | ||
createDataSourceConfigPage, | ||
readProvisionedDataSource, | ||
page, | ||
selectors, | ||
}) => { | ||
await page.route('*/**/analytics/licenses', async (route) => { | ||
await route.fulfill({ status: 200, body: 'OK' }); | ||
}); | ||
const ds = await readProvisionedDataSource<BitmovinDataSourceOptions>({ fileName: 'datasources.yml' }); | ||
const configPage = await createDataSourceConfigPage({ type: ds.type }); | ||
|
||
await page.getByTestId(`config-editor-${configPage.datasource.name}_api-key-input`).fill('test-api-key'); | ||
await page.getByTestId(`config-editor-${configPage.datasource.name}_tenant-org-id-input`).fill('test-tenant-org-id'); | ||
|
||
const queryPromise = page.waitForRequest('*/**/analytics/licenses'); | ||
await configPage.getByGrafanaSelector(selectors.pages.DataSource.saveAndTest).click(); | ||
const queryRequest = await queryPromise; | ||
|
||
expect(queryRequest.headers()['x-api-client']).toBe('analytics-grafana-datasource'); | ||
expect(queryRequest.headers()['x-api-key']).toBe('test-api-key'); | ||
expect(queryRequest.headers()['x-tenant-org-id']).toBe('test-tenant-org-id'); | ||
|
||
expect(configPage).toHaveAlert('success'); | ||
}); | ||
|
||
test('should not save invalid configuration', async ({ | ||
createDataSourceConfigPage, | ||
readProvisionedDataSource, | ||
page, | ||
selectors, | ||
}) => { | ||
const ds = await readProvisionedDataSource<BitmovinDataSourceOptions>({ fileName: 'datasources.yml' }); | ||
const configPage = await createDataSourceConfigPage({ type: ds.type }); | ||
|
||
await page.getByTestId(`config-editor-${configPage.datasource.name}_api-key-input`).fill('grafana-invalid-api-key'); | ||
|
||
const responsePromise = page.waitForResponse('*/**/analytics/licenses'); | ||
await configPage.getByGrafanaSelector(selectors.pages.DataSource.saveAndTest).click(); | ||
const response = await responsePromise; | ||
|
||
expect(response.status()).toBe(403); | ||
expect(configPage).toHaveAlert('error'); | ||
}); |
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.
why changes in github workflow files ? Have they not been generated by grafana plugin generator tool ?
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.
See answer below.
But good point, instead of having a seperate e2e workflow I will include this here. I will check how the ci file that is generated today with the tool looks like and copy it over.