-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add e2e tests for panel-frame-select
- Loading branch information
Showing
9 changed files
with
284 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { dirname } from 'path'; | ||
import { defineConfig, devices } from '@playwright/test'; | ||
|
||
const pluginE2eAuth = `${dirname(require.resolve('@grafana/plugin-e2e'))}/auth`; | ||
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, | ||
/* Opt out of parallel tests on CI. */ | ||
workers: process.env.CI ? 1 : undefined, | ||
/* 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: '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: [ | ||
{ | ||
name: 'auth', | ||
testDir: pluginE2eAuth, | ||
testMatch: [/.*\.js/], | ||
}, | ||
{ | ||
name: 'run-tests', | ||
use: { | ||
...devices['Desktop Chrome'], | ||
// @grafana/plugin-e2e writes the auth state to this file, | ||
// the path should not be modified | ||
storageState: 'playwright/.auth/admin.json', | ||
}, | ||
dependencies: ['auth'], | ||
}, | ||
], | ||
}); |
7 changes: 7 additions & 0 deletions
7
examples/panel-frame-select/provisioning/dashboards/default.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
apiVersion: 1 | ||
|
||
providers: | ||
- name: Default | ||
type: file | ||
options: | ||
path: /etc/grafana/provisioning/dashboards |
93 changes: 93 additions & 0 deletions
93
examples/panel-frame-select/provisioning/dashboards/panels.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
{ | ||
"annotations": { | ||
"list": [ | ||
{ | ||
"builtIn": 1, | ||
"datasource": { | ||
"type": "grafana", | ||
"uid": "-- Grafana --" | ||
}, | ||
"enable": true, | ||
"hide": true, | ||
"iconColor": "rgba(0, 211, 255, 1)", | ||
"name": "Annotations & Alerts", | ||
"type": "dashboard" | ||
} | ||
] | ||
}, | ||
"editable": true, | ||
"fiscalYearStartMonth": 0, | ||
"graphTooltip": 0, | ||
"id": 1, | ||
"links": [], | ||
"liveNow": false, | ||
"panels": [ | ||
{ | ||
"datasource": { | ||
"type": "marcusolsson-static-datasource", | ||
"uid": "P1D2C73DC01F2359B" | ||
}, | ||
"gridPos": { | ||
"h": 8, | ||
"w": 12, | ||
"x": 0, | ||
"y": 0 | ||
}, | ||
"id": 2, | ||
"options": { | ||
"seriesCountSize": "sm", | ||
"showSeriesCount": false, | ||
"text": "Default value of text input option" | ||
}, | ||
"title": "Panel Title", | ||
"type": "example-frameselect-panel" | ||
}, | ||
{ | ||
"datasource": { | ||
"type": "grafana-testdata-datasource", | ||
"uid": "trlxrdZVk" | ||
}, | ||
"gridPos": { | ||
"h": 8, | ||
"w": 12, | ||
"x": 0, | ||
"y": 8 | ||
}, | ||
"id": 1, | ||
"options": { | ||
"selectedRefId": "A", | ||
"seriesCountSize": "sm", | ||
"showSeriesCount": false, | ||
"text": "Default value of text input option" | ||
}, | ||
"targets": [ | ||
{ | ||
"datasource": { | ||
"type": "grafana-testdata-datasource", | ||
"uid": "trlxrdZVk" | ||
}, | ||
"refId": "A", | ||
"scenarioId": "exponential_heatmap_bucket_data" | ||
} | ||
], | ||
"title": "Panel frame select", | ||
"type": "example-frameselect-panel" | ||
} | ||
], | ||
"refresh": "", | ||
"schemaVersion": 39, | ||
"tags": [], | ||
"templating": { | ||
"list": [] | ||
}, | ||
"time": { | ||
"from": "now-6h", | ||
"to": "now" | ||
}, | ||
"timepicker": {}, | ||
"timezone": "", | ||
"title": "Panel frame select", | ||
"uid": "cda759d7-d406-46fe-97f6-31b4752d79d9", | ||
"version": 1, | ||
"weekStart": "" | ||
} |
14 changes: 14 additions & 0 deletions
14
examples/panel-frame-select/provisioning/datasources/datasources.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
apiVersion: 1 | ||
|
||
datasources: | ||
- name: Static | ||
type: marcusolsson-static-datasource | ||
access: proxy | ||
isDefault: true | ||
orgId: 1 | ||
version: 1 | ||
editable: true | ||
|
||
- name: TestData DB | ||
type: testdata | ||
uid: trlxrdZVk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { test, expect } from '@grafana/plugin-e2e'; | ||
|
||
test('should display "No data" in case panel data is empty', async ({ | ||
gotoPanelEditPage, | ||
readProvisionedDashboard, | ||
}) => { | ||
const dashboard = await readProvisionedDashboard({ fileName: 'panels.json' }); | ||
const panelEditPage = await gotoPanelEditPage({ dashboard, id: '2' }); | ||
await expect(panelEditPage.panel.locator).toContainText('No data'); | ||
}); | ||
|
||
test('should display selected data', async ({ gotoPanelEditPage, readProvisionedDashboard }) => { | ||
const dashboard = await readProvisionedDashboard({ fileName: 'panels.json' }); | ||
const panelEditPage = await gotoPanelEditPage({ dashboard, id: '1' }); | ||
await expect(panelEditPage.panel.locator).toContainText('Currently selected: data'); | ||
}); |