mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
* fix(catalog): prefer rendering installed version over latest version * feat(catalog): signify installed version in version history * feat(catalog): introduce installedVersion and latestVersion * refactor(catalog): use latestVersion for installation, simplify plugindetails header logic * refactor(catalog): clean up installedVersion and latestVersion * feat(catalog): use table-layout so versions list table has consistent column widths * test(catalog): update failing tests * removed the need of having a latest version in the plugin catalog type root level. * fixed flaky test depending on what locale it was being running with. * added missing test to verify version for a remote plugin. * fixed version in header. * preventing the UI from break if no versions are available. * fixed failing test due to missing mock data. * added todo as a reminder. * refactor(catalog): prefer grafana plugin icons over gcom notfound images * refactor(Plugins/Admin): change constant name * refactor(Plugins/Admin): add comment to make condition easier to understand * chore: update go modules * feat(Backend/Plugins): add "dependencies" field to `PluginListItem` * feat(Plugins/Admin): show the grafana dependency for the installed version * refactor(Plugins/Admin): use the local version of links * refactor(Plugins/Admin): prefer the local version for `.type` * refactor(Plugins/ADmin): prefer the local `.description` field * fix(Plugins/Admin): fix tests * test(plugins/api): update the expected response for the `api/plugins` tests * chore(Plugins/Admin): add todo comments to check preferation of remote/local values * feat(backend/api): always send the grafana version as a header when proxying to GCOM * feat(plugins/admin): use the `isCompatible` flag to get the latest compatible version * feat(plugins/admin): show the latest compatible version in the versions list * fix(plugins/admin): show the grafana dependency for the latest compatible version * fix(plugins/admin): update the version list when installing/uninstalling a plugin * test(plugins/admin): add some test-cases for the latest-compatible-version * fix(plugins/admin): show the grafana dependency for the installed version (if installed) * feat(plugins/backend): add the `dependencies.grafanaDependency` property to the plugin object * test(plugins/backend): fix tests by adjusting expected response json Co-authored-by: Marcus Andersson <marcus.andersson@grafana.com> Co-authored-by: Levente Balogh <balogh.levente.hu@gmail.com>
75 lines
2.7 KiB
TypeScript
75 lines
2.7 KiB
TypeScript
import React from 'react';
|
|
import { render, screen } from '@testing-library/react';
|
|
import { PluginErrorCode, PluginSignatureStatus } from '@grafana/data';
|
|
import { PluginListItemBadges } from './PluginListItemBadges';
|
|
import { CatalogPlugin } from '../types';
|
|
import { config } from '@grafana/runtime';
|
|
|
|
describe('PluginListItemBadges', () => {
|
|
const plugin: CatalogPlugin = {
|
|
description: 'The test plugin',
|
|
downloads: 5,
|
|
id: 'test-plugin',
|
|
info: {
|
|
logos: {
|
|
small: 'https://grafana.com/api/plugins/test-plugin/versions/0.0.10/logos/small',
|
|
large: 'https://grafana.com/api/plugins/test-plugin/versions/0.0.10/logos/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,
|
|
};
|
|
|
|
afterEach(() => {
|
|
jest.clearAllMocks();
|
|
});
|
|
|
|
it('renders a plugin signature badge', () => {
|
|
render(<PluginListItemBadges plugin={plugin} />);
|
|
|
|
expect(screen.getByText(/signed/i)).toBeVisible();
|
|
});
|
|
|
|
it('renders an installed badge', () => {
|
|
render(<PluginListItemBadges plugin={{ ...plugin, isInstalled: true }} />);
|
|
|
|
expect(screen.getByText(/signed/i)).toBeVisible();
|
|
expect(screen.getByText(/installed/i)).toBeVisible();
|
|
});
|
|
|
|
it('renders an enterprise badge (when a license is valid)', () => {
|
|
config.licenseInfo.hasValidLicense = true;
|
|
render(<PluginListItemBadges plugin={{ ...plugin, isEnterprise: true }} />);
|
|
expect(screen.getByText(/enterprise/i)).toBeVisible();
|
|
expect(screen.queryByRole('button', { name: /learn more/i })).not.toBeInTheDocument();
|
|
});
|
|
|
|
it('renders an enterprise badge with icon and link (when a license is invalid)', () => {
|
|
config.licenseInfo.hasValidLicense = false;
|
|
render(<PluginListItemBadges plugin={{ ...plugin, isEnterprise: true }} />);
|
|
expect(screen.getByText(/enterprise/i)).toBeVisible();
|
|
expect(screen.getByLabelText(/lock icon/i)).toBeInTheDocument();
|
|
expect(screen.getByRole('button', { name: /learn more/i })).toBeInTheDocument();
|
|
});
|
|
|
|
it('renders a error badge (when plugin has an error)', () => {
|
|
render(<PluginListItemBadges plugin={{ ...plugin, isDisabled: true, error: PluginErrorCode.modifiedSignature }} />);
|
|
expect(screen.getByText(/disabled/i)).toBeVisible();
|
|
});
|
|
|
|
it('renders an upgrade badge (when plugin has an available update)', () => {
|
|
render(<PluginListItemBadges plugin={{ ...plugin, hasUpdate: true, installedVersion: '0.0.9' }} />);
|
|
expect(screen.getByText(/update available/i)).toBeVisible();
|
|
});
|
|
});
|