Skip to content

Commit 1bc1dc7

Browse files
committed
chore: migrate from grafana/e2e to grafana/plugin-e2e
1 parent 1694ee8 commit 1bc1dc7

File tree

8 files changed

+127
-36
lines changed

8 files changed

+127
-36
lines changed

.github/workflows/build.yml

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ jobs:
1818
- name: Setup Node.js environment
1919
uses: actions/setup-node@v3
2020
with:
21-
node-version: '20'
22-
cache: 'yarn'
21+
node-version: "20"
22+
cache: "yarn"
2323

2424
- name: Install dependencies
2525
run: yarn install --immutable --prefer-offline
@@ -48,7 +48,7 @@ jobs:
4848
if: steps.check-for-backend.outputs.has-backend == 'true'
4949
uses: actions/setup-go@v3
5050
with:
51-
go-version: '1.20'
51+
go-version: "1.20"
5252

5353
- name: Test backend
5454
if: steps.check-for-backend.outputs.has-backend == 'true'
@@ -64,30 +64,21 @@ jobs:
6464
version: latest
6565
args: buildAll
6666

67-
- name: Check for E2E
68-
id: check-for-e2e
69-
run: |
70-
if [ -d "cypress" ]
71-
then
72-
echo "has-e2e=true" >> $GITHUB_OUTPUT
73-
fi
67+
- name: Install Playwright Browsers
68+
run: yarn playwright install --with-deps
7469

7570
- name: Start grafana docker
76-
if: steps.check-for-e2e.outputs.has-e2e == 'true'
7771
run: docker-compose up -d
7872

79-
- name: Run e2e tests
80-
if: steps.check-for-e2e.outputs.has-e2e == 'true'
81-
run: yarn run e2e
73+
- name: Run Playwright tests
74+
run: yarn playwright test
8275

8376
- name: Stop grafana docker
84-
if: steps.check-for-e2e.outputs.has-e2e == 'true'
8577
run: docker-compose down
8678

87-
- name: Archive E2E output
88-
uses: actions/upload-artifact@v3
89-
if: steps.check-for-e2e.outputs.has-e2e == 'true' && steps.run-e2e-tests.outcome != 'success'
79+
- uses: actions/upload-artifact@v4
80+
if: always()
9081
with:
91-
name: cypress-videos
92-
path: cypress/videos
93-
retention-days: 5
82+
name: playwright-report
83+
path: playwright-report/
84+
retention-days: 30

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,8 @@ grafana
6868

6969
# Binaries
7070
build/
71+
/test-results/
72+
/playwright-report/
73+
/blob-report/
74+
/playwright/.cache/
75+
tests-examples/

cypress.json

Lines changed: 0 additions & 3 deletions
This file was deleted.

cypress/integration/01-smoke.spec.ts

Lines changed: 0 additions & 10 deletions
This file was deleted.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@
2020
"devDependencies": {
2121
"@babel/core": "^7.24.9",
2222
"@grafana/eslint-config": "^7.0.0",
23-
"@grafana/plugin-e2e": "^1.6.0",
23+
"@grafana/plugin-e2e": "^1.6.1",
2424
"@grafana/tsconfig": "^1.3.0-rc1",
25+
"@playwright/test": "^1.45.3",
2526
"@swc/core": "^1.7.1",
2627
"@swc/helpers": "^0.5.12",
2728
"@swc/jest": "^0.2.36",

playwright.config.ts

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import { dirname } from 'path';
2+
import { defineConfig, devices } from '@playwright/test';
3+
import type { PluginOptions } from '@grafana/plugin-e2e';
4+
5+
const pluginE2eAuth = `${dirname(require.resolve('@grafana/plugin-e2e'))}/auth`;
6+
7+
/**
8+
* Read environment variables from file.
9+
* https://github.com/motdotla/dotenv
10+
*/
11+
// import dotenv from 'dotenv';
12+
// dotenv.config({ path: path.resolve(__dirname, '.env') });
13+
14+
/**
15+
* See https://playwright.dev/docs/test-configuration.
16+
*/
17+
export default defineConfig<PluginOptions>({
18+
testDir: './tests',
19+
/* Run tests in files in parallel */
20+
fullyParallel: true,
21+
/* Fail the build on CI if you accidentally left test.only in the source code. */
22+
forbidOnly: !!process.env.CI,
23+
/* Retry on CI only */
24+
retries: process.env.CI ? 2 : 0,
25+
/* Opt out of parallel tests on CI. */
26+
workers: process.env.CI ? 1 : undefined,
27+
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
28+
reporter: 'html',
29+
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
30+
use: {
31+
/* Base URL to use in actions like `await page.goto('/')`. */
32+
baseURL: 'http://localhost:3000',
33+
34+
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
35+
trace: 'on-first-retry',
36+
},
37+
38+
/* Configure projects for major browsers */
39+
projects: [
40+
{
41+
name: 'auth',
42+
testDir: pluginE2eAuth,
43+
testMatch: [/.*\.js/],
44+
},
45+
{
46+
name: 'run-tests',
47+
use: {
48+
...devices['Desktop Chrome'],
49+
// @grafana/plugin-e2e writes the auth state to this file,
50+
// the path should not be modified
51+
storageState: 'playwright/.auth/admin.json',
52+
},
53+
dependencies: ['auth'],
54+
}
55+
],
56+
57+
/* Run your local dev server before starting the tests */
58+
// webServer: {
59+
// command: 'npm run start',
60+
// url: 'http://127.0.0.1:3000',
61+
// reuseExistingServer: !process.env.CI,
62+
// },
63+
});

tests/example.spec.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { test, expect } from '@playwright/test';
2+
3+
test('has title', async ({ page }) => {
4+
await page.goto('https://playwright.dev/');
5+
6+
// Expect a title "to contain" a substring.
7+
await expect(page).toHaveTitle(/Playwright/);
8+
});
9+
10+
test('get started link', async ({ page }) => {
11+
await page.goto('https://playwright.dev/');
12+
13+
// Click the get started link.
14+
await page.getByRole('link', { name: 'Get started' }).click();
15+
16+
// Expects page to have a heading with the name of Installation.
17+
await expect(page.getByRole('heading', { name: 'Installation' })).toBeVisible();
18+
});

yarn.lock

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,7 @@
659659
ua-parser-js "^1.0.32"
660660
web-vitals "^4.0.1"
661661

662-
"@grafana/plugin-e2e@^1.6.0":
662+
"@grafana/plugin-e2e@^1.6.1":
663663
version "1.6.1"
664664
resolved "https://registry.yarnpkg.com/@grafana/plugin-e2e/-/plugin-e2e-1.6.1.tgz#51c4f9d32f5d92e38061f09f5bcaa9d5070d64b5"
665665
integrity sha512-1Ww1luGFKeytiAhbg321+z8n0yZ5ARTkUgSN4YdRkupHThwi+pysqGmmiy9tJyewyqkZMt8maawL6gK2qyTKHA==
@@ -1240,6 +1240,13 @@
12401240
resolved "https://registry.yarnpkg.com/@pkgr/core/-/core-0.1.1.tgz#1ec17e2edbec25c8306d424ecfbf13c7de1aaa31"
12411241
integrity sha512-cq8o4cWH0ibXh9VGi5P20Tu9XF/0fFXl9EUinr9QfTM7a7p0oTA4iJRCQWppXR1Pg8dSM0UCItCkPwsk9qWWYA==
12421242

1243+
"@playwright/test@^1.45.3":
1244+
version "1.45.3"
1245+
resolved "https://registry.yarnpkg.com/@playwright/test/-/test-1.45.3.tgz#22e9c38b3081d6674b28c6e22f784087776c72e5"
1246+
integrity sha512-UKF4XsBfy+u3MFWEH44hva1Q8Da28G6RFtR2+5saw+jgAFQV5yYnB1fu68Mz7fO+5GJF3wgwAIs0UelU8TxFrA==
1247+
dependencies:
1248+
playwright "1.45.3"
1249+
12431250
"@popperjs/[email protected]":
12441251
version "2.11.8"
12451252
resolved "https://registry.yarnpkg.com/@popperjs/core/-/core-2.11.8.tgz#6b79032e760a0899cd4204710beede972a3a185f"
@@ -4189,6 +4196,11 @@ fs.realpath@^1.0.0:
41894196
resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
41904197
integrity sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==
41914198

4199+
4200+
version "2.3.2"
4201+
resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.2.tgz#8a526f78b8fdf4623b709e0b975c52c24c02fd1a"
4202+
integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==
4203+
41924204
fsevents@^2.3.2, fsevents@~2.3.2:
41934205
version "2.3.3"
41944206
resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.3.tgz#cac6407785d03675a2a5e1a5305c697b347d90d6"
@@ -6152,6 +6164,20 @@ pkg-dir@^4.2.0:
61526164
dependencies:
61536165
find-up "^4.0.0"
61546166

6167+
6168+
version "1.45.3"
6169+
resolved "https://registry.yarnpkg.com/playwright-core/-/playwright-core-1.45.3.tgz#e77bc4c78a621b96c3e629027534ee1d25faac93"
6170+
integrity sha512-+ym0jNbcjikaOwwSZycFbwkWgfruWvYlJfThKYAlImbxUgdWFO2oW70ojPm4OpE4t6TAo2FY/smM+hpVTtkhDA==
6171+
6172+
6173+
version "1.45.3"
6174+
resolved "https://registry.yarnpkg.com/playwright/-/playwright-1.45.3.tgz#75143f73093a6e1467f7097083d2f0846fb8dd2f"
6175+
integrity sha512-QhVaS+lpluxCaioejDZ95l4Y4jSFCsBvl2UZkpeXlzxmqS+aABr5c82YmfMHrL6x27nvrvykJAFpkzT2eWdJww==
6176+
dependencies:
6177+
playwright-core "1.45.3"
6178+
optionalDependencies:
6179+
fsevents "2.3.2"
6180+
61556181
portfinder@^1.0.17:
61566182
version "1.0.32"
61576183
resolved "https://registry.yarnpkg.com/portfinder/-/portfinder-1.0.32.tgz#2fe1b9e58389712429dc2bea5beb2146146c7f81"

0 commit comments

Comments
 (0)