grafana/playwright.config.ts
Konrad Lalik 0faab257b1
Some checks are pending
Actionlint / Lint GitHub Actions files (push) Waiting to run
Backend Code Checks / Detect whether code changed (push) Waiting to run
Backend Code Checks / Validate Backend Configs (push) Blocked by required conditions
Backend Unit Tests / Detect whether code changed (push) Waiting to run
Backend Unit Tests / Grafana (1/8) (push) Blocked by required conditions
Backend Unit Tests / Grafana (2/8) (push) Blocked by required conditions
Backend Unit Tests / Grafana (3/8) (push) Blocked by required conditions
Backend Unit Tests / Grafana (4/8) (push) Blocked by required conditions
Backend Unit Tests / Grafana (5/8) (push) Blocked by required conditions
Backend Unit Tests / Grafana (6/8) (push) Blocked by required conditions
Backend Unit Tests / Grafana (7/8) (push) Blocked by required conditions
Backend Unit Tests / Grafana (8/8) (push) Blocked by required conditions
Backend Unit Tests / Grafana Enterprise (1/8) (push) Blocked by required conditions
Backend Unit Tests / Grafana Enterprise (2/8) (push) Blocked by required conditions
Backend Unit Tests / Grafana Enterprise (3/8) (push) Blocked by required conditions
Backend Unit Tests / Grafana Enterprise (4/8) (push) Blocked by required conditions
Backend Unit Tests / Grafana Enterprise (5/8) (push) Blocked by required conditions
Backend Unit Tests / Grafana Enterprise (6/8) (push) Blocked by required conditions
Backend Unit Tests / Grafana Enterprise (7/8) (push) Blocked by required conditions
Backend Unit Tests / Grafana Enterprise (8/8) (push) Blocked by required conditions
Backend Unit Tests / All backend unit tests complete (push) Blocked by required conditions
CodeQL checks / Detect whether code changed (push) Waiting to run
CodeQL checks / Analyze (push) Blocked by required conditions
Lint Frontend / Detect whether code changed (push) Waiting to run
Lint Frontend / Lint (push) Blocked by required conditions
Lint Frontend / Typecheck (push) Blocked by required conditions
Lint Frontend / Verify API clients (push) Waiting to run
Lint Frontend / Verify API clients (enterprise) (push) Waiting to run
Lint Frontend / Verify packed frontend packages (push) Blocked by required conditions
golangci-lint / Detect whether code changed (push) Waiting to run
golangci-lint / go-fmt (push) Blocked by required conditions
golangci-lint / lint-go (push) Blocked by required conditions
Crowdin Upload Action / upload-sources-to-crowdin (push) Waiting to run
Verify i18n / verify-i18n (push) Waiting to run
Documentation / Build & Verify Docs (push) Waiting to run
End-to-end tests / Detect whether code changed (push) Waiting to run
End-to-end tests / Build & Package Grafana (push) Blocked by required conditions
End-to-end tests / Build E2E test runner (push) Blocked by required conditions
End-to-end tests / push-docker-image (push) Blocked by required conditions
End-to-end tests / dashboards-suite (old arch) (push) Blocked by required conditions
End-to-end tests / panels-suite (old arch) (push) Blocked by required conditions
End-to-end tests / smoke-tests-suite (old arch) (push) Blocked by required conditions
End-to-end tests / various-suite (old arch) (push) Blocked by required conditions
End-to-end tests / Verify Storybook (Playwright) (push) Blocked by required conditions
End-to-end tests / Playwright E2E tests (1/8) (push) Blocked by required conditions
End-to-end tests / Playwright E2E tests (2/8) (push) Blocked by required conditions
End-to-end tests / Playwright E2E tests (3/8) (push) Blocked by required conditions
End-to-end tests / Playwright E2E tests (4/8) (push) Blocked by required conditions
End-to-end tests / Playwright E2E tests (5/8) (push) Blocked by required conditions
End-to-end tests / Playwright E2E tests (6/8) (push) Blocked by required conditions
End-to-end tests / Playwright E2E tests (7/8) (push) Blocked by required conditions
End-to-end tests / Playwright E2E tests (8/8) (push) Blocked by required conditions
End-to-end tests / run-azure-monitor-e2e (push) Blocked by required conditions
End-to-end tests / All Playwright tests complete (push) Blocked by required conditions
End-to-end tests / A11y test (push) Blocked by required conditions
End-to-end tests / Publish metrics (push) Blocked by required conditions
End-to-end tests / All E2E tests complete (push) Blocked by required conditions
Frontend tests / Detect whether code changed (push) Waiting to run
Frontend tests / Unit tests (1 / 16) (push) Blocked by required conditions
Frontend tests / Unit tests (10 / 16) (push) Blocked by required conditions
Frontend tests / Unit tests (11 / 16) (push) Blocked by required conditions
Frontend tests / Unit tests (12 / 16) (push) Blocked by required conditions
Frontend tests / Unit tests (13 / 16) (push) Blocked by required conditions
Frontend tests / Unit tests (14 / 16) (push) Blocked by required conditions
Frontend tests / Unit tests (15 / 16) (push) Blocked by required conditions
Frontend tests / Unit tests (16 / 16) (push) Blocked by required conditions
Frontend tests / Unit tests (2 / 16) (push) Blocked by required conditions
Frontend tests / Unit tests (3 / 16) (push) Blocked by required conditions
Frontend tests / Unit tests (4 / 16) (push) Blocked by required conditions
Frontend tests / Unit tests (5 / 16) (push) Blocked by required conditions
Frontend tests / Unit tests (6 / 16) (push) Blocked by required conditions
Frontend tests / Unit tests (7 / 16) (push) Blocked by required conditions
Frontend tests / Unit tests (8 / 16) (push) Blocked by required conditions
Frontend tests / Unit tests (9 / 16) (push) Blocked by required conditions
Frontend tests / Decoupled plugin tests (push) Blocked by required conditions
Frontend tests / Packages unit tests (push) Blocked by required conditions
Frontend tests / All frontend unit tests complete (push) Blocked by required conditions
Frontend tests / Devenv frontend-service build (push) Blocked by required conditions
Integration Tests / Detect whether code changed (push) Waiting to run
Integration Tests / Sqlite (1/4) (push) Blocked by required conditions
Integration Tests / Sqlite (2/4) (push) Blocked by required conditions
Integration Tests / Sqlite (3/4) (push) Blocked by required conditions
Integration Tests / Sqlite (4/4) (push) Blocked by required conditions
Integration Tests / Sqlite Without CGo (1/4) (push) Blocked by required conditions
Integration Tests / Sqlite Without CGo (2/4) (push) Blocked by required conditions
Integration Tests / Sqlite Without CGo (3/4) (push) Blocked by required conditions
Integration Tests / Sqlite Without CGo (4/4) (push) Blocked by required conditions
Integration Tests / Sqlite Without CGo (profiled) (push) Blocked by required conditions
Integration Tests / MySQL (1/16) (push) Blocked by required conditions
Integration Tests / MySQL (10/16) (push) Blocked by required conditions
Integration Tests / MySQL (11/16) (push) Blocked by required conditions
Integration Tests / MySQL (12/16) (push) Blocked by required conditions
Integration Tests / MySQL (13/16) (push) Blocked by required conditions
Integration Tests / MySQL (14/16) (push) Blocked by required conditions
Integration Tests / MySQL (15/16) (push) Blocked by required conditions
Integration Tests / MySQL (16/16) (push) Blocked by required conditions
Integration Tests / MySQL (2/16) (push) Blocked by required conditions
Integration Tests / MySQL (3/16) (push) Blocked by required conditions
Integration Tests / MySQL (4/16) (push) Blocked by required conditions
Integration Tests / MySQL (5/16) (push) Blocked by required conditions
Integration Tests / MySQL (6/16) (push) Blocked by required conditions
Integration Tests / MySQL (7/16) (push) Blocked by required conditions
Integration Tests / MySQL (8/16) (push) Blocked by required conditions
Integration Tests / MySQL (9/16) (push) Blocked by required conditions
Integration Tests / Postgres (1/16) (push) Blocked by required conditions
Integration Tests / Postgres (10/16) (push) Blocked by required conditions
Integration Tests / Postgres (11/16) (push) Blocked by required conditions
Integration Tests / Postgres (12/16) (push) Blocked by required conditions
Integration Tests / Postgres (13/16) (push) Blocked by required conditions
Integration Tests / Postgres (14/16) (push) Blocked by required conditions
Integration Tests / Postgres (15/16) (push) Blocked by required conditions
Integration Tests / Postgres (16/16) (push) Blocked by required conditions
Integration Tests / Postgres (2/16) (push) Blocked by required conditions
Integration Tests / Postgres (3/16) (push) Blocked by required conditions
Integration Tests / Postgres (4/16) (push) Blocked by required conditions
Integration Tests / Postgres (5/16) (push) Blocked by required conditions
Integration Tests / Postgres (6/16) (push) Blocked by required conditions
Integration Tests / Postgres (7/16) (push) Blocked by required conditions
Integration Tests / Postgres (8/16) (push) Blocked by required conditions
Integration Tests / Postgres (9/16) (push) Blocked by required conditions
Integration Tests / All backend integration tests complete (push) Blocked by required conditions
publish-kinds-next / main (push) Waiting to run
publish-technical-documentation-next / sync (push) Waiting to run
Reject GitHub secrets / reject-gh-secrets (push) Waiting to run
Build Release Packages / setup (push) Waiting to run
Build Release Packages / Dispatch grafana-enterprise build (push) Blocked by required conditions
Build Release Packages / / darwin-amd64 (push) Blocked by required conditions
Build Release Packages / / darwin-arm64 (push) Blocked by required conditions
Build Release Packages / / linux-amd64 (push) Blocked by required conditions
Build Release Packages / / linux-armv6 (push) Blocked by required conditions
Build Release Packages / / linux-armv7 (push) Blocked by required conditions
Build Release Packages / / linux-arm64 (push) Blocked by required conditions
Build Release Packages / / linux-s390x (push) Blocked by required conditions
Build Release Packages / / windows-amd64 (push) Blocked by required conditions
Build Release Packages / / windows-arm64 (push) Blocked by required conditions
Build Release Packages / Upload artifacts (push) Blocked by required conditions
Build Release Packages / publish-dockerhub (push) Blocked by required conditions
Build Release Packages / Dispatch publish NPM canaries (push) Blocked by required conditions
Build Release Packages / notify-pr (push) Blocked by required conditions
Run dashboard schema v2 e2e / dashboard-schema-v2-e2e (push) Waiting to run
Shellcheck / Shellcheck scripts (push) Waiting to run
Run Storybook a11y tests / Detect whether code changed (push) Waiting to run
Run Storybook a11y tests / Run Storybook a11y tests (light theme) (push) Blocked by required conditions
Run Storybook a11y tests / Run Storybook a11y tests (dark theme) (push) Blocked by required conditions
Swagger generated code / Detect whether code changed (push) Waiting to run
Swagger generated code / Verify committed API specs match (push) Blocked by required conditions
Dispatch sync to mirror / dispatch-job (push) Waiting to run
trigger-dashboard-search-e2e / trigger-search-e2e (push) Waiting to run
Trivy Scan / trivy-scan (push) Waiting to run
Alerting: Add E2E test configuration and fix saved searches tests (#116203)
* Alerting: Fix and stabilize saved searches E2E tests

Stabilizes the saved searches E2E tests by ensuring correct feature
toggles are enabled and improving the data cleanup logic.

Previously, `clearSavedSearches` relied on clearing localStorage, which
was insufficient as saved searches are persisted server-side via the
UserStorage API. The cleanup now correctly invokes the UserStorage API.

Changes:
- Add `alerting` project to Playwright configuration with authentication
- Enable `alertingListViewV2`, `alertingFilterV2`, and `alertingSavedSearches` toggles in tests
- Update `clearSavedSearches` helper to use UserStorage API for reliable cleanup
- Improve test selectors to use more robust `getByRole` and `getByText` queries
- Update `SavedSearchItem` to merge `aria-label` into `tooltip` for consistency

* Fix saved searchers unit tests
2026-01-14 16:41:53 +01:00

215 lines
6.2 KiB
TypeScript

import { defineConfig, devices, PlaywrightTestConfig, Project } from '@playwright/test';
import path, { dirname } from 'path';
import { PluginOptions } from '@grafana/plugin-e2e';
export const testDirRoot = 'e2e-playwright';
const pluginDirRoot = path.join(testDirRoot, 'plugin-e2e');
export const DEFAULT_URL = 'http://localhost:3001';
export function withAuth(project: Project): Project {
project.dependencies ??= [];
project.use ??= {};
project.dependencies = project.dependencies.concat('authenticate');
project.use = {
...project.use,
storageState: `playwright/.auth/${process.env.GRAFANA_ADMIN_USER || 'admin'}.json`,
};
return project;
}
export const baseConfig: PlaywrightTestConfig<PluginOptions, {}> = {
fullyParallel: true,
/* Retry on CI only */
retries: process.env.CI ? 2 : 0,
/* Opt out of parallel tests on CI. */
workers: process.env.CI ? 1 : undefined,
reporter: [
['html'], // pretty
],
expect: {
timeout: 10_000,
},
use: {
...devices['Desktop Chrome'],
baseURL: process.env.GRAFANA_URL ?? DEFAULT_URL,
trace: 'retain-on-failure',
httpCredentials: {
username: 'admin',
password: 'admin',
},
screenshot: 'only-on-failure',
permissions: ['clipboard-read', 'clipboard-write'],
provisioningRootDir: path.join(process.cwd(), process.env.PROV_DIR ?? 'conf/provisioning'),
},
};
export default defineConfig<PluginOptions>({
...baseConfig,
...(!process.env.GRAFANA_URL && {
webServer: {
command: 'yarn e2e:plugin:build && ./e2e-playwright/start-server',
url: DEFAULT_URL,
stdout: 'pipe',
stderr: 'pipe',
},
}),
projects: [
// Login to Grafana with admin user and store the cookie on disk for use in other tests
{
name: 'authenticate',
testDir: `${dirname(require.resolve('@grafana/plugin-e2e'))}/auth`,
testMatch: [/.*\.js/],
},
// Login to Grafana with new user with viewer role and store the cookie on disk for use in other tests
{
name: 'createUserAndAuthenticate',
testDir: `${dirname(require.resolve('@grafana/plugin-e2e'))}/auth`,
testMatch: [/.*\.js/],
use: {
user: {
user: 'viewer',
password: 'password',
role: 'Viewer',
},
},
},
// Run all tests in parallel using user with admin role
withAuth({
name: 'admin',
testDir: path.join(pluginDirRoot, '/plugin-e2e-api-tests/as-admin-user'),
}),
// Run all tests in parallel using user with viewer role
{
name: 'viewer',
testDir: path.join(pluginDirRoot, '/plugin-e2e-api-tests/as-viewer-user'),
use: {
...devices['Desktop Chrome'],
storageState: 'playwright/.auth/viewer.json',
},
dependencies: ['createUserAndAuthenticate'],
},
withAuth({
name: 'elasticsearch',
testDir: path.join(pluginDirRoot, '/elasticsearch'),
}),
withAuth({
name: 'mysql',
testDir: path.join(pluginDirRoot, '/mysql'),
}),
withAuth({
name: 'mssql',
testDir: path.join(pluginDirRoot, '/mssql'),
}),
withAuth({
name: 'extensions-test-app',
testDir: path.join(testDirRoot, '/test-plugins/grafana-extensionstest-app'),
}),
withAuth({
name: 'grafana-e2etest-datasource',
testDir: path.join(testDirRoot, '/test-plugins/grafana-test-datasource'),
}),
withAuth({
name: 'cloudwatch',
testDir: path.join(pluginDirRoot, '/cloudwatch'),
}),
withAuth({
name: 'azuremonitor',
testDir: path.join(pluginDirRoot, '/azuremonitor'),
}),
withAuth({
name: 'cloudmonitoring',
testDir: path.join(pluginDirRoot, '/cloudmonitoring'),
}),
withAuth({
name: 'graphite',
testDir: path.join(pluginDirRoot, '/graphite'),
}),
withAuth({
name: 'influxdb',
testDir: path.join(pluginDirRoot, '/influxdb'),
}),
withAuth({
name: 'opentsdb',
testDir: path.join(pluginDirRoot, '/opentsdb'),
}),
withAuth({
name: 'jaeger',
testDir: path.join(pluginDirRoot, '/jaeger'),
}),
withAuth({
name: 'grafana-postgresql-datasource',
testDir: path.join(pluginDirRoot, '/grafana-postgresql-datasource'),
}),
withAuth({
name: 'canvas',
testDir: path.join(testDirRoot, '/canvas'),
}),
withAuth({
name: 'zipkin',
testDir: path.join(pluginDirRoot, '/zipkin'),
}),
{
name: 'unauthenticated',
testDir: path.join(testDirRoot, '/unauthenticated'),
},
withAuth({
name: 'various',
testDir: path.join(testDirRoot, '/various-suite'),
}),
withAuth({
name: 'panels',
testDir: path.join(testDirRoot, '/panels-suite'),
}),
withAuth({
name: 'smoke',
testDir: path.join(testDirRoot, '/smoke-tests-suite'),
}),
withAuth({
name: 'dashboards',
testDir: path.join(testDirRoot, '/dashboards-suite'),
}),
withAuth({
name: 'loki',
testDir: path.join(testDirRoot, '/loki'),
}),
withAuth({
name: 'cloud-plugins',
testDir: path.join(testDirRoot, '/cloud-plugins-suite'),
}),
withAuth({
name: 'alerting',
testDir: path.join(testDirRoot, '/alerting-suite'),
}),
withAuth({
name: 'dashboard-new-layouts',
testDir: path.join(testDirRoot, '/dashboard-new-layouts'),
}),
// Setup project for dashboard CUJS tests
withAuth({
name: 'dashboard-cujs-setup',
testDir: path.join(testDirRoot, '/dashboard-cujs'),
testMatch: ['global-setup.spec.ts'],
}),
// Main dashboard CUJS tests
withAuth({
name: 'dashboard-cujs',
testDir: path.join(testDirRoot, '/dashboard-cujs'),
testIgnore: ['global-setup.spec.ts', 'global-teardown.spec.ts'],
dependencies: ['dashboard-cujs-setup'],
}),
// Teardown project for dashboard CUJS tests
withAuth({
name: 'dashboard-cujs-teardown',
testDir: path.join(testDirRoot, '/dashboard-cujs'),
testMatch: ['global-teardown.spec.ts'],
dependencies: ['dashboard-cujs'],
}),
withAuth({
name: 'grafana-e2etest-panel',
testDir: path.join(testDirRoot, '/test-plugins/grafana-test-panel'),
}),
],
});