@grafana/plugin-e2e 0.24.0 → 0.25.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.
Files changed (70) hide show
  1. package/dist/auth/auth.setup.js +2 -2
  2. package/dist/fixtures/annotationEditPage.d.ts +5 -6
  3. package/dist/fixtures/annotationEditPage.js +4 -3
  4. package/dist/fixtures/commands/createDataSource.d.ts +4 -6
  5. package/dist/fixtures/commands/createDataSource.js +2 -2
  6. package/dist/fixtures/commands/createDataSourceConfigPage.d.ts +5 -7
  7. package/dist/fixtures/commands/createDataSourceConfigPage.js +4 -3
  8. package/dist/fixtures/commands/createUser.d.ts +4 -5
  9. package/dist/fixtures/commands/createUser.js +2 -1
  10. package/dist/fixtures/commands/gotoAnnotationEditPage.d.ts +5 -7
  11. package/dist/fixtures/commands/gotoAnnotationEditPage.js +4 -3
  12. package/dist/fixtures/commands/gotoAppConfigPage.d.ts +3 -5
  13. package/dist/fixtures/commands/gotoAppConfigPage.js +0 -1
  14. package/dist/fixtures/commands/gotoAppPage.d.ts +3 -4
  15. package/dist/fixtures/commands/gotoAppPage.js +0 -1
  16. package/dist/fixtures/commands/gotoDashboardPage.d.ts +5 -7
  17. package/dist/fixtures/commands/gotoDashboardPage.js +4 -3
  18. package/dist/fixtures/commands/gotoDataSourceConfigPage.d.ts +5 -6
  19. package/dist/fixtures/commands/gotoDataSourceConfigPage.js +4 -3
  20. package/dist/fixtures/commands/gotoPanelEditPage.d.ts +5 -7
  21. package/dist/fixtures/commands/gotoPanelEditPage.js +4 -3
  22. package/dist/fixtures/commands/gotoVariableEditPage.d.ts +5 -7
  23. package/dist/fixtures/commands/gotoVariableEditPage.js +4 -3
  24. package/dist/fixtures/commands/login.d.ts +4 -5
  25. package/dist/fixtures/commands/login.js +2 -2
  26. package/dist/fixtures/commands/readProvisionedDashboard.d.ts +4 -6
  27. package/dist/fixtures/commands/readProvisionedDashboard.js +2 -1
  28. package/dist/fixtures/commands/readProvisionedDataSource.d.ts +4 -6
  29. package/dist/fixtures/commands/readProvisionedDataSource.js +2 -1
  30. package/dist/fixtures/dashboardPage.d.ts +5 -6
  31. package/dist/fixtures/dashboardPage.js +4 -3
  32. package/dist/fixtures/explorePage.d.ts +4 -5
  33. package/dist/fixtures/explorePage.js +2 -1
  34. package/dist/fixtures/grafanaVersion.d.ts +2 -2
  35. package/dist/fixtures/grafanaVersion.js +2 -1
  36. package/dist/fixtures/isFeatureToggleEnabled.d.ts +4 -5
  37. package/dist/fixtures/isFeatureToggleEnabled.js +2 -1
  38. package/dist/fixtures/page.d.ts +4 -5
  39. package/dist/fixtures/page.js +2 -1
  40. package/dist/fixtures/panelEditPage.d.ts +5 -6
  41. package/dist/fixtures/panelEditPage.js +2 -1
  42. package/dist/fixtures/selectors.d.ts +4 -5
  43. package/dist/fixtures/selectors.js +2 -1
  44. package/dist/fixtures/variableEditPage.d.ts +5 -6
  45. package/dist/fixtures/variableEditPage.js +4 -3
  46. package/dist/index.d.ts +46 -6
  47. package/dist/index.js +105 -7
  48. package/dist/matchers/toBeOK.d.ts +1 -2
  49. package/dist/matchers/toBeOK.js +2 -1
  50. package/dist/matchers/toDisplayPreviews.d.ts +2 -3
  51. package/dist/matchers/toDisplayPreviews.js +2 -1
  52. package/dist/matchers/toHaveAlert.d.ts +2 -3
  53. package/dist/matchers/toHaveAlert.js +2 -1
  54. package/dist/models/pages/AppPage.d.ts +1 -1
  55. package/dist/models/pages/AppPage.js +2 -2
  56. package/dist/options.d.ts +3 -0
  57. package/dist/{options/index.js → options.js} +2 -2
  58. package/dist/types.d.ts +275 -39
  59. package/package.json +2 -2
  60. package/dist/api.d.ts +0 -254
  61. package/dist/api.js +0 -26
  62. package/dist/fixtures/index.d.ts +0 -25
  63. package/dist/fixtures/index.js +0 -52
  64. package/dist/fixtures/types.d.ts +0 -2
  65. package/dist/fixtures/types.js +0 -2
  66. package/dist/matchers/index.d.ts +0 -25
  67. package/dist/matchers/index.js +0 -13
  68. package/dist/models/index.d.ts +0 -15
  69. package/dist/models/index.js +0 -33
  70. package/dist/options/index.d.ts +0 -4
package/dist/types.d.ts CHANGED
@@ -1,5 +1,237 @@
1
- import { Locator, PlaywrightTestArgs, Response, TestInfo } from '@playwright/test';
1
+ import { Locator, PlaywrightTestArgs, PlaywrightTestOptions, PlaywrightWorkerArgs, PlaywrightWorkerOptions, Response, TestInfo } from '@playwright/test';
2
2
  import { E2ESelectors } from './e2e-selectors/types';
3
+ import { AnnotationEditPage } from './models/pages/AnnotationEditPage';
4
+ import { AppConfigPage } from './models/pages/AppConfigPage';
5
+ import { AppPage } from './models/pages/AppPage';
6
+ import { DashboardPage } from './models/pages/DashboardPage';
7
+ import { DataSourceConfigPage } from './models/pages/DataSourceConfigPage';
8
+ import { ExplorePage } from './models/pages/ExplorePage';
9
+ import { PanelEditPage } from './models/pages/PanelEditPage';
10
+ import { VariableEditPage } from './models/pages/VariableEditPage';
11
+ export type PluginOptions = {
12
+ /**
13
+ * When using the readProvisioning fixture, files will be read from this directory. If no directory is provided,
14
+ * the 'provisioning' directory in the current working directory will be used.
15
+ *
16
+ * eg.
17
+ * export default defineConfig({
18
+ use: {
19
+ provisioningRootDir: 'path/to/provisioning',
20
+ },
21
+ });
22
+ *
23
+ */
24
+ provisioningRootDir: string;
25
+ /**
26
+ * Optionally, you can add or override feature toggles.
27
+ * 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
28
+ * need to need to enable the feature in the Grafana config. See https://grafana.com/docs/grafana/latest/setup-grafana/configure-grafana/#feature_toggles
29
+ *
30
+ * To override feature toggles globally in the playwright.config.ts file:
31
+ * export default defineConfig({
32
+ use: {
33
+ featureToggles: {
34
+ exploreMixedDatasource: true,
35
+ redshiftAsyncQueryDataSupport: false
36
+ },
37
+ },
38
+ });
39
+ *
40
+ * To override feature toggles for tests on a certain file:
41
+ test.use({
42
+ featureToggles: {
43
+ exploreMixedDatasource: true,
44
+ },
45
+ * });
46
+ */
47
+ featureToggles: Record<string, boolean>;
48
+ /**
49
+ * The Grafana user to use for the tests. If no user is provided, the default admin/admin user will be used.
50
+ *
51
+ * You can use different users for different projects. See the fixture createUser for more information on how to create a user,
52
+ * and the fixture login for more information on how to authenticate.
53
+ */
54
+ user?: CreateUserArgs;
55
+ };
56
+ export type PluginFixture = {
57
+ /**
58
+ * The current Grafana version.
59
+ *
60
+ * If a GRAFANA_VERSION environment variable is set, this will be used. Otherwise,
61
+ * the version will be picked from window.grafanaBootData.settings.buildInfo.version.
62
+ */
63
+ grafanaVersion: string;
64
+ /**
65
+ * The E2E selectors to use for the current version of Grafana
66
+ */
67
+ selectors: E2ESelectors;
68
+ /**
69
+ * Isolated {@link DashboardPage} instance for each test.
70
+ *
71
+ * Navigates to a new to a new dashboard page.
72
+ */
73
+ dashboardPage: DashboardPage;
74
+ /**
75
+ * Isolated {@link PanelEditPage} instance for each test.
76
+ *
77
+ * Navigates to a new dashboard page and adds a new panel.
78
+ *
79
+ * Use {@link PanelEditPage.setVisualization} to change the visualization
80
+ * Use {@link PanelEditPage.datasource.set} to change the datasource
81
+ * Use {@link ExplorePage.getQueryEditorEditorRow} to retrieve the query
82
+ * editor row locator for a given query refId
83
+ */
84
+ panelEditPage: PanelEditPage;
85
+ /**
86
+ * Isolated {@link VariableEditPage} instance for each test.
87
+ *
88
+ * Navigates to a new dashboard page and adds a new variable.
89
+ *
90
+ * Use {@link VariableEditPage.setVariableType} to change the variable type
91
+ */
92
+ variableEditPage: VariableEditPage;
93
+ /**
94
+ * Isolated {@link AnnotationEditPage} instance for each test.
95
+ *
96
+ * Navigates to a new dashboard page and adds a new annotation.
97
+ *
98
+ * Use {@link AnnotationEditPage.datasource.set} to change the datasource
99
+ */
100
+ annotationEditPage: AnnotationEditPage;
101
+ /**
102
+ * Isolated {@link ExplorePage} instance for each test.
103
+ *
104
+ * Navigates to a the explore page.
105
+ *
106
+ * Use {@link ExplorePage.datasource.set} to change the datasource
107
+ * Use {@link ExplorePage.getQueryEditorEditorRow} to retrieve the query editor
108
+ * row locator for a given query refId
109
+ */
110
+ explorePage: ExplorePage;
111
+ /**
112
+ * Fixture command that will create an isolated DataSourceConfigPage instance for a given data source type.
113
+ *
114
+ * The data source config page cannot be navigated to without a data source uid, so this fixture will create a new
115
+ * data source using the Grafana API, create a new DataSourceConfigPage instance and navigate to the page.
116
+ */
117
+ createDataSourceConfigPage: (args: CreateDataSourcePageArgs) => Promise<DataSourceConfigPage>;
118
+ /**
119
+ * Fixture command that creates a data source via the Grafana API.
120
+ *
121
+ * If you have tests that depend on the the existance of a data source,
122
+ * you may use this command in a setup project. Read more about setup projects
123
+ * here: https://playwright.dev/docs/auth#basic-shared-account-in-all-tests
124
+ */
125
+ createDataSource: (args: CreateDataSourceArgs) => Promise<DataSourceSettings>;
126
+ /**
127
+ * Fixture command that creates a user via the Grafana API and assigns a role to it if a role is provided
128
+ * This may be useful if your plugin supports RBAC and you need to create a user with a specific role. See login fixture for more information.
129
+ */
130
+ createUser: () => Promise<void>;
131
+ /**
132
+ * Fixture command that login to Grafana using the Grafana API and stores the cookie state on disk.
133
+ * The file name for the storage state will be `playwright/.auth/<username>.json`, so it's important that the username is unique.
134
+ *
135
+ * If you have not specified a user, the default admin/admin credentials will be used.
136
+ *
137
+ * e.g
138
+ * projects: [
139
+ {
140
+ name: 'authenticate',
141
+ testDir: './src/auth',
142
+ testMatch: [/.*auth\.setup\.ts/],
143
+ },
144
+ {
145
+ name: 'run tests as admin user',
146
+ testDir: './tests',
147
+ use: {
148
+ ...devices['Desktop Chrome'],
149
+ storageState: 'playwright/.auth/admin.json',
150
+ },
151
+ dependencies: ['authenticate'],
152
+ }
153
+ }
154
+ *
155
+ * If your plugin supports RBAC, you may want to use different projects for different roles.
156
+ * In the following example, a new user with the role `Viewer` gets created and authenticated in a `createUserAndAuthenticate` project.
157
+ * In the `viewer` project, authentication state from the previous project is used in all tests in the ./tests/viewer folder.
158
+ * projects: [
159
+ {
160
+ name: 'createUserAndAuthenticate',
161
+ testDir: 'node_modules/@grafana/plugin-e2e/dist/auth',
162
+ testMatch: [/.*auth\.setup\.ts/],
163
+ use: {
164
+ user: {
165
+ user: 'viewer',
166
+ password: 'password',
167
+ role: 'Viewer',
168
+ },
169
+ },
170
+ },
171
+ {
172
+ name: 'viewer',
173
+ testDir: './tests/viewer',
174
+ use: {
175
+ ...devices['Desktop Chrome'],
176
+ storageState: 'playwright/.auth/viewer.json',
177
+ },
178
+ dependencies: ['createUserAndAuthenticate'],
179
+ }
180
+ }
181
+ *
182
+ * To override credentials in a single test:
183
+ * test.use({ storageState: 'playwright/.auth/admin.json', user: { user: 'admin', password: 'admin' } });
184
+ * To avoid authentication in a single test:
185
+ * test.use({ storageState: { cookies: [], origins: [] } });
186
+ */
187
+ login: () => Promise<void>;
188
+ /**
189
+ * Fixture command that reads a yaml file in the provisioning/datasources directory.
190
+ *
191
+ * The file name should be the name of the file with the .yaml|.yml extension.
192
+ * If a data source name is provided, the first data source that matches the name will be returned.
193
+ * If no name is provided, the first data source in the list of data sources will be returned.
194
+ */
195
+ readProvisionedDataSource<T = {}, S = {}>(args: ReadProvisionedDataSourceArgs): Promise<DataSourceSettings<T, S>>;
196
+ /**
197
+ * Fixture command that reads a dashboard json file in the provisioning/dashboards directory.
198
+ *
199
+ * Can be useful when navigating to a provisioned dashboard and you don't want to hard code the dashboard UID.
200
+ */
201
+ readProvisionedDashboard(args: ReadProvisionedDashboardArgs): Promise<Dashboard>;
202
+ /**
203
+ * Function that checks if a feature toggle is enabled. Only works for frontend feature toggles.
204
+ */
205
+ isFeatureToggleEnabled<T = object>(featureToggle: keyof T): Promise<boolean>;
206
+ /**
207
+ * Fixture command that navigates to an already exist dashboard. Returns a DashboardPage instance.
208
+ */
209
+ gotoDashboardPage: (args: DashboardPageArgs) => Promise<DashboardPage>;
210
+ /**
211
+ * Fixture command that navigates a panel edit page for an already existing panel in a dashboard.
212
+ */
213
+ gotoPanelEditPage: (args: DashboardEditViewArgs<string>) => Promise<PanelEditPage>;
214
+ /**
215
+ * Fixture command that navigates a variable edit page for an already existing variable query in a dashboard.
216
+ */
217
+ gotoVariableEditPage: (args: DashboardEditViewArgs<string>) => Promise<VariableEditPage>;
218
+ /**
219
+ * Fixture command that navigates an annotation edit page for an already existing annotation query in a dashboard.
220
+ */
221
+ gotoAnnotationEditPage: (args: DashboardEditViewArgs<string>) => Promise<AnnotationEditPage>;
222
+ /**
223
+ * Fixture command that navigates a configuration page for an already existing data source instance.
224
+ */
225
+ gotoDataSourceConfigPage: (uid: string) => Promise<DataSourceConfigPage>;
226
+ /**
227
+ * Fixture command that navigates to the AppConfigPage for a given plugin.
228
+ */
229
+ gotoAppConfigPage: (args: GotoAppConfigPageArgs) => Promise<AppConfigPage>;
230
+ /**
231
+ * Fixture command that navigates to an AppPage for a given plugin.
232
+ */
233
+ gotoAppPage: (args: GotoAppPageArgs) => Promise<AppPage>;
234
+ };
3
235
  /**
4
236
  * The context object passed to page object models
5
237
  */
@@ -8,6 +240,10 @@ export type PluginTestCtx = {
8
240
  selectors: E2ESelectors;
9
241
  testInfo: TestInfo;
10
242
  } & Pick<PlaywrightTestArgs, 'page' | 'request'>;
243
+ /**
244
+ * Playwright args used when defining fixtures
245
+ */
246
+ export type PlaywrightArgs = PluginFixture & PluginOptions & PlaywrightTestArgs & PlaywrightTestOptions & PlaywrightWorkerArgs & PlaywrightWorkerOptions;
11
247
  /**
12
248
  * The data source settings
13
249
  */
@@ -32,7 +268,6 @@ export interface Dashboard {
32
268
  uid: string;
33
269
  title?: string;
34
270
  }
35
- export type OrgRole = 'None' | 'Viewer' | 'Editor' | 'Admin';
36
271
  export type CreateUserArgs = {
37
272
  /**
38
273
  * The username of the user to create. Needs to be unique
@@ -78,16 +313,6 @@ export type CreateDataSourcePageArgs = {
78
313
  */
79
314
  deleteDataSourceAfterTest?: boolean;
80
315
  };
81
- export type RequestOptions = {
82
- /**
83
- * Maximum wait time in milliseconds, defaults to 30 seconds, pass `0` to disable the timeout. The default value can
84
- * be changed by using the
85
- * [browserContext.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-browsercontext#browser-context-set-default-timeout)
86
- * or [page.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-page#page-set-default-timeout) methods.
87
- */
88
- timeout?: number;
89
- waitForResponsePredicateCallback?: string | RegExp | ((response: Response) => boolean | Promise<boolean>);
90
- };
91
316
  export interface TimeRangeArgs {
92
317
  /**
93
318
  * The from time
@@ -149,6 +374,23 @@ export type ReadProvisionedDataSourceArgs = {
149
374
  */
150
375
  name?: string;
151
376
  };
377
+ export type PluginPageArgs = {
378
+ pluginId: string;
379
+ };
380
+ export type GotoAppConfigPageArgs = PluginPageArgs;
381
+ export type GotoAppPageArgs = PluginPageArgs & {
382
+ path?: string;
383
+ };
384
+ export type RequestOptions = {
385
+ /**
386
+ * Maximum wait time in milliseconds, defaults to 30 seconds, pass `0` to disable the timeout. The default value can
387
+ * be changed by using the
388
+ * [browserContext.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-browsercontext#browser-context-set-default-timeout)
389
+ * or [page.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-page#page-set-default-timeout) methods.
390
+ */
391
+ timeout?: number;
392
+ waitForResponsePredicateCallback?: string | RegExp | ((response: Response) => boolean | Promise<boolean>);
393
+ };
152
394
  export type NavigateOptions = {
153
395
  /**
154
396
  * Referer header value.
@@ -193,11 +435,21 @@ export type TriggerRequestOptions = {
193
435
  */
194
436
  path?: string;
195
437
  };
196
- /**
197
- * Panel visualization types
198
- */
199
- export type Visualization = 'Alert list' | 'Bar gauge' | 'Clock' | 'Dashboard list' | 'Gauge' | 'Graph' | 'Heatmap' | 'Logs' | 'News' | 'Pie Chart' | 'Plugin list' | 'Polystat' | 'Stat' | 'Table' | 'Text' | 'Time series' | 'Worldmap Panel';
200
- export type AlertVariant = 'success' | 'warning' | 'error' | 'info';
438
+ export interface ContainTextOptions {
439
+ /**
440
+ * Whether to perform case-insensitive match. `ignoreCase` option takes precedence over the corresponding regular
441
+ * expression flag if specified.
442
+ */
443
+ ignoreCase?: boolean;
444
+ /**
445
+ * Time to retry the assertion for in milliseconds. Defaults to `timeout` in `TestConfig.expect`.
446
+ */
447
+ timeout?: number;
448
+ /**
449
+ * Whether to use `element.innerText` instead of `element.textContent` when retrieving DOM node text.
450
+ */
451
+ useInnerText?: boolean;
452
+ }
201
453
  export interface AlertPageOptions {
202
454
  /**
203
455
  * Maximum wait time in milliseconds, defaults to 30 seconds, pass `0` to disable the timeout. The default value can
@@ -234,25 +486,9 @@ export interface AlertPageOptions {
234
486
  */
235
487
  hasText?: string | RegExp;
236
488
  }
237
- export interface ContainTextOptions {
238
- /**
239
- * Whether to perform case-insensitive match. `ignoreCase` option takes precedence over the corresponding regular
240
- * expression flag if specified.
241
- */
242
- ignoreCase?: boolean;
243
- /**
244
- * Time to retry the assertion for in milliseconds. Defaults to `timeout` in `TestConfig.expect`.
245
- */
246
- timeout?: number;
247
- /**
248
- * Whether to use `element.innerText` instead of `element.textContent` when retrieving DOM node text.
249
- */
250
- useInnerText?: boolean;
251
- }
252
- export type PluginPageArgs = {
253
- pluginId: string;
254
- };
255
- export type GotoAppConfigPageArgs = PluginPageArgs;
256
- export type GotoAppPageArgs = PluginPageArgs & {
257
- path?: string;
258
- };
489
+ export type OrgRole = 'None' | 'Viewer' | 'Editor' | 'Admin';
490
+ /**
491
+ * Panel visualization types
492
+ */
493
+ export type Visualization = 'Alert list' | 'Bar gauge' | 'Clock' | 'Dashboard list' | 'Gauge' | 'Graph' | 'Heatmap' | 'Logs' | 'News' | 'Pie Chart' | 'Plugin list' | 'Polystat' | 'Stat' | 'Table' | 'Text' | 'Time series' | 'Worldmap Panel';
494
+ export type AlertVariant = 'success' | 'warning' | 'error' | 'info';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grafana/plugin-e2e",
3
- "version": "0.24.0",
3
+ "version": "0.25.0",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "files": [
@@ -55,5 +55,5 @@
55
55
  "start": "cls || clear"
56
56
  }
57
57
  },
58
- "gitHead": "7f7322d20145ff8a7de9c729b4f5a8f1abfe9139"
58
+ "gitHead": "10210195e3353c840a52d0af5d89597c160e2689"
59
59
  }
package/dist/api.d.ts DELETED
@@ -1,254 +0,0 @@
1
- import { E2ESelectors } from './e2e-selectors/types';
2
- import { CreateDataSourceArgs, CreateDataSourcePageArgs, DataSourceSettings, ReadProvisionedDashboardArgs, ReadProvisionedDataSourceArgs, CreateUserArgs, Dashboard, DashboardPageArgs, DashboardEditViewArgs, GotoAppConfigPageArgs, GotoAppPageArgs } from './types';
3
- import { PanelEditPage, GrafanaPage, DataSourceConfigPage, DashboardPage, VariableEditPage, AnnotationEditPage, AppConfigPage, AppPage } from './models';
4
- import { ExplorePage } from './models/pages/ExplorePage';
5
- export type PluginOptions = {
6
- /**
7
- * When using the readProvisioning fixture, files will be read from this directory. If no directory is provided,
8
- * the 'provisioning' directory in the current working directory will be used.
9
- *
10
- * eg.
11
- * export default defineConfig({
12
- use: {
13
- provisioningRootDir: 'path/to/provisioning',
14
- },
15
- });
16
- *
17
- */
18
- provisioningRootDir: string;
19
- /**
20
- * Optionally, you can add or override feature toggles.
21
- * 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
22
- * need to need to enable the feature in the Grafana config. See https://grafana.com/docs/grafana/latest/setup-grafana/configure-grafana/#feature_toggles
23
- *
24
- * To override feature toggles globally in the playwright.config.ts file:
25
- * export default defineConfig({
26
- use: {
27
- featureToggles: {
28
- exploreMixedDatasource: true,
29
- redshiftAsyncQueryDataSupport: false
30
- },
31
- },
32
- });
33
- *
34
- * To override feature toggles for tests on a certain file:
35
- test.use({
36
- featureToggles: {
37
- exploreMixedDatasource: true,
38
- },
39
- * });
40
- */
41
- featureToggles: Record<string, boolean>;
42
- /**
43
- * The Grafana user to use for the tests. If no user is provided, the default admin/admin user will be used.
44
- *
45
- * You can use different users for different projects. See the fixture createUser for more information on how to create a user,
46
- * and the fixture login for more information on how to authenticate.
47
- */
48
- user?: CreateUserArgs;
49
- };
50
- export type PluginFixture = {
51
- /**
52
- * The current Grafana version.
53
- *
54
- * If a GRAFANA_VERSION environment variable is set, this will be used. Otherwise,
55
- * the version will be picked from window.grafanaBootData.settings.buildInfo.version.
56
- */
57
- grafanaVersion: string;
58
- /**
59
- * The E2E selectors to use for the current version of Grafana
60
- */
61
- selectors: E2ESelectors;
62
- /**
63
- * Isolated {@link DashboardPage} instance for each test.
64
- *
65
- * Navigates to a new to a new dashboard page.
66
- */
67
- dashboardPage: DashboardPage;
68
- /**
69
- * Isolated {@link PanelEditPage} instance for each test.
70
- *
71
- * Navigates to a new dashboard page and adds a new panel.
72
- *
73
- * Use {@link PanelEditPage.setVisualization} to change the visualization
74
- * Use {@link PanelEditPage.datasource.set} to change the datasource
75
- * Use {@link ExplorePage.getQueryEditorEditorRow} to retrieve the query
76
- * editor row locator for a given query refId
77
- */
78
- panelEditPage: PanelEditPage;
79
- /**
80
- * Isolated {@link VariableEditPage} instance for each test.
81
- *
82
- * Navigates to a new dashboard page and adds a new variable.
83
- *
84
- * Use {@link VariableEditPage.setVariableType} to change the variable type
85
- */
86
- variableEditPage: VariableEditPage;
87
- /**
88
- * Isolated {@link AnnotationEditPage} instance for each test.
89
- *
90
- * Navigates to a new dashboard page and adds a new annotation.
91
- *
92
- * Use {@link AnnotationEditPage.datasource.set} to change the datasource
93
- */
94
- annotationEditPage: AnnotationEditPage;
95
- /**
96
- * Isolated {@link ExplorePage} instance for each test.
97
- *
98
- * Navigates to a the explore page.
99
- *
100
- * Use {@link ExplorePage.datasource.set} to change the datasource
101
- * Use {@link ExplorePage.getQueryEditorEditorRow} to retrieve the query editor
102
- * row locator for a given query refId
103
- */
104
- explorePage: ExplorePage;
105
- /**
106
- * Fixture command that will create an isolated DataSourceConfigPage instance for a given data source type.
107
- *
108
- * The data source config page cannot be navigated to without a data source uid, so this fixture will create a new
109
- * data source using the Grafana API, create a new DataSourceConfigPage instance and navigate to the page.
110
- */
111
- createDataSourceConfigPage: (args: CreateDataSourcePageArgs) => Promise<DataSourceConfigPage>;
112
- /**
113
- * Fixture command that creates a data source via the Grafana API.
114
- *
115
- * If you have tests that depend on the the existance of a data source,
116
- * you may use this command in a setup project. Read more about setup projects
117
- * here: https://playwright.dev/docs/auth#basic-shared-account-in-all-tests
118
- */
119
- createDataSource: (args: CreateDataSourceArgs) => Promise<DataSourceSettings>;
120
- /**
121
- * Fixture command that creates a user via the Grafana API and assigns a role to it if a role is provided
122
- * This may be useful if your plugin supports RBAC and you need to create a user with a specific role. See login fixture for more information.
123
- */
124
- createUser: () => Promise<void>;
125
- /**
126
- * Fixture command that login to Grafana using the Grafana API and stores the cookie state on disk.
127
- * The file name for the storage state will be `playwright/.auth/<username>.json`, so it's important that the username is unique.
128
- *
129
- * If you have not specified a user, the default admin/admin credentials will be used.
130
- *
131
- * e.g
132
- * projects: [
133
- {
134
- name: 'authenticate',
135
- testDir: './src/auth',
136
- testMatch: [/.*auth\.setup\.ts/],
137
- },
138
- {
139
- name: 'run tests as admin user',
140
- testDir: './tests',
141
- use: {
142
- ...devices['Desktop Chrome'],
143
- storageState: 'playwright/.auth/admin.json',
144
- },
145
- dependencies: ['authenticate'],
146
- }
147
- }
148
- *
149
- * If your plugin supports RBAC, you may want to use different projects for different roles.
150
- * In the following example, a new user with the role `Viewer` gets created and authenticated in a `createUserAndAuthenticate` project.
151
- * In the `viewer` project, authentication state from the previous project is used in all tests in the ./tests/viewer folder.
152
- * projects: [
153
- {
154
- name: 'createUserAndAuthenticate',
155
- testDir: 'node_modules/@grafana/plugin-e2e/dist/auth',
156
- testMatch: [/.*auth\.setup\.ts/],
157
- use: {
158
- user: {
159
- user: 'viewer',
160
- password: 'password',
161
- role: 'Viewer',
162
- },
163
- },
164
- },
165
- {
166
- name: 'viewer',
167
- testDir: './tests/viewer',
168
- use: {
169
- ...devices['Desktop Chrome'],
170
- storageState: 'playwright/.auth/viewer.json',
171
- },
172
- dependencies: ['createUserAndAuthenticate'],
173
- }
174
- }
175
- *
176
- * To override credentials in a single test:
177
- * test.use({ storageState: 'playwright/.auth/admin.json', user: { user: 'admin', password: 'admin' } });
178
- * To avoid authentication in a single test:
179
- * test.use({ storageState: { cookies: [], origins: [] } });
180
- */
181
- login: () => Promise<void>;
182
- /**
183
- * Fixture command that reads a yaml file in the provisioning/datasources directory.
184
- *
185
- * The file name should be the name of the file with the .yaml|.yml extension.
186
- * If a data source name is provided, the first data source that matches the name will be returned.
187
- * If no name is provided, the first data source in the list of data sources will be returned.
188
- */
189
- readProvisionedDataSource<T = {}, S = {}>(args: ReadProvisionedDataSourceArgs): Promise<DataSourceSettings<T, S>>;
190
- /**
191
- * Fixture command that reads a dashboard json file in the provisioning/dashboards directory.
192
- *
193
- * Can be useful when navigating to a provisioned dashboard and you don't want to hard code the dashboard UID.
194
- */
195
- readProvisionedDashboard(args: ReadProvisionedDashboardArgs): Promise<Dashboard>;
196
- /**
197
- * Function that checks if a feature toggle is enabled. Only works for frontend feature toggles.
198
- */
199
- isFeatureToggleEnabled<T = object>(featureToggle: keyof T): Promise<boolean>;
200
- /**
201
- * Fixture command that navigates to an already exist dashboard. Returns a DashboardPage instance.
202
- */
203
- gotoDashboardPage: (args: DashboardPageArgs) => Promise<DashboardPage>;
204
- /**
205
- * Fixture command that navigates a panel edit page for an already existing panel in a dashboard.
206
- */
207
- gotoPanelEditPage: (args: DashboardEditViewArgs<string>) => Promise<PanelEditPage>;
208
- /**
209
- * Fixture command that navigates a variable edit page for an already existing variable query in a dashboard.
210
- */
211
- gotoVariableEditPage: (args: DashboardEditViewArgs<string>) => Promise<VariableEditPage>;
212
- /**
213
- * Fixture command that navigates an annotation edit page for an already existing annotation query in a dashboard.
214
- */
215
- gotoAnnotationEditPage: (args: DashboardEditViewArgs<string>) => Promise<AnnotationEditPage>;
216
- /**
217
- * Fixture command that navigates a configuration page for an already existing data source instance.
218
- */
219
- gotoDataSourceConfigPage: (uid: string) => Promise<DataSourceConfigPage>;
220
- /**
221
- * Fixture command that navigates to the AppConfigPage for a given plugin.
222
- */
223
- gotoAppConfigPage: (args: GotoAppConfigPageArgs) => Promise<AppConfigPage>;
224
- /**
225
- * Fixture command that navigates to an AppPage for a given plugin.
226
- */
227
- gotoAppPage: (args: GotoAppPageArgs) => Promise<AppPage>;
228
- };
229
- export declare const test: import("@playwright/test").TestType<import("@playwright/test").PlaywrightTestArgs & import("@playwright/test").PlaywrightTestOptions & PluginFixture, import("@playwright/test").PlaywrightWorkerArgs & import("@playwright/test").PlaywrightWorkerOptions & PluginOptions>;
230
- export declare const expect: import("@playwright/test").Expect<{
231
- toBeOK: (request: Promise<import("@playwright/test").Response>) => Promise<{
232
- message: () => string;
233
- pass: boolean;
234
- actual: number;
235
- } | {
236
- message: () => string;
237
- pass: boolean;
238
- actual: undefined;
239
- }>;
240
- toDisplayPreviews: (variableEditPage: VariableEditPage, previewTexts: (string | RegExp)[], options?: import("./types").ContainTextOptions | undefined) => Promise<{
241
- pass: boolean;
242
- actual: boolean;
243
- message: () => string;
244
- } | {
245
- message: () => string;
246
- pass: boolean;
247
- actual: undefined;
248
- }>;
249
- toHaveAlert: (grafanaPage: GrafanaPage, severity: import("./matchers/toHaveAlert").AlertVariant, options?: import("./types").AlertPageOptions | undefined) => Promise<{
250
- message: () => any;
251
- pass: boolean;
252
- }>;
253
- }>;
254
- export { selectors } from '@playwright/test';
package/dist/api.js DELETED
@@ -1,26 +0,0 @@
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
- exports.selectors = exports.expect = exports.test = void 0;
7
- const test_1 = require("@playwright/test");
8
- const fixtures_1 = __importDefault(require("./fixtures"));
9
- const matchers_1 = __importDefault(require("./matchers"));
10
- const selectorEngine_1 = require("./selectorEngine");
11
- const options_1 = __importDefault(require("./options"));
12
- // extend Playwright with Grafana plugin specific fixtures
13
- exports.test = test_1.test.extend({ ...fixtures_1.default, ...options_1.default });
14
- exports.expect = test_1.expect.extend(matchers_1.default);
15
- /** Register a custom selector engine that resolves locators for Grafana E2E selectors
16
- *
17
- * The same functionality is available in the {@link GrafanaPage.getByTestIdOrAriaLabel} method. However,
18
- * by registering the selector engine, one can resolve locators by Grafana E2E selectors also within a locator.
19
- *
20
- * Example:
21
- * const queryEditorRow = await panelEditPage.getQueryEditorRow('A'); // returns a locator
22
- * queryEditorRow.locator(`selector=${selectors.components.TimePicker.openButton}`).click();
23
- * */
24
- test_1.selectors.register('selector', selectorEngine_1.grafanaE2ESelectorEngine);
25
- var test_2 = require("@playwright/test");
26
- Object.defineProperty(exports, "selectors", { enumerable: true, get: function () { return test_2.selectors; } });