Skip to content

Commit

Permalink
test: add e2e test for datalinks
Browse files Browse the repository at this point in the history
The configured datalink should update a dashboard variable, which is displayed in a text panel, by
clicking on a feature of a data layer.
  • Loading branch information
felix-mu committed May 2, 2024
1 parent 677fd95 commit 813c03b
Show file tree
Hide file tree
Showing 11 changed files with 111 additions and 319 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ After each build the Docker-Container must be restarted to reload the new versio
- [Build tools for plugins](https://grafana.com/developers/plugin-tools/)
- [Create a panel plugin](https://grafana.com/docs/grafana/latest/developers/plugins/create-a-grafana-plugin/develop-a-plugin/build-a-panel-plugin/)
- [Sample plugins](https://github.com/grafana/grafana-plugin-examples/tree/main/examples)
- [Grafana UI catalog](https://developers.grafana.com/ui/latest/index.html)

<!-- ## Changelog
### Migration des Plugins
Expand Down
Binary file modified datalinks_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified datalinks_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

This file was deleted.

13 changes: 11 additions & 2 deletions provisioning/dashboards/dashboard_e2e.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,10 @@
}
},
"location": {
"geojson": "geometry",
"latitude": "Y",
"longitude": "X",
"mode": "coords"
"mode": "geojson"
},
"name": "Test data",
"query": {
Expand All @@ -127,7 +128,7 @@
},
"targets": [
{
"csvContent": "X,Y,id,name\r\n11.5624734687586,48.1124784080786,1,\"Point 1\"\r\n11.5507255958882,48.1174377336411,2,\"Point 2\"\r\n11.5683192640278,48.1389435109252,3,\"Point 3\"\r\n11.5796695601224,48.130505868826,4,\"Point 4\"\r\n11.5856016503162,48.1224164966297,5,\"Point 5\"\r\n11.5687129102152,48.1196130685219,6,\"Point 6\"\r\n11.6002930000666,48.1376937121368,7,\"Point 7\"",
"csvContent": "\"geom\",\"id\",\"name\"\r\n\"{\"\"type\"\":\"\"Feature\"\",\"\"properties\"\":{},\"\"geometry\"\":{\"\"type\"\":\"\"Polygon\"\",\"\"coordinates\"\":[[[11.528,48.157],[11.525,48.101],[11.611,48.098],[11.613,48.155],[11.613,48.155],[11.528,48.157]]]}}\",1,\"Polygon feature\"",
"datasource": {
"type": "grafana-testdata-datasource",
"uid": "uid-test-data-123"
Expand All @@ -137,6 +138,14 @@
}
],
"title": "Geomap WMS Panel",
"transformations": [
{
"id": "extractFields",
"options": {
"source": "geom"
}
}
],
"type": "geomap-wms-panel"
},
{
Expand Down
35 changes: 35 additions & 0 deletions tests/geomap-wms-panel-wms-data-links.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { test, expect, DashboardPage } from '@grafana/plugin-e2e';
import { WMS_ENDPOINT, HAR_FILEPATH, UPDATE_HAR } from './test_config';
import { Locator } from '@playwright/test';
import { update } from 'lodash';
// import { selectors} from '@playwright/test';


test('Should update the dashboard variable when clicking on map feature', async ({
gotoPanelEditPage,
readProvisionedDashboard,
gotoDashboardPage,
selectors,
context,
page
}) => {
const dashboard = await readProvisionedDashboard({ fileName: 'dashboard_e2e.json' });
const dashboardPage = await gotoDashboardPage(dashboard);
const geomapPanel = dashboardPage.getByGrafanaSelector("data-testid geomap-panel-container");
// geomapPanel.locator("canvas");
// const p = page.waitForTimeout(3000);
// await p;
const boundingBox = await geomapPanel.boundingBox();
await geomapPanel.click({
position: {
x: boundingBox!.width / 2,
y: boundingBox!.height / 2
}
});

const dataLinkTextPanel = dashboardPage.getByGrafanaSelector("data-testid Panel header Datalink test");
// const p2 = page.waitForTimeout(3000);
// await p2;
await expect(dataLinkTextPanel).toContainText(new RegExp("Polygon feature"));

});
Loading

0 comments on commit 813c03b

Please sign in to comment.