Skip to content

Commit 1373b37

Browse files
sunkertolzhabayev
andauthored
Plugin Extensions: E2E test addLink and legacy APIs (grafana#92394)
* cleanup tests * more cleanup * added links * test legacy hooks * test legacy hooks * update codeowners * revert package changes * add project specfic example script * remove console log * Update .github/CODEOWNERS Co-authored-by: Timur Olzhabayev <[email protected]> * Update CODEOWNERS * use correct file names * cleanup tests --------- Co-authored-by: Timur Olzhabayev <[email protected]>
1 parent a2de893 commit 1373b37

35 files changed

+421
-389
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,7 @@
319319
/e2e/ @grafana/grafana-frontend-platform
320320
/e2e/cloud-plugins-suite/ @grafana/partner-datasources
321321
/e2e/plugin-e2e/plugin-e2e-api-tests/ @grafana/plugins-platform-frontend
322+
/e2e/test-plugins/grafana-extensionstest-app/ @grafana/plugins-platform-frontend
322323

323324
# Packages
324325
/packages/ @grafana/grafana-frontend-platform @grafana/plugins-platform-frontend

e2e/plugin-e2e/plugin-e2e-api-tests/as-admin-user/extensions/extensionPoints.spec.ts

Lines changed: 0 additions & 51 deletions
This file was deleted.

e2e/plugin-e2e/plugin-e2e-api-tests/as-admin-user/extensions/extensions.spec.ts

Lines changed: 0 additions & 44 deletions
This file was deleted.

e2e/plugin-e2e/plugin-e2e-api-tests/as-admin-user/extensions/useExposedComponent.spec.ts

Lines changed: 0 additions & 9 deletions
This file was deleted.

e2e/plugin-e2e/plugin-e2e-api-tests/as-admin-user/extensions/usePluginComponents.spec.ts

Lines changed: 0 additions & 11 deletions
This file was deleted.

e2e/test-plugins/grafana-extensionstest-app/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,4 @@ Note that this plugin extends the `@grafana/plugin-configs` configs which is why
3232

3333
## Run Playwright tests
3434

35-
- `yarn e2e:playwright`
35+
- `yarn playwright --project extensions-test-app`

e2e/test-plugins/grafana-extensionstest-app/components/ActionButton/ActionButton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { PluginExtension, PluginExtensionLink, SelectableValue, locationUtil } from '@grafana/data';
22
import { isPluginExtensionLink, locationService } from '@grafana/runtime';
33
import { Button, ButtonGroup, ButtonSelect, Modal, Stack, ToolbarButton } from '@grafana/ui';
4-
import { testIds } from '../testIds';
4+
import { testIds } from '../../testIds';
55

66
import { ReactElement, useMemo, useState } from 'react';
77

e2e/test-plugins/grafana-extensionstest-app/components/App/App.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
import { Route, Routes } from 'react-router-dom';
2+
23
import { AppRootProps } from '@grafana/data';
4+
35
import { ROUTES } from '../../constants';
4-
import { AddedComponents, ExposedComponents, LegacyAPIs } from '../../pages';
5-
import { testIds } from '../testIds';
6+
import { AddedComponents, AddedLinks, ExposedComponents, LegacyGetters, LegacyHooks } from '../../pages';
7+
import { testIds } from '../../testIds';
68

79
export function App(props: AppRootProps) {
810
return (
911
<div data-testid={testIds.container} style={{ marginTop: '5%' }}>
1012
<Routes>
11-
<Route path={ROUTES.LegacyAPIs} element={<LegacyAPIs />} />
13+
<Route path={ROUTES.LegacyGetters} element={<LegacyGetters />} />
14+
<Route path={ROUTES.LegacyHooks} element={<LegacyHooks />} />
1215
<Route path={ROUTES.ExposedComponents} element={<ExposedComponents />} />
1316
<Route path={ROUTES.AddedComponents} element={<AddedComponents />} />
17+
<Route path={ROUTES.AddedLinks} element={<AddedLinks />} />
1418

15-
<Route path={'*'} element={<LegacyAPIs />} />
19+
<Route path={'*'} element={<LegacyGetters />} />
1620
</Routes>
1721
</div>
1822
);

e2e/test-plugins/grafana-extensionstest-app/components/AppConfig/AppConfig.tsx

Lines changed: 0 additions & 135 deletions
This file was deleted.

e2e/test-plugins/grafana-extensionstest-app/components/AppConfig/index.tsx

Lines changed: 0 additions & 1 deletion
This file was deleted.

e2e/test-plugins/grafana-extensionstest-app/components/QueryModal/QueryModal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { DataQuery } from '@grafana/data';
22
import { Button, FilterPill, Modal, Stack } from '@grafana/ui';
3-
import { testIds } from '../testIds';
3+
import { testIds } from '../../testIds';
44
import { ReactElement, useState } from 'react';
55
import { selectQuery } from '../../utils/utils';
66

e2e/test-plugins/grafana-extensionstest-app/components/testIds.ts

Lines changed: 0 additions & 36 deletions
This file was deleted.

e2e/test-plugins/grafana-extensionstest-app/constants.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ import pluginJson from './plugin.json';
33
export const PLUGIN_BASE_URL = `/a/${pluginJson.id}`;
44

55
export enum ROUTES {
6-
LegacyAPIs = 'legacy-apis',
6+
LegacyGetters = 'legacy-getters',
7+
LegacyHooks = 'legacy-hooks',
78
ExposedComponents = 'exposed-components',
89
AddedComponents = 'added-components',
10+
AddedLinks = 'added-links',
911
}

e2e/test-plugins/grafana-extensionstest-app/pages/AddedComponents.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import { testIds } from '../components/testIds';
21
import { PluginPage, usePluginComponents } from '@grafana/runtime';
32
import { Stack } from '@grafana/ui';
43

4+
import { testIds } from '../testIds';
5+
56
type ReusableComponentProps = {
67
name: string;
78
};
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { PluginPage, usePluginLinks } from '@grafana/runtime';
2+
3+
import { testIds } from '../testIds';
4+
5+
export const LINKS_EXTENSION_POINT_ID = 'plugins/grafana-extensionstest-app/use-plugin-links/v1';
6+
7+
export function AddedLinks() {
8+
const { links, isLoading } = usePluginLinks({ extensionPointId: LINKS_EXTENSION_POINT_ID });
9+
10+
return (
11+
<PluginPage>
12+
<div data-testid={testIds.addedLinksPage.container}>
13+
{isLoading ? (
14+
<div>Loading...</div>
15+
) : (
16+
links.map(({ id, title, path, onClick }) => (
17+
<a href={path} title={title} key={id} onClick={onClick}>
18+
{title}
19+
</a>
20+
))
21+
)}
22+
</div>
23+
</PluginPage>
24+
);
25+
}

0 commit comments

Comments
 (0)