@grafana/plugin-e2e 0.10.3 → 0.11.0-canary.698.057e3a5.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.
package/dist/matchers/index.js
CHANGED
|
@@ -4,12 +4,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const toBeOK_1 = __importDefault(require("./toBeOK"));
|
|
7
|
-
const toHavePanelError_1 = __importDefault(require("./toHavePanelError"));
|
|
8
7
|
const toDisplayPreviews_1 = __importDefault(require("./toDisplayPreviews"));
|
|
9
8
|
const toHaveAlert_1 = __importDefault(require("./toHaveAlert"));
|
|
10
9
|
exports.default = {
|
|
11
10
|
toBeOK: toBeOK_1.default,
|
|
12
|
-
toHavePanelError: toHavePanelError_1.default,
|
|
13
11
|
toDisplayPreviews: toDisplayPreviews_1.default,
|
|
14
12
|
toHaveAlert: toHaveAlert_1.default,
|
|
15
13
|
};
|
|
@@ -5,13 +5,23 @@ const test_1 = require("@playwright/test");
|
|
|
5
5
|
const DataSourcePicker_1 = require("./DataSourcePicker");
|
|
6
6
|
const GrafanaPage_1 = require("./GrafanaPage");
|
|
7
7
|
const TimeRange_1 = require("./TimeRange");
|
|
8
|
+
const Panel_1 = require("./Panel");
|
|
9
|
+
const TIME_SERIES_PANEL_SELECTOR_SUFFIX = 'Graph';
|
|
10
|
+
const TABLE_PANEL_SELECTOR_SUFFIX = 'Table';
|
|
11
|
+
const LOGS_PANEL_SELECTOR_SUFFIX = 'Logs';
|
|
8
12
|
class ExplorePage extends GrafanaPage_1.GrafanaPage {
|
|
9
13
|
datasource;
|
|
10
14
|
timeRange;
|
|
15
|
+
timeSeriesPanel;
|
|
16
|
+
logsPanel;
|
|
17
|
+
tablePanel;
|
|
11
18
|
constructor(ctx) {
|
|
12
19
|
super(ctx);
|
|
13
20
|
this.datasource = new DataSourcePicker_1.DataSourcePicker(ctx);
|
|
14
21
|
this.timeRange = new TimeRange_1.TimeRange(ctx);
|
|
22
|
+
this.timeSeriesPanel = new Panel_1.Panel(ctx, this.getByTestIdOrAriaLabel(ctx.selectors.components.Panels.Panel.title(TIME_SERIES_PANEL_SELECTOR_SUFFIX)));
|
|
23
|
+
this.tablePanel = new Panel_1.Panel(ctx, this.getByTestIdOrAriaLabel(ctx.selectors.components.Panels.Panel.title(TABLE_PANEL_SELECTOR_SUFFIX)));
|
|
24
|
+
this.logsPanel = new Panel_1.Panel(ctx, this.getByTestIdOrAriaLabel(ctx.selectors.components.Panels.Panel.title(LOGS_PANEL_SELECTOR_SUFFIX)));
|
|
15
25
|
}
|
|
16
26
|
/**
|
|
17
27
|
* Navigates to the explore page.
|
|
@@ -25,11 +25,12 @@ class GrafanaPage {
|
|
|
25
25
|
* @param selector the data-testid or aria-label of the element
|
|
26
26
|
* @param root optional root locator to search within. If no locator is provided, the page will be used
|
|
27
27
|
*/
|
|
28
|
-
getByTestIdOrAriaLabel(selector,
|
|
28
|
+
getByTestIdOrAriaLabel(selector, options) {
|
|
29
|
+
const startsWith = options?.startsWith ? '^' : '';
|
|
29
30
|
if (selector.startsWith('data-testid')) {
|
|
30
|
-
return (root || this.ctx.page).
|
|
31
|
+
return (options?.root || this.ctx.page).locator(`[data-testid${startsWith}="${selector}"]`);
|
|
31
32
|
}
|
|
32
|
-
return (root || this.ctx.page).locator(`[aria-label="${selector}"]`);
|
|
33
|
+
return (options?.root || this.ctx.page).locator(`[aria-label${startsWith}="${selector}"]`);
|
|
33
34
|
}
|
|
34
35
|
/**
|
|
35
36
|
* Mocks the response of the datasource query call
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.Panel = void 0;
|
|
27
|
+
const semver = __importStar(require("semver"));
|
|
28
|
+
const GrafanaPage_1 = require("./GrafanaPage");
|
|
29
|
+
const ERROR_STATUS = 'error';
|
|
30
|
+
class Panel extends GrafanaPage_1.GrafanaPage {
|
|
31
|
+
ctx;
|
|
32
|
+
locator;
|
|
33
|
+
constructor(ctx, locator) {
|
|
34
|
+
super(ctx);
|
|
35
|
+
this.ctx = ctx;
|
|
36
|
+
this.locator = locator;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Returns the locator for the panel error (if any)
|
|
40
|
+
*/
|
|
41
|
+
getErrorIcon() {
|
|
42
|
+
let selector = this.ctx.selectors.components.Panels.Panel.status(ERROR_STATUS);
|
|
43
|
+
// the selector (not the selector value) used to identify a panel error changed in 9.4.3
|
|
44
|
+
if (semver.lte(this.ctx.grafanaVersion, '9.4.3')) {
|
|
45
|
+
selector = this.ctx.selectors.components.Panels.Panel.headerCornerInfo(ERROR_STATUS);
|
|
46
|
+
}
|
|
47
|
+
return this.getByTestIdOrAriaLabel(selector, {
|
|
48
|
+
root: this.locator,
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
exports.Panel = Panel;
|
|
@@ -1,46 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
3
|
exports.PanelEditPage = void 0;
|
|
27
4
|
const test_1 = require("@playwright/test");
|
|
28
|
-
const semver = __importStar(require("semver"));
|
|
29
5
|
const DataSourcePicker_1 = require("./DataSourcePicker");
|
|
30
6
|
const GrafanaPage_1 = require("./GrafanaPage");
|
|
31
7
|
const TimeRange_1 = require("./TimeRange");
|
|
32
|
-
const
|
|
8
|
+
const Panel_1 = require("./Panel");
|
|
33
9
|
class PanelEditPage extends GrafanaPage_1.GrafanaPage {
|
|
34
10
|
ctx;
|
|
35
11
|
args;
|
|
36
12
|
datasource;
|
|
37
13
|
timeRange;
|
|
14
|
+
panel;
|
|
38
15
|
constructor(ctx, args) {
|
|
39
16
|
super(ctx);
|
|
40
17
|
this.ctx = ctx;
|
|
41
18
|
this.args = args;
|
|
42
19
|
this.datasource = new DataSourcePicker_1.DataSourcePicker(ctx);
|
|
43
20
|
this.timeRange = new TimeRange_1.TimeRange(ctx);
|
|
21
|
+
this.panel = new Panel_1.Panel(ctx,
|
|
22
|
+
// only one panel is allowed in the panel edit page, so we don't need to use panel title to locate it
|
|
23
|
+
this.getByTestIdOrAriaLabel(ctx.selectors.components.Panels.Panel.title(''), { startsWith: true }));
|
|
44
24
|
}
|
|
45
25
|
/**
|
|
46
26
|
* Navigates to the panel edit page. If a dashboard uid was not provided, it's assumed that it's a new dashboard.
|
|
@@ -115,16 +95,6 @@ class PanelEditPage extends GrafanaPage_1.GrafanaPage {
|
|
|
115
95
|
await (0, test_1.expect)(locator).toBeVisible();
|
|
116
96
|
return locator;
|
|
117
97
|
}
|
|
118
|
-
/**
|
|
119
|
-
* Returns the locator for the panel error (if any)
|
|
120
|
-
*/
|
|
121
|
-
getPanelError() {
|
|
122
|
-
// the selector (not the selector value) used to identify a panel error changed in 9.4.3
|
|
123
|
-
if (semver.lte(this.ctx.grafanaVersion, '9.4.3')) {
|
|
124
|
-
return this.getByTestIdOrAriaLabel(this.ctx.selectors.components.Panels.Panel.headerCornerInfo(ERROR_STATUS));
|
|
125
|
-
}
|
|
126
|
-
return this.getByTestIdOrAriaLabel(this.ctx.selectors.components.Panels.Panel.status(ERROR_STATUS));
|
|
127
|
-
}
|
|
128
98
|
/**
|
|
129
99
|
* Clicks the "Refresh" button in the panel editor. Returns the response promise for the data query
|
|
130
100
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@grafana/plugin-e2e",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0-canary.698.057e3a5.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": "057e3a5850cb1e7016946cb8e4b7091a6b6b8ab5"
|
|
49
49
|
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const test_1 = require("@playwright/test");
|
|
4
|
-
const utils_1 = require("./utils");
|
|
5
|
-
const toHavePanelError = async (panelError, options) => {
|
|
6
|
-
let pass = true;
|
|
7
|
-
let actual;
|
|
8
|
-
let message = 'A panel error to be displayed';
|
|
9
|
-
try {
|
|
10
|
-
const numberOfErrors = await panelError.getPanelError().count();
|
|
11
|
-
await (0, test_1.expect)(numberOfErrors).toBe(1);
|
|
12
|
-
}
|
|
13
|
-
catch (_) {
|
|
14
|
-
message = (0, utils_1.getMessage)(message, 'No panel error was found on the page');
|
|
15
|
-
actual = await panelError.getPanelError().count();
|
|
16
|
-
pass = false;
|
|
17
|
-
}
|
|
18
|
-
return {
|
|
19
|
-
message: () => message,
|
|
20
|
-
pass,
|
|
21
|
-
actual,
|
|
22
|
-
};
|
|
23
|
-
};
|
|
24
|
-
exports.default = toHavePanelError;
|