@grafana/plugin-e2e 0.10.0 → 0.10.1

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.
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const isFeatureToggleEnabled = async ({ page }, use) => {
3
+ const isFeatureToggleEnabled = async ({ page, grafanaVersion }, use) => {
4
4
  await use(async (featureToggle) => {
5
5
  const featureToggles = await page.evaluate('window.grafanaBootData.settings.featureToggles');
6
6
  return Boolean(featureToggles[featureToggle]);
@@ -21,6 +21,7 @@ const page = async ({ page, featureToggles }, use) => {
21
21
  console.error('Failed to set feature toggles', error);
22
22
  }
23
23
  }
24
+ await page.goto('/');
24
25
  await use(page);
25
26
  };
26
27
  exports.default = page;
@@ -4,7 +4,6 @@ exports.overrideFeatureToggles = void 0;
4
4
  // this script is evaluated in the browser context, so we cannot use typescript
5
5
  const overrideFeatureToggles = (featureToggles) => {
6
6
  const timeout = 5;
7
- const localStorageKey = 'grafana.featureToggles';
8
7
  const waitForGrafanaBootData = (cb) => {
9
8
  if (window.grafanaBootData) {
10
9
  cb();
@@ -13,28 +12,14 @@ const overrideFeatureToggles = (featureToggles) => {
13
12
  setTimeout(() => waitForGrafanaBootData(cb), timeout);
14
13
  }
15
14
  };
16
- const versionGte = (version, major, minor) => {
17
- const [majorVersion, minorVersion] = version.split('.');
18
- return Number(majorVersion) >= major && Number(minorVersion) >= minor;
19
- };
20
15
  // wait for Grafana boot data to be added to the window object
21
16
  waitForGrafanaBootData(() => {
22
17
  const version = window?.grafanaBootData?.settings?.buildInfo?.version;
23
- // since Grafana 10.1.0, Grafana reads feature toggles from localStorage
24
- // since this script runs in the browser context, we don't have access to semver.gte function that is used in other places of this package
25
- if (versionGte(version, 10, 1)) {
26
- const value = Object.entries(featureToggles)
27
- .map(([key, value]) => `${key}=${value}`)
28
- .join(',');
29
- localStorage.setItem(localStorageKey, value);
30
- }
31
- else {
32
- // override feature toggles with the ones provided by the test
33
- window.grafanaBootData.settings.featureToggles = {
34
- ...window.grafanaBootData.settings.featureToggles,
35
- ...featureToggles,
36
- };
37
- }
18
+ // override feature toggles with the ones provided by the test
19
+ window.grafanaBootData.settings.featureToggles = {
20
+ ...window.grafanaBootData.settings.featureToggles,
21
+ ...featureToggles,
22
+ };
38
23
  });
39
24
  };
40
25
  exports.overrideFeatureToggles = overrideFeatureToggles;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grafana/plugin-e2e",
3
- "version": "0.10.0",
3
+ "version": "0.10.1",
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": "da3e1f43dc07bcbfd3aed3da205ff6f672d368ca"
48
+ "gitHead": "adb7ab1910fa9c1e70bd0cf1a83b5e1ea1d9b5c7"
49
49
  }