mirror of
https://github.com/grafana/grafana.git
synced 2025-02-14 01:23:32 -06:00
Plugins: Group tests (#74667)
refactor: group plugin-details page tests together
This commit is contained in:
parent
6f785f7269
commit
9c83dd43d9
@ -1,64 +0,0 @@
|
|||||||
import { render, screen, act } from '@testing-library/react';
|
|
||||||
import React from 'react';
|
|
||||||
import { TestProvider } from 'test/helpers/TestProvider';
|
|
||||||
|
|
||||||
import { PluginSignatureStatus } from '@grafana/data';
|
|
||||||
|
|
||||||
import { PluginDetailsPage } from './PluginDetailsPage';
|
|
||||||
|
|
||||||
jest.mock('../state/hooks', () => ({
|
|
||||||
__esModule: true,
|
|
||||||
...jest.requireActual('../state/hooks'),
|
|
||||||
useGetSingle: jest.fn().mockImplementation((id: string) => {
|
|
||||||
return {
|
|
||||||
description: 'The test plugin',
|
|
||||||
downloads: 5,
|
|
||||||
id: 'test-plugin',
|
|
||||||
info: {
|
|
||||||
logos: { small: '', large: '' },
|
|
||||||
},
|
|
||||||
name: 'Testing Plugin',
|
|
||||||
orgName: 'Test',
|
|
||||||
popularity: 0,
|
|
||||||
signature: PluginSignatureStatus.valid,
|
|
||||||
publishedAt: '2020-09-01',
|
|
||||||
updatedAt: '2021-06-28',
|
|
||||||
hasUpdate: false,
|
|
||||||
isInstalled: false,
|
|
||||||
isCore: false,
|
|
||||||
isDev: false,
|
|
||||||
isEnterprise: false,
|
|
||||||
isDisabled: false,
|
|
||||||
isPublished: true,
|
|
||||||
angularDetected: id === 'angular',
|
|
||||||
};
|
|
||||||
}),
|
|
||||||
}));
|
|
||||||
|
|
||||||
describe('PluginDetailsPage Angular deprecation', () => {
|
|
||||||
afterAll(() => {
|
|
||||||
jest.resetAllMocks();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('renders the component for angular plugins', async () => {
|
|
||||||
await act(async () =>
|
|
||||||
render(
|
|
||||||
<TestProvider>
|
|
||||||
<PluginDetailsPage pluginId="angular" />
|
|
||||||
</TestProvider>
|
|
||||||
)
|
|
||||||
);
|
|
||||||
expect(screen.getByText(/angular plugin/i)).toBeVisible();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('does not render the component for non-angular plugins', async () => {
|
|
||||||
await act(async () =>
|
|
||||||
render(
|
|
||||||
<TestProvider>
|
|
||||||
<PluginDetailsPage pluginId="not-angular" />
|
|
||||||
</TestProvider>
|
|
||||||
)
|
|
||||||
);
|
|
||||||
expect(screen.queryByText(/angular plugin/i)).toBeNull();
|
|
||||||
});
|
|
||||||
});
|
|
@ -726,6 +726,22 @@ describe('Plugin details page', () => {
|
|||||||
|
|
||||||
expect(queryByRole('button', { name: /uninstall/i })).not.toBeInTheDocument();
|
expect(queryByRole('button', { name: /uninstall/i })).not.toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('shows a "angular warning" if the plugin uses Angular', async () => {
|
||||||
|
const { queryByText } = renderPluginDetails({
|
||||||
|
angularDetected: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
await waitFor(() => expect(queryByText(/angular plugin/i)).toBeInTheDocument);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('does not show an "angular warning" if the plugin is not using Angular', async () => {
|
||||||
|
const { queryByText } = renderPluginDetails({
|
||||||
|
angularDetected: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
await waitFor(() => expect(queryByText(/angular plugin/i)).not.toBeInTheDocument);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('viewed as user without grafana admin permissions', () => {
|
describe('viewed as user without grafana admin permissions', () => {
|
||||||
|
Loading…
Reference in New Issue
Block a user