mirror of
https://github.com/grafana/grafana.git
synced 2025-02-11 16:15:42 -06:00
* remove Plugins and CloudIntegrations tab and add ConnectData tab * ConnectData: add Search component and use it * ConnectData: add DataSourcePluginList component * add CardGrid component * add CategoryHeader component * ConnectData: restructure content DataSourcePluginList is removed, because its responsibilities are actually the same as ConnectData's responsibilities. NoResults was added as a reusable component, and was moved out of CardGrid, since there could be more CardGrid on one page, but only one NoResults. * fix spacer * use LoadingPlaceholder * CardGrid: add margin * generalize CardGridProps * move isLoading and error into CardGrid We'd like CardGrid to be reusable, even multiple times within a page. In this case, it's better UX if we show the loading or error states per card grid, not for the whole page. * ConnectData: fix NoResults condition * fix and add meaningful tests * fix indentation * move isLoading and error back to ConnectData * make `url` required for CardGrid items
49 lines
1.6 KiB
TypeScript
49 lines
1.6 KiB
TypeScript
import { fireEvent, render, RenderResult, screen } from '@testing-library/react';
|
|
import React from 'react';
|
|
import { Provider } from 'react-redux';
|
|
|
|
import { CatalogPlugin } from 'app/features/plugins/admin/types';
|
|
import { configureStore } from 'app/store/configureStore';
|
|
|
|
import { getCatalogPluginMock, getPluginsStateMock } from '../../../plugins/admin/__mocks__';
|
|
|
|
import { ConnectData } from './ConnectData';
|
|
|
|
jest.mock('app/features/datasources/api');
|
|
|
|
const renderPage = (plugins: CatalogPlugin[] = []): RenderResult => {
|
|
// @ts-ignore
|
|
const store = configureStore({ plugins: getPluginsStateMock(plugins) });
|
|
|
|
return render(
|
|
<Provider store={store}>
|
|
<ConnectData />
|
|
</Provider>
|
|
);
|
|
};
|
|
|
|
describe('Connect Data', () => {
|
|
test('renders no results if the plugins list is empty', async () => {
|
|
renderPage();
|
|
|
|
expect(screen.queryByText('No results matching your query were found.')).toBeInTheDocument();
|
|
});
|
|
|
|
test('renders card if plugins list is populated', async () => {
|
|
renderPage([getCatalogPluginMock()]);
|
|
|
|
expect(await screen.findByText('Zabbix')).toBeVisible();
|
|
});
|
|
|
|
test('renders card if search term matches', async () => {
|
|
renderPage([getCatalogPluginMock()]);
|
|
const searchField = await screen.findByRole('textbox');
|
|
|
|
fireEvent.change(searchField, { target: { value: 'abbi' } });
|
|
expect(await screen.findByText('Zabbix')).toBeVisible();
|
|
|
|
fireEvent.change(searchField, { target: { value: 'rabbit' } });
|
|
expect(screen.queryByText('No results matching your query were found.')).toBeInTheDocument();
|
|
});
|
|
});
|