diff --git a/.gitignore b/.gitignore index 770f2f54475..9b9f93c7bc5 100644 --- a/.gitignore +++ b/.gitignore @@ -191,6 +191,8 @@ compilation-stats.json /e2e/build_results.zip /e2e/extensions !/e2e/extensions/.keep +/e2e-playwright/extensions +!/e2e-playwright/extensions/.keep /e2e/extensions-suite /test-results/ /playwright-report/ diff --git a/e2e-playwright/extensions/.keep b/e2e-playwright/extensions/.keep new file mode 100644 index 00000000000..e69de29bb2d diff --git a/e2e-playwright/start-server b/e2e-playwright/start-server index 6685cd472d0..e7c219d9350 100755 --- a/e2e-playwright/start-server +++ b/e2e-playwright/start-server @@ -1,5 +1,8 @@ #!/bin/bash +# Ensure we're in the Grafana root directory +cd "$(dirname "${BASH_SOURCE[0]}")/.." || exit 1 + . scripts/grafana-server/variables LICENSE_PATH="" diff --git a/pkg/build/e2e-playwright/main.go b/pkg/build/e2e-playwright/main.go index a7cff28cff0..97f4caf2e0e 100644 --- a/pkg/build/e2e-playwright/main.go +++ b/pkg/build/e2e-playwright/main.go @@ -144,8 +144,8 @@ func run(ctx context.Context, cmd *cli.Command) error { "public/app/core/icons/cached.json", // packages we use in playwright tests - "packages", // TODO: do we need all of this? - "public/app/plugins", // TODO: do we need all of this? + "packages", + "public", // e2e files "e2e-playwright", diff --git a/playwright.config.ts b/playwright.config.ts index 279ceb8a3f4..fae810c796f 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -3,11 +3,11 @@ import path, { dirname } from 'path'; import { PluginOptions } from '@grafana/plugin-e2e'; -const testDirRoot = 'e2e-playwright'; +export const testDirRoot = 'e2e-playwright'; const pluginDirRoot = path.join(testDirRoot, 'plugin-e2e'); -const DEFAULT_URL = 'http://localhost:3001'; +export const DEFAULT_URL = 'http://localhost:3001'; -function withAuth(project: Project): Project { +export function withAuth(project: Project): Project { project.dependencies ??= []; project.use ??= {}; @@ -20,7 +20,7 @@ function withAuth(project: Project): Project { return project; } -export default defineConfig({ +export const baseConfig: PlaywrightTestConfig = { fullyParallel: true, /* Retry on CI only */ retries: process.env.CI ? 2 : 0, @@ -44,6 +44,10 @@ export default defineConfig({ permissions: ['clipboard-read', 'clipboard-write'], provisioningRootDir: path.join(process.cwd(), process.env.PROV_DIR ?? 'conf/provisioning'), }, +}; + +export default defineConfig({ + ...baseConfig, ...(!process.env.GRAFANA_URL && { webServer: { command: 'yarn e2e:plugin:build && ./e2e-playwright/start-server',