diff --git a/docusaurus/docs/tutorials/build-a-logs-data-source-plugin.md b/docusaurus/docs/tutorials/build-a-logs-data-source-plugin.md index 05c798684..a01a0043a 100644 --- a/docusaurus/docs/tutorials/build-a-logs-data-source-plugin.md +++ b/docusaurus/docs/tutorials/build-a-logs-data-source-plugin.md @@ -554,7 +554,7 @@ export class ExampleDatasource return undefined; } } - + private getLogsSampleDataProvider( request: DataQueryRequest, options?: LogsSampleOptions diff --git a/packages/create-plugin/templates/common/.config/playwright.config.ts b/packages/create-plugin/templates/common/.config/playwright.config.ts new file mode 100644 index 000000000..7d6681ce1 --- /dev/null +++ b/packages/create-plugin/templates/common/.config/playwright.config.ts @@ -0,0 +1,51 @@ +/* + * ⚠️⚠️⚠️ THIS FILE WAS SCAFFOLDED BY `@grafana/create-plugin`. DO NOT EDIT THIS FILE DIRECTLY. ⚠️⚠️⚠️ + * + * In order to extend the configuration follow the steps in + * https://grafana.com/developers/plugin-tools/get-started/set-up-development-environment#extend-the-playwright-config + */ + +import type { PluginOptions } from '@grafana/plugin-e2e'; +import { defineConfig, devices } from '@playwright/test'; +import { dirname } from 'node:path'; + +const pluginE2eAuth = `${dirname(require.resolve('@grafana/plugin-e2e'))}/auth`; + +/** + * See https://playwright.dev/docs/test-configuration. + */ +export default defineConfig({ + testDir: './tests', + /* Run tests in files in parallel */ + fullyParallel: true, + /* Fail the build on CI if you accidentally left test.only in the source code. */ + forbidOnly: !!process.env.CI, + /* Retry on CI only */ + retries: process.env.CI ? 2 : 0, + /* Reporter to use. See https://playwright.dev/docs/test-reporters */ + reporter: 'html', + /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ + use: { + /* Base URL to use in actions like `await page.goto('/')`. */ + baseURL: process.env.GRAFANA_URL || 'http://localhost:3000', + + /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ + trace: 'on-first-retry', + }, + + /* Configure projects for major browsers */ + projects: [ + // 1. Login to Grafana and store the cookie on disk for use in other tests. + { + name: 'auth', + testDir: pluginE2eAuth, + testMatch: [/.*\.js/], + }, + // 2. Run tests in Google Chrome. Every test will start authenticated as admin user. + { + name: 'chromium', + use: { ...devices['Desktop Chrome'], storageState: 'playwright/.auth/admin.json' }, + dependencies: ['auth'], + }, + ], +}); diff --git a/packages/create-plugin/templates/common/playwright.config b/packages/create-plugin/templates/common/playwright.config index ca2f02866..ebb38c851 100644 --- a/packages/create-plugin/templates/common/playwright.config +++ b/packages/create-plugin/templates/common/playwright.config @@ -1,8 +1,6 @@ import type { PluginOptions } from '@grafana/plugin-e2e'; -import { defineConfig, devices } from '@playwright/test'; -import { dirname } from 'node:path'; - -const pluginE2eAuth = `${dirname(require.resolve('@grafana/plugin-e2e'))}/auth`; +import { defineConfig } from '@playwright/test'; +import baseConfig from './.config/playwright.config'; /** * Read environment variables from file. @@ -13,39 +11,6 @@ const pluginE2eAuth = `${dirname(require.resolve('@grafana/plugin-e2e'))}/auth`; /** * See https://playwright.dev/docs/test-configuration. */ -export default defineConfig({ - testDir: './tests', - /* Run tests in files in parallel */ - fullyParallel: true, - /* Fail the build on CI if you accidentally left test.only in the source code. */ - forbidOnly: !!process.env.CI, - /* Retry on CI only */ - retries: process.env.CI ? 2 : 0, - /* Reporter to use. See https://playwright.dev/docs/test-reporters */ - reporter: 'html', - /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ - use: { - /* Base URL to use in actions like `await page.goto('/')`. */ - baseURL: process.env.GRAFANA_URL || 'http://localhost:3000', - - /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ - trace: 'on-first-retry', - }, - - /* Configure projects for major browsers */ - projects: [ - // 1. Login to Grafana and store the cookie on disk for use in other tests. - { - name: 'auth', - testDir: pluginE2eAuth, - testMatch: [/.*\.js/], - }, - // 2. Run tests in Google Chrome. Every test will start authenticated as admin user. - { - name: 'chromium', - use: { ...devices['Desktop Chrome'], storageState: 'playwright/.auth/admin.json' }, - dependencies: ['auth'], - }, - ], - +export default defineConfig(baseConfig, { + // Add your own configuration here });