@grafana/plugin-e2e 0.16.0 → 0.17.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/api.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { E2ESelectors } from './e2e-selectors/types';
2
- import { CreateDataSourceArgs, CreateDataSourcePageArgs, DataSourceSettings, ReadProvisionedDataSourceArgs, CreateUserArgs } from './types';
2
+ import { CreateDataSourceArgs, CreateDataSourcePageArgs, DataSourceSettings, ReadProvisionedDashboardArgs, ReadProvisionedDataSourceArgs, CreateUserArgs, Dashboard } from './types';
3
3
  import { PanelEditPage, GrafanaPage, DataSourceConfigPage, DashboardPage, VariableEditPage, AnnotationEditPage } from './models';
4
4
  import { ExplorePage } from './models/pages/ExplorePage';
5
5
  export type PluginOptions = {
@@ -192,6 +192,12 @@ export type PluginFixture = {
192
192
  * If no name is provided, the first data source in the list of data sources will be returned.
193
193
  */
194
194
  readProvisionedDataSource<T = {}, S = {}>(args: ReadProvisionedDataSourceArgs): Promise<DataSourceSettings<T, S>>;
195
+ /**
196
+ * Fixture command that reads a dashboard json file in the provisioning/dashboards directory.
197
+ *
198
+ * Can be useful when navigating to a provisioned dashboard and you don't want to hard code the dashboard UID.
199
+ */
200
+ readProvisionedDashboard(args: ReadProvisionedDashboardArgs): Promise<Dashboard>;
195
201
  /**
196
202
  * Function that checks if a feature toggle is enabled. Only works for frontend feature toggles.
197
203
  */
@@ -0,0 +1,7 @@
1
+ import { TestFixture } from '@playwright/test';
2
+ import { PluginFixture, PluginOptions } from '../../api';
3
+ import { ReadProvisionedDashboardArgs } from '../../types';
4
+ import { PlaywrightCombinedArgs } from '../types';
5
+ type ReadProvisionedDashboardFixture = TestFixture<(<T = any>(args: ReadProvisionedDashboardArgs) => Promise<T>), PluginFixture & PluginOptions & PlaywrightCombinedArgs>;
6
+ declare const readProvisionedDashboard: ReadProvisionedDashboardFixture;
7
+ export default readProvisionedDashboard;
@@ -3,14 +3,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const fs_1 = require("fs");
7
6
  const path_1 = __importDefault(require("path"));
8
- const yaml_1 = require("yaml");
9
- const readProvision = async ({ provisioningRootDir }, use) => {
10
- await use(async ({ filePath }) => {
11
- const resolvedPath = path_1.default.resolve(path_1.default.join(provisioningRootDir, filePath));
7
+ const fs_1 = require("fs");
8
+ const DASHBOARDS_DIR = 'dashboards';
9
+ const readProvisionedDashboard = async ({ provisioningRootDir }, use) => {
10
+ await use(async ({ fileName }) => {
11
+ const resolvedPath = path_1.default.resolve(path_1.default.join(provisioningRootDir, DASHBOARDS_DIR, fileName));
12
12
  const contents = await fs_1.promises.readFile(resolvedPath, 'utf8');
13
- return (0, yaml_1.parse)(contents);
13
+ return JSON.parse(contents);
14
14
  });
15
15
  };
16
- exports.default = readProvision;
16
+ exports.default = readProvisionedDashboard;
@@ -6,9 +6,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const fs_1 = require("fs");
7
7
  const path_1 = __importDefault(require("path"));
8
8
  const yaml_1 = require("yaml");
9
+ const DATASOURCES_DIR = 'datasources';
9
10
  const readProvisionedDataSource = async ({ provisioningRootDir }, use) => {
10
11
  await use(async ({ fileName: filePath, name }) => {
11
- const resolvedPath = path_1.default.resolve(path_1.default.join(provisioningRootDir, 'datasources', filePath));
12
+ const resolvedPath = path_1.default.resolve(path_1.default.join(provisioningRootDir, DATASOURCES_DIR, filePath));
12
13
  const contents = await fs_1.promises.readFile(resolvedPath, 'utf8');
13
14
  const yml = (0, yaml_1.parse)(contents);
14
15
  if (!name) {
@@ -10,8 +10,8 @@ declare const fixtures: {
10
10
  annotationEditPage: (args: import("..").PluginFixture & import("..").PluginOptions & import("playwright/test").PlaywrightTestArgs & import("playwright/test").PlaywrightTestOptions & import("playwright/test").PlaywrightWorkerArgs & import("playwright/test").PlaywrightWorkerOptions, use: (r: import("..").AnnotationEditPage) => Promise<void>, testInfo: import("playwright/test").TestInfo) => any;
11
11
  explorePage: (args: import("..").PluginFixture & import("..").PluginOptions & import("playwright/test").PlaywrightTestArgs & import("playwright/test").PlaywrightTestOptions & import("playwright/test").PlaywrightWorkerArgs & import("playwright/test").PlaywrightWorkerOptions, use: (r: import("..").ExplorePage) => Promise<void>, testInfo: import("playwright/test").TestInfo) => any;
12
12
  createDataSource: (args: import("..").PluginFixture & import("..").PluginOptions & import("playwright/test").PlaywrightTestArgs & import("playwright/test").PlaywrightTestOptions & import("playwright/test").PlaywrightWorkerArgs & import("playwright/test").PlaywrightWorkerOptions, use: (r: (args: import("..").CreateDataSourceArgs) => Promise<import("..").DataSourceSettings<{}, {}>>) => Promise<void>, testInfo: import("playwright/test").TestInfo) => any;
13
- readProvision: (args: import("..").PluginFixture & import("..").PluginOptions & import("playwright/test").PlaywrightTestArgs & import("playwright/test").PlaywrightTestOptions & import("playwright/test").PlaywrightWorkerArgs & import("playwright/test").PlaywrightWorkerOptions, use: (r: <T = any>(args: import("..").ReadProvisionArgs) => Promise<T>) => Promise<void>, testInfo: import("playwright/test").TestInfo) => any;
14
- readProvisionedDataSource: (args: import("..").PluginFixture & import("..").PluginOptions & import("playwright/test").PlaywrightTestArgs & import("playwright/test").PlaywrightTestOptions & import("playwright/test").PlaywrightWorkerArgs & import("playwright/test").PlaywrightWorkerOptions, use: (r: <T_1 = any>(args: import("..").ReadProvisionedDataSourceArgs) => Promise<T_1>) => Promise<void>, testInfo: import("playwright/test").TestInfo) => any;
13
+ readProvisionedDataSource: (args: import("..").PluginFixture & import("..").PluginOptions & import("playwright/test").PlaywrightTestArgs & import("playwright/test").PlaywrightTestOptions & import("playwright/test").PlaywrightWorkerArgs & import("playwright/test").PlaywrightWorkerOptions, use: (r: <T = any>(args: import("..").ReadProvisionedDataSourceArgs) => Promise<T>) => Promise<void>, testInfo: import("playwright/test").TestInfo) => any;
14
+ readProvisionedDashboard: (args: import("..").PluginFixture & import("..").PluginOptions & import("playwright/test").PlaywrightTestArgs & import("playwright/test").PlaywrightTestOptions & import("playwright/test").PlaywrightWorkerArgs & import("playwright/test").PlaywrightWorkerOptions, use: (r: <T_1 = any>(args: import("..").ReadProvisionedDashboardArgs) => Promise<T_1>) => Promise<void>, testInfo: import("playwright/test").TestInfo) => any;
15
15
  isFeatureToggleEnabled: (args: import("..").PluginFixture & import("..").PluginOptions & import("playwright/test").PlaywrightTestArgs & import("playwright/test").PlaywrightTestOptions & import("playwright/test").PlaywrightWorkerArgs & import("playwright/test").PlaywrightWorkerOptions, use: (r: <T_2 = object>(featureToggle: keyof T_2) => Promise<boolean>) => Promise<void>, testInfo: import("playwright/test").TestInfo) => any;
16
16
  createUser: (args: import("..").PluginFixture & import("..").PluginOptions & import("playwright/test").PlaywrightTestArgs & import("playwright/test").PlaywrightTestOptions & import("playwright/test").PlaywrightWorkerArgs & import("playwright/test").PlaywrightWorkerOptions, use: (r: () => Promise<void>) => Promise<void>, testInfo: import("playwright/test").TestInfo) => any;
17
17
  };
@@ -10,8 +10,8 @@ const login_1 = __importDefault(require("./commands/login"));
10
10
  const createDataSourceConfigPage_1 = __importDefault(require("./commands/createDataSourceConfigPage"));
11
11
  const panelEditPage_1 = __importDefault(require("./panelEditPage"));
12
12
  const createDataSource_1 = __importDefault(require("./commands/createDataSource"));
13
- const readProvision_1 = __importDefault(require("./commands/readProvision"));
14
13
  const readProvisionedDataSource_1 = __importDefault(require("./commands/readProvisionedDataSource"));
14
+ const readProvisionedDashboard_1 = __importDefault(require("./commands/readProvisionedDashboard"));
15
15
  const newDashboardPage_1 = __importDefault(require("./newDashboardPage"));
16
16
  const variableEditPage_1 = __importDefault(require("./variableEditPage"));
17
17
  const explorePage_1 = __importDefault(require("./explorePage"));
@@ -30,8 +30,8 @@ const fixtures = {
30
30
  annotationEditPage: annotationEditPage_1.default,
31
31
  explorePage: explorePage_1.default,
32
32
  createDataSource: createDataSource_1.default,
33
- readProvision: readProvision_1.default,
34
33
  readProvisionedDataSource: readProvisionedDataSource_1.default,
34
+ readProvisionedDashboard: readProvisionedDashboard_1.default,
35
35
  isFeatureToggleEnabled: isFeatureToggleEnabled_1.default,
36
36
  createUser: createUser_1.default,
37
37
  };
package/dist/types.d.ts CHANGED
@@ -132,11 +132,11 @@ export type DashboardEditViewArgs<T> = {
132
132
  dashboard?: DashboardPageArgs;
133
133
  id: T;
134
134
  };
135
- export type ReadProvisionArgs = {
135
+ export type ReadProvisionedDashboardArgs = {
136
136
  /**
137
137
  * The path, relative to the provisioning folder, to the dashboard json file
138
138
  */
139
- filePath: string;
139
+ fileName: string;
140
140
  };
141
141
  export type ReadProvisionedDataSourceArgs = {
142
142
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grafana/plugin-e2e",
3
- "version": "0.16.0",
3
+ "version": "0.17.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": "959073a920b21a7a650449446bdac9693cc68a65"
48
+ "gitHead": "8841e5d604d588ccf42d771fff63007c8bde4d25"
49
49
  }
@@ -1,7 +0,0 @@
1
- import { TestFixture } from '@playwright/test';
2
- import { PluginFixture, PluginOptions } from '../../api';
3
- import { ReadProvisionArgs } from '../../types';
4
- import { PlaywrightCombinedArgs } from '../types';
5
- type ReadProvisionFixture = TestFixture<(<T = any>(args: ReadProvisionArgs) => Promise<T>), PluginFixture & PluginOptions & PlaywrightCombinedArgs>;
6
- declare const readProvision: ReadProvisionFixture;
7
- export default readProvision;