@grafana/plugin-e2e 0.11.0 → 0.12.0-canary.688.217f78d.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -6,6 +6,7 @@ const DataSourcePicker_1 = require("./DataSourcePicker");
|
|
|
6
6
|
const GrafanaPage_1 = require("./GrafanaPage");
|
|
7
7
|
const PanelEditPage_1 = require("./PanelEditPage");
|
|
8
8
|
const TimeRange_1 = require("./TimeRange");
|
|
9
|
+
const Panel_1 = require("./Panel");
|
|
9
10
|
class DashboardPage extends GrafanaPage_1.GrafanaPage {
|
|
10
11
|
ctx;
|
|
11
12
|
dashboard;
|
|
@@ -42,6 +43,32 @@ class DashboardPage extends GrafanaPage_1.GrafanaPage {
|
|
|
42
43
|
await panelEditPage.goto();
|
|
43
44
|
return panelEditPage;
|
|
44
45
|
}
|
|
46
|
+
/**
|
|
47
|
+
* Returns a Panel object for the panel with the given title. Only works for panels that currently are in the viewport.
|
|
48
|
+
*
|
|
49
|
+
* Note that this won't navigate to the panel edit page, it will only return the Panel object, which
|
|
50
|
+
* points to the locator for the panel in the dashboard page. Can be used to assert on the panel data, eg.
|
|
51
|
+
* const panel = await dashboardPage.getPanelByTitle('Table panel');
|
|
52
|
+
* await expect(panel.getFieldNames()).toContainText(['time', 'temperature']);
|
|
53
|
+
*/
|
|
54
|
+
getPanelByTitle(title) {
|
|
55
|
+
return new Panel_1.Panel(this.ctx, () => {
|
|
56
|
+
return this.getByTestIdOrAriaLabel(this.ctx.selectors.components.Panels.Panel.title(title));
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Returns a Panel object for the panel with the given id. Only works for panels that currently are in the viewport.
|
|
61
|
+
*
|
|
62
|
+
* Note that this won't navigate to the panel edit page, it will only return the Panel object, which
|
|
63
|
+
* points to the locator for the panel in the dashboard page. Can be used to assert on the panel data, eg.
|
|
64
|
+
* const panel = await dashboardPage.getPanelByTitle('2');
|
|
65
|
+
* await expect(panel.getFieldNames()).toContainText(['time', 'temperature']);
|
|
66
|
+
*/
|
|
67
|
+
getPanelById(panelId) {
|
|
68
|
+
return new Panel_1.Panel(this.ctx, () => {
|
|
69
|
+
return this.ctx.page.locator(`[data-panelid="${panelId}"]`);
|
|
70
|
+
});
|
|
71
|
+
}
|
|
45
72
|
/**
|
|
46
73
|
* Clicks the buttons to add a new panel and returns the panel edit page for the new panel
|
|
47
74
|
*/
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ExplorePage = void 0;
|
|
4
4
|
const semver = require('semver');
|
|
5
|
-
const test_1 = require("@playwright/test");
|
|
6
5
|
const DataSourcePicker_1 = require("./DataSourcePicker");
|
|
7
6
|
const GrafanaPage_1 = require("./GrafanaPage");
|
|
8
7
|
const TimeRange_1 = require("./TimeRange");
|
|
@@ -51,12 +50,10 @@ class ExplorePage extends GrafanaPage_1.GrafanaPage {
|
|
|
51
50
|
/**
|
|
52
51
|
* Returns the locator for the query editor row with the given refId
|
|
53
52
|
*/
|
|
54
|
-
|
|
55
|
-
|
|
53
|
+
getQueryEditorRow(refId) {
|
|
54
|
+
return this.getByTestIdOrAriaLabel(this.ctx.selectors.components.QueryEditorRows.rows).filter({
|
|
56
55
|
has: this.getByTestIdOrAriaLabel(this.ctx.selectors.components.QueryEditorRow.title(refId)),
|
|
57
56
|
});
|
|
58
|
-
await (0, test_1.expect)(locator).toBeVisible();
|
|
59
|
-
return locator;
|
|
60
57
|
}
|
|
61
58
|
/**
|
|
62
59
|
* Clicks the "Run Query" button in the refresh picker to run the query. Returns the response promise for the data query
|
package/dist/models/Panel.js
CHANGED
|
@@ -35,6 +35,24 @@ class Panel extends GrafanaPage_1.GrafanaPage {
|
|
|
35
35
|
this.ctx = ctx;
|
|
36
36
|
this.locator = locator;
|
|
37
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* Returns a locator that resolves element(s) that contain the field name(s) that are currently displayed in the panel.
|
|
40
|
+
*
|
|
41
|
+
* Can be used to assert the field names displayed in the panel visualization. e.g
|
|
42
|
+
* await expect(panelEditPage.panel.getFieldNames()).toHaveValues(['Month', 'Stockholm', 'Berlin', 'Log Angeles']);
|
|
43
|
+
*/
|
|
44
|
+
getFieldNames() {
|
|
45
|
+
return this.locator().locator('[role="columnheader"]');
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Returns a locator that resolves element(s) that contain the value(s) that are currently displayed in the panel.
|
|
49
|
+
*
|
|
50
|
+
* Can be used to assert the values displayed in the panel visualization. e.g
|
|
51
|
+
* await expect(panelEditPage.panel.getData()).toContainText(['1', '4', '14']);
|
|
52
|
+
*/
|
|
53
|
+
getData() {
|
|
54
|
+
return this.locator().locator('[role="cell"]');
|
|
55
|
+
}
|
|
38
56
|
/**
|
|
39
57
|
* Returns the locator for the panel error (if any)
|
|
40
58
|
*/
|
|
@@ -6,6 +6,7 @@ const DataSourcePicker_1 = require("./DataSourcePicker");
|
|
|
6
6
|
const GrafanaPage_1 = require("./GrafanaPage");
|
|
7
7
|
const TimeRange_1 = require("./TimeRange");
|
|
8
8
|
const Panel_1 = require("./Panel");
|
|
9
|
+
const utils_1 = require("./utils");
|
|
9
10
|
class PanelEditPage extends GrafanaPage_1.GrafanaPage {
|
|
10
11
|
ctx;
|
|
11
12
|
args;
|
|
@@ -34,6 +35,14 @@ class PanelEditPage extends GrafanaPage_1.GrafanaPage {
|
|
|
34
35
|
options.queryParams.append('editPanel', this.args.id);
|
|
35
36
|
await super.navigate(url, options);
|
|
36
37
|
}
|
|
38
|
+
async toggleTableView() {
|
|
39
|
+
await (0, utils_1.radioButtonSetChecked)(this.ctx.page, 'Table view', true);
|
|
40
|
+
this.panel = new Panel_1.Panel(this.ctx, () => this.ctx.page.getByTestId('Panel'));
|
|
41
|
+
}
|
|
42
|
+
async untoggleTableView() {
|
|
43
|
+
await (0, utils_1.radioButtonSetChecked)(this.ctx.page, 'Table view', false);
|
|
44
|
+
this.panel = new Panel_1.Panel(this.ctx, () => this.getByTestIdOrAriaLabel(this.ctx.selectors.components.Panels.Panel.title(''), { startsWith: true }));
|
|
45
|
+
}
|
|
37
46
|
/**
|
|
38
47
|
* Sets the title of the panel. This method will open the panel options, set the title and close the panel options.
|
|
39
48
|
*/
|
|
@@ -88,12 +97,10 @@ class PanelEditPage extends GrafanaPage_1.GrafanaPage {
|
|
|
88
97
|
/**
|
|
89
98
|
* Returns the locator for the query editor row with the given refId
|
|
90
99
|
*/
|
|
91
|
-
|
|
92
|
-
|
|
100
|
+
getQueryEditorRow(refId) {
|
|
101
|
+
return this.getByTestIdOrAriaLabel(this.ctx.selectors.components.QueryEditorRows.rows).filter({
|
|
93
102
|
has: this.getByTestIdOrAriaLabel(this.ctx.selectors.components.QueryEditorRow.title(refId)),
|
|
94
103
|
});
|
|
95
|
-
await (0, test_1.expect)(locator).toBeVisible();
|
|
96
|
-
return locator;
|
|
97
104
|
}
|
|
98
105
|
/**
|
|
99
106
|
* Clicks the "Refresh" button in the panel editor. Returns the response promise for the data query
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.radioButtonSetChecked = void 0;
|
|
4
|
+
const radioButtonSetChecked = async (page, label, checked, options) => {
|
|
5
|
+
try {
|
|
6
|
+
await page.getByLabel(label, options).setChecked(checked);
|
|
7
|
+
}
|
|
8
|
+
catch (_) {
|
|
9
|
+
await page.getByText(label, options).setChecked(checked);
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
exports.radioButtonSetChecked = radioButtonSetChecked;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@grafana/plugin-e2e",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0-canary.688.217f78d.0",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
"semver": "^7.5.4",
|
|
46
46
|
"uuid": "^9.0.1"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "217f78d72382226581a41474c8f338e1ef6ed78e"
|
|
49
49
|
}
|