@grafana/plugin-e2e 1.10.0 → 1.11.0-canary.1123.bad6246.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/fixtures/selectors.d.ts +2 -3
- package/dist/fixtures/selectors.js +9 -9
- package/dist/index.d.ts +0 -2
- package/dist/index.js +1 -3
- package/dist/models/pages/AnnotationEditPage.js +1 -1
- package/dist/models/pages/AnnotationPage.js +2 -8
- package/dist/models/pages/DashboardPage.js +2 -2
- package/dist/models/pages/ExplorePage.js +2 -1
- package/dist/models/pages/PanelEditPage.js +4 -3
- package/dist/models/pages/VariableEditPage.js +1 -1
- package/dist/models/pages/VariablePage.js +2 -2
- package/dist/{e2e-selectors/versioned/apis.d.ts → selectors/versionedAPIs.d.ts} +2 -1
- package/dist/selectors/versionedAPIs.js +47 -0
- package/dist/selectors/versionedConstants.d.ts +9 -0
- package/dist/selectors/versionedConstants.js +12 -0
- package/dist/types.d.ts +11 -3
- package/package.json +4 -3
- package/dist/e2e-selectors/index.d.ts +0 -2
- package/dist/e2e-selectors/index.js +0 -20
- package/dist/e2e-selectors/resolver.d.ts +0 -10
- package/dist/e2e-selectors/resolver.js +0 -50
- package/dist/e2e-selectors/resolver.test.d.ts +0 -1
- package/dist/e2e-selectors/resolver.test.js +0 -34
- package/dist/e2e-selectors/types.d.ts +0 -255
- package/dist/e2e-selectors/types.js +0 -2
- package/dist/e2e-selectors/versioned/apis.js +0 -47
- package/dist/e2e-selectors/versioned/components.d.ts +0 -288
- package/dist/e2e-selectors/versioned/components.js +0 -271
- package/dist/e2e-selectors/versioned/index.d.ts +0 -2
- package/dist/e2e-selectors/versioned/index.js +0 -7
- package/dist/e2e-selectors/versioned/pages.d.ts +0 -186
- package/dist/e2e-selectors/versioned/pages.js +0 -190
- package/dist/e2e-selectors/versioned/types.d.ts +0 -8
- package/dist/e2e-selectors/versioned/types.js +0 -2
- /package/dist/{e2e-selectors/versioned/constants.d.ts → selectors/minGrafanaVersion.d.ts} +0 -0
- /package/dist/{e2e-selectors/versioned/constants.js → selectors/minGrafanaVersion.js} +0 -0
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { TestFixture } from '@playwright/test';
|
|
2
|
-
import { PlaywrightArgs } from '../types';
|
|
3
|
-
|
|
4
|
-
type SelectorFixture = TestFixture<E2ESelectors, PlaywrightArgs>;
|
|
2
|
+
import { E2ESelectorGroups, PlaywrightArgs } from '../types';
|
|
3
|
+
type SelectorFixture = TestFixture<E2ESelectorGroups, PlaywrightArgs>;
|
|
5
4
|
export declare const selectors: SelectorFixture;
|
|
6
5
|
export {};
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.selectors = void 0;
|
|
4
|
-
const e2e_selectors_1 = require("
|
|
5
|
-
const
|
|
6
|
-
const
|
|
4
|
+
const e2e_selectors_1 = require("@grafana/e2e-selectors");
|
|
5
|
+
const versionedConstants_1 = require("../selectors/versionedConstants");
|
|
6
|
+
const versionedAPIs_1 = require("../selectors/versionedAPIs");
|
|
7
7
|
const selectors = async ({ grafanaVersion }, use) => {
|
|
8
|
-
|
|
9
|
-
components:
|
|
10
|
-
pages:
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
await use({
|
|
9
|
+
components: (0, e2e_selectors_1.resolveSelectors)(e2e_selectors_1.versionedComponents, grafanaVersion),
|
|
10
|
+
pages: (0, e2e_selectors_1.resolveSelectors)(e2e_selectors_1.versionedPages, grafanaVersion),
|
|
11
|
+
constants: (0, e2e_selectors_1.resolveSelectors)(versionedConstants_1.versionedConstants, grafanaVersion),
|
|
12
|
+
apis: (0, e2e_selectors_1.resolveSelectors)(versionedAPIs_1.versionedAPIs, grafanaVersion),
|
|
13
|
+
});
|
|
14
14
|
};
|
|
15
15
|
exports.selectors = selectors;
|
package/dist/index.d.ts
CHANGED
|
@@ -16,8 +16,6 @@ export { VariablePage } from './models/pages/VariablePage';
|
|
|
16
16
|
export { AppConfigPage } from './models/pages/AppConfigPage';
|
|
17
17
|
export { PluginConfigPage } from './models/pages/PluginConfigPage';
|
|
18
18
|
export { AppPage } from './models/pages/AppPage';
|
|
19
|
-
export { Components, Pages, APIs, E2ESelectors } from './e2e-selectors/types';
|
|
20
|
-
export { resolveSelectors } from './e2e-selectors/resolver';
|
|
21
19
|
export * from './types';
|
|
22
20
|
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>;
|
|
23
21
|
export declare const expect: import("@playwright/test").Expect<{
|
package/dist/index.js
CHANGED
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.selectors = exports.expect = exports.test = exports.
|
|
17
|
+
exports.selectors = exports.expect = exports.test = exports.AppPage = exports.PluginConfigPage = exports.AppConfigPage = exports.VariablePage = exports.VariableEditPage = exports.PanelEditPage = exports.GrafanaPage = exports.ExplorePage = exports.DataSourceConfigPage = exports.DashboardPage = exports.AnnotationPage = exports.AnnotationEditPage = exports.TimeRange = exports.Panel = exports.DataSourcePicker = void 0;
|
|
18
18
|
const test_1 = require("@playwright/test");
|
|
19
19
|
const annotationEditPage_1 = require("./fixtures/annotationEditPage");
|
|
20
20
|
const grafanaAPIClient_1 = require("./fixtures/grafanaAPIClient");
|
|
@@ -79,8 +79,6 @@ var PluginConfigPage_1 = require("./models/pages/PluginConfigPage");
|
|
|
79
79
|
Object.defineProperty(exports, "PluginConfigPage", { enumerable: true, get: function () { return PluginConfigPage_1.PluginConfigPage; } });
|
|
80
80
|
var AppPage_1 = require("./models/pages/AppPage");
|
|
81
81
|
Object.defineProperty(exports, "AppPage", { enumerable: true, get: function () { return AppPage_1.AppPage; } });
|
|
82
|
-
var resolver_1 = require("./e2e-selectors/resolver");
|
|
83
|
-
Object.defineProperty(exports, "resolveSelectors", { enumerable: true, get: function () { return resolver_1.resolveSelectors; } });
|
|
84
82
|
// types
|
|
85
83
|
__exportStar(require("./types"), exports);
|
|
86
84
|
exports.test = test_1.test.extend({
|
|
@@ -43,7 +43,7 @@ class AnnotationEditPage extends GrafanaPage_1.GrafanaPage {
|
|
|
43
43
|
async goto(options) {
|
|
44
44
|
const { Dashboard, AddDashboard } = this.ctx.selectors.pages;
|
|
45
45
|
const url = this.args.dashboard?.uid
|
|
46
|
-
? Dashboard.
|
|
46
|
+
? `${Dashboard.url(this.args.dashboard.uid)}?${Dashboard.Settings.Annotations.Edit.urlParams(this.args.id)}`
|
|
47
47
|
: AddDashboard.Settings.Annotations.Edit.url(this.args.id);
|
|
48
48
|
await super.navigate(url, options);
|
|
49
49
|
// In versions before 9.2.0, the annotation index is not part of the URL so there's no way to navigate to it directly.
|
|
@@ -49,15 +49,9 @@ class AnnotationPage extends GrafanaPage_1.GrafanaPage {
|
|
|
49
49
|
* Clicks the add new annotation button and returns the annotation edit page
|
|
50
50
|
*/
|
|
51
51
|
async clickAddNew() {
|
|
52
|
-
const { addAnnotationCTAV2
|
|
52
|
+
const { addAnnotationCTAV2 } = this.ctx.selectors.pages.Dashboard.Settings.Annotations.List;
|
|
53
53
|
if (!this.dashboard?.uid) {
|
|
54
|
-
|
|
55
|
-
if (semver.gte(this.ctx.grafanaVersion, '8.3.0')) {
|
|
56
|
-
await this.getByGrafanaSelector(addAnnotationCTAV2).click();
|
|
57
|
-
}
|
|
58
|
-
else {
|
|
59
|
-
await this.getByGrafanaSelector(addAnnotationCTA).click();
|
|
60
|
-
}
|
|
54
|
+
await this.getByGrafanaSelector(addAnnotationCTAV2).click();
|
|
61
55
|
}
|
|
62
56
|
else {
|
|
63
57
|
//the dashboard already has annotations
|
|
@@ -97,13 +97,13 @@ class DashboardPage extends GrafanaPage_1.GrafanaPage {
|
|
|
97
97
|
* Clicks the buttons to add a new panel and returns the panel edit page for the new panel
|
|
98
98
|
*/
|
|
99
99
|
async addPanel() {
|
|
100
|
-
const { components, pages } = this.ctx.selectors;
|
|
100
|
+
const { components, pages, constants } = this.ctx.selectors;
|
|
101
101
|
// From Grafana 11.3.0, one needs to click the edit button before adding a new panel in already existing dashboards
|
|
102
102
|
if (semver.gte(this.ctx.grafanaVersion, '11.3.0') && this.dashboard?.uid) {
|
|
103
103
|
await this.getByGrafanaSelector(components.NavToolbar.editDashboard.editButton).click();
|
|
104
104
|
}
|
|
105
105
|
if (semver.gte(this.ctx.grafanaVersion, '10.0.0')) {
|
|
106
|
-
await this.getByGrafanaSelector(components.PageToolbar.itemButton(
|
|
106
|
+
await this.getByGrafanaSelector(components.PageToolbar.itemButton(constants.PageToolBar.itemButtonTitle)).click();
|
|
107
107
|
await this.getByGrafanaSelector(pages.AddDashboard.itemButton(pages.AddDashboard.itemButtonAddViz)).click();
|
|
108
108
|
}
|
|
109
109
|
else {
|
|
@@ -88,7 +88,8 @@ class ExplorePage extends GrafanaPage_1.GrafanaPage {
|
|
|
88
88
|
}
|
|
89
89
|
catch (_) {
|
|
90
90
|
// handle the case when the run button is hidden behind the "Show more items" button
|
|
91
|
-
|
|
91
|
+
const toolbarText = 'Show more items';
|
|
92
|
+
await this.getByGrafanaSelector(components.PageToolbar.item(toolbarText)).click();
|
|
92
93
|
await this.getByGrafanaSelector(components.RefreshPicker.runButtonV2).last().click();
|
|
93
94
|
}
|
|
94
95
|
return responsePromise;
|
|
@@ -71,7 +71,7 @@ class PanelEditPage extends GrafanaPage_1.GrafanaPage {
|
|
|
71
71
|
}
|
|
72
72
|
async toggleTableView() {
|
|
73
73
|
await (0, utils_1.radioButtonSetChecked)(this.ctx.page, 'Table view', true);
|
|
74
|
-
let locator = this.getByGrafanaSelector(this.ctx.selectors.components.Panels.Panel.
|
|
74
|
+
let locator = this.getByGrafanaSelector(this.ctx.selectors.components.Panels.Panel.title(''));
|
|
75
75
|
if (semver.lt(this.ctx.grafanaVersion, '10.4.0')) {
|
|
76
76
|
locator = this.ctx.page.getByRole('table');
|
|
77
77
|
}
|
|
@@ -87,10 +87,11 @@ class PanelEditPage extends GrafanaPage_1.GrafanaPage {
|
|
|
87
87
|
async setPanelTitle(titleText) {
|
|
88
88
|
const TITLE = 'Title';
|
|
89
89
|
const { OptionsGroup, PanelEditor } = this.ctx.selectors.components;
|
|
90
|
-
|
|
90
|
+
const sectionGroupTitle = 'Panel options';
|
|
91
|
+
await this.collapseSection(sectionGroupTitle);
|
|
91
92
|
const vizInput = semver.gte(this.ctx.grafanaVersion, '11.0.0')
|
|
92
93
|
? this.getByGrafanaSelector(PanelEditor.OptionsPane.fieldInput(TITLE))
|
|
93
|
-
: this.getByGrafanaSelector(OptionsGroup.group(
|
|
94
|
+
: this.getByGrafanaSelector(OptionsGroup.group(sectionGroupTitle)).locator('input').first();
|
|
94
95
|
await vizInput.fill(titleText);
|
|
95
96
|
await this.ctx.page.keyboard.press('Tab');
|
|
96
97
|
}
|
|
@@ -43,7 +43,7 @@ class VariableEditPage extends GrafanaPage_1.GrafanaPage {
|
|
|
43
43
|
async goto(options) {
|
|
44
44
|
const { Dashboard, AddDashboard } = this.ctx.selectors.pages;
|
|
45
45
|
const url = this.args.dashboard?.uid
|
|
46
|
-
? Dashboard.
|
|
46
|
+
? `${Dashboard.url(this.args.dashboard.uid)}?${Dashboard.Settings.Variables.Edit.urlParams(this.args.id)}`
|
|
47
47
|
: AddDashboard.Settings.Variables.Edit.url(this.args.id);
|
|
48
48
|
await super.navigate(url, options);
|
|
49
49
|
// In versions before 9.2.0, the variable index is not part of the URL so there's no way to navigate to it directly.
|
|
@@ -25,9 +25,9 @@ class VariablePage extends GrafanaPage_1.GrafanaPage {
|
|
|
25
25
|
* Clicks the add new variable button and returns the variable edit page
|
|
26
26
|
*/
|
|
27
27
|
async clickAddNew() {
|
|
28
|
-
const { addVariableCTAV2,
|
|
28
|
+
const { addVariableCTAV2, newButton } = this.ctx.selectors.pages.Dashboard.Settings.Variables.List;
|
|
29
29
|
if (!this.dashboard?.uid) {
|
|
30
|
-
await this.getByGrafanaSelector(addVariableCTAV2
|
|
30
|
+
await this.getByGrafanaSelector(addVariableCTAV2).click();
|
|
31
31
|
}
|
|
32
32
|
else {
|
|
33
33
|
await this.getByGrafanaSelector(newButton).click();
|
|
@@ -19,7 +19,7 @@ export declare const versionedAPIs: {
|
|
|
19
19
|
"8.0.0": string;
|
|
20
20
|
};
|
|
21
21
|
health: {
|
|
22
|
-
|
|
22
|
+
'9.5.0': (uid: string, _: string) => string;
|
|
23
23
|
"8.0.0": (_: string, id: string) => string;
|
|
24
24
|
};
|
|
25
25
|
datasourceByUID: {
|
|
@@ -41,3 +41,4 @@ export declare const versionedAPIs: {
|
|
|
41
41
|
};
|
|
42
42
|
};
|
|
43
43
|
};
|
|
44
|
+
export type VersionedAPIs = typeof versionedAPIs;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.versionedAPIs = void 0;
|
|
4
|
+
const minGrafanaVersion_1 = require("./minGrafanaVersion");
|
|
5
|
+
exports.versionedAPIs = {
|
|
6
|
+
Alerting: {
|
|
7
|
+
eval: {
|
|
8
|
+
[minGrafanaVersion_1.MIN_GRAFANA_VERSION]: '/api/v1/eval',
|
|
9
|
+
},
|
|
10
|
+
},
|
|
11
|
+
DataSource: {
|
|
12
|
+
resourcePattern: {
|
|
13
|
+
[minGrafanaVersion_1.MIN_GRAFANA_VERSION]: '/api/datasources/*/resources',
|
|
14
|
+
},
|
|
15
|
+
resourceUIDPattern: {
|
|
16
|
+
'9.4.4': '/api/datasources/uid/*/resources',
|
|
17
|
+
[minGrafanaVersion_1.MIN_GRAFANA_VERSION]: '/api/datasources/*/resources',
|
|
18
|
+
},
|
|
19
|
+
queryPattern: {
|
|
20
|
+
[minGrafanaVersion_1.MIN_GRAFANA_VERSION]: '*/**/api/ds/query*',
|
|
21
|
+
},
|
|
22
|
+
query: {
|
|
23
|
+
[minGrafanaVersion_1.MIN_GRAFANA_VERSION]: '/api/ds/query',
|
|
24
|
+
},
|
|
25
|
+
health: {
|
|
26
|
+
'9.5.0': (uid, _) => `/api/datasources/uid/${uid}/health`,
|
|
27
|
+
[minGrafanaVersion_1.MIN_GRAFANA_VERSION]: (_, id) => `/api/datasources/${id}/health`,
|
|
28
|
+
},
|
|
29
|
+
datasourceByUID: {
|
|
30
|
+
[minGrafanaVersion_1.MIN_GRAFANA_VERSION]: (uid) => `/api/datasources/uid/${uid}`,
|
|
31
|
+
},
|
|
32
|
+
proxy: {
|
|
33
|
+
'9.4.0': (uid, _) => `api/datasources/proxy/uid/${uid}`,
|
|
34
|
+
[minGrafanaVersion_1.MIN_GRAFANA_VERSION]: (_, id) => `/api/datasources/proxy/${id}`,
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
Dashboard: {
|
|
38
|
+
delete: {
|
|
39
|
+
[minGrafanaVersion_1.MIN_GRAFANA_VERSION]: (uid) => `/api/dashboards/uid/${uid}`,
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
Plugin: {
|
|
43
|
+
settings: {
|
|
44
|
+
[minGrafanaVersion_1.MIN_GRAFANA_VERSION]: (pluginId) => `/api/plugins/${pluginId}/settings`,
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.versionedConstants = void 0;
|
|
4
|
+
const minGrafanaVersion_1 = require("./minGrafanaVersion");
|
|
5
|
+
exports.versionedConstants = {
|
|
6
|
+
PageToolBar: {
|
|
7
|
+
itemButtonTitle: {
|
|
8
|
+
'10.1.0': 'Add button',
|
|
9
|
+
[minGrafanaVersion_1.MIN_GRAFANA_VERSION]: 'Add panel button',
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
};
|
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Locator, PlaywrightTestArgs, PlaywrightTestOptions, PlaywrightWorkerArgs, PlaywrightWorkerOptions, Response, TestInfo } from '@playwright/test';
|
|
2
|
-
import { E2ESelectors } from './e2e-selectors/types';
|
|
3
2
|
import { AnnotationEditPage } from './models/pages/AnnotationEditPage';
|
|
4
3
|
import { AppConfigPage } from './models/pages/AppConfigPage';
|
|
5
4
|
import { AppPage } from './models/pages/AppPage';
|
|
@@ -11,6 +10,9 @@ import { VariableEditPage } from './models/pages/VariableEditPage';
|
|
|
11
10
|
import { VariablePage } from './models/pages/VariablePage';
|
|
12
11
|
import { AlertRuleEditPage } from './models/pages/AlertRuleEditPage';
|
|
13
12
|
import { GrafanaAPIClient } from './models/GrafanaAPIClient';
|
|
13
|
+
import { versionedPages, versionedComponents, SelectorsOf } from '@grafana/e2e-selectors';
|
|
14
|
+
import { VersionedAPIs } from './selectors/versionedAPIs';
|
|
15
|
+
import { VersionedConstants } from './selectors/versionedConstants';
|
|
14
16
|
export type PluginOptions = {
|
|
15
17
|
/**
|
|
16
18
|
* When using the readProvisioning fixture, files will be read from this directory. If no directory is provided,
|
|
@@ -73,7 +75,7 @@ export type PluginFixture = {
|
|
|
73
75
|
* The E2E selectors to use for the current version of Grafana.
|
|
74
76
|
* See https://grafana.com/developers/plugin-tools/e2e-test-a-plugin/selecting-elements#grafana-end-to-end-selectors for more information.
|
|
75
77
|
*/
|
|
76
|
-
selectors:
|
|
78
|
+
selectors: E2ESelectorGroups;
|
|
77
79
|
/**
|
|
78
80
|
* Fixture command that creates a data source via the Grafana API.
|
|
79
81
|
*
|
|
@@ -280,7 +282,7 @@ export type PluginFixture = {
|
|
|
280
282
|
*/
|
|
281
283
|
export type PluginTestCtx = {
|
|
282
284
|
grafanaVersion: string;
|
|
283
|
-
selectors:
|
|
285
|
+
selectors: E2ESelectorGroups;
|
|
284
286
|
testInfo: TestInfo;
|
|
285
287
|
} & Pick<PlaywrightTestArgs, 'page' | 'request'>;
|
|
286
288
|
/**
|
|
@@ -563,3 +565,9 @@ export type OrgRole = 'None' | 'Viewer' | 'Editor' | 'Admin';
|
|
|
563
565
|
*/
|
|
564
566
|
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';
|
|
565
567
|
export type AlertVariant = 'success' | 'warning' | 'error' | 'info';
|
|
568
|
+
export type E2ESelectorGroups = {
|
|
569
|
+
constants: SelectorsOf<VersionedConstants>;
|
|
570
|
+
apis: SelectorsOf<VersionedAPIs>;
|
|
571
|
+
pages: SelectorsOf<typeof versionedPages>;
|
|
572
|
+
components: SelectorsOf<typeof versionedComponents>;
|
|
573
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@grafana/plugin-e2e",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.11.0-canary.1123.bad6246.0",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"lint:fix": "npm run lint -- --fix",
|
|
27
27
|
"server": "docker compose up --build",
|
|
28
28
|
"typecheck": "tsc --emitDeclarationOnly false --noEmit",
|
|
29
|
-
"test": "vitest",
|
|
29
|
+
"test": "vitest --passWithNoTests",
|
|
30
30
|
"playwright:test": "npx playwright test --grep-invert @integration",
|
|
31
31
|
"playwright:test:integration": "npx playwright test --grep @integration",
|
|
32
32
|
"playwright:all": "npx playwright test"
|
|
@@ -43,6 +43,7 @@
|
|
|
43
43
|
"dotenv": "^16.3.1"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
+
"@grafana/e2e-selectors": "^11.4.0-204289",
|
|
46
47
|
"semver": "^7.5.4",
|
|
47
48
|
"uuid": "^10.0.0",
|
|
48
49
|
"yaml": "^2.3.4"
|
|
@@ -56,5 +57,5 @@
|
|
|
56
57
|
"start": "cls || clear"
|
|
57
58
|
}
|
|
58
59
|
},
|
|
59
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "bad6246b41de1f145003fbecf6350e533ff12242"
|
|
60
61
|
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.resolveSelectors = void 0;
|
|
18
|
-
var resolver_1 = require("./resolver");
|
|
19
|
-
Object.defineProperty(exports, "resolveSelectors", { enumerable: true, get: function () { return resolver_1.resolveSelectors; } });
|
|
20
|
-
__exportStar(require("./types"), exports);
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { E2ESelectors } from './types';
|
|
2
|
-
import { VersionedSelectors } from './versioned/types';
|
|
3
|
-
/**
|
|
4
|
-
* Resolves selectors based on the Grafana version
|
|
5
|
-
*
|
|
6
|
-
* If the selector has multiple versions, the last version that is less
|
|
7
|
-
* than or equal to the Grafana version will be returned.
|
|
8
|
-
* If the selector doesn't have a version, it will be returned as is.
|
|
9
|
-
*/
|
|
10
|
-
export declare const resolveSelectors: (versionedSelectors: VersionedSelectors, grafanaVersion: string) => E2ESelectors;
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resolveSelectors = void 0;
|
|
4
|
-
const semver = require('semver');
|
|
5
|
-
const processSelectors = (selectors, versionedSelectors, grafanaVersion) => {
|
|
6
|
-
const keys = Object.keys(versionedSelectors);
|
|
7
|
-
for (let index = 0; index < keys.length; index++) {
|
|
8
|
-
const key = keys[index];
|
|
9
|
-
// @ts-ignore
|
|
10
|
-
const value = versionedSelectors[key];
|
|
11
|
-
if (typeof value === 'object' && Object.keys(value).length > 0 && !semver.valid(Object.keys(value)[0])) {
|
|
12
|
-
// @ts-ignore
|
|
13
|
-
selectors[key] = processSelectors({}, value, grafanaVersion);
|
|
14
|
-
}
|
|
15
|
-
else {
|
|
16
|
-
if (typeof value === 'object' && Object.keys(value).length > 0 && semver.valid(Object.keys(value)[0])) {
|
|
17
|
-
// @ts-ignore
|
|
18
|
-
const sorted = Object.keys(value).sort(semver.rcompare);
|
|
19
|
-
let validVersion = sorted[0];
|
|
20
|
-
for (let index = 0; index < sorted.length; index++) {
|
|
21
|
-
const version = sorted[index];
|
|
22
|
-
if (semver.gte(grafanaVersion, version)) {
|
|
23
|
-
validVersion = version;
|
|
24
|
-
break;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
// @ts-ignore
|
|
28
|
-
selectors[key] = value[validVersion];
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
// @ts-ignore
|
|
32
|
-
selectors[key] = value;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
continue;
|
|
36
|
-
}
|
|
37
|
-
return selectors;
|
|
38
|
-
};
|
|
39
|
-
/**
|
|
40
|
-
* Resolves selectors based on the Grafana version
|
|
41
|
-
*
|
|
42
|
-
* If the selector has multiple versions, the last version that is less
|
|
43
|
-
* than or equal to the Grafana version will be returned.
|
|
44
|
-
* If the selector doesn't have a version, it will be returned as is.
|
|
45
|
-
*/
|
|
46
|
-
const resolveSelectors = (versionedSelectors, grafanaVersion) => {
|
|
47
|
-
const selectors = {};
|
|
48
|
-
return processSelectors(selectors, versionedSelectors, grafanaVersion.replace(/\-.*/, ''));
|
|
49
|
-
};
|
|
50
|
-
exports.resolveSelectors = resolveSelectors;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const resolver_1 = require("./resolver");
|
|
4
|
-
const versioned_1 = require("./versioned");
|
|
5
|
-
const apis_1 = require("./versioned/apis");
|
|
6
|
-
const constants_1 = require("./versioned/constants");
|
|
7
|
-
let versionedSelectors = {
|
|
8
|
-
components: versioned_1.versionedComponents,
|
|
9
|
-
pages: versioned_1.versionedPages,
|
|
10
|
-
apis: apis_1.versionedAPIs,
|
|
11
|
-
};
|
|
12
|
-
const originalVersionedSelectors = versionedSelectors;
|
|
13
|
-
describe('resolveSelectors', () => {
|
|
14
|
-
afterEach(() => {
|
|
15
|
-
versionedSelectors = originalVersionedSelectors;
|
|
16
|
-
});
|
|
17
|
-
test('returns the right selector value when it has multiple versions', () => {
|
|
18
|
-
versionedSelectors.components.CodeEditor.container = {
|
|
19
|
-
'10.2.3': 'data-testid Code editor container',
|
|
20
|
-
[constants_1.MIN_GRAFANA_VERSION]: 'Code editor container',
|
|
21
|
-
};
|
|
22
|
-
// semver great than
|
|
23
|
-
let selectors = (0, resolver_1.resolveSelectors)(versionedSelectors, '10.4.0');
|
|
24
|
-
expect(selectors.components.CodeEditor.container).toBe('data-testid Code editor container');
|
|
25
|
-
// semver equals to
|
|
26
|
-
selectors = (0, resolver_1.resolveSelectors)(versionedSelectors, '10.3.0');
|
|
27
|
-
expect(selectors.components.CodeEditor.container).toBe('data-testid Code editor container');
|
|
28
|
-
// semver equals to when using pre-release
|
|
29
|
-
selectors = (0, resolver_1.resolveSelectors)(versionedSelectors, '10.3.0-pre');
|
|
30
|
-
expect(selectors.components.CodeEditor.container).toBe('data-testid Code editor container');
|
|
31
|
-
selectors = (0, resolver_1.resolveSelectors)(versionedSelectors, '9.2.0');
|
|
32
|
-
expect(selectors.components.CodeEditor.container).toBe('Code editor container');
|
|
33
|
-
});
|
|
34
|
-
});
|