@grafana/plugin-e2e 0.13.2 → 0.14.0-canary.740.aade71f.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, DataSource, ReadProvisionArgs } from './types';
2
+ import { CreateDataSourceArgs, CreateDataSourcePageArgs, DataSourceSettings, ReadProvisionedDataSourceArgs } from './types';
3
3
  import { PanelEditPage, GrafanaPage, DataSourceConfigPage, DashboardPage, VariableEditPage, AnnotationEditPage } from './models';
4
4
  import { ExplorePage } from './models/ExplorePage';
5
5
  export type PluginOptions = {
@@ -114,7 +114,7 @@ export type PluginFixture = {
114
114
  * you may use this command in a setup project. Read more about setup projects
115
115
  * here: https://playwright.dev/docs/auth#basic-shared-account-in-all-tests
116
116
  */
117
- createDataSource: (args: CreateDataSourceArgs) => Promise<DataSource>;
117
+ createDataSource: (args: CreateDataSourceArgs) => Promise<DataSourceSettings>;
118
118
  /**
119
119
  * Fixture command that login to Grafana using the Grafana API.
120
120
  * If the same credentials should be used in every test,
@@ -141,10 +141,13 @@ export type PluginFixture = {
141
141
  */
142
142
  login: () => Promise<void>;
143
143
  /**
144
- * Fixture command that reads a the yaml file for a provisioned dashboard
145
- * or data source and returns it as json.
144
+ * Fixture command that reads a yaml file in the provisioning/datasources directory.
145
+ *
146
+ * The file name should be the name of the file with the .yaml|.yml extension.
147
+ * If a data source name is provided, the first data source that matches the name will be returned.
148
+ * If no name is provided, the first data source in the list of data sources will be returned.
146
149
  */
147
- readProvision<T = any>(args: ReadProvisionArgs): Promise<T>;
150
+ readProvisionedDataSource<T = {}, S = {}>(args: ReadProvisionedDataSourceArgs): Promise<DataSourceSettings<T, S>>;
148
151
  /**
149
152
  * Function that checks if a feature toggle is enabled. Only works for frontend feature toggles.
150
153
  */
@@ -172,7 +175,28 @@ export declare const expect: import("@playwright/test").Expect<{
172
175
  }>;
173
176
  toHaveAlert: (grafanaPage: GrafanaPage, severity: import("./matchers/toHaveAlert").AlertVariant, options?: import("./types").AlertPageOptions | undefined) => Promise<{
174
177
  message: () => any;
175
- pass: boolean;
178
+ pass: boolean; /**
179
+ * Optionally, you can add or override feature toggles.
180
+ * The feature toggles you specify here will only work in the frontend. If you need a feature toggle to work across the entire stack, you
181
+ * need to need to enable the feature in the Grafana config. See https://grafana.com/docs/grafana/latest/setup-grafana/configure-grafana/#feature_toggles
182
+ *
183
+ * To override feature toggles globally in the playwright.config.ts file:
184
+ * export default defineConfig({
185
+ use: {
186
+ featureToggles: {
187
+ exploreMixedDatasource: true,
188
+ redshiftAsyncQueryDataSupport: false
189
+ },
190
+ },
191
+ });
192
+ *
193
+ * To override feature toggles for tests on a certain file:
194
+ test.use({
195
+ featureToggles: {
196
+ exploreMixedDatasource: true,
197
+ },
198
+ * });
199
+ */
176
200
  }>;
177
201
  }>;
178
202
  export { selectors } from '@playwright/test';
@@ -1,8 +1,8 @@
1
1
  import { APIRequestContext, TestFixture } from '@playwright/test';
2
2
  import { PluginFixture, PluginOptions } from '../../api';
3
- import { CreateDataSourceArgs, DataSource } from '../../types';
3
+ import { CreateDataSourceArgs, DataSourceSettings } from '../../types';
4
4
  import { PlaywrightCombinedArgs } from '../types';
5
- type CreateDataSourceViaAPIFixture = TestFixture<(args: CreateDataSourceArgs) => Promise<DataSource>, PluginFixture & PluginOptions & PlaywrightCombinedArgs>;
6
- export declare const createDataSourceViaAPI: (request: APIRequestContext, datasource: CreateDataSourceArgs) => Promise<DataSource>;
5
+ type CreateDataSourceViaAPIFixture = TestFixture<(args: CreateDataSourceArgs) => Promise<DataSourceSettings>, PluginFixture & PluginOptions & PlaywrightCombinedArgs>;
6
+ export declare const createDataSourceViaAPI: (request: APIRequestContext, datasource: CreateDataSourceArgs) => Promise<DataSourceSettings>;
7
7
  declare const createDataSource: CreateDataSourceViaAPIFixture;
8
8
  export default createDataSource;
@@ -0,0 +1,7 @@
1
+ import { TestFixture } from '@playwright/test';
2
+ import { PluginFixture, PluginOptions } from '../../api';
3
+ import { ReadProvisionedDataSourceArgs } from '../../types';
4
+ import { PlaywrightCombinedArgs } from '../types';
5
+ type ReadProvisionedDataSourceFixture = TestFixture<(<T = any>(args: ReadProvisionedDataSourceArgs) => Promise<T>), PluginFixture & PluginOptions & PlaywrightCombinedArgs>;
6
+ declare const readProvisionedDataSource: ReadProvisionedDataSourceFixture;
7
+ export default readProvisionedDataSource;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const fs_1 = require("fs");
7
+ const path_1 = __importDefault(require("path"));
8
+ const yaml_1 = require("yaml");
9
+ const readProvisionedDataSource = async ({ provisioningRootDir }, use) => {
10
+ await use(async ({ fileName: filePath, name }) => {
11
+ const resolvedPath = path_1.default.resolve(path_1.default.join(provisioningRootDir, 'datasources', filePath));
12
+ const contents = await fs_1.promises.readFile(resolvedPath, 'utf8');
13
+ const yml = (0, yaml_1.parse)(contents);
14
+ if (!name) {
15
+ return yml.datasources[0];
16
+ }
17
+ return yml.datasources.find((ds) => ds.name === name);
18
+ });
19
+ };
20
+ exports.default = readProvisionedDataSource;
@@ -9,8 +9,9 @@ declare const fixtures: {
9
9
  variableEditPage: (args: import("..").PluginFixture & import("..").PluginOptions & import("playwright/test").PlaywrightTestArgs & import("playwright/test").PlaywrightTestOptions & import("playwright/test").PlaywrightWorkerArgs & import("playwright/test").PlaywrightWorkerOptions, use: (r: import("..").VariableEditPage) => Promise<void>, testInfo: import("playwright/test").TestInfo) => any;
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("../models/ExplorePage").ExplorePage) => Promise<void>, testInfo: import("playwright/test").TestInfo) => any;
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("../types").CreateDataSourceArgs) => Promise<import("../types").DataSource<any>>) => Promise<void>, testInfo: import("playwright/test").TestInfo) => any;
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("../types").CreateDataSourceArgs) => Promise<import("../types").DataSourceSettings<{}, {}>>) => Promise<void>, testInfo: import("playwright/test").TestInfo) => any;
13
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("../types").ReadProvisionArgs) => Promise<T>) => Promise<void>, testInfo: import("playwright/test").TestInfo) => any;
14
- 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_1 = object>(featureToggle: keyof T_1) => Promise<boolean>) => 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("../types").ReadProvisionedDataSourceArgs) => Promise<T_1>) => Promise<void>, testInfo: import("playwright/test").TestInfo) => any;
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;
15
16
  };
16
17
  export default fixtures;
@@ -11,6 +11,7 @@ const createDataSourceConfigPage_1 = __importDefault(require("./commands/createD
11
11
  const panelEditPage_1 = __importDefault(require("./panelEditPage"));
12
12
  const createDataSource_1 = __importDefault(require("./commands/createDataSource"));
13
13
  const readProvision_1 = __importDefault(require("./commands/readProvision"));
14
+ const readProvisionedDataSource_1 = __importDefault(require("./commands/readProvisionedDataSource"));
14
15
  const newDashboardPage_1 = __importDefault(require("./newDashboardPage"));
15
16
  const variableEditPage_1 = __importDefault(require("./variableEditPage"));
16
17
  const explorePage_1 = __importDefault(require("./explorePage"));
@@ -29,6 +30,7 @@ const fixtures = {
29
30
  explorePage: explorePage_1.default,
30
31
  createDataSource: createDataSource_1.default,
31
32
  readProvision: readProvision_1.default,
33
+ readProvisionedDataSource: readProvisionedDataSource_1.default,
32
34
  isFeatureToggleEnabled: isFeatureToggleEnabled_1.default,
33
35
  };
34
36
  exports.default = fixtures;
@@ -1,9 +1,9 @@
1
1
  import { Response } from '@playwright/test';
2
- import { DataSource, NavigateOptions, PluginTestCtx, TriggerQueryOptions } from '../types';
2
+ import { DataSourceSettings, NavigateOptions, PluginTestCtx, TriggerQueryOptions } from '../types';
3
3
  import { GrafanaPage } from './GrafanaPage';
4
4
  export declare class DataSourceConfigPage extends GrafanaPage {
5
5
  private datasource;
6
- constructor(ctx: PluginTestCtx, datasource: DataSource);
6
+ constructor(ctx: PluginTestCtx, datasource: DataSourceSettings);
7
7
  deleteDataSource(): Promise<void>;
8
8
  /**
9
9
  * Navigates to the datasource edit page for an existing datasource
package/dist/types.d.ts CHANGED
@@ -8,21 +8,21 @@ export type PluginTestCtx = {
8
8
  selectors: E2ESelectors;
9
9
  } & Pick<PlaywrightTestArgs, 'page' | 'request'>;
10
10
  /**
11
- * The data source object
11
+ * The data source settings
12
12
  */
13
- export interface DataSource<T = any> {
13
+ export interface DataSourceSettings<T = {}, S = {}> {
14
14
  id: number;
15
15
  editable?: boolean;
16
16
  uid: string;
17
17
  orgId?: number;
18
- name?: string;
18
+ name: string;
19
19
  type: string;
20
20
  access?: string;
21
21
  url?: string;
22
22
  database?: string;
23
23
  isDefault?: boolean;
24
- jsonData?: T;
25
- secureJsonData?: T;
24
+ jsonData: T;
25
+ secureJsonData?: S;
26
26
  }
27
27
  /**
28
28
  * The dashboard object
@@ -31,12 +31,6 @@ export interface Dashboard {
31
31
  uid: string;
32
32
  title?: string;
33
33
  }
34
- /**
35
- * The YAML provision file parsed to a javascript object
36
- */
37
- export type ProvisionFile<T = DataSource> = {
38
- datasources: Array<DataSource<T>>;
39
- };
40
34
  export type CreateDataSourceArgs<T = any> = {
41
35
  /**
42
36
  * The data source to create
@@ -129,6 +123,16 @@ export type ReadProvisionArgs = {
129
123
  */
130
124
  filePath: string;
131
125
  };
126
+ export type ReadProvisionedDataSourceArgs = {
127
+ /**
128
+ * The path, relative to the provisioning folder, to the dashboard json file
129
+ */
130
+ fileName: string;
131
+ /**
132
+ * The name of the data source in the datasources list
133
+ */
134
+ name?: string;
135
+ };
132
136
  export type NavigateOptions = {
133
137
  /**
134
138
  * Referer header value.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grafana/plugin-e2e",
3
- "version": "0.13.2",
3
+ "version": "0.14.0-canary.740.aade71f.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": "e33d8bcf282d0642b0207c07eee75c68a0611f02"
48
+ "gitHead": "aade71f7c634349d24ff8ae8ac4885d480034ad6"
49
49
  }