Skip to content

Commit

Permalink
update e2e
Browse files Browse the repository at this point in the history
  • Loading branch information
vitPinchuk committed Dec 20, 2024
1 parent 2399e34 commit a0fc610
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 60 deletions.
123 changes: 94 additions & 29 deletions provisioning/dashboards/localServer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,21 @@
{
"datasource": {
"type": "volkovlabs-rss-datasource",
"uid": "xmlsRv1"
"uid": "PE12154EB4CA97411"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"custom": {
"align": "auto",
"cellOptions": {
"type": "auto"
},
"inspect": false
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
Expand All @@ -50,36 +61,30 @@
"x": 0,
"y": 0
},
"id": 2,
"id": 6,
"options": {
"afterRender": "",
"content": "<div class=\"row\">\n <p class=\"text\">{{title}}</p>\n <p class=\"text\">{{description}}</p>\n <a class=\"link\" href=\"{{link}}\"\">Link to documentation</a>\n<div>",
"contentPartials": [],
"defaultContent": "The query didn't return any results.",
"editor": {
"format": "auto",
"language": "html"
"cellHeight": "sm",
"footer": {
"countRows": false,
"fields": "",
"reducer": ["sum"],
"show": false
},
"editors": ["styles"],
"externalScripts": [],
"externalStyles": [],
"helpers": "",
"renderMode": "everyRow",
"styles": ".row {\n display: flex;\n flex-direction: column;\n padding: 10px 15px;\n}\n\n.text {\nmargin: 3px 0px;\n}\n\n.link {\n color:coral;\n font-weight: 600;\n margin: 0;\n}",
"wrap": true
"showHeader": true
},
"targets": [
{
"datasource": {
"type": "volkovlabs-rss-datasource",
"uid": "xmlsRv1"
"uid": "PE12154EB4CA97411"
},
"feedType": "items",
"dateField": "updated",
"feedType": "channel",
"refId": "A"
}
],
"title": "Server RSS",
"type": "marcusolsson-dynamictext-panel"
"title": "Table Google",
"type": "table"
},
{
"datasource": {
Expand Down Expand Up @@ -143,7 +148,7 @@
{
"datasource": {
"type": "volkovlabs-rss-datasource",
"uid": "xmlsRv2"
"uid": "xmlsRv1"
},
"fieldConfig": {
"defaults": {
Expand All @@ -169,35 +174,35 @@
"x": 0,
"y": 8
},
"id": 1,
"id": 2,
"options": {
"afterRender": "",
"content": "<table width=100% style='border:0'>\n <tr>\n <td width=\"*\" style='border:0'>\n <h3><a target=\"_blank\" style=\"color: blue\" href=\"{{link}}\">{{title}}</a></h3>\n {{{content:h4}}}\n </tr>\n <tr>\n <td style='border:0'><b>{{date updated 'MMM, DD YYYY'}} by {{author}}</b></td>\n</table>",
"content": "<div class=\"row\">\n <p class=\"text\">{{title}}</p>\n <p class=\"text\">{{description}}</p>\n <a class=\"link\" href=\"{{link}}\"\">Link to documentation</a>\n<div>",
"contentPartials": [],
"defaultContent": "The query didn't return any results.",
"editor": {
"format": "auto",
"language": "html"
},
"editors": [],
"editors": ["styles"],
"externalScripts": [],
"externalStyles": [],
"helpers": "",
"renderMode": "everyRow",
"styles": "",
"styles": ".row {\n display: flex;\n flex-direction: column;\n padding: 10px 15px;\n}\n\n.text {\nmargin: 3px 0px;\n}\n\n.link {\n color:coral;\n font-weight: 600;\n margin: 0;\n}",
"wrap": true
},
"targets": [
{
"datasource": {
"type": "volkovlabs-rss-datasource",
"uid": "xmlsRv2"
"uid": "xmlsRv1"
},
"feedType": "items",
"refId": "A"
}
],
"title": "Server Feed",
"title": "Server RSS",
"type": "marcusolsson-dynamictext-panel"
},
{
Expand Down Expand Up @@ -264,6 +269,66 @@
"title": "Server Feed Table",
"type": "table"
},
{
"datasource": {
"type": "volkovlabs-rss-datasource",
"uid": "xmlsRv2"
},
"fieldConfig": {
"defaults": {
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
}
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 16
},
"id": 1,
"options": {
"afterRender": "",
"content": "<table width=100% style='border:0'>\n <tr>\n <td width=\"*\" style='border:0'>\n <h3><a target=\"_blank\" style=\"color: blue\" href=\"{{link}}\">{{title}}</a></h3>\n {{{content:h4}}}\n </tr>\n <tr>\n <td style='border:0'><b>{{date updated 'MMM, DD YYYY'}} by {{author}}</b></td>\n</table>",
"contentPartials": [],
"defaultContent": "The query didn't return any results.",
"editor": {
"format": "auto",
"language": "html"
},
"editors": [],
"externalScripts": [],
"externalStyles": [],
"helpers": "",
"renderMode": "everyRow",
"styles": "",
"wrap": true
},
"targets": [
{
"datasource": {
"type": "volkovlabs-rss-datasource",
"uid": "xmlsRv2"
},
"feedType": "items",
"refId": "A"
}
],
"title": "Server Feed",
"type": "marcusolsson-dynamictext-panel"
},
{
"datasource": {
"type": "volkovlabs-rss-datasource",
Expand Down Expand Up @@ -302,7 +367,7 @@
"h": 8,
"w": 12,
"x": 0,
"y": 16
"y": 24
},
"id": 3,
"options": {
Expand Down Expand Up @@ -344,6 +409,6 @@
"timezone": "",
"title": "Local Feeds",
"uid": "fe91dd52-a33a-4c1b-bdb8-10e4ede99a25",
"version": 1,
"version": 2,
"weekStart": ""
}
29 changes: 4 additions & 25 deletions test/panel.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,39 +135,18 @@ test.describe('RSS datasource', () => {
});

test.describe('Provisioning', () => {
test('Should return data', async ({ gotoDashboardPage, readProvisionedDashboard, grafanaVersion, selectors }) => {
test('Should return data', async ({ gotoDashboardPage, readProvisionedDashboard, selectors }) => {
/**
* Go To Panels dashboard localServer.json
* return dashboardPage
*/
const dashboard = await readProvisionedDashboard({ fileName: 'localServer.json' });
const dashboardPage = await gotoDashboardPage({ uid: dashboard.uid });

const panel = new PanelHelper(dashboardPage, 'Server RSS Table', selectors);
const panel = new PanelHelper(dashboardPage, 'Table Google', selectors);
await panel.checkIfNoErrors();

await panel.checkContent(
`{
"data": [
{
"title": "RSS Tutorial",
"link": "https://www.w3schools.com/xml/xml_rss.asp",
"description": "New RSS tutorial on W3Schools"
},
{
"title": "XML Tutorial 1",
"link": "https://www.w3schools.com/xml",
"description": "New XML tutorial on W3Schools"
},
{
"title": "XML Tutorial 4",
"link": "https://www.w3schools.com/xml",
"description": "New XML tutorial on W3Schools"
}
]
}`,
grafanaVersion
);
await panel.checkFieldValues(['author', 'id', 'title', 'updated']);
await panel.checkDataValues(['Google Workspace']);
});
});
});
14 changes: 8 additions & 6 deletions test/utils/panel.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as semver from 'semver';
import { Locator } from '@playwright/test';
import { DashboardPage, E2ESelectorGroups, expect, Panel } from '@grafana/plugin-e2e';

Expand Down Expand Up @@ -28,11 +27,14 @@ export class PanelHelper {
return this.get().getByTestId(this.selectors.components.Panels.Panel.content);
}

public async checkContent(text: string, grafanaVersion: string) {
if (semver.gte(grafanaVersion, '11.3.0')) {
return expect(this.getContainer(), this.getMsg('Check Content')).toContainText(text);
}
return expect(this.get().getByTestId('data-testid text content'), this.getMsg('Check Content')).toContainText(text);
public async checkFieldValues(fieldsArray: string[]) {
const fields = this.panel.fieldNames;
return expect(fields).toContainText(fieldsArray);
}

public async checkDataValues(dataArray: string[]) {
const data = this.panel.data;
return expect(data).toContainText(dataArray);
}

public async checkIfNoErrors() {
Expand Down

0 comments on commit a0fc610

Please sign in to comment.