mirror of https://github.com/grafana/grafana
Grafana E2E: Add deprecation notice and update docs (#85619)
* add deprecation notice * update docs * Update packages/grafana-e2e/README.md Co-authored-by: Jack Westbrook <jack.westbrook@gmail.com> --------- Co-authored-by: Jack Westbrook <jack.westbrook@gmail.com>pull/85594/head
parent
df72cfd38e
commit
0f1b65a7ad
@ -1,28 +1,35 @@ |
|||||||
# End-to-End Tests for plugins |
# end-to-end tests for plugins |
||||||
|
|
||||||
Be sure that you've read the [generalized E2E document](e2e.md). |
When end-to-end testing Grafana plugins, it's recommended to use the [`@grafana/plugin-e2e`](https://www.npmjs.com/package/@grafana/plugin-e2e?activeTab=readme) testing tool. `@grafana/plugin-e2e` extends [`@playwright/test`](https://playwright.dev/) capabilities with relevant fixtures, models, and expect matchers; enabling comprehensive end-to-end testing of Grafana plugins across multiple versions of Grafana. For information on how to get started with Plugin end-to-end testing and Playwright, checkout the [Get started](https://grafana.com/developers/plugin-tools/e2e-test-a-plugin/get-started) guide. |
||||||
|
|
||||||
## Commands |
## Adding end-to-end tests for a core plugin |
||||||
|
|
||||||
|
Playwright end-to-end tests for plugins should be added to the [`e2e/plugin-e2e`](https://github.com/grafana/grafana/tree/main/e2e/plugin-e2e) directory. |
||||||
|
|
||||||
- `yarn test:e2e` will run [Grafana's E2E utility](../../packages/grafana-e2e) against an already running Grafana server. |
1. Add a new directory that has the name as your plugin [`here`](https://github.com/grafana/grafana/tree/main/e2e/plugin-e2e). This is where your plugin tests will be kept. |
||||||
- `yarn test:e2e:update` will run `test:e2e` but instead of asserting that screenshots match their expected fixtures, they'll be replaced with new ones. |
|
||||||
|
|
||||||
Your running Grafana instance can be targeted by setting the `CYPRESS_BASE_URL`, `CYPRESS_USERNAME` and `CYPRESS_PASSWORD` environment variableS: |
2. Playwright uses [projects](https://playwright.dev/docs/test-projects) to logically group tests together. All tests in a project share the same configuration. |
||||||
|
In the [Playwright config file](https://github.com/grafana/grafana/blob/main/playwright.config.ts), add a new project item. Make sure the `name` and the `testDir` sub directory matches the name of the directory that contains your plugin tests. |
||||||
|
Adding `'authenticate'` to the list of dependencies and specifying `'playwright/.auth/admin.json'` as storage state will ensure all tests in your project will start already authenticated as an admin user. If you wish to use a different role for and perhaps test RBAC for some of your tests, please refer to the plugin-e2e [documentation](https://grafana.com/developers/plugin-tools/e2e-test-a-plugin/use-authentication). |
||||||
|
|
||||||
```shell |
```ts |
||||||
CYPRESS_BASE_URL=https://localhost:3000 CYPRESS_USERNAME=admin CYPRESS_PASSWORD=admin yarn test:e2e |
{ |
||||||
``` |
name: 'mysql', |
||||||
|
testDir: path.join(testDirRoot, '/mysql'), |
||||||
|
use: { |
||||||
|
...devices['Desktop Chrome'], |
||||||
|
storageState: 'playwright/.auth/admin.json', |
||||||
|
}, |
||||||
|
dependencies: ['authenticate'], |
||||||
|
}, |
||||||
|
``` |
||||||
|
|
||||||
## Test suites |
3. Update the [CODEOWNERS](https://github.com/grafana/grafana/blob/main/.github/CODEOWNERS/#L315) file so that your team is owner of the tests in the directory you added in step 1. |
||||||
|
|
||||||
|
## Commands |
||||||
|
|
||||||
All tests are located at _\<repo-root>/cypress/integration_ by default. |
- `yarn e2e:playwright` will run all Playwright tests. Optionally, you can provide the `--project mysql` argument to run tests in a certain project. |
||||||
|
|
||||||
## Things to test |
The script above assumes you have Grafana running on `localhost:3000`. You may change this by providing environment variables. |
||||||
|
|
||||||
- Add data source (if applicable) |
`HOST=127.0.0.1 PORT=3001 yarn e2e:playwright` |
||||||
- Add panel |
|
||||||
- Edit panel |
|
||||||
- Annotations (if applicable) |
|
||||||
- Aliases (if applicable) |
|
||||||
- Template variables |
|
||||||
- "Explore" view |
|
||||||
|
@ -1,5 +1,5 @@ |
|||||||
# Grafana End-to-End Test library |
# Grafana End-to-End Test library |
||||||
|
|
||||||
> **@grafana/e2e is currently in BETA**. |
> [!CAUTION] |
||||||
|
> This package is deprecated. |
||||||
This package contains an API wrapper built on top of [Cypress](https://www.cypress.io) that simplifies creating end-to-end tests for Grafana. More information can be found [here](https://github.com/grafana/grafana/blob/main/contribute/style-guides/e2e.md). |
> If you'd like to write end-to-end tests for a Grafana plugin (core or external), use the [`@grafana/plugin-e2e`](https://grafana.com/developers/plugin-tools/e2e-test-a-plugin/introduction) package. |
||||||
|
Loading…
Reference in new issue