update plugin install filter to show all by default

This commit is contained in:
David Harris
2024-05-01 11:56:18 +01:00
parent b0f1222a21
commit a9751729e4
2 changed files with 10 additions and 8 deletions
@@ -45,20 +45,22 @@ const renderBrowse = (
describe('Browse list of plugins', () => {
describe('when filtering', () => {
it('should list installed plugins by default', async () => {
it('should list all plugins (including core plugins) by default', async () => {
const { queryByText } = renderBrowse('/plugins', [
getCatalogPluginMock({ id: 'plugin-1', name: 'Plugin 1', isInstalled: true }),
getCatalogPluginMock({ id: 'plugin-2', name: 'Plugin 2', isInstalled: true }),
getCatalogPluginMock({ id: 'plugin-3', name: 'Plugin 3', isInstalled: true }),
getCatalogPluginMock({ id: 'plugin-4', name: 'Plugin 4', isInstalled: false }),
getCatalogPluginMock({ id: 'plugin-3', name: 'Plugin 3', isInstalled: false }),
getCatalogPluginMock({ id: 'plugin-4', name: 'Plugin 4', isInstalled: true, isCore: true }),
]);
await waitFor(() => expect(queryByText('Plugin 1')).toBeInTheDocument());
expect(queryByText('Plugin 1')).toBeInTheDocument();
expect(queryByText('Plugin 2')).toBeInTheDocument();
expect(queryByText('Plugin 2')).toBeInTheDocument();
// Plugins which are not installed should still be listed
expect(queryByText('Plugin 3')).toBeInTheDocument();
expect(queryByText('Plugin 4')).toBeNull();
// Core plugins should still be listed
expect(queryByText('Plugin 4')).toBeInTheDocument();
});
it('should list all plugins (including core plugins) when filtering by all', async () => {
@@ -28,7 +28,7 @@ export default function Browse({ route }: GrafanaRouteComponentProps): ReactElem
const history = useHistory();
const remotePluginsAvailable = useIsRemotePluginsAvailable();
const keyword = locationSearch.q?.toString() || '';
const filterBy = locationSearch.filterBy?.toString() || 'installed';
const filterBy = locationSearch.filterBy?.toString() || 'all';
const filterByType = (locationSearch.filterByType as PluginType | 'all') || 'all';
const sortBy = (locationSearch.sortBy as Sorters) || Sorters.nameAsc;
const { isLoading, error, plugins } = useGetAll(