@grafana/plugin-e2e 1.3.0-canary.930.bdc666d.0 → 1.3.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/auth/auth.setup.js +1 -1
- package/dist/fixtures/commands/createUser.js +4 -4
- package/dist/fixtures/commands/gotoDataSourceConfigPage.js +2 -3
- package/dist/fixtures/commands/login.d.ts +1 -2
- package/dist/fixtures/commands/login.js +3 -5
- package/dist/options.d.ts +2 -1
- package/dist/options.js +4 -4
- package/dist/types.d.ts +7 -20
- package/package.json +2 -2
package/dist/auth/auth.setup.js
CHANGED
|
@@ -13,7 +13,7 @@ const getUserIdByUsername = async (request, userName, grafanaAPIUser) => {
|
|
|
13
13
|
const json = await getUserIdByUserNameReq.json();
|
|
14
14
|
return json.id;
|
|
15
15
|
};
|
|
16
|
-
const createUser = async ({ request, user,
|
|
16
|
+
const createUser = async ({ request, user, grafanaAPICredentials }, use) => {
|
|
17
17
|
await use(async () => {
|
|
18
18
|
if (!user) {
|
|
19
19
|
throw new Error('Playwright option `User` was not provided');
|
|
@@ -24,7 +24,7 @@ const createUser = async ({ request, user, grafanaAPIUser }, use) => {
|
|
|
24
24
|
login: user?.user,
|
|
25
25
|
password: user?.password,
|
|
26
26
|
},
|
|
27
|
-
headers: getHeaders(
|
|
27
|
+
headers: getHeaders(grafanaAPICredentials),
|
|
28
28
|
});
|
|
29
29
|
let userId;
|
|
30
30
|
if (createUserReq.ok()) {
|
|
@@ -33,7 +33,7 @@ const createUser = async ({ request, user, grafanaAPIUser }, use) => {
|
|
|
33
33
|
}
|
|
34
34
|
else if (createUserReq.status() === 412) {
|
|
35
35
|
// user already exists
|
|
36
|
-
userId = await getUserIdByUsername(request, user?.user,
|
|
36
|
+
userId = await getUserIdByUsername(request, user?.user, grafanaAPICredentials);
|
|
37
37
|
}
|
|
38
38
|
else {
|
|
39
39
|
throw new Error(`Could not create user '${user?.user}': ${await createUserReq.text()}`);
|
|
@@ -41,7 +41,7 @@ const createUser = async ({ request, user, grafanaAPIUser }, use) => {
|
|
|
41
41
|
if (user.role) {
|
|
42
42
|
const updateRoleReq = await request.patch(`/api/org/users/${userId}`, {
|
|
43
43
|
data: { role: user.role },
|
|
44
|
-
headers: getHeaders(
|
|
44
|
+
headers: getHeaders(grafanaAPICredentials),
|
|
45
45
|
});
|
|
46
46
|
const updateRoleReqText = await updateRoleReq.text();
|
|
47
47
|
(0, test_1.expect)(updateRoleReq.ok(), `Could not assign role '${user.role}' to user '${user.user}': ${updateRoleReqText}`).toBeTruthy();
|
|
@@ -2,12 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.gotoDataSourceConfigPage = void 0;
|
|
4
4
|
const DataSourceConfigPage_1 = require("../../models/pages/DataSourceConfigPage");
|
|
5
|
-
const gotoDataSourceConfigPage = async ({ request, page, selectors, grafanaVersion,
|
|
5
|
+
const gotoDataSourceConfigPage = async ({ request, page, selectors, grafanaVersion, grafanaAPICredentials }, use, testInfo) => {
|
|
6
6
|
await use(async (uid) => {
|
|
7
7
|
const response = await request.get(`/api/datasources/uid/${uid}`, {
|
|
8
8
|
headers: {
|
|
9
|
-
|
|
10
|
-
Authorization: `Basic ${Buffer.from(`${grafanaAPIUser.user}:${grafanaAPIUser.password}`).toString('base64')}`,
|
|
9
|
+
Authorization: `Basic ${Buffer.from(`${grafanaAPICredentials.user}:${grafanaAPICredentials.password}`).toString('base64')}`,
|
|
11
10
|
},
|
|
12
11
|
});
|
|
13
12
|
if (!response.ok()) {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { TestFixture } from '@playwright/test';
|
|
2
|
-
import { PlaywrightArgs
|
|
2
|
+
import { PlaywrightArgs } from '../../types';
|
|
3
3
|
type LoginFixture = TestFixture<() => Promise<void>, PlaywrightArgs>;
|
|
4
|
-
export declare const DEFAULT_ADMIN_USER: User;
|
|
5
4
|
export declare const login: LoginFixture;
|
|
6
5
|
export {};
|
|
@@ -3,17 +3,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.login =
|
|
6
|
+
exports.login = void 0;
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
8
|
const test_1 = require("@playwright/test");
|
|
9
|
-
exports.DEFAULT_ADMIN_USER = { user: 'admin', password: 'admin' };
|
|
10
9
|
const login = async ({ request, user }, use) => {
|
|
11
10
|
await use(async () => {
|
|
12
|
-
const
|
|
13
|
-
const loginReq = await request.post('/login', { data });
|
|
11
|
+
const loginReq = await request.post('/login', { data: user });
|
|
14
12
|
const text = await loginReq.text();
|
|
15
13
|
test_1.expect.soft(loginReq.ok(), `Could not log in to Grafana: ${text}`).toBeTruthy();
|
|
16
|
-
await request.storageState({ path: path_1.default.join(process.cwd(), `playwright/.auth/${
|
|
14
|
+
await request.storageState({ path: path_1.default.join(process.cwd(), `playwright/.auth/${user?.user}.json`) });
|
|
17
15
|
});
|
|
18
16
|
};
|
|
19
17
|
exports.login = login;
|
package/dist/options.d.ts
CHANGED
package/dist/options.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.options = void 0;
|
|
3
|
+
exports.options = exports.DEFAULT_ADMIN_USER = void 0;
|
|
4
4
|
const path = require("path");
|
|
5
|
-
|
|
5
|
+
exports.DEFAULT_ADMIN_USER = { user: 'admin', password: 'admin' };
|
|
6
6
|
exports.options = {
|
|
7
|
-
user: [undefined, { option: true, scope: 'worker' }],
|
|
8
7
|
featureToggles: [{}, { option: true, scope: 'worker' }],
|
|
9
8
|
provisioningRootDir: [path.join(process.cwd(), 'provisioning'), { option: true, scope: 'worker' }],
|
|
10
|
-
|
|
9
|
+
user: [exports.DEFAULT_ADMIN_USER, { option: true, scope: 'worker' }],
|
|
10
|
+
grafanaAPICredentials: [exports.DEFAULT_ADMIN_USER, { option: true, scope: 'worker' }],
|
|
11
11
|
};
|
package/dist/types.d.ts
CHANGED
|
@@ -51,12 +51,12 @@ export type PluginOptions = {
|
|
|
51
51
|
* You can use different users for different projects. See the fixture createUser for more information on how to create a user,
|
|
52
52
|
* and the fixture login for more information on how to authenticate. Also see https://grafana.com/developers/plugin-tools/e2e-test-a-plugin/use-authentication
|
|
53
53
|
*/
|
|
54
|
-
user?:
|
|
54
|
+
user?: User;
|
|
55
55
|
/**
|
|
56
|
-
* The
|
|
57
|
-
* If no
|
|
56
|
+
* The credentials to use when making requests to the Grafana API. For example when creating users, fetching data sources etc.
|
|
57
|
+
* If no credentials are provided, the server default admin:admin credentials will be used.
|
|
58
58
|
*/
|
|
59
|
-
|
|
59
|
+
grafanaAPICredentials: Credentials;
|
|
60
60
|
};
|
|
61
61
|
export type PluginFixture = {
|
|
62
62
|
/**
|
|
@@ -265,32 +265,19 @@ export interface Dashboard {
|
|
|
265
265
|
uid: string;
|
|
266
266
|
title?: string;
|
|
267
267
|
}
|
|
268
|
-
export type
|
|
268
|
+
export type User = {
|
|
269
269
|
/**
|
|
270
|
-
* The username of the user
|
|
270
|
+
* The username of the user
|
|
271
271
|
*/
|
|
272
272
|
user: string;
|
|
273
|
-
/**
|
|
274
|
-
* The password of the user to create
|
|
275
|
-
*/
|
|
276
273
|
password: string;
|
|
277
|
-
/**
|
|
278
|
-
* The role of the user to create
|
|
279
|
-
*/
|
|
280
274
|
role?: OrgRole;
|
|
281
|
-
/**
|
|
282
|
-
* Set this to true if the user already exist in the database. If omitted or set to false, the user will be created.
|
|
283
|
-
*/
|
|
284
|
-
skipCreateUser?: boolean;
|
|
285
275
|
};
|
|
286
|
-
export type
|
|
276
|
+
export type Credentials = {
|
|
287
277
|
/**
|
|
288
278
|
* The username of the user
|
|
289
279
|
*/
|
|
290
280
|
user: string;
|
|
291
|
-
/**
|
|
292
|
-
* The passwords
|
|
293
|
-
*/
|
|
294
281
|
password: string;
|
|
295
282
|
};
|
|
296
283
|
export type CreateDataSourceArgs<T = any> = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@grafana/plugin-e2e",
|
|
3
|
-
"version": "1.3.0
|
|
3
|
+
"version": "1.3.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": "
|
|
58
|
+
"gitHead": "07e8e88ac5f4a64474a011620c9b2e740ce7b64c"
|
|
59
59
|
}
|