The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
grafana/public/app/features/alerting/unified/components/PluginBridge.test.tsx

41 lines
1.5 KiB

import { screen, render } from 'test/test-utils';
import { setupMswServer } from 'app/features/alerting/unified/mockApi';
import { SupportedPlugin } from '../types/pluginBridges';
import { createBridgeURL, PluginBridge } from './PluginBridge';
const NON_EXISTING_PLUGIN = '__does_not_exist__';
setupMswServer();
describe('createBridgeURL', () => {
it('should work with path', () => {
expect(createBridgeURL(SupportedPlugin.Incident, '/incidents/declare')).toBe(
'/a/grafana-incident-app/incidents/declare'
);
});
it('should work with path and options', () => {
expect(createBridgeURL(SupportedPlugin.Incident, '/incidents/declare', { title: 'My Incident' })).toBe(
'/a/grafana-incident-app/incidents/declare?title=My+Incident'
);
});
});
describe('<PluginBridge />', () => {
it('should render notInstalled component', async () => {
render(<PluginBridge plugin={NON_EXISTING_PLUGIN} notInstalledFallback={<div>plugin not installed</div>} />);
expect(await screen.findByText('plugin not installed')).toBeInTheDocument();
});
it('should render loading and installed component', async () => {
render(
<PluginBridge plugin={SupportedPlugin.Incident} loadingComponent={<>Loading...</>}>
Plugin installed!
</PluginBridge>
);
expect(await screen.findByText('Loading...')).toBeInTheDocument();
expect(await screen.findByText('Plugin installed!')).toBeInTheDocument();
expect(screen.queryByText('Loading...')).not.toBeInTheDocument();
});
});