@grafana/plugin-e2e 0.12.0 → 0.12.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api.d.ts +178 -0
- package/dist/auth/auth.setup.d.ts +1 -0
- package/dist/e2e-selectors/index.d.ts +2 -0
- package/dist/e2e-selectors/resolver.d.ts +10 -0
- package/dist/e2e-selectors/resolver.test.d.ts +1 -0
- package/dist/e2e-selectors/types.d.ts +174 -0
- package/dist/e2e-selectors/versioned/apis.d.ts +29 -0
- package/dist/e2e-selectors/versioned/components.d.ts +154 -0
- package/dist/e2e-selectors/versioned/constants.d.ts +1 -0
- package/dist/e2e-selectors/versioned/index.d.ts +2 -0
- package/dist/e2e-selectors/versioned/pages.d.ts +125 -0
- package/dist/e2e-selectors/versioned/types.d.ts +8 -0
- package/dist/fixtures/annotationEditPage.d.ts +7 -0
- package/dist/fixtures/commands/createDataSource.d.ts +8 -0
- package/dist/fixtures/commands/createDataSourceConfigPage.d.ts +8 -0
- package/dist/fixtures/commands/login.d.ts +6 -0
- package/dist/fixtures/commands/readProvision.d.ts +7 -0
- package/dist/fixtures/explorePage.d.ts +7 -0
- package/dist/fixtures/grafanaVersion.d.ts +4 -0
- package/dist/fixtures/index.d.ts +16 -0
- package/dist/fixtures/isFeatureToggleEnabled.d.ts +6 -0
- package/dist/fixtures/newDashboardPage.d.ts +7 -0
- package/dist/fixtures/page.d.ts +17 -0
- package/dist/fixtures/panelEditPage.d.ts +7 -0
- package/dist/fixtures/scripts/overrideFeatureToggles.d.ts +1 -0
- package/dist/fixtures/scripts/overrideFeatureToggles.js +3 -3
- package/dist/fixtures/selectors.d.ts +7 -0
- package/dist/fixtures/types.d.ts +2 -0
- package/dist/fixtures/variableEditPage.d.ts +7 -0
- package/dist/index.d.ts +35 -0
- package/dist/matchers/index.d.ts +25 -0
- package/dist/matchers/toBeOK.d.ts +11 -0
- package/dist/matchers/toDisplayPreviews.d.ts +12 -0
- package/dist/matchers/toHaveAlert.d.ts +8 -0
- package/dist/matchers/utils.d.ts +1 -0
- package/dist/models/AnnotationEditPage.d.ts +18 -0
- package/dist/models/AnnotationPage.d.ts +16 -0
- package/dist/models/DashboardPage.d.ts +33 -0
- package/dist/models/DataSourceConfigPage.d.ts +23 -0
- package/dist/models/DataSourcePicker.d.ts +9 -0
- package/dist/models/ExplorePage.d.ts +26 -0
- package/dist/models/GrafanaPage.d.ts +43 -0
- package/dist/models/Panel.d.ts +12 -0
- package/dist/models/PanelEditPage.d.ts +55 -0
- package/dist/models/TimeRange.d.ts +9 -0
- package/dist/models/VariableEditPage.d.ts +26 -0
- package/dist/models/VariablePage.d.ts +16 -0
- package/dist/models/index.d.ts +8 -0
- package/dist/options/index.d.ts +4 -0
- package/dist/selectorEngine.d.ts +7 -0
- package/dist/types.d.ts +228 -0
- package/package.json +2 -2
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { TestFixture } from '@playwright/test';
|
|
2
|
+
import { PluginFixture, PluginOptions } from '../api';
|
|
3
|
+
import { AnnotationEditPage } from '../models';
|
|
4
|
+
import { PlaywrightCombinedArgs } from './types';
|
|
5
|
+
type AnnotationEditPageFixture = TestFixture<AnnotationEditPage, PluginFixture & PluginOptions & PlaywrightCombinedArgs>;
|
|
6
|
+
declare const annotationEditPage: AnnotationEditPageFixture;
|
|
7
|
+
export default annotationEditPage;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { APIRequestContext, TestFixture } from '@playwright/test';
|
|
2
|
+
import { PluginFixture, PluginOptions } from '../../api';
|
|
3
|
+
import { CreateDataSourceArgs, DataSource } from '../../types';
|
|
4
|
+
import { PlaywrightCombinedArgs } from '../types';
|
|
5
|
+
type CreateDataSourceViaAPIFixture = TestFixture<(args: CreateDataSourceArgs) => Promise<DataSource>, PluginFixture & PluginOptions & PlaywrightCombinedArgs>;
|
|
6
|
+
export declare const createDataSourceViaAPI: (request: APIRequestContext, datasource: CreateDataSourceArgs) => Promise<DataSource>;
|
|
7
|
+
declare const createDataSource: CreateDataSourceViaAPIFixture;
|
|
8
|
+
export default createDataSource;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { TestFixture } from '@playwright/test';
|
|
2
|
+
import { PluginFixture, PluginOptions } from '../../api';
|
|
3
|
+
import { CreateDataSourcePageArgs } from '../../types';
|
|
4
|
+
import { PlaywrightCombinedArgs } from '../types';
|
|
5
|
+
import { DataSourceConfigPage } from '../../models';
|
|
6
|
+
type CreateDataSourceConfigPageFixture = TestFixture<(args: CreateDataSourcePageArgs) => Promise<DataSourceConfigPage>, PluginFixture & PluginOptions & PlaywrightCombinedArgs>;
|
|
7
|
+
declare const createDataSourceConfigPage: CreateDataSourceConfigPageFixture;
|
|
8
|
+
export default createDataSourceConfigPage;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { TestFixture } from '@playwright/test';
|
|
2
|
+
import { PluginFixture, PluginOptions } from '../../api';
|
|
3
|
+
import { PlaywrightCombinedArgs } from '../types';
|
|
4
|
+
type LoginFixture = TestFixture<() => Promise<void>, PluginFixture & PluginOptions & PlaywrightCombinedArgs>;
|
|
5
|
+
declare const login: LoginFixture;
|
|
6
|
+
export default login;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { TestFixture } from '@playwright/test';
|
|
2
|
+
import { PluginFixture, PluginOptions } from '../../api';
|
|
3
|
+
import { ReadProvisionArgs } from '../../types';
|
|
4
|
+
import { PlaywrightCombinedArgs } from '../types';
|
|
5
|
+
type ReadProvisionFixture = TestFixture<(<T = any>(args: ReadProvisionArgs) => Promise<T>), PluginFixture & PluginOptions & PlaywrightCombinedArgs>;
|
|
6
|
+
declare const readProvision: ReadProvisionFixture;
|
|
7
|
+
export default readProvision;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { TestFixture } from '@playwright/test';
|
|
2
|
+
import { PluginFixture, PluginOptions } from '../api';
|
|
3
|
+
import { ExplorePage } from '../models/ExplorePage';
|
|
4
|
+
import { PlaywrightCombinedArgs } from './types';
|
|
5
|
+
type ExplorePageFixture = TestFixture<ExplorePage, PluginFixture & PluginOptions & PlaywrightCombinedArgs>;
|
|
6
|
+
declare const explorePage: ExplorePageFixture;
|
|
7
|
+
export default explorePage;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
declare const fixtures: {
|
|
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
|
+
grafanaVersion: (args: import("playwright/test").PlaywrightTestArgs, use: (r: string) => Promise<void>, testInfo: import("playwright/test").TestInfo) => any;
|
|
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("..").DataSourceConfigPage>) => Promise<void>, testInfo: import("playwright/test").TestInfo) => any;
|
|
6
|
+
page: (args: import("..").PluginFixture & import("..").PluginOptions & import("playwright/test").PlaywrightTestArgs & import("playwright/test").PlaywrightTestOptions & import("playwright/test").PlaywrightWorkerArgs & import("playwright/test").PlaywrightWorkerOptions, use: (r: import("playwright-core").Page) => Promise<void>, testInfo: import("playwright/test").TestInfo) => any;
|
|
7
|
+
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;
|
|
8
|
+
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;
|
|
9
|
+
variableEditPage: (args: import("..").PluginFixture & import("..").PluginOptions & import("playwright/test").PlaywrightTestArgs & import("playwright/test").PlaywrightTestOptions & import("playwright/test").PlaywrightWorkerArgs & import("playwright/test").PlaywrightWorkerOptions, use: (r: import("..").VariableEditPage) => Promise<void>, testInfo: import("playwright/test").TestInfo) => any;
|
|
10
|
+
annotationEditPage: (args: import("..").PluginFixture & import("..").PluginOptions & import("playwright/test").PlaywrightTestArgs & import("playwright/test").PlaywrightTestOptions & import("playwright/test").PlaywrightWorkerArgs & import("playwright/test").PlaywrightWorkerOptions, use: (r: import("..").AnnotationEditPage) => Promise<void>, testInfo: import("playwright/test").TestInfo) => any;
|
|
11
|
+
explorePage: (args: import("..").PluginFixture & import("..").PluginOptions & import("playwright/test").PlaywrightTestArgs & import("playwright/test").PlaywrightTestOptions & import("playwright/test").PlaywrightWorkerArgs & import("playwright/test").PlaywrightWorkerOptions, use: (r: import("../models/ExplorePage").ExplorePage) => Promise<void>, testInfo: import("playwright/test").TestInfo) => any;
|
|
12
|
+
createDataSource: (args: import("..").PluginFixture & import("..").PluginOptions & import("playwright/test").PlaywrightTestArgs & import("playwright/test").PlaywrightTestOptions & import("playwright/test").PlaywrightWorkerArgs & import("playwright/test").PlaywrightWorkerOptions, use: (r: (args: import("../types").CreateDataSourceArgs) => Promise<import("../types").DataSource<any>>) => Promise<void>, testInfo: import("playwright/test").TestInfo) => any;
|
|
13
|
+
readProvision: (args: import("..").PluginFixture & import("..").PluginOptions & import("playwright/test").PlaywrightTestArgs & import("playwright/test").PlaywrightTestOptions & import("playwright/test").PlaywrightWorkerArgs & import("playwright/test").PlaywrightWorkerOptions, use: (r: <T = any>(args: import("../types").ReadProvisionArgs) => Promise<T>) => Promise<void>, testInfo: import("playwright/test").TestInfo) => any;
|
|
14
|
+
isFeatureToggleEnabled: (args: import("..").PluginFixture & import("..").PluginOptions & import("playwright/test").PlaywrightTestArgs & import("playwright/test").PlaywrightTestOptions & import("playwright/test").PlaywrightWorkerArgs & import("playwright/test").PlaywrightWorkerOptions, use: (r: <T_1 = object>(featureToggle: keyof T_1) => Promise<boolean>) => Promise<void>, testInfo: import("playwright/test").TestInfo) => any;
|
|
15
|
+
};
|
|
16
|
+
export default fixtures;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { TestFixture } from '@playwright/test';
|
|
2
|
+
import { PluginFixture, PluginOptions } from '../api';
|
|
3
|
+
import { PlaywrightCombinedArgs } from './types';
|
|
4
|
+
type FeatureToggleFixture = TestFixture<(<T = object>(featureToggle: keyof T) => Promise<boolean>), PluginFixture & PluginOptions & PlaywrightCombinedArgs>;
|
|
5
|
+
declare const isFeatureToggleEnabled: FeatureToggleFixture;
|
|
6
|
+
export default isFeatureToggleEnabled;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { TestFixture } from '@playwright/test';
|
|
2
|
+
import { PluginFixture, PluginOptions } from '../api';
|
|
3
|
+
import { DashboardPage } from '../models';
|
|
4
|
+
import { PlaywrightCombinedArgs } from './types';
|
|
5
|
+
type NewDashboardPageFixture = TestFixture<DashboardPage, PluginFixture & PluginOptions & PlaywrightCombinedArgs>;
|
|
6
|
+
declare const newDashboardPage: NewDashboardPageFixture;
|
|
7
|
+
export default newDashboardPage;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { TestFixture, Page } from '@playwright/test';
|
|
2
|
+
import { PluginFixture, PluginOptions } from '../api';
|
|
3
|
+
import { PlaywrightCombinedArgs } from './types';
|
|
4
|
+
type PageFixture = TestFixture<Page, PluginFixture & PluginOptions & PlaywrightCombinedArgs>;
|
|
5
|
+
/**
|
|
6
|
+
* This fixture ensures the feature toggles defined in the Playwright config are being used in Grafana frontend.
|
|
7
|
+
* If Grafana version >= 10.1.0, feature toggles are read from to the 'grafana.featureToggles' key in the browser's localStorage.
|
|
8
|
+
* Otherwise, feature toggles are added directly to the window.grafanaBootData.settings.featureToggles object.
|
|
9
|
+
*
|
|
10
|
+
* page.addInitScript adds a script which would be evaluated in one of the following scenarios:
|
|
11
|
+
* - Whenever the page is navigated.
|
|
12
|
+
* - Whenever the child frame is attached or navigated. In this case, the script is evaluated in the context of the
|
|
13
|
+
* newly attached frame.
|
|
14
|
+
* The script is evaluated after the document was created but before any of its scripts were run.
|
|
15
|
+
*/
|
|
16
|
+
declare const page: PageFixture;
|
|
17
|
+
export default page;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { TestFixture } from '@playwright/test';
|
|
2
|
+
import { PluginFixture, PluginOptions } from '../api';
|
|
3
|
+
import { PanelEditPage } from '../models';
|
|
4
|
+
import { PlaywrightCombinedArgs } from './types';
|
|
5
|
+
type PanelEditPageFixture = TestFixture<PanelEditPage, PluginFixture & PluginOptions & PlaywrightCombinedArgs>;
|
|
6
|
+
declare const panelEditPage: PanelEditPageFixture;
|
|
7
|
+
export default panelEditPage;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function overrideFeatureToggles(featureToggles: any): void;
|
|
@@ -3,9 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.overrideFeatureToggles = void 0;
|
|
4
4
|
// this script is evaluated in the browser context, so we cannot use typescript
|
|
5
5
|
const overrideFeatureToggles = (featureToggles) => {
|
|
6
|
-
const timeout =
|
|
6
|
+
const timeout = 1;
|
|
7
7
|
const waitForGrafanaBootData = (cb) => {
|
|
8
|
-
if (window
|
|
8
|
+
if (window?.grafanaBootData?.settings?.featureToggles) {
|
|
9
9
|
cb();
|
|
10
10
|
}
|
|
11
11
|
else {
|
|
@@ -14,7 +14,7 @@ const overrideFeatureToggles = (featureToggles) => {
|
|
|
14
14
|
};
|
|
15
15
|
// wait for Grafana boot data to be added to the window object
|
|
16
16
|
waitForGrafanaBootData(() => {
|
|
17
|
-
|
|
17
|
+
console.log('@grafana/plugin-e2e: setting the following feature toggles', featureToggles);
|
|
18
18
|
// override feature toggles with the ones provided by the test
|
|
19
19
|
window.grafanaBootData.settings.featureToggles = {
|
|
20
20
|
...window.grafanaBootData.settings.featureToggles,
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { TestFixture } from '@playwright/test';
|
|
2
|
+
import { PluginFixture, PluginOptions } from '../api';
|
|
3
|
+
import { E2ESelectors } from '../e2e-selectors';
|
|
4
|
+
import { PlaywrightCombinedArgs } from './types';
|
|
5
|
+
type SelectorFixture = TestFixture<E2ESelectors, PluginFixture & PluginOptions & PlaywrightCombinedArgs>;
|
|
6
|
+
declare const selectors: SelectorFixture;
|
|
7
|
+
export default selectors;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { TestFixture } from '@playwright/test';
|
|
2
|
+
import { PluginFixture, PluginOptions } from '../api';
|
|
3
|
+
import { VariableEditPage } from '../models';
|
|
4
|
+
import { PlaywrightCombinedArgs } from './types';
|
|
5
|
+
type VariableEditPageFixture = TestFixture<VariableEditPage, PluginFixture & PluginOptions & PlaywrightCombinedArgs>;
|
|
6
|
+
declare const variableEditPage: VariableEditPageFixture;
|
|
7
|
+
export default variableEditPage;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { GrafanaPage, VariableEditPage } from './models';
|
|
2
|
+
import { AlertPageOptions, AlertVariant, ContainTextOptions } from './types';
|
|
3
|
+
export { expect, test, type PluginFixture, type PluginOptions } from './api';
|
|
4
|
+
export * from './e2e-selectors';
|
|
5
|
+
export * from './fixtures';
|
|
6
|
+
export * from './models';
|
|
7
|
+
declare global {
|
|
8
|
+
interface Window {
|
|
9
|
+
grafanaBootData: {
|
|
10
|
+
settings: {
|
|
11
|
+
featureToggles: Record<string, boolean>;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
namespace PlaywrightTest {
|
|
16
|
+
const r: unique symbol;
|
|
17
|
+
const t: unique symbol;
|
|
18
|
+
interface Matchers<R, T> {
|
|
19
|
+
[r]: R;
|
|
20
|
+
[t]: T;
|
|
21
|
+
/**
|
|
22
|
+
* Await the response of a Playwright request and asserts the response was successful (status in the range 200-299).
|
|
23
|
+
*/
|
|
24
|
+
toBeOK(this: Matchers<unknown, Promise<Response>>): R;
|
|
25
|
+
/**
|
|
26
|
+
* Asserts that preview text elements are displayed on the Variable Edit Page. You should make sure any variable queries are completed before calling this matcher.
|
|
27
|
+
*/
|
|
28
|
+
toDisplayPreviews(this: Matchers<unknown, VariableEditPage>, previewTexts: Array<string | RegExp>, options: ContainTextOptions): R;
|
|
29
|
+
/**
|
|
30
|
+
* Asserts that a GrafanaPage contains an alert with the specified severity. Use the options to specify the timeout and to filter the alerts.
|
|
31
|
+
*/
|
|
32
|
+
toHaveAlert(this: Matchers<unknown, GrafanaPage>, severity: AlertVariant, options?: AlertPageOptions): R;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
toBeOK: (request: Promise<import("playwright-core").Response>) => Promise<{
|
|
3
|
+
message: () => string;
|
|
4
|
+
pass: boolean;
|
|
5
|
+
actual: number;
|
|
6
|
+
} | {
|
|
7
|
+
message: () => string;
|
|
8
|
+
pass: boolean;
|
|
9
|
+
actual: undefined;
|
|
10
|
+
}>;
|
|
11
|
+
toDisplayPreviews: (variableEditPage: import("..").VariableEditPage, previewTexts: (string | RegExp)[], options?: import("../types").ContainTextOptions | undefined) => Promise<{
|
|
12
|
+
pass: boolean;
|
|
13
|
+
actual: boolean;
|
|
14
|
+
message: () => string;
|
|
15
|
+
} | {
|
|
16
|
+
message: () => string;
|
|
17
|
+
pass: boolean;
|
|
18
|
+
actual: undefined;
|
|
19
|
+
}>;
|
|
20
|
+
toHaveAlert: (grafanaPage: import("..").GrafanaPage, severity: import("./toHaveAlert").AlertVariant, options?: import("../types").AlertPageOptions | undefined) => Promise<{
|
|
21
|
+
message: () => any;
|
|
22
|
+
pass: boolean;
|
|
23
|
+
}>;
|
|
24
|
+
};
|
|
25
|
+
export default _default;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Response } from '@playwright/test';
|
|
2
|
+
declare const toBeOK: (request: Promise<Response>) => Promise<{
|
|
3
|
+
message: () => string;
|
|
4
|
+
pass: boolean;
|
|
5
|
+
actual: number;
|
|
6
|
+
} | {
|
|
7
|
+
message: () => string;
|
|
8
|
+
pass: boolean;
|
|
9
|
+
actual: undefined;
|
|
10
|
+
}>;
|
|
11
|
+
export default toBeOK;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { VariableEditPage } from '../models';
|
|
2
|
+
import { ContainTextOptions } from '../types';
|
|
3
|
+
declare const toDisplayPreviews: (variableEditPage: VariableEditPage, previewTexts: Array<string | RegExp>, options?: ContainTextOptions) => Promise<{
|
|
4
|
+
pass: boolean;
|
|
5
|
+
actual: boolean;
|
|
6
|
+
message: () => string;
|
|
7
|
+
} | {
|
|
8
|
+
message: () => string;
|
|
9
|
+
pass: boolean;
|
|
10
|
+
actual: undefined;
|
|
11
|
+
}>;
|
|
12
|
+
export default toDisplayPreviews;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { GrafanaPage } from '../models';
|
|
2
|
+
import { AlertPageOptions } from '../types';
|
|
3
|
+
export type AlertVariant = 'success' | 'warning' | 'error' | 'info';
|
|
4
|
+
declare const toHaveAlert: (grafanaPage: GrafanaPage, severity: AlertVariant, options?: AlertPageOptions) => Promise<{
|
|
5
|
+
message: () => any;
|
|
6
|
+
pass: boolean;
|
|
7
|
+
}>;
|
|
8
|
+
export default toHaveAlert;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getMessage: (expected: string, received: string) => string;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { DataSourcePicker } from './DataSourcePicker';
|
|
2
|
+
import { DashboardEditViewArgs, NavigateOptions, PluginTestCtx, RequestOptions } from '../types';
|
|
3
|
+
import { GrafanaPage } from './GrafanaPage';
|
|
4
|
+
export declare class AnnotationEditPage extends GrafanaPage {
|
|
5
|
+
readonly ctx: PluginTestCtx;
|
|
6
|
+
readonly args: DashboardEditViewArgs<string>;
|
|
7
|
+
datasource: DataSourcePicker;
|
|
8
|
+
constructor(ctx: PluginTestCtx, args: DashboardEditViewArgs<string>);
|
|
9
|
+
/**
|
|
10
|
+
* Navigates to the annotation edit page. If a dashboard uid was not provided, it's assumed that it's a new dashboard.
|
|
11
|
+
*/
|
|
12
|
+
goto(options?: NavigateOptions): Promise<void>;
|
|
13
|
+
/**
|
|
14
|
+
* Executes the annotation query defined in the annotation page and returns the response promise
|
|
15
|
+
* @param options - Optional. RequestOptions to pass to waitForResponse
|
|
16
|
+
*/
|
|
17
|
+
runQuery(options?: RequestOptions): Promise<import("playwright-core").Response>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { DashboardPageArgs, NavigateOptions, PluginTestCtx } from '../types';
|
|
2
|
+
import { AnnotationEditPage } from './AnnotationEditPage';
|
|
3
|
+
import { GrafanaPage } from './GrafanaPage';
|
|
4
|
+
export declare class AnnotationPage extends GrafanaPage {
|
|
5
|
+
readonly ctx: PluginTestCtx;
|
|
6
|
+
readonly dashboard?: DashboardPageArgs | undefined;
|
|
7
|
+
constructor(ctx: PluginTestCtx, dashboard?: DashboardPageArgs | undefined);
|
|
8
|
+
/**
|
|
9
|
+
* Navigates to the annotation list page. If a dashboard uid was not provided, it's assumed that it's a new dashboard.
|
|
10
|
+
*/
|
|
11
|
+
goto(options?: NavigateOptions): Promise<void>;
|
|
12
|
+
/**
|
|
13
|
+
* Clicks the add new annotation button and returns the annotation edit page
|
|
14
|
+
*/
|
|
15
|
+
clickAddNew(): Promise<AnnotationEditPage>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { DashboardPageArgs, NavigateOptions, PluginTestCtx } from '../types';
|
|
2
|
+
import { GrafanaPage } from './GrafanaPage';
|
|
3
|
+
import { PanelEditPage } from './PanelEditPage';
|
|
4
|
+
import { TimeRange } from './TimeRange';
|
|
5
|
+
export declare class DashboardPage extends GrafanaPage {
|
|
6
|
+
readonly ctx: PluginTestCtx;
|
|
7
|
+
readonly dashboard?: DashboardPageArgs | undefined;
|
|
8
|
+
dataSourcePicker: any;
|
|
9
|
+
timeRange: TimeRange;
|
|
10
|
+
constructor(ctx: PluginTestCtx, dashboard?: DashboardPageArgs | undefined);
|
|
11
|
+
/**
|
|
12
|
+
* Navigates to the dashboard page. If a dashboard uid was not provided, it's assumed that it's a new dashboard.
|
|
13
|
+
*/
|
|
14
|
+
goto(options?: NavigateOptions): Promise<void>;
|
|
15
|
+
/**
|
|
16
|
+
* Navigates to the panel edit page for the given panel id
|
|
17
|
+
*
|
|
18
|
+
* If the panel id does not exist in the dashboard, Grafana will redirect to the dashboard page
|
|
19
|
+
*/
|
|
20
|
+
gotoPanelEditPage(panelId: string): Promise<PanelEditPage>;
|
|
21
|
+
/**
|
|
22
|
+
* Clicks the buttons to add a new panel and returns the panel edit page for the new panel
|
|
23
|
+
*/
|
|
24
|
+
addPanel(): Promise<PanelEditPage>;
|
|
25
|
+
/**
|
|
26
|
+
* Deletes the dashboard
|
|
27
|
+
*/
|
|
28
|
+
deleteDashboard(): Promise<void>;
|
|
29
|
+
/**
|
|
30
|
+
* Clicks the run button in the refresh picker to refresh the dashboard
|
|
31
|
+
*/
|
|
32
|
+
refreshDashboard(): Promise<void>;
|
|
33
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { DataSource, NavigateOptions, PluginTestCtx, TriggerQueryOptions } from '../types';
|
|
2
|
+
import { GrafanaPage } from './GrafanaPage';
|
|
3
|
+
export declare class DataSourceConfigPage extends GrafanaPage {
|
|
4
|
+
private datasource;
|
|
5
|
+
constructor(ctx: PluginTestCtx, datasource: DataSource);
|
|
6
|
+
deleteDataSource(): Promise<void>;
|
|
7
|
+
/**
|
|
8
|
+
* Navigates to the datasource edit page for an existing datasource
|
|
9
|
+
*/
|
|
10
|
+
goto(options?: NavigateOptions): Promise<void>;
|
|
11
|
+
/**
|
|
12
|
+
* Mocks the response of the datasource health check call
|
|
13
|
+
* @param json the json response to return
|
|
14
|
+
* @param status the HTTP status code to return. Defaults to 200
|
|
15
|
+
*/
|
|
16
|
+
mockHealthCheckResponse<T = any>(json: T, status?: number): Promise<void>;
|
|
17
|
+
/**
|
|
18
|
+
* Clicks the save and test button and waits for the response
|
|
19
|
+
*
|
|
20
|
+
* Optionally, you can skip waiting for the response by passing in { skipWaitForResponse: true } as the options parameter
|
|
21
|
+
*/
|
|
22
|
+
saveAndTest(options?: TriggerQueryOptions): Promise<void | import("playwright-core").Response>;
|
|
23
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { PluginTestCtx } from '../types';
|
|
2
|
+
import { GrafanaPage } from './GrafanaPage';
|
|
3
|
+
export declare class DataSourcePicker extends GrafanaPage {
|
|
4
|
+
constructor(ctx: PluginTestCtx);
|
|
5
|
+
/**
|
|
6
|
+
* Sets the data source picker to the provided name
|
|
7
|
+
*/
|
|
8
|
+
set(name: string): Promise<void>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Locator } from '@playwright/test';
|
|
2
|
+
import { NavigateOptions, PluginTestCtx, RequestOptions } from '../types';
|
|
3
|
+
import { DataSourcePicker } from './DataSourcePicker';
|
|
4
|
+
import { GrafanaPage } from './GrafanaPage';
|
|
5
|
+
import { Panel } from './Panel';
|
|
6
|
+
export declare class ExplorePage extends GrafanaPage {
|
|
7
|
+
datasource: DataSourcePicker;
|
|
8
|
+
timeRange: any;
|
|
9
|
+
timeSeriesPanel: Panel;
|
|
10
|
+
logsPanel: Panel;
|
|
11
|
+
tablePanel: Panel;
|
|
12
|
+
constructor(ctx: PluginTestCtx);
|
|
13
|
+
private getPanelLocators;
|
|
14
|
+
/**
|
|
15
|
+
* Navigates to the explore page.
|
|
16
|
+
*/
|
|
17
|
+
goto(options?: NavigateOptions): Promise<void>;
|
|
18
|
+
/**
|
|
19
|
+
* Returns the locator for the query editor row with the given refId
|
|
20
|
+
*/
|
|
21
|
+
getQueryEditorRow(refId: string): Locator;
|
|
22
|
+
/**
|
|
23
|
+
* Clicks the "Run Query" button in the refresh picker to run the query. Returns the response promise for the data query
|
|
24
|
+
*/
|
|
25
|
+
runQuery(options?: RequestOptions): Promise<import("@playwright/test").Response>;
|
|
26
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Locator, Request, Response } from '@playwright/test';
|
|
2
|
+
import { GetByTestIdOrAriaLabelOptions, NavigateOptions, PluginTestCtx } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Base class for all Grafana pages.
|
|
5
|
+
*
|
|
6
|
+
* Exposes methods for locating Grafana specific elements on the page
|
|
7
|
+
*/
|
|
8
|
+
export declare abstract class GrafanaPage {
|
|
9
|
+
readonly ctx: PluginTestCtx;
|
|
10
|
+
constructor(ctx: PluginTestCtx);
|
|
11
|
+
protected navigate(url: string, options?: NavigateOptions): Promise<void>;
|
|
12
|
+
/**
|
|
13
|
+
* Get a locator for a Grafana element by data-testid or aria-label
|
|
14
|
+
* @param selector the data-testid or aria-label of the element
|
|
15
|
+
* @param root optional root locator to search within. If no locator is provided, the page will be used
|
|
16
|
+
*/
|
|
17
|
+
getByTestIdOrAriaLabel(selector: string, options?: GetByTestIdOrAriaLabelOptions): Locator;
|
|
18
|
+
/**
|
|
19
|
+
* Mocks the response of the datasource query call
|
|
20
|
+
* @param json the json response to return
|
|
21
|
+
* @param status the HTTP status code to return. Defaults to 200
|
|
22
|
+
*/
|
|
23
|
+
mockQueryDataResponse<T = any>(json: T, status?: number): Promise<void>;
|
|
24
|
+
/**
|
|
25
|
+
* Mocks the response of the datasource resource request
|
|
26
|
+
* @param path the path of the resource to mock
|
|
27
|
+
* @param json the json response to return
|
|
28
|
+
* @param status the HTTP status code to return. Defaults to 200
|
|
29
|
+
*/
|
|
30
|
+
mockResourceResponse<T = any>(path: string, json: T, status?: number): Promise<void>;
|
|
31
|
+
/**
|
|
32
|
+
* Waits for a data source query data request to be made.
|
|
33
|
+
*
|
|
34
|
+
* @param cb optional callback to filter the request. Use this to filter by request body or other request properties
|
|
35
|
+
*/
|
|
36
|
+
waitForQueryDataRequest(cb?: (request: Request) => boolean | Promise<boolean>): Promise<Request>;
|
|
37
|
+
/**
|
|
38
|
+
* Waits for a data source query data response
|
|
39
|
+
*
|
|
40
|
+
* @param cb optional callback to filter the response. Use this to filter by response body or other response properties
|
|
41
|
+
*/
|
|
42
|
+
waitForQueryDataResponse(cb?: (request: Response) => boolean | Promise<boolean>): Promise<Response>;
|
|
43
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Locator } from '@playwright/test';
|
|
2
|
+
import { PluginTestCtx } from '../types';
|
|
3
|
+
import { GrafanaPage } from './GrafanaPage';
|
|
4
|
+
export declare class Panel extends GrafanaPage {
|
|
5
|
+
readonly ctx: PluginTestCtx;
|
|
6
|
+
readonly locator: () => Locator;
|
|
7
|
+
constructor(ctx: PluginTestCtx, locator: () => Locator);
|
|
8
|
+
/**
|
|
9
|
+
* Returns the locator for the panel error (if any)
|
|
10
|
+
*/
|
|
11
|
+
getErrorIcon(): Locator;
|
|
12
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Locator, Response } from '@playwright/test';
|
|
2
|
+
import { DashboardEditViewArgs, NavigateOptions, PluginTestCtx, RequestOptions, Visualization } from '../types';
|
|
3
|
+
import { DataSourcePicker } from './DataSourcePicker';
|
|
4
|
+
import { GrafanaPage } from './GrafanaPage';
|
|
5
|
+
import { TimeRange } from './TimeRange';
|
|
6
|
+
import { Panel } from './Panel';
|
|
7
|
+
export declare class PanelEditPage extends GrafanaPage {
|
|
8
|
+
readonly ctx: PluginTestCtx;
|
|
9
|
+
readonly args: DashboardEditViewArgs<string>;
|
|
10
|
+
datasource: DataSourcePicker;
|
|
11
|
+
timeRange: TimeRange;
|
|
12
|
+
panel: Panel;
|
|
13
|
+
constructor(ctx: PluginTestCtx, args: DashboardEditViewArgs<string>);
|
|
14
|
+
/**
|
|
15
|
+
* Navigates to the panel edit page. If a dashboard uid was not provided, it's assumed that it's a new dashboard.
|
|
16
|
+
*/
|
|
17
|
+
goto(options?: NavigateOptions): Promise<void>;
|
|
18
|
+
/**
|
|
19
|
+
* Sets the title of the panel. This method will open the panel options, set the title and close the panel options.
|
|
20
|
+
*/
|
|
21
|
+
setPanelTitle(title: string): Promise<void>;
|
|
22
|
+
/**
|
|
23
|
+
* Sets the visualization for the panel. This method will open the visualization picker, select the given visualization
|
|
24
|
+
*/
|
|
25
|
+
setVisualization(visualization: Visualization): Promise<void>;
|
|
26
|
+
/**
|
|
27
|
+
* Expands the section for the given category name. If the section is already expanded, this method does nothing.
|
|
28
|
+
*/
|
|
29
|
+
collapseSection(categoryName: string): Promise<void>;
|
|
30
|
+
/**
|
|
31
|
+
* Returns the name of the visualization currently selected in the panel editor
|
|
32
|
+
*/
|
|
33
|
+
getVisualizationName(): Locator;
|
|
34
|
+
/**
|
|
35
|
+
* Clicks the "Apply" button in the panel editor
|
|
36
|
+
*/
|
|
37
|
+
apply(): Promise<void>;
|
|
38
|
+
/**
|
|
39
|
+
* Returns the locator for the query editor row with the given refId
|
|
40
|
+
*/
|
|
41
|
+
getQueryEditorRow(refId: string): Locator;
|
|
42
|
+
/**
|
|
43
|
+
* Clicks the "Refresh" button in the panel editor. Returns the response promise for the data query
|
|
44
|
+
*
|
|
45
|
+
* By default, this method will wait for any response that has the url '/api/ds/query'.
|
|
46
|
+
* If you need to wait for a specific response, you can pass a callback to the `waitForResponsePredicateCallback` option.
|
|
47
|
+
* e.g
|
|
48
|
+
* panelEditPage.refreshPanel({
|
|
49
|
+
waitForResponsePredicateCallback: (r) =>
|
|
50
|
+
r.url().includes(selectors.apis.DataSource.query) &&
|
|
51
|
+
r.body().then((body) => body.includes(`"status":"finished"`)),
|
|
52
|
+
})
|
|
53
|
+
*/
|
|
54
|
+
refreshPanel(options?: RequestOptions): Promise<Response>;
|
|
55
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { PluginTestCtx, TimeRangeArgs } from '../types';
|
|
2
|
+
import { GrafanaPage } from './GrafanaPage';
|
|
3
|
+
export declare class TimeRange extends GrafanaPage {
|
|
4
|
+
constructor(ctx: PluginTestCtx);
|
|
5
|
+
/**
|
|
6
|
+
* Opens the time picker and sets the time range to the provided values
|
|
7
|
+
*/
|
|
8
|
+
set({ from, to, zone }: TimeRangeArgs): Promise<void>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { DashboardEditViewArgs, NavigateOptions, PluginTestCtx } from '../types';
|
|
2
|
+
import { DataSourcePicker } from './DataSourcePicker';
|
|
3
|
+
import { GrafanaPage } from './GrafanaPage';
|
|
4
|
+
export type VariableType = 'Query' | 'Constant' | 'Custom';
|
|
5
|
+
export declare class VariableEditPage extends GrafanaPage {
|
|
6
|
+
readonly ctx: PluginTestCtx;
|
|
7
|
+
readonly args: DashboardEditViewArgs<string>;
|
|
8
|
+
datasource: DataSourcePicker;
|
|
9
|
+
constructor(ctx: PluginTestCtx, args: DashboardEditViewArgs<string>);
|
|
10
|
+
/**
|
|
11
|
+
* Navigates to the variable edit page. If a dashboard uid was not provided, it's assumed that it's a new dashboard.
|
|
12
|
+
*/
|
|
13
|
+
goto(options?: NavigateOptions): Promise<void>;
|
|
14
|
+
/**
|
|
15
|
+
* Sets the type of variable in the 'Variable type' dropdown to the given type
|
|
16
|
+
*/
|
|
17
|
+
setVariableType(type: VariableType): Promise<void>;
|
|
18
|
+
/**
|
|
19
|
+
* Triggers the variable query to run. Note that unlike {@link PanelEditPage.refreshPanel}, this method doesn't
|
|
20
|
+
* return a request promise. This is because there's no canonical way of querying variables - data sources may
|
|
21
|
+
* call any endpoint or resolve variables in the frontend. If you need to wait for a specific request, you can
|
|
22
|
+
* do that in your test.
|
|
23
|
+
* @example await this.ctx.page.waitForResponse((resp) => resp.url().includes('<url>')
|
|
24
|
+
*/
|
|
25
|
+
runQuery(): Promise<void>;
|
|
26
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { DashboardPageArgs, NavigateOptions, PluginTestCtx } from '../types';
|
|
2
|
+
import { GrafanaPage } from './GrafanaPage';
|
|
3
|
+
import { VariableEditPage } from './VariableEditPage';
|
|
4
|
+
export declare class VariablePage extends GrafanaPage {
|
|
5
|
+
readonly ctx: PluginTestCtx;
|
|
6
|
+
readonly dashboard?: DashboardPageArgs | undefined;
|
|
7
|
+
constructor(ctx: PluginTestCtx, dashboard?: DashboardPageArgs | undefined);
|
|
8
|
+
/**
|
|
9
|
+
* Navigates to the variable list page. If a dashboard uid was not provided, it's assumed that it's a new dashboard.
|
|
10
|
+
*/
|
|
11
|
+
goto(options?: NavigateOptions): Promise<void>;
|
|
12
|
+
/**
|
|
13
|
+
* Clicks the add new variable button and returns the variable edit page
|
|
14
|
+
*/
|
|
15
|
+
clickAddNew(): Promise<VariableEditPage>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { AnnotationEditPage } from './AnnotationEditPage';
|
|
2
|
+
export { AnnotationPage } from './AnnotationPage';
|
|
3
|
+
export { DashboardPage } from './DashboardPage';
|
|
4
|
+
export { DataSourceConfigPage } from './DataSourceConfigPage';
|
|
5
|
+
export { GrafanaPage } from './GrafanaPage';
|
|
6
|
+
export { PanelEditPage } from './PanelEditPage';
|
|
7
|
+
export { VariableEditPage } from './VariableEditPage';
|
|
8
|
+
export { VariablePage } from './VariablePage';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns a selector engine that resolves selectors by data-testid or aria-label
|
|
3
|
+
*/
|
|
4
|
+
export declare const grafanaE2ESelectorEngine: () => {
|
|
5
|
+
query(root: Element, selector: string): Element | null;
|
|
6
|
+
queryAll(root: Element, selector: string): NodeListOf<Element>;
|
|
7
|
+
};
|