@grafana/plugin-e2e 1.17.1 → 1.17.2-canary.1508.adff3b9.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.
|
@@ -13,12 +13,24 @@ export declare class AlertRuleEditPage extends GrafanaPage {
|
|
|
13
13
|
* Returns a locator for hte alert rule name field
|
|
14
14
|
*/
|
|
15
15
|
get alertRuleNameField(): import("playwright-core").Locator;
|
|
16
|
+
get advancedModeSwitch(): import("playwright-core").Locator;
|
|
17
|
+
isAdvancedModeSupported(): Promise<boolean>;
|
|
18
|
+
enableAdvancedQueryMode(): Promise<void>;
|
|
19
|
+
disableAdvancedQueryMode(): Promise<void>;
|
|
20
|
+
getQueryRow(refId?: string): Promise<AlertRuleQuery>;
|
|
16
21
|
/**
|
|
17
|
-
*
|
|
22
|
+
* @deprecated Use getQueryRow instead
|
|
23
|
+
* Returns an instance of the {@link AlertRuleQuery} class for a query in the query and expression step (step 2)
|
|
24
|
+
*
|
|
25
|
+
* @param refId is optional. If not provided, it will return query row with refId 'A' in Grafana versions <11.6.
|
|
26
|
+
* In Grafana versions >=11.6 where advanced mode is supported, it will return the default query if advanced mode
|
|
27
|
+
* is not enabled. If advanced mode is enabled, it will return the a query by refId.
|
|
18
28
|
*/
|
|
19
|
-
getAlertRuleQueryRow(refId
|
|
29
|
+
getAlertRuleQueryRow(refId?: string): AlertRuleQuery;
|
|
20
30
|
/**
|
|
21
31
|
* Clicks the "Add query" button and returns an instance of the {@link AlertRuleQuery} class for the new query row.
|
|
32
|
+
*
|
|
33
|
+
* Since Grafana 11.6, this method is only available if advanced mode is enabled. Use enableQueryAdvancedMode() method to enable it.
|
|
22
34
|
*/
|
|
23
35
|
clickAddQueryRow(): Promise<AlertRuleQuery>;
|
|
24
36
|
/**
|
|
@@ -37,6 +37,7 @@ exports.AlertRuleEditPage = void 0;
|
|
|
37
37
|
const semver = __importStar(require("semver"));
|
|
38
38
|
const GrafanaPage_1 = require("./GrafanaPage");
|
|
39
39
|
const AlertRuleQuery_1 = require("../components/AlertRuleQuery");
|
|
40
|
+
const QUERY_AND_EXPRESSION_STEP_ID = '2';
|
|
40
41
|
class AlertRuleEditPage extends GrafanaPage_1.GrafanaPage {
|
|
41
42
|
ctx;
|
|
42
43
|
args;
|
|
@@ -62,10 +63,59 @@ class AlertRuleEditPage extends GrafanaPage_1.GrafanaPage {
|
|
|
62
63
|
}
|
|
63
64
|
return this.ctx.page.getByPlaceholder('Give your alert rule a name');
|
|
64
65
|
}
|
|
66
|
+
get advancedModeSwitch() {
|
|
67
|
+
return this.getByGrafanaSelector(this.ctx.selectors.components.AlertRules.stepAdvancedModeSwitch(QUERY_AND_EXPRESSION_STEP_ID));
|
|
68
|
+
}
|
|
69
|
+
async isAdvancedModeSupported() {
|
|
70
|
+
// why not check if alertingQueryAndExpressionsStepMode feature is enabled? then we'd have to update the code when the toggle is removed.
|
|
71
|
+
const count = await this.getByGrafanaSelector(this.ctx.selectors.components.AlertRules.stepAdvancedModeSwitch(QUERY_AND_EXPRESSION_STEP_ID)).count();
|
|
72
|
+
return count > 0;
|
|
73
|
+
}
|
|
74
|
+
/*
|
|
75
|
+
* Enables the advanced mode for the query and expression step.
|
|
76
|
+
* Only available in Grafana 11.6.0 and later. If advanced mode is not supported, this method will do nothing.
|
|
77
|
+
*/
|
|
78
|
+
async enableAdvancedQueryMode() {
|
|
79
|
+
const advancedModeSupported = await this.isAdvancedModeSupported();
|
|
80
|
+
if (!advancedModeSupported) {
|
|
81
|
+
console.log('Advanced query mode is not supported in this Grafana version. Ignoring the request.');
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
await this.getByGrafanaSelector(this.ctx.selectors.components.AlertRules.stepAdvancedModeSwitch(QUERY_AND_EXPRESSION_STEP_ID)).check({ force: true });
|
|
85
|
+
}
|
|
86
|
+
/*
|
|
87
|
+
* Disabled the advanced mode for the query and expression step.
|
|
88
|
+
* Advanced mode is enabled by default in Grafana 11.6.0 and later.
|
|
89
|
+
*/
|
|
90
|
+
async disableAdvancedQueryMode() {
|
|
91
|
+
const advancedModeSupported = await this.isAdvancedModeSupported();
|
|
92
|
+
if (!advancedModeSupported) {
|
|
93
|
+
console.log('Advanced query mode is not supported in this Grafana version. Ignoring the request.');
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
await this.getByGrafanaSelector(this.ctx.selectors.components.AlertRules.stepAdvancedModeSwitch(QUERY_AND_EXPRESSION_STEP_ID)).uncheck({ force: true });
|
|
97
|
+
}
|
|
98
|
+
async getQueryRow(refId = 'A') {
|
|
99
|
+
const advancedModeSupported = await this.isAdvancedModeSupported();
|
|
100
|
+
if (advancedModeSupported && !(await this.advancedModeSwitch.isChecked()) && refId === 'A') {
|
|
101
|
+
// return the default query row
|
|
102
|
+
return new AlertRuleQuery_1.AlertRuleQuery(this.ctx, this.ctx.page.getByTestId('query-editor-row'));
|
|
103
|
+
}
|
|
104
|
+
// return query by refId
|
|
105
|
+
const locator = this.getByGrafanaSelector(this.ctx.selectors.components.QueryEditorRows.rows).filter({
|
|
106
|
+
has: this.getByGrafanaSelector(this.ctx.selectors.components.QueryEditorRow.title(refId)),
|
|
107
|
+
});
|
|
108
|
+
return new AlertRuleQuery_1.AlertRuleQuery(this.ctx, locator);
|
|
109
|
+
}
|
|
65
110
|
/**
|
|
66
|
-
*
|
|
111
|
+
* @deprecated Use getQueryRow instead
|
|
112
|
+
* Returns an instance of the {@link AlertRuleQuery} class for a query in the query and expression step (step 2)
|
|
113
|
+
*
|
|
114
|
+
* @param refId is optional. If not provided, it will return query row with refId 'A' in Grafana versions <11.6.
|
|
115
|
+
* In Grafana versions >=11.6 where advanced mode is supported, it will return the default query if advanced mode
|
|
116
|
+
* is not enabled. If advanced mode is enabled, it will return the a query by refId.
|
|
67
117
|
*/
|
|
68
|
-
getAlertRuleQueryRow(refId) {
|
|
118
|
+
getAlertRuleQueryRow(refId = 'A') {
|
|
69
119
|
const locator = this.getByGrafanaSelector(this.ctx.selectors.components.QueryEditorRows.rows).filter({
|
|
70
120
|
has: this.getByGrafanaSelector(this.ctx.selectors.components.QueryEditorRow.title(refId)),
|
|
71
121
|
});
|
|
@@ -73,8 +123,14 @@ class AlertRuleEditPage extends GrafanaPage_1.GrafanaPage {
|
|
|
73
123
|
}
|
|
74
124
|
/**
|
|
75
125
|
* Clicks the "Add query" button and returns an instance of the {@link AlertRuleQuery} class for the new query row.
|
|
126
|
+
*
|
|
127
|
+
* Since Grafana 11.6, this method is only available if advanced mode is enabled. Use enableQueryAdvancedMode() method to enable it.
|
|
76
128
|
*/
|
|
77
129
|
async clickAddQueryRow() {
|
|
130
|
+
const advancedModeSupported = await this.isAdvancedModeSupported();
|
|
131
|
+
if (advancedModeSupported && !(await this.advancedModeSwitch.isChecked())) {
|
|
132
|
+
throw new Error('Since Grafana 11.6, you need to enable advanced mode to add queries. Use enableQueryAdvancedMode() method to enable it.');
|
|
133
|
+
}
|
|
78
134
|
await this.getByGrafanaSelector(this.ctx.selectors.components.QueryTab.addQuery).click();
|
|
79
135
|
const locator = this.getByGrafanaSelector(this.ctx.selectors.components.QueryEditorRows.rows).last();
|
|
80
136
|
return new AlertRuleQuery_1.AlertRuleQuery(this.ctx, locator);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@grafana/plugin-e2e",
|
|
3
|
-
"version": "1.17.
|
|
3
|
+
"version": "1.17.2-canary.1508.adff3b9.0",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"@playwright/test": "^1.41.2"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@playwright/test": "^1.50.
|
|
39
|
+
"@playwright/test": "^1.50.1",
|
|
40
40
|
"@types/uuid": "^10.0.0",
|
|
41
41
|
"dotenv": "^16.4.7"
|
|
42
42
|
},
|
|
@@ -55,5 +55,5 @@
|
|
|
55
55
|
"start": "cls || clear"
|
|
56
56
|
}
|
|
57
57
|
},
|
|
58
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "adff3b954e1a7e5fa93c4d7ef72755db2add926b"
|
|
59
59
|
}
|