@grafana/plugin-e2e
Advanced tools
Comparing version 1.17.0-canary.1490.97adea2.0 to 1.17.0
@@ -16,20 +16,8 @@ import { AlertRuleArgs, NavigateOptions, PluginTestCtx, RequestOptions } from '../../types'; | ||
get alertRuleNameField(): import("playwright-core").Locator; | ||
get advancedModeSwitch(): import("playwright-core").Locator; | ||
isAdvancedModeSupported(): Promise<boolean>; | ||
enableAdvancedQueryMode(): Promise<void>; | ||
disableAdvancedQueryMode(): Promise<void>; | ||
getQueryRow(refId?: string): Promise<AlertRuleQuery>; | ||
/** | ||
* @deprecated Use getQueryRow instead | ||
* Returns an instance of the {@link AlertRuleQuery} class for a query in the query and expression step (step 2) | ||
* | ||
* @param refId is optional. If not provided, it will return query row with refId 'A' in Grafana versions <11.5. | ||
* In Grafana versions >=11.5 where advanced mode is supported, it will return the default query if advanced mode | ||
* is not enabled. If advanced mode is enabled, it will return the a query by refId. | ||
* Returns an instance of the {@link AlertRuleQuery} class for the query row with the provided refId. | ||
*/ | ||
getAlertRuleQueryRow(refId?: string): AlertRuleQuery; | ||
getAlertRuleQueryRow(refId: string): AlertRuleQuery; | ||
/** | ||
* Clicks the "Add query" button and returns an instance of the {@link AlertRuleQuery} class for the new query row. | ||
* | ||
* Since Grafana 11.5, this method is only available if advanced mode is enabled. Use enableQueryAdvancedMode() method to enable it. | ||
*/ | ||
@@ -36,0 +24,0 @@ clickAddQueryRow(): Promise<AlertRuleQuery>; |
@@ -40,3 +40,2 @@ "use strict"; | ||
const AlertRuleQuery_1 = require("../components/AlertRuleQuery"); | ||
const QUERY_AND_EXPRESSION_STEP_ID = '2'; | ||
class AlertRuleEditPage extends GrafanaPage_1.GrafanaPage { | ||
@@ -67,55 +66,6 @@ ctx; | ||
} | ||
get advancedModeSwitch() { | ||
return this.getByGrafanaSelector(this.ctx.selectors.components.AlertRules.stepAdvancedModeSwitch(QUERY_AND_EXPRESSION_STEP_ID)); | ||
} | ||
async isAdvancedModeSupported() { | ||
// why not check if alertingQueryAndExpressionsStepMode feature is enabled? then we'd have to update the code when the toggle is removed. | ||
const count = await this.getByGrafanaSelector(this.ctx.selectors.components.AlertRules.stepAdvancedModeSwitch(QUERY_AND_EXPRESSION_STEP_ID)).count(); | ||
return count > 0; | ||
} | ||
/* | ||
* Enables the advanced mode for the query and expression step. | ||
* Only available in Grafana 11.5.0 and later. If advanced mode is not supported, this method will do nothing. | ||
*/ | ||
async enableAdvancedQueryMode() { | ||
const advancedModeSupported = await this.isAdvancedModeSupported(); | ||
if (!advancedModeSupported) { | ||
console.log('Advanced query mode is not supported in this Grafana version. Ignoring the request.'); | ||
return; | ||
} | ||
await this.getByGrafanaSelector(this.ctx.selectors.components.AlertRules.stepAdvancedModeSwitch(QUERY_AND_EXPRESSION_STEP_ID)).check({ force: true }); | ||
} | ||
/* | ||
* Disabled the advanced mode for the query and expression step. | ||
* Advanced mode is enabled by default in Grafana 11.5.0 and later. | ||
*/ | ||
async disableAdvancedQueryMode() { | ||
const advancedModeSupported = await this.isAdvancedModeSupported(); | ||
if (!advancedModeSupported) { | ||
console.log('Advanced query mode is not supported in this Grafana version. Ignoring the request.'); | ||
return; | ||
} | ||
await this.getByGrafanaSelector(this.ctx.selectors.components.AlertRules.stepAdvancedModeSwitch(QUERY_AND_EXPRESSION_STEP_ID)).uncheck({ force: true }); | ||
} | ||
async getQueryRow(refId = 'A') { | ||
const advancedModeSupported = await this.isAdvancedModeSupported(); | ||
if (advancedModeSupported && !(await this.advancedModeSwitch.isChecked()) && refId === 'A') { | ||
// return the default query row | ||
return new AlertRuleQuery_1.AlertRuleQuery(this.ctx, this.ctx.page.getByTestId('query-editor-row')); | ||
} | ||
// return query by refId | ||
const locator = this.getByGrafanaSelector(this.ctx.selectors.components.QueryEditorRows.rows).filter({ | ||
has: this.getByGrafanaSelector(this.ctx.selectors.components.QueryEditorRow.title(refId)), | ||
}); | ||
return new AlertRuleQuery_1.AlertRuleQuery(this.ctx, locator); | ||
} | ||
/** | ||
* @deprecated Use getQueryRow instead | ||
* Returns an instance of the {@link AlertRuleQuery} class for a query in the query and expression step (step 2) | ||
* | ||
* @param refId is optional. If not provided, it will return query row with refId 'A' in Grafana versions <11.5. | ||
* In Grafana versions >=11.5 where advanced mode is supported, it will return the default query if advanced mode | ||
* is not enabled. If advanced mode is enabled, it will return the a query by refId. | ||
* Returns an instance of the {@link AlertRuleQuery} class for the query row with the provided refId. | ||
*/ | ||
getAlertRuleQueryRow(refId = 'A') { | ||
getAlertRuleQueryRow(refId) { | ||
const locator = this.getByGrafanaSelector(this.ctx.selectors.components.QueryEditorRows.rows).filter({ | ||
@@ -128,10 +78,4 @@ has: this.getByGrafanaSelector(this.ctx.selectors.components.QueryEditorRow.title(refId)), | ||
* Clicks the "Add query" button and returns an instance of the {@link AlertRuleQuery} class for the new query row. | ||
* | ||
* Since Grafana 11.5, this method is only available if advanced mode is enabled. Use enableQueryAdvancedMode() method to enable it. | ||
*/ | ||
async clickAddQueryRow() { | ||
const advancedModeSupported = await this.isAdvancedModeSupported(); | ||
if (advancedModeSupported && !(await this.advancedModeSwitch.isChecked())) { | ||
throw new Error('Since Grafana 11.5, you need to enable advanced mode to add queries. Use enableQueryAdvancedMode() method to enable it.'); | ||
} | ||
await this.getByGrafanaSelector(this.ctx.selectors.components.QueryTab.addQuery).click(); | ||
@@ -138,0 +82,0 @@ const locator = this.getByGrafanaSelector(this.ctx.selectors.components.QueryEditorRows.rows).last(); |
{ | ||
"name": "@grafana/plugin-e2e", | ||
"version": "1.17.0-canary.1490.97adea2.0", | ||
"version": "1.17.0", | ||
"main": "./dist/index.js", | ||
@@ -44,3 +44,3 @@ "types": "./dist/index.d.ts", | ||
"dependencies": { | ||
"@grafana/e2e-selectors": "^11.5.0-219872", | ||
"@grafana/e2e-selectors": "^11.5.0-220285", | ||
"semver": "^7.5.4", | ||
@@ -59,3 +59,3 @@ "uuid": "^11.0.2", | ||
}, | ||
"gitHead": "97adea296f92c532261aa2bda96c4e294aa3fa90" | ||
"gitHead": "67ae0eb2276faace68e4742d9b273a3109fb508d" | ||
} |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
1
208746
4306