2020-01-06 09:56:34 -06:00
|
|
|
import { DataSourcePluginMeta } from '@grafana/data';
|
2022-07-20 02:25:09 -05:00
|
|
|
import { getMockPlugin } from 'app/features/plugins/__mocks__/pluginMocks';
|
2022-04-22 08:33:13 -05:00
|
|
|
|
|
|
|
import { buildCategories } from './buildCategories';
|
|
|
|
|
2020-01-06 09:56:34 -06:00
|
|
|
const plugins: DataSourcePluginMeta[] = [
|
|
|
|
{
|
|
|
|
...getMockPlugin({ id: 'graphite' }),
|
|
|
|
category: 'tsdb',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
...getMockPlugin({ id: 'prometheus' }),
|
|
|
|
category: 'tsdb',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
...getMockPlugin({ id: 'elasticsearch' }),
|
|
|
|
category: 'logging',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
...getMockPlugin({ id: 'loki' }),
|
|
|
|
category: 'logging',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
...getMockPlugin({ id: 'azure' }),
|
|
|
|
category: 'cloud',
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
describe('buildCategories', () => {
|
|
|
|
const categories = buildCategories(plugins);
|
|
|
|
|
2020-10-28 02:15:32 -05:00
|
|
|
it('should group plugins into categories and remove empty categories', () => {
|
|
|
|
expect(categories.length).toBe(4);
|
2020-01-06 09:56:34 -06:00
|
|
|
expect(categories[0].title).toBe('Time series databases');
|
|
|
|
expect(categories[0].plugins.length).toBe(2);
|
|
|
|
expect(categories[1].title).toBe('Logging & document databases');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should sort plugins according to hard coded sorting rules', () => {
|
|
|
|
expect(categories[1].plugins[0].id).toBe('loki');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should add phantom plugin for Grafana cloud', () => {
|
2020-10-28 02:15:32 -05:00
|
|
|
expect(categories[2].title).toBe('Cloud');
|
|
|
|
expect(categories[2].plugins.length).toBe(2);
|
|
|
|
expect(categories[2].plugins[1].id).toBe('gcloud');
|
2020-01-06 09:56:34 -06:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should set module to phantom on phantom plugins', () => {
|
2020-10-28 02:15:32 -05:00
|
|
|
expect(categories[3].plugins[0].module).toBe('phantom');
|
2020-01-06 09:56:34 -06:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should add enterprise phantom plugins', () => {
|
2022-05-23 11:37:19 -05:00
|
|
|
const enterprisePluginsCategory = categories[3];
|
|
|
|
expect(enterprisePluginsCategory.title).toBe('Enterprise plugins');
|
|
|
|
expect(enterprisePluginsCategory.plugins.length).toBe(17);
|
|
|
|
expect(enterprisePluginsCategory.plugins[0].name).toBe('AppDynamics');
|
|
|
|
expect(enterprisePluginsCategory.plugins[enterprisePluginsCategory.plugins.length - 1].name).toBe('Wavefront');
|
2020-01-06 09:56:34 -06:00
|
|
|
});
|
|
|
|
});
|