Skip to content

Commit 0f1b65a

Browse files
sunkerjackw
andauthored
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 <[email protected]> --------- Co-authored-by: Jack Westbrook <[email protected]>
1 parent df72cfd commit 0f1b65a

File tree

5 files changed

+33
-26
lines changed

5 files changed

+33
-26
lines changed

contribute/developer-guide.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ make test-go-integration-postgres
172172

173173
### Run end-to-end tests
174174

175-
The end to end tests in Grafana use [Cypress](https://www.cypress.io/) and [Playwright](https://playwright.dev/) to run automated scripts in a browser. Read more about our Cypress [e2e framework](/contribute/style-guides/e2e.md).
175+
Grafana uses [Cypress](https://www.cypress.io/) to end-to-end test core features. Core plugins use [Playwright](https://playwright.dev/) to run automated end-to-end tests. You can find more information on how to add end-to-end tests to your core plugin [here](./style-guides/e2e-plugins.md)
176176

177177
#### Running Cypress tests
178178

contribute/style-guides/e2e-core.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ The above commands use some utils scripts under [_\<repo-root>/e2e_](../../e2e)
2222

2323
## Test suites
2424

25-
All the integration tests are located at _\<repo-root>/e2e/suite\<x>/specs_. The page objects and reusable flows are in the [_\<repo-root>/packages/grafana-e2e_](../../packages/grafana-e2e) package.
25+
All the integration tests are located at _\<repo-root>/e2e/suite\<x>/specs_.
+26-19
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,35 @@
1-
# End-to-End Tests for plugins
1+
# end-to-end tests for plugins
22

3-
Be sure that you've read the [generalized E2E document](e2e.md).
3+
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.
44

5-
## Commands
5+
## Adding end-to-end tests for a core plugin
6+
7+
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.
68

7-
- `yarn test:e2e` will run [Grafana's E2E utility](../../packages/grafana-e2e) against an already running Grafana server.
8-
- `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.
9+
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.
910

10-
Your running Grafana instance can be targeted by setting the `CYPRESS_BASE_URL`, `CYPRESS_USERNAME` and `CYPRESS_PASSWORD` environment variableS:
11+
2. Playwright uses [projects](https://playwright.dev/docs/test-projects) to logically group tests together. All tests in a project share the same configuration.
12+
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.
13+
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).
1114

12-
```shell
13-
CYPRESS_BASE_URL=https://localhost:3000 CYPRESS_USERNAME=admin CYPRESS_PASSWORD=admin yarn test:e2e
14-
```
15+
```ts
16+
{
17+
name: 'mysql',
18+
testDir: path.join(testDirRoot, '/mysql'),
19+
use: {
20+
...devices['Desktop Chrome'],
21+
storageState: 'playwright/.auth/admin.json',
22+
},
23+
dependencies: ['authenticate'],
24+
},
25+
```
1526

16-
## Test suites
27+
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.
28+
29+
## Commands
1730

18-
All tests are located at _\<repo-root>/cypress/integration_ by default.
31+
- `yarn e2e:playwright` will run all Playwright tests. Optionally, you can provide the `--project mysql` argument to run tests in a certain project.
1932

20-
## Things to test
33+
The script above assumes you have Grafana running on `localhost:3000`. You may change this by providing environment variables.
2134

22-
- Add data source (if applicable)
23-
- Add panel
24-
- Edit panel
25-
- Annotations (if applicable)
26-
- Aliases (if applicable)
27-
- Template variables
28-
- "Explore" view
35+
`HOST=127.0.0.1 PORT=3001 yarn e2e:playwright`

contribute/style-guides/e2e.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# End-to-End tests
22

3-
Grafana Labs uses a minimal [homegrown solution](../../packages/grafana-e2e) built on top of [Cypress](https://cypress.io) for its end-to-end (E2E) tests.
3+
Grafana Labs uses a minimal [homegrown solution](../../e2e/utils/index.ts) built on top of [Cypress](https://cypress.io) for its end-to-end (E2E) tests.
44

55
Important notes:
66

77
- We generally store all element identifiers ([CSS selectors](https://mdn.io/docs/Web/CSS/CSS_Selectors)) within the framework for reuse and maintainability.
88
- We generally do not use stubs or mocks as to fully simulate a real user.
99
- Cypress' promises [do not behave as you'd expect](https://docs.cypress.io/guides/core-concepts/introduction-to-cypress.html#Mixing-Async-and-Sync-code).
10-
- [Testing core Grafana](e2e-core.md) is slightly different than [testing plugins](e2e-plugins.md).
10+
- [Testing core Grafana](e2e-core.md) is different than [testing plugins](e2e-plugins.md) - core Grafana uses Cypress whereas plugins use [Playwright test](https://playwright.dev/).
1111

1212
## Framework structure
1313

packages/grafana-e2e/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Grafana End-to-End Test library
22

3-
> **@grafana/e2e is currently in BETA**.
4-
5-
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).
3+
> [!CAUTION]
4+
> This package is deprecated.
5+
> 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.

0 commit comments

Comments
 (0)