@grafana/plugin-e2e 0.0.3 → 0.0.4-canary.616.8eb70b7.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.
@@ -257,6 +257,7 @@ export type Components = {
257
257
  OptionsGroup: {
258
258
  group: (title?: string) => string;
259
259
  toggle: (title?: string) => string;
260
+ groupTitle: string;
260
261
  };
261
262
  PluginVisualization: {
262
263
  current: string;
@@ -425,7 +426,12 @@ export type Pages = {
425
426
  };
426
427
  };
427
428
  Variables: {
428
- url: string;
429
+ List: {
430
+ url: string;
431
+ };
432
+ Edit: {
433
+ url: (variableIndex: string) => string;
434
+ };
429
435
  };
430
436
  };
431
437
  };
@@ -462,7 +468,11 @@ export type Pages = {
462
468
  title: string;
463
469
  };
464
470
  Annotations: {
471
+ Edit: {
472
+ url: (dashboardUid: string, annotationIndex: string) => string;
473
+ };
465
474
  List: {
475
+ url: (uid: string) => string;
466
476
  addAnnotationCTA: string;
467
477
  addAnnotationCTAV2: string;
468
478
  };
@@ -477,6 +487,7 @@ export type Pages = {
477
487
  };
478
488
  Variables: {
479
489
  List: {
490
+ url: (dashboardUid: string) => string;
480
491
  newButton: string;
481
492
  table: string;
482
493
  tableRowNameFields: (variableName: string) => string;
@@ -489,6 +500,7 @@ export type Pages = {
489
500
  addVariableCTAV2Item: string;
490
501
  };
491
502
  Edit: {
503
+ url: (dashboardUid: string, editIndex: string) => string;
492
504
  General: {
493
505
  headerLink: string;
494
506
  modeLabelNew: string;
@@ -276,6 +276,9 @@ export declare const versionedComponents: {
276
276
  OptionsGroup: {
277
277
  group: (title?: string) => string;
278
278
  toggle: (title?: string) => string;
279
+ groupTitle: {
280
+ "8.0.0": string;
281
+ };
279
282
  };
280
283
  PluginVisualization: {
281
284
  item: (title: string) => string;
@@ -280,6 +280,9 @@ exports.versionedComponents = {
280
280
  OptionsGroup: {
281
281
  group: (title) => (title ? `Options group ${title}` : 'Options group'),
282
282
  toggle: (title) => (title ? `Options group ${title} toggle` : 'Options group toggle'),
283
+ groupTitle: {
284
+ [constants_1.MIN_GRAFANA_VERSION]: 'Panel options',
285
+ },
283
286
  },
284
287
  PluginVisualization: {
285
288
  item: (title) => `Plugin visualization item ${title}`,
@@ -63,7 +63,12 @@ export declare const versionedPages: {
63
63
  };
64
64
  };
65
65
  Variables: {
66
- url: string;
66
+ List: {
67
+ url: string;
68
+ };
69
+ Edit: {
70
+ url: (annotationIndex: string) => string;
71
+ };
67
72
  };
68
73
  };
69
74
  };
@@ -100,7 +105,11 @@ export declare const versionedPages: {
100
105
  title: string;
101
106
  };
102
107
  Annotations: {
108
+ Edit: {
109
+ url: (dashboardUid: string, annotationIndex: string) => string;
110
+ };
103
111
  List: {
112
+ url: (dashboardUid: string) => string;
104
113
  addAnnotationCTA: string;
105
114
  addAnnotationCTAV2: string;
106
115
  };
@@ -115,6 +124,7 @@ export declare const versionedPages: {
115
124
  };
116
125
  Variables: {
117
126
  List: {
127
+ url: (dashboardUid: string) => string;
118
128
  newButton: string;
119
129
  table: string;
120
130
  tableRowNameFields: (variableName: string) => string;
@@ -129,6 +139,9 @@ export declare const versionedPages: {
129
139
  };
130
140
  };
131
141
  Edit: {
142
+ url: {
143
+ "8.0.0": (dashboardUid: string, editIndex: string) => string;
144
+ };
132
145
  General: {
133
146
  headerLink: string;
134
147
  modeLabelNew: string;
@@ -67,7 +67,12 @@ exports.versionedPages = {
67
67
  },
68
68
  },
69
69
  Variables: {
70
- url: '/dashboard/new?orgId=1&editview=templating',
70
+ List: {
71
+ url: '/dashboard/new?orgId=1&editview=templating',
72
+ },
73
+ Edit: {
74
+ url: (annotationIndex) => `/dashboard/new?orgId=1&editview=templating&editIndex=${annotationIndex}`,
75
+ },
71
76
  },
72
77
  },
73
78
  },
@@ -104,7 +109,11 @@ exports.versionedPages = {
104
109
  title: 'Tab General',
105
110
  },
106
111
  Annotations: {
112
+ Edit: {
113
+ url: (dashboardUid, annotationIndex) => `${exports.versionedPages.Dashboard.url(dashboardUid)}?editview=annotations&editIndex=${annotationIndex}`,
114
+ },
107
115
  List: {
116
+ url: (dashboardUid) => `${exports.versionedPages.Dashboard.url(dashboardUid)}?editview=annotations`,
108
117
  addAnnotationCTA: 'Call to action button Add annotation query',
109
118
  addAnnotationCTAV2: 'data-testid Call to action button Add annotation query',
110
119
  },
@@ -119,6 +128,7 @@ exports.versionedPages = {
119
128
  },
120
129
  Variables: {
121
130
  List: {
131
+ url: (dashboardUid) => `${exports.versionedPages.Dashboard.url(dashboardUid)}?editview=templating`,
122
132
  newButton: 'Variable editor New variable button',
123
133
  table: 'Variable editor Table',
124
134
  tableRowNameFields: (variableName) => `Variable editor Table Name field ${variableName}`,
@@ -133,6 +143,9 @@ exports.versionedPages = {
133
143
  },
134
144
  },
135
145
  Edit: {
146
+ url: {
147
+ [constants_1.MIN_GRAFANA_VERSION]: (dashboardUid, editIndex) => `${exports.versionedPages.Dashboard.url(dashboardUid)}?editview=templating&editIndex=${editIndex}`,
148
+ },
136
149
  General: {
137
150
  headerLink: 'Variable editor Header link',
138
151
  modeLabelNew: 'Variable editor Header mode New',
@@ -2,11 +2,11 @@ declare const _default: {
2
2
  selectors: (args: import("..").PluginFixture & import("..").PluginOptions & import("playwright/test").PlaywrightTestArgs & import("playwright/test").PlaywrightTestOptions & import("playwright/test").PlaywrightWorkerArgs & import("playwright/test").PlaywrightWorkerOptions, use: (r: import("..").E2ESelectors) => Promise<void>, testInfo: import("playwright/test").TestInfo) => any;
3
3
  grafanaVersion: (args: import("..").PluginFixture & import("..").PluginOptions & import("playwright/test").PlaywrightTestArgs & import("playwright/test").PlaywrightTestOptions & import("playwright/test").PlaywrightWorkerArgs & import("playwright/test").PlaywrightWorkerOptions, use: (r: string) => Promise<void>, testInfo: import("playwright/test").TestInfo) => any;
4
4
  login: (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;
5
- createDataSourceConfigPage: (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").CreateDataSourcePageArgs) => Promise<import("../models").DataSourceConfigPage>) => Promise<void>, testInfo: import("playwright/test").TestInfo) => any;
6
- newDashboardPage: (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").DashboardPage) => Promise<void>, testInfo: import("playwright/test").TestInfo) => any;
7
- panelEditPage: (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").PanelEditPage) => Promise<void>, testInfo: import("playwright/test").TestInfo) => any;
8
- 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("../models").VariableEditPage) => Promise<void>, testInfo: import("playwright/test").TestInfo) => any;
9
- 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("../models").AnnotationEditPage) => Promise<void>, testInfo: import("playwright/test").TestInfo) => any;
5
+ createDataSourceConfigPage: (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").CreateDataSourcePageArgs) => Promise<import("..").DataSourceConfigPage>) => Promise<void>, testInfo: import("playwright/test").TestInfo) => any;
6
+ newDashboardPage: (args: import("..").PluginFixture & import("..").PluginOptions & import("playwright/test").PlaywrightTestArgs & import("playwright/test").PlaywrightTestOptions & import("playwright/test").PlaywrightWorkerArgs & import("playwright/test").PlaywrightWorkerOptions, use: (r: import("..").DashboardPage) => Promise<void>, testInfo: import("playwright/test").TestInfo) => any;
7
+ panelEditPage: (args: import("..").PluginFixture & import("..").PluginOptions & import("playwright/test").PlaywrightTestArgs & import("playwright/test").PlaywrightTestOptions & import("playwright/test").PlaywrightWorkerArgs & import("playwright/test").PlaywrightWorkerOptions, use: (r: import("..").PanelEditPage) => Promise<void>, testInfo: import("playwright/test").TestInfo) => any;
8
+ 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;
9
+ 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;
10
10
  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;
11
11
  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
12
  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;
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export { expect, test, type PluginFixture, type PluginOptions } from './api';
2
2
  export * from './e2e-selectors';
3
3
  export * from './fixtures';
4
+ export * from './models';
package/dist/index.js CHANGED
@@ -20,3 +20,4 @@ Object.defineProperty(exports, "expect", { enumerable: true, get: function () {
20
20
  Object.defineProperty(exports, "test", { enumerable: true, get: function () { return api_1.test; } });
21
21
  __exportStar(require("./e2e-selectors"), exports);
22
22
  __exportStar(require("./fixtures"), exports);
23
+ __exportStar(require("./models"), exports);
@@ -11,12 +11,12 @@ declare const _default: {
11
11
  pass: boolean;
12
12
  actual: number;
13
13
  }>;
14
- toDisplayPreviews: (variableEditPage: import("../models").VariableEditPage, previewTexts: (string | RegExp)[]) => Promise<{
14
+ toDisplayPreviews: (variableEditPage: import("..").VariableEditPage, previewTexts: (string | RegExp)[]) => Promise<{
15
15
  pass: boolean;
16
16
  actual: boolean;
17
17
  message: () => string;
18
18
  }>;
19
- toHaveAlert: (grafanaPage: import("../models").GrafanaPage, severity: import("./toHaveAlert").AlertVariant, options?: import("../types").AlertPageOptions) => Promise<{
19
+ toHaveAlert: (grafanaPage: import("..").GrafanaPage, severity: import("./toHaveAlert").AlertVariant, options?: import("../types").AlertPageOptions) => Promise<{
20
20
  message: () => any;
21
21
  pass: boolean;
22
22
  }>;
@@ -1,8 +1,11 @@
1
1
  import { DataSourcePicker } from './DataSourcePicker';
2
- import { PluginTestCtx, RequestOptions } from '../types';
2
+ import { DashboardEditViewArgs, NavigateOptions, PluginTestCtx, RequestOptions } from '../types';
3
3
  import { GrafanaPage } from './GrafanaPage';
4
4
  export declare class AnnotationEditPage extends GrafanaPage {
5
+ readonly ctx: PluginTestCtx;
6
+ readonly args: DashboardEditViewArgs<string>;
5
7
  datasource: DataSourcePicker;
6
- constructor(ctx: PluginTestCtx);
8
+ constructor(ctx: PluginTestCtx, args: DashboardEditViewArgs<string>);
9
+ goto(options?: NavigateOptions): Promise<void>;
7
10
  runQuery(options?: RequestOptions): Promise<import("playwright-core").Response>;
8
11
  }
@@ -4,11 +4,22 @@ exports.AnnotationEditPage = void 0;
4
4
  const DataSourcePicker_1 = require("./DataSourcePicker");
5
5
  const GrafanaPage_1 = require("./GrafanaPage");
6
6
  class AnnotationEditPage extends GrafanaPage_1.GrafanaPage {
7
+ ctx;
8
+ args;
7
9
  datasource;
8
- constructor(ctx) {
10
+ constructor(ctx, args) {
9
11
  super(ctx);
12
+ this.ctx = ctx;
13
+ this.args = args;
10
14
  this.datasource = new DataSourcePicker_1.DataSourcePicker(ctx);
11
15
  }
16
+ async goto(options) {
17
+ const { Dashboard, AddDashboard } = this.ctx.selectors.pages;
18
+ const url = this.args.dashboard?.uid
19
+ ? Dashboard.Settings.Annotations.Edit.url(this.args.dashboard.uid, this.args.id)
20
+ : AddDashboard.Settings.Annotations.Edit.url(this.args.id);
21
+ return super.navigate(url, options);
22
+ }
12
23
  async runQuery(options) {
13
24
  const responsePromise = this.ctx.page.waitForResponse((resp) => resp.url().includes(this.ctx.selectors.apis.DataSource.query), options);
14
25
  await this.ctx.page.getByRole('button', { name: 'TEST' }).click();
@@ -1,8 +1,10 @@
1
- import { PluginTestCtx } from '../types';
1
+ import { DashboardPageArgs, NavigateOptions, PluginTestCtx } from '../types';
2
2
  import { AnnotationEditPage } from './AnnotationEditPage';
3
3
  import { GrafanaPage } from './GrafanaPage';
4
4
  export declare class AnnotationPage extends GrafanaPage {
5
- constructor(ctx: PluginTestCtx);
6
- goto(): Promise<void>;
5
+ readonly ctx: PluginTestCtx;
6
+ readonly dashboard?: DashboardPageArgs;
7
+ constructor(ctx: PluginTestCtx, dashboard?: DashboardPageArgs);
8
+ goto(options?: NavigateOptions): Promise<void>;
7
9
  clickAddNew(): Promise<AnnotationEditPage>;
8
10
  }
@@ -28,23 +28,38 @@ const semver = __importStar(require("semver"));
28
28
  const AnnotationEditPage_1 = require("./AnnotationEditPage");
29
29
  const GrafanaPage_1 = require("./GrafanaPage");
30
30
  class AnnotationPage extends GrafanaPage_1.GrafanaPage {
31
- constructor(ctx) {
31
+ ctx;
32
+ dashboard;
33
+ constructor(ctx, dashboard) {
32
34
  super(ctx);
35
+ this.ctx = ctx;
36
+ this.dashboard = dashboard;
33
37
  }
34
- async goto() {
35
- await this.ctx.page.goto(this.ctx.selectors.pages.AddDashboard.Settings.Annotations.List.url, {
36
- waitUntil: 'networkidle',
37
- });
38
+ async goto(options) {
39
+ const { Dashboard, AddDashboard } = this.ctx.selectors.pages;
40
+ let url = this.dashboard?.uid
41
+ ? Dashboard.Settings.Annotations.List.url(this.dashboard.uid)
42
+ : AddDashboard.Settings.Annotations.List.url;
43
+ return super.navigate(url, options);
38
44
  }
39
45
  async clickAddNew() {
40
46
  const { Dashboard } = this.ctx.selectors.pages;
41
- if (semver.gte(this.ctx.grafanaVersion, '8.3.0')) {
42
- await this.getByTestIdOrAriaLabel(Dashboard.Settings.Annotations.List.addAnnotationCTAV2).click();
47
+ if (!this.dashboard?.uid) {
48
+ if (semver.gte(this.ctx.grafanaVersion, '8.3.0')) {
49
+ await this.getByTestIdOrAriaLabel(Dashboard.Settings.Annotations.List.addAnnotationCTAV2).click();
50
+ }
51
+ else {
52
+ await this.getByTestIdOrAriaLabel(Dashboard.Settings.Annotations.List.addAnnotationCTA).click();
53
+ }
43
54
  }
44
55
  else {
45
- await this.getByTestIdOrAriaLabel(Dashboard.Settings.Annotations.List.addAnnotationCTA).click();
56
+ await this.ctx.page.getByRole('button', { name: 'New query' }).click();
46
57
  }
47
- return new AnnotationEditPage_1.AnnotationEditPage(this.ctx);
58
+ const editIndex = await this.ctx.page.evaluate(() => {
59
+ const urlParams = new URLSearchParams(window.location.search);
60
+ return urlParams.get('editIndex');
61
+ });
62
+ return new AnnotationEditPage_1.AnnotationEditPage(this.ctx, { id: editIndex || '1' });
48
63
  }
49
64
  }
50
65
  exports.AnnotationPage = AnnotationPage;
@@ -1,13 +1,14 @@
1
- import { GotoDashboardArgs, PluginTestCtx } from '../types';
1
+ import { DashboardPageArgs, NavigateOptions, PluginTestCtx } from '../types';
2
2
  import { GrafanaPage } from './GrafanaPage';
3
3
  import { PanelEditPage } from './PanelEditPage';
4
4
  import { TimeRange } from './TimeRange';
5
5
  export declare class DashboardPage extends GrafanaPage {
6
- protected readonly dashboardUid?: string;
6
+ readonly ctx: PluginTestCtx;
7
+ readonly dashboard?: DashboardPageArgs;
7
8
  dataSourcePicker: any;
8
9
  timeRange: TimeRange;
9
- constructor(ctx: PluginTestCtx, dashboardUid?: string);
10
- goto(opts?: GotoDashboardArgs): Promise<void>;
10
+ constructor(ctx: PluginTestCtx, dashboard?: DashboardPageArgs);
11
+ goto(options?: NavigateOptions): Promise<void>;
11
12
  gotoPanelEditPage(panelId: string): Promise<PanelEditPage>;
12
13
  addPanel(): Promise<PanelEditPage>;
13
14
  deleteDashboard(): Promise<void>;
@@ -7,34 +7,32 @@ const GrafanaPage_1 = require("./GrafanaPage");
7
7
  const PanelEditPage_1 = require("./PanelEditPage");
8
8
  const TimeRange_1 = require("./TimeRange");
9
9
  class DashboardPage extends GrafanaPage_1.GrafanaPage {
10
- dashboardUid;
10
+ ctx;
11
+ dashboard;
11
12
  dataSourcePicker;
12
13
  timeRange;
13
- constructor(ctx, dashboardUid) {
14
+ constructor(ctx, dashboard) {
14
15
  super(ctx);
15
- this.dashboardUid = dashboardUid;
16
+ this.ctx = ctx;
17
+ this.dashboard = dashboard;
16
18
  this.dataSourcePicker = new DataSourcePicker_1.DataSourcePicker(ctx);
17
19
  this.timeRange = new TimeRange_1.TimeRange(ctx);
18
20
  }
19
- async goto(opts) {
20
- const uid = opts?.uid || this.dashboardUid;
21
- let url = uid ? this.ctx.selectors.pages.Dashboard.url(uid) : this.ctx.selectors.pages.AddDashboard.url;
22
- if (opts?.queryParams) {
23
- url += `?${opts.queryParams.toString()}`;
24
- }
25
- await this.ctx.page.goto(url, {
26
- waitUntil: 'networkidle',
27
- });
28
- if (opts?.timeRange) {
29
- await this.timeRange.set(opts.timeRange);
21
+ async goto(options) {
22
+ let url = this.dashboard?.uid
23
+ ? this.ctx.selectors.pages.Dashboard.url(this.dashboard.uid)
24
+ : this.ctx.selectors.pages.AddDashboard.url;
25
+ if (this.dashboard?.timeRange) {
26
+ options.queryParams = options.queryParams ?? new URLSearchParams();
27
+ options.queryParams.append('from', this.dashboard.timeRange.from);
28
+ options.queryParams.append('to', this.dashboard.timeRange.to);
30
29
  }
30
+ return super.navigate(url, options);
31
31
  }
32
32
  async gotoPanelEditPage(panelId) {
33
- const url = this.ctx.selectors.pages.Dashboard.url(this.dashboardUid ?? '');
34
- await this.ctx.page.goto(`${url}?editPanel=${panelId}`, {
35
- waitUntil: 'networkidle',
36
- });
37
- return new PanelEditPage_1.PanelEditPage(this.ctx);
33
+ const panelEditPage = new PanelEditPage_1.PanelEditPage(this.ctx, { dashboard: this.dashboard, id: panelId });
34
+ await panelEditPage.goto();
35
+ return panelEditPage;
38
36
  }
39
37
  async addPanel() {
40
38
  const { components, pages } = this.ctx.selectors;
@@ -45,10 +43,14 @@ class DashboardPage extends GrafanaPage_1.GrafanaPage {
45
43
  else {
46
44
  await this.getByTestIdOrAriaLabel(pages.AddDashboard.addNewPanel).click();
47
45
  }
48
- return new PanelEditPage_1.PanelEditPage(this.ctx);
46
+ const panelId = await this.ctx.page.evaluate(() => {
47
+ const urlParams = new URLSearchParams(window.location.search);
48
+ return urlParams.get('editPanel');
49
+ });
50
+ return new PanelEditPage_1.PanelEditPage(this.ctx, { dashboard: this.dashboard, id: panelId });
49
51
  }
50
52
  async deleteDashboard() {
51
- await this.ctx.request.delete(this.ctx.selectors.apis.Dashboard.delete(this.dashboardUid));
53
+ await this.ctx.request.delete(this.ctx.selectors.apis.Dashboard.delete(this.dashboard.uid));
52
54
  }
53
55
  async refreshDashboard() {
54
56
  await this.ctx.page.getByTestId(this.ctx.selectors.components.RefreshPicker.runButtonV2).click();
@@ -1,10 +1,10 @@
1
- import { DataSource, PluginTestCtx, TriggerQueryOptions } from '../types';
1
+ import { DataSource, NavigateOptions, PluginTestCtx, TriggerQueryOptions } from '../types';
2
2
  import { GrafanaPage } from './GrafanaPage';
3
3
  export declare class DataSourceConfigPage extends GrafanaPage {
4
4
  private datasource;
5
5
  constructor(ctx: PluginTestCtx, datasource: DataSource);
6
6
  deleteDataSource(): Promise<void>;
7
- goto(): Promise<void>;
7
+ goto(options?: NavigateOptions): Promise<void>;
8
8
  mockHealthCheckResponse<T = any>(json: T, status?: number): Promise<void>;
9
9
  saveAndTest(options?: TriggerQueryOptions): Promise<void | import("playwright-core").Response>;
10
10
  }
@@ -11,10 +11,8 @@ class DataSourceConfigPage extends GrafanaPage_1.GrafanaPage {
11
11
  async deleteDataSource() {
12
12
  await this.ctx.request.delete(this.ctx.selectors.apis.DataSource.datasourceByUID(this.datasource.uid));
13
13
  }
14
- async goto() {
15
- await this.ctx.page.goto(this.ctx.selectors.pages.EditDataSource.url(this.datasource.uid), {
16
- waitUntil: 'load',
17
- });
14
+ async goto(options) {
15
+ return super.navigate(this.ctx.selectors.pages.EditDataSource.url(this.datasource.uid), options);
18
16
  }
19
17
  async mockHealthCheckResponse(json, status = 200) {
20
18
  await this.ctx.page.route(`${this.ctx.selectors.apis.DataSource.health(this.datasource.uid ?? '', this.datasource.id.toString() ?? '')}`, async (route) => {
@@ -44,7 +44,7 @@ class GrafanaPage {
44
44
  }
45
45
  async waitForQueryDataResponse(cb) {
46
46
  return this.ctx.page.waitForResponse((response) => {
47
- if (response.url().includes(this.ctx.selectors.apis.DataSource.query) && response.request().method() === 'POST') {
47
+ if (response.url().includes(this.ctx.selectors.apis.DataSource.query)) {
48
48
  return cb ? cb(response) : true;
49
49
  }
50
50
  return false;
@@ -1,13 +1,18 @@
1
1
  import { Locator } from '@playwright/test';
2
- import { PanelError, PluginTestCtx, RequestOptions, Visualization } from '../types';
2
+ import { DashboardEditViewArgs, NavigateOptions, PanelError, PluginTestCtx, RequestOptions, Visualization } from '../types';
3
3
  import { DataSourcePicker } from './DataSourcePicker';
4
4
  import { GrafanaPage } from './GrafanaPage';
5
5
  import { TimeRange } from './TimeRange';
6
6
  export declare class PanelEditPage extends GrafanaPage implements PanelError {
7
+ readonly ctx: PluginTestCtx;
8
+ readonly args: DashboardEditViewArgs<string>;
7
9
  datasource: DataSourcePicker;
8
10
  timeRange: TimeRange;
9
- constructor(ctx: PluginTestCtx);
11
+ constructor(ctx: PluginTestCtx, args: DashboardEditViewArgs<string>);
12
+ goto(options?: NavigateOptions): Promise<void>;
13
+ setPanelTitle(title: string): Promise<void>;
10
14
  setVisualization(visualization: Visualization): Promise<void>;
15
+ getVisualizationName(): Locator;
11
16
  apply(): Promise<void>;
12
17
  getQueryEditorRow(refId: string): Promise<Locator>;
13
18
  getPanelError(): Locator;
@@ -31,18 +31,45 @@ const GrafanaPage_1 = require("./GrafanaPage");
31
31
  const TimeRange_1 = require("./TimeRange");
32
32
  const ERROR_STATUS = 'error';
33
33
  class PanelEditPage extends GrafanaPage_1.GrafanaPage {
34
+ ctx;
35
+ args;
34
36
  datasource;
35
37
  timeRange;
36
- constructor(ctx) {
38
+ constructor(ctx, args) {
37
39
  super(ctx);
40
+ this.ctx = ctx;
41
+ this.args = args;
38
42
  this.datasource = new DataSourcePicker_1.DataSourcePicker(ctx);
39
43
  this.timeRange = new TimeRange_1.TimeRange(ctx);
40
44
  }
45
+ async goto(options) {
46
+ const url = this.args.dashboard?.uid
47
+ ? this.ctx.selectors.pages.Dashboard.url(this.args.dashboard.uid)
48
+ : this.ctx.selectors.pages.AddDashboard.url;
49
+ options ??= {};
50
+ options.queryParams ??= new URLSearchParams();
51
+ options.queryParams.append('editPanel', this.args.id);
52
+ await super.navigate(url, options);
53
+ }
54
+ async setPanelTitle(title) {
55
+ const { OptionsGroup } = this.ctx.selectors.components;
56
+ const vizInput = await this.getByTestIdOrAriaLabel(OptionsGroup.group(OptionsGroup.groupTitle))
57
+ .locator('input')
58
+ .first();
59
+ const isVisible = await vizInput.isVisible();
60
+ if (!isVisible) {
61
+ await this.getByTestIdOrAriaLabel(OptionsGroup.group(OptionsGroup.groupTitle)).locator('button').click();
62
+ }
63
+ await vizInput.fill(title);
64
+ }
41
65
  async setVisualization(visualization) {
42
66
  await this.getByTestIdOrAriaLabel(this.ctx.selectors.components.PanelEditor.toggleVizPicker).click();
43
67
  await this.getByTestIdOrAriaLabel(this.ctx.selectors.components.PluginVisualization.item(visualization)).click();
44
68
  await (0, test_1.expect)(this.getByTestIdOrAriaLabel(this.ctx.selectors.components.PanelEditor.toggleVizPicker), `Could not set visualization to ${visualization}. Ensure the panel is installed.`).toHaveText(visualization);
45
69
  }
70
+ getVisualizationName() {
71
+ return this.getByTestIdOrAriaLabel(this.ctx.selectors.components.PanelEditor.toggleVizPicker);
72
+ }
46
73
  async apply() {
47
74
  await this.ctx.page.getByTestId(this.ctx.selectors.components.PanelEditor.applyButton).click();
48
75
  }
@@ -1,10 +1,13 @@
1
- import { PluginTestCtx } from '../types';
1
+ import { DashboardEditViewArgs, NavigateOptions, PluginTestCtx } from '../types';
2
2
  import { DataSourcePicker } from './DataSourcePicker';
3
3
  import { GrafanaPage } from './GrafanaPage';
4
4
  export type VariableType = 'Query' | 'Constant' | 'Custom';
5
5
  export declare class VariableEditPage extends GrafanaPage {
6
+ readonly ctx: PluginTestCtx;
7
+ readonly args: DashboardEditViewArgs<string>;
6
8
  datasource: DataSourcePicker;
7
- constructor(ctx: PluginTestCtx);
9
+ constructor(ctx: PluginTestCtx, args: DashboardEditViewArgs<string>);
10
+ goto(options?: NavigateOptions): Promise<void>;
8
11
  setVariableType(type: VariableType): Promise<void>;
9
12
  runQuery(): Promise<void>;
10
13
  }
@@ -5,11 +5,22 @@ const gte = require('semver/functions/gte');
5
5
  const DataSourcePicker_1 = require("./DataSourcePicker");
6
6
  const GrafanaPage_1 = require("./GrafanaPage");
7
7
  class VariableEditPage extends GrafanaPage_1.GrafanaPage {
8
+ ctx;
9
+ args;
8
10
  datasource;
9
- constructor(ctx) {
11
+ constructor(ctx, args) {
10
12
  super(ctx);
13
+ this.ctx = ctx;
14
+ this.args = args;
11
15
  this.datasource = new DataSourcePicker_1.DataSourcePicker(ctx);
12
16
  }
17
+ async goto(options) {
18
+ const { Dashboard, AddDashboard } = this.ctx.selectors.pages;
19
+ const url = this.args.dashboard?.uid
20
+ ? Dashboard.Settings.Variables.Edit.url(this.args.dashboard.uid, this.args.id)
21
+ : AddDashboard.Settings.Variables.Edit.url(this.args.id);
22
+ await super.navigate(url, options);
23
+ }
13
24
  async setVariableType(type) {
14
25
  await this.getByTestIdOrAriaLabel(this.ctx.selectors.pages.Dashboard.Settings.Variables.Edit.General.generalTypeSelectV2)
15
26
  .locator('input')
@@ -1,8 +1,10 @@
1
- import { PluginTestCtx } from '../types';
1
+ import { DashboardPageArgs, NavigateOptions, PluginTestCtx } from '../types';
2
2
  import { GrafanaPage } from './GrafanaPage';
3
3
  import { VariableEditPage } from './VariableEditPage';
4
4
  export declare class VariablePage extends GrafanaPage {
5
- constructor(ctx: PluginTestCtx);
6
- goto(): Promise<void>;
5
+ readonly ctx: PluginTestCtx;
6
+ readonly dashboard?: DashboardPageArgs;
7
+ constructor(ctx: PluginTestCtx, dashboard?: DashboardPageArgs);
8
+ goto(options?: NavigateOptions): Promise<void>;
7
9
  clickAddNew(): Promise<VariableEditPage>;
8
10
  }
@@ -4,25 +4,33 @@ exports.VariablePage = void 0;
4
4
  const GrafanaPage_1 = require("./GrafanaPage");
5
5
  const VariableEditPage_1 = require("./VariableEditPage");
6
6
  class VariablePage extends GrafanaPage_1.GrafanaPage {
7
- constructor(ctx) {
7
+ ctx;
8
+ dashboard;
9
+ constructor(ctx, dashboard) {
8
10
  super(ctx);
11
+ this.ctx = ctx;
12
+ this.dashboard = dashboard;
9
13
  }
10
- async goto() {
11
- await this.ctx.page.goto(this.ctx.selectors.pages.AddDashboard.Settings.Variables.url, {
12
- waitUntil: 'networkidle',
13
- });
14
+ async goto(options) {
15
+ const { Dashboard, AddDashboard } = this.ctx.selectors.pages;
16
+ let url = this.dashboard?.uid
17
+ ? Dashboard.Settings.Variables.List.url(this.dashboard.uid)
18
+ : AddDashboard.Settings.Variables.List.url;
19
+ return super.navigate(url, options);
14
20
  }
15
21
  async clickAddNew() {
16
22
  const { addVariableCTAV2, addVariableCTAV2Item, newButton } = this.ctx.selectors.pages.Dashboard.Settings.Variables.List;
17
- try {
18
- const ctaSelector = this.getByTestIdOrAriaLabel(addVariableCTAV2(addVariableCTAV2Item));
19
- await ctaSelector.waitFor();
20
- await ctaSelector.click();
23
+ if (!this.dashboard?.uid) {
24
+ await this.getByTestIdOrAriaLabel(addVariableCTAV2(addVariableCTAV2Item)).click();
21
25
  }
22
- catch (error) {
26
+ else {
23
27
  await this.getByTestIdOrAriaLabel(newButton).click();
24
28
  }
25
- return new VariableEditPage_1.VariableEditPage(this.ctx);
29
+ const editIndex = await this.ctx.page.evaluate(() => {
30
+ const urlParams = new URLSearchParams(window.location.search);
31
+ return urlParams.get('editIndex');
32
+ });
33
+ return new VariableEditPage_1.VariableEditPage(this.ctx, { dashboard: this.dashboard, id: editIndex || '1' });
26
34
  }
27
35
  }
28
36
  exports.VariablePage = VariablePage;
package/dist/types.d.ts CHANGED
@@ -18,6 +18,10 @@ export interface DataSource<T = any> {
18
18
  jsonData?: T;
19
19
  secureJsonData?: T;
20
20
  }
21
+ export interface Dashboard {
22
+ uid: string;
23
+ title?: string;
24
+ }
21
25
  export type ProvisionFile<T = DataSource> = {
22
26
  datasources: Array<DataSource<T>>;
23
27
  };
@@ -37,11 +41,15 @@ export interface TimeRangeArgs {
37
41
  to: string;
38
42
  zone?: string;
39
43
  }
40
- export type GotoDashboardArgs = {
44
+ export type DashboardPageArgs = {
41
45
  uid?: string;
42
46
  timeRange?: TimeRangeArgs;
43
47
  queryParams?: URLSearchParams;
44
48
  };
49
+ export type DashboardEditViewArgs<T> = {
50
+ dashboard?: DashboardPageArgs;
51
+ id: T;
52
+ };
45
53
  export type ReadProvisionArgs = {
46
54
  filePath: string;
47
55
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grafana/plugin-e2e",
3
- "version": "0.0.3",
3
+ "version": "0.0.4-canary.616.8eb70b7.0",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "files": [
@@ -44,5 +44,5 @@
44
44
  "semver": "^7.5.4",
45
45
  "uuid": "^9.0.1"
46
46
  },
47
- "gitHead": "9089459dfdad8c4bb04abc7adbe38320528a7229"
47
+ "gitHead": "8eb70b7baf34a20a3c35c9b5fd003ca96241e204"
48
48
  }