@grafana/plugin-e2e 3.9.1 → 3.9.2

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.
@@ -12,17 +12,11 @@ const overrideGrafanaBootData = ({ featureToggles, userPreferences }) => {
12
12
  waitForGrafanaBootData(() => {
13
13
  if (Object.keys(featureToggles).length > 0) {
14
14
  console.log("@grafana/plugin-e2e: setting the following feature toggles", featureToggles);
15
- window.grafanaBootData.settings.featureToggles = {
16
- ...window.grafanaBootData.settings.featureToggles,
17
- ...featureToggles
18
- };
15
+ Object.assign(window.grafanaBootData.settings.featureToggles, featureToggles);
19
16
  }
20
17
  if (Object.keys(userPreferences).length > 0) {
21
18
  console.log("@grafana/plugin-e2e: setting the following user preferences", userPreferences);
22
- window.grafanaBootData.user = {
23
- ...window.grafanaBootData.user,
24
- ...userPreferences
25
- };
19
+ Object.assign(window.grafanaBootData.user, userPreferences);
26
20
  }
27
21
  });
28
22
  };
@@ -7,12 +7,20 @@ const toDisplayPreviews = async (variableEditPage, previewTexts, options) => {
7
7
  let pass = false;
8
8
  let actual;
9
9
  let message = `To find preview of values: ${previewTexts.join(", ")}}`;
10
+ const { Edit } = variableEditPage.ctx.selectors.pages.Dashboard.Settings.Variables;
11
+ const previewLabels = variableEditPage.getByGrafanaSelector(Edit.General.previewOfValuesOption);
12
+ const previewTable = variableEditPage.getByGrafanaSelector(Edit.CustomVariable.previewTable);
10
13
  try {
11
- await test.expect(
12
- variableEditPage.getByGrafanaSelector(
13
- variableEditPage.ctx.selectors.pages.Dashboard.Settings.Variables.Edit.General.previewOfValuesOption
14
- )
15
- ).toContainText(previewTexts, options);
14
+ await test.expect(previewLabels.or(previewTable).first()).toBeVisible({ timeout: options?.timeout });
15
+ if (await previewTable.isVisible()) {
16
+ const headerTexts = await previewTable.locator("thead th").allInnerTexts();
17
+ const textColumnIndex = headerTexts.findIndex((headerText) => headerText.trim() === "text");
18
+ const textCellSelector = `tbody tr td:nth-child(${textColumnIndex === -1 ? 3 : textColumnIndex + 1})`;
19
+ const textCells = previewTable.locator(textCellSelector);
20
+ await test.expect(textCells).toContainText(previewTexts, options);
21
+ } else {
22
+ await test.expect(previewLabels).toContainText(previewTexts, options);
23
+ }
16
24
  return {
17
25
  pass: true,
18
26
  actual: false,
@@ -4,7 +4,6 @@ var version = require('../../utils/version.js');
4
4
  var GrafanaPage = require('./GrafanaPage.js');
5
5
  var AlertRuleQuery = require('../components/AlertRuleQuery.js');
6
6
  var test = require('@playwright/test');
7
- var isFeatureToggleEnabled = require('../../fixtures/isFeatureToggleEnabled.js');
8
7
 
9
8
  const QUERY_AND_EXPRESSION_STEP_ID = "2";
10
9
  const ALERT_PAGE_READY_TIMEOUT = 15e3;
@@ -37,18 +36,13 @@ class AlertRuleEditPage extends GrafanaPage.GrafanaPage {
37
36
  );
38
37
  }
39
38
  async isAdvancedModeSupported() {
40
- const alertingQueryAndExpressionsStepMode = await isFeatureToggleEnabled.isLegacyFeatureEnabled(
41
- this.ctx.page,
42
- "alertingQueryAndExpressionsStepMode"
43
- );
44
- if (alertingQueryAndExpressionsStepMode) {
45
- await test.expect(this.advancedModeSwitch).toBeVisible({ timeout: ALERT_PAGE_READY_TIMEOUT });
46
- await test.expect(this.advancedModeSwitch).toHaveCount(1, { timeout: ALERT_PAGE_READY_TIMEOUT });
47
- return true;
39
+ if (version.lt(this.ctx.grafanaVersion, "11.5.0")) {
40
+ return false;
48
41
  }
49
- await test.expect(this.advancedModeSwitch).not.toBeVisible({ timeout: ALERT_PAGE_READY_TIMEOUT });
50
- await test.expect(this.advancedModeSwitch).toHaveCount(0, { timeout: ALERT_PAGE_READY_TIMEOUT });
51
- return false;
42
+ await this.getByGrafanaSelector(
43
+ this.ctx.selectors.components.AlertRules.step(QUERY_AND_EXPRESSION_STEP_ID)
44
+ ).waitFor({ state: "visible", timeout: ALERT_PAGE_READY_TIMEOUT });
45
+ return await this.advancedModeSwitch.count() > 0;
52
46
  }
53
47
  /*
54
48
  * Enables the advanced mode for the query and expression step.
package/dist/options.js CHANGED
@@ -7,7 +7,11 @@ const DEFAULT_ADMIN_USER = {
7
7
  };
8
8
  const DEFAULT_OPEN_FEATURE_FLAGS = {
9
9
  // disable the splash screen by default for all consumers of plugin-e2e
10
- splashScreen: false
10
+ splashScreen: false,
11
+ // keep the variables and annotations tabs on the dashboard settings page.
12
+ // when this flag is enabled (default since Grafana 13.2.0), the tabs only show
13
+ // an alert pointing to the dashboard sidebar, which breaks VariableEditPage and AnnotationEditPage
14
+ "grafana.dashboardSettingsRedesign": false
11
15
  };
12
16
  const options = {
13
17
  userPreferences: [{}, { option: true, scope: "worker" }],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grafana/plugin-e2e",
3
- "version": "3.9.1",
3
+ "version": "3.9.2",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "files": [