grafana/public/app/features/search/components/DashboardSearch.test.tsx

136 lines
3.7 KiB
TypeScript
Raw Normal View History

Search/refactor dashboard search (#23274) * Search: add search wrapper * Search: add DashboardSearch.tsx * Search: enable search * Search: update types * Search: useReducer for saving search results * Search: use default query * Search: add toggle custom action * Search: add onQueryChange * Search: debounce search * Search: pas dispatch as a prop * Search: add tag filter * Search: Fix types * Search: revert changes * Search: close overlay on esc * Search: enable tag filtering * Search: clear query * Search: add autofocus to search field * Search: Rename close to closeSearch * Search: Add no results message * Search: Add loading state * Search: Remove Select from Forms namespace * Remove Add selectedIndex * Remove Add getFlattenedSections * Remove Enable selecting items * Search: add hasId * Search: preselect first item * Search: Add utils tests * Search: Fix moving selection down * Search: Add findSelected * Search: Add type to section * Search: Handle Enter key press on item highlight * Search: Move reducer et al. to separate files * Search: Remove redundant render check * Search: Close overlay on Esc and ArrowLeft press * Search: Add close button * Search: Document utils * Search: use Icon for remove icon * Search: Add DashboardSearch.test.tsx * Search: Move test data to a separate file * Search: Finalise DashboardSearch.test.tsx * Add search reducer tests * Search: Add search results loading indicator * Search: Remove inline function * Search: Do not mutate item * Search: Tweak utils * Search: Do not clear query on tag clear * Search: Fix folder:current search * Search: Fix results scroll * Search: Update tests * Search: Close overlay on cog icon click * Add mobile styles for close button * Search: Use CustomScrollbar * Search: Memoize TagList.tsx * Search: Fix type errors * Search: More strictNullChecks fixes * Search: Consistent handler names * Search: Fix search items types in test * Search: Fix merge conflicts * Search: Fix strictNullChecks errors
2020-04-08 10:14:03 -05:00
import React from 'react';
import { render, fireEvent, screen, waitFor, act } from '@testing-library/react';
import selectEvent from 'react-select-event';
import * as SearchSrv from 'app/core/services/search_srv';
import * as MockSearchSrv from 'app/core/services/__mocks__/search_srv';
import { DashboardSearch, Props } from './DashboardSearch';
Search/refactor dashboard search (#23274) * Search: add search wrapper * Search: add DashboardSearch.tsx * Search: enable search * Search: update types * Search: useReducer for saving search results * Search: use default query * Search: add toggle custom action * Search: add onQueryChange * Search: debounce search * Search: pas dispatch as a prop * Search: add tag filter * Search: Fix types * Search: revert changes * Search: close overlay on esc * Search: enable tag filtering * Search: clear query * Search: add autofocus to search field * Search: Rename close to closeSearch * Search: Add no results message * Search: Add loading state * Search: Remove Select from Forms namespace * Remove Add selectedIndex * Remove Add getFlattenedSections * Remove Enable selecting items * Search: add hasId * Search: preselect first item * Search: Add utils tests * Search: Fix moving selection down * Search: Add findSelected * Search: Add type to section * Search: Handle Enter key press on item highlight * Search: Move reducer et al. to separate files * Search: Remove redundant render check * Search: Close overlay on Esc and ArrowLeft press * Search: Add close button * Search: Document utils * Search: use Icon for remove icon * Search: Add DashboardSearch.test.tsx * Search: Move test data to a separate file * Search: Finalise DashboardSearch.test.tsx * Add search reducer tests * Search: Add search results loading indicator * Search: Remove inline function * Search: Do not mutate item * Search: Tweak utils * Search: Do not clear query on tag clear * Search: Fix folder:current search * Search: Fix results scroll * Search: Update tests * Search: Close overlay on cog icon click * Add mobile styles for close button * Search: Use CustomScrollbar * Search: Memoize TagList.tsx * Search: Fix type errors * Search: More strictNullChecks fixes * Search: Consistent handler names * Search: Fix search items types in test * Search: Fix merge conflicts * Search: Fix strictNullChecks errors
2020-04-08 10:14:03 -05:00
import { searchResults } from '../testData';
import { SearchLayout } from '../types';
Search/refactor dashboard search (#23274) * Search: add search wrapper * Search: add DashboardSearch.tsx * Search: enable search * Search: update types * Search: useReducer for saving search results * Search: use default query * Search: add toggle custom action * Search: add onQueryChange * Search: debounce search * Search: pas dispatch as a prop * Search: add tag filter * Search: Fix types * Search: revert changes * Search: close overlay on esc * Search: enable tag filtering * Search: clear query * Search: add autofocus to search field * Search: Rename close to closeSearch * Search: Add no results message * Search: Add loading state * Search: Remove Select from Forms namespace * Remove Add selectedIndex * Remove Add getFlattenedSections * Remove Enable selecting items * Search: add hasId * Search: preselect first item * Search: Add utils tests * Search: Fix moving selection down * Search: Add findSelected * Search: Add type to section * Search: Handle Enter key press on item highlight * Search: Move reducer et al. to separate files * Search: Remove redundant render check * Search: Close overlay on Esc and ArrowLeft press * Search: Add close button * Search: Document utils * Search: use Icon for remove icon * Search: Add DashboardSearch.test.tsx * Search: Move test data to a separate file * Search: Finalise DashboardSearch.test.tsx * Add search reducer tests * Search: Add search results loading indicator * Search: Remove inline function * Search: Do not mutate item * Search: Tweak utils * Search: Do not clear query on tag clear * Search: Fix folder:current search * Search: Fix results scroll * Search: Update tests * Search: Close overlay on cog icon click * Add mobile styles for close button * Search: Use CustomScrollbar * Search: Memoize TagList.tsx * Search: Fix type errors * Search: More strictNullChecks fixes * Search: Consistent handler names * Search: Fix search items types in test * Search: Fix merge conflicts * Search: Fix strictNullChecks errors
2020-04-08 10:14:03 -05:00
jest.mock('app/core/services/search_srv');
// Typecast the mock search so the mock import is correctly recognised by TS
// https://stackoverflow.com/a/53222290
const { mockSearch } = SearchSrv as typeof MockSearchSrv;
Search/refactor dashboard search (#23274) * Search: add search wrapper * Search: add DashboardSearch.tsx * Search: enable search * Search: update types * Search: useReducer for saving search results * Search: use default query * Search: add toggle custom action * Search: add onQueryChange * Search: debounce search * Search: pas dispatch as a prop * Search: add tag filter * Search: Fix types * Search: revert changes * Search: close overlay on esc * Search: enable tag filtering * Search: clear query * Search: add autofocus to search field * Search: Rename close to closeSearch * Search: Add no results message * Search: Add loading state * Search: Remove Select from Forms namespace * Remove Add selectedIndex * Remove Add getFlattenedSections * Remove Enable selecting items * Search: add hasId * Search: preselect first item * Search: Add utils tests * Search: Fix moving selection down * Search: Add findSelected * Search: Add type to section * Search: Handle Enter key press on item highlight * Search: Move reducer et al. to separate files * Search: Remove redundant render check * Search: Close overlay on Esc and ArrowLeft press * Search: Add close button * Search: Document utils * Search: use Icon for remove icon * Search: Add DashboardSearch.test.tsx * Search: Move test data to a separate file * Search: Finalise DashboardSearch.test.tsx * Add search reducer tests * Search: Add search results loading indicator * Search: Remove inline function * Search: Do not mutate item * Search: Tweak utils * Search: Do not clear query on tag clear * Search: Fix folder:current search * Search: Fix results scroll * Search: Update tests * Search: Close overlay on cog icon click * Add mobile styles for close button * Search: Use CustomScrollbar * Search: Memoize TagList.tsx * Search: Fix type errors * Search: More strictNullChecks fixes * Search: Consistent handler names * Search: Fix search items types in test * Search: Fix merge conflicts * Search: Fix strictNullChecks errors
2020-04-08 10:14:03 -05:00
beforeEach(() => {
jest.useFakeTimers();
mockSearch.mockClear();
});
afterEach(() => {
jest.useRealTimers();
});
const setup = (testProps?: Partial<Props>) => {
Search: migrate manage dashboards (#23530) * Search: add search wrapper * Search: add DashboardSearch.tsx * Search: enable search * Search: update types * Search: useReducer for saving search results * Search: use default query * Search: add toggle custom action * Search: add onQueryChange * Search: debounce search * Search: pas dispatch as a prop * Search: add tag filter * Search: Fix types * Search: revert changes * Search: close overlay on esc * Search: enable tag filtering * Search: clear query * Search: add autofocus to search field * Search: Rename close to closeSearch * Search: Add no results message * Search: Add loading state * Search: Remove Select from Forms namespace * Remove Add selectedIndex * Remove Add getFlattenedSections * Remove Enable selecting items * Search: add hasId * Search: preselect first item * Search: Add utils tests * Search: Fix moving selection down * Search: Add findSelected * Search: Add type to section * Search: Handle Enter key press on item highlight * Search: Move reducer et al. to separate files * Search: Remove redundant render check * Search: Close overlay on Esc and ArrowLeft press * Search: Add close button * Search: Document utils * Search: use Icon for remove icon * Search: Add DashboardSearch.test.tsx * Search: Move test data to a separate file * Search: Finalise DashboardSearch.test.tsx * Add search reducer tests * Search: Add search results loading indicator * Search: Remove inline function * Search: Do not mutate item * Search: Tweak utils * Search: Do not clear query on tag clear * Search: Fix folder:current search * Search: Fix results scroll * Search: Update tests * Search: Close overlay on cog icon click * Add mobile styles for close button * Search: Use CustomScrollbar * Search: Memoize TagList.tsx * Search: Fix type errors * Search: More strictNullChecks fixes * Search: Add ManageDashboards.tsx * Search: Add mergeReducers * Search: Use mergeReducers * Search: remove default state from reducers * Search: Fix recent and starred icons * Search: Enable search * Search: Add markup * Search: Separate manageDashboardsReducer * Search: Add DashboardActions.tsx * Use new Select for TagFilter * Search: Use TagFilter for search filters * Search: Use TagList * Search: Add toggleSection * Search: Add more actions * Search add manageDashboards.test.ts * Search: Add getCheckedUids * Search: Add modify and toggle checked actions * Search: Update tests * Search: Update component template * Search: Enable section toggle * Search: Derive canMove and canDelete * Search: Handle delete items * Search: Fix tests * Search: Enable toggle items * Search: Add confirm modal subtitle * Search: Use theme vars * Search: Add getCheckedDashboardsUids * Search: Add MoveToFolderModal * Search: Enable moving dashboards * Search: Fix strict null checks errors * Search: Fix strict null checks errors[2] * Search: Enable filters * Search: Add useSearchQuery.ts * Search: Toggle items when toggling all * Search: Update useSearchQuery to accept custom params * Search: Add useSearchQuery to dashboard search * Search: use SearchField for manage dashboards * Search: Remove event param from query change * Search: Add base search hooks * Search: refactor useSearch to accept reducer * Search: use useDashboardSearch hook * Search: Fix useSearchQuery params * Search: Enable folder search * Search: Update tests * Search: Pass the props to manage-dashboards * Search: Add search filters margin * Search: Remove search-field-wrapper class and hide logic for it * Search: Adjust SearchField styles * Search: Move search-results-container inside SearchResults * Search: Fix type errors * Search: Add EmptyListCTA * Search: Update move message * Search: Cleanup * Search: Add todo * Search: Fix action type * Search: Use React wrapper vs FolderDashboardsCtrl and DashboardListCtrl * Search: DashboardList => DashboardListPage * Search: Remove ManageDashboards from angular_wrappers * Minor style tweaks * Search: Use LinkButton Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
2020-04-17 07:29:20 -05:00
const props: any = {
onCloseSearch: () => {},
...testProps,
Search: migrate manage dashboards (#23530) * Search: add search wrapper * Search: add DashboardSearch.tsx * Search: enable search * Search: update types * Search: useReducer for saving search results * Search: use default query * Search: add toggle custom action * Search: add onQueryChange * Search: debounce search * Search: pas dispatch as a prop * Search: add tag filter * Search: Fix types * Search: revert changes * Search: close overlay on esc * Search: enable tag filtering * Search: clear query * Search: add autofocus to search field * Search: Rename close to closeSearch * Search: Add no results message * Search: Add loading state * Search: Remove Select from Forms namespace * Remove Add selectedIndex * Remove Add getFlattenedSections * Remove Enable selecting items * Search: add hasId * Search: preselect first item * Search: Add utils tests * Search: Fix moving selection down * Search: Add findSelected * Search: Add type to section * Search: Handle Enter key press on item highlight * Search: Move reducer et al. to separate files * Search: Remove redundant render check * Search: Close overlay on Esc and ArrowLeft press * Search: Add close button * Search: Document utils * Search: use Icon for remove icon * Search: Add DashboardSearch.test.tsx * Search: Move test data to a separate file * Search: Finalise DashboardSearch.test.tsx * Add search reducer tests * Search: Add search results loading indicator * Search: Remove inline function * Search: Do not mutate item * Search: Tweak utils * Search: Do not clear query on tag clear * Search: Fix folder:current search * Search: Fix results scroll * Search: Update tests * Search: Close overlay on cog icon click * Add mobile styles for close button * Search: Use CustomScrollbar * Search: Memoize TagList.tsx * Search: Fix type errors * Search: More strictNullChecks fixes * Search: Add ManageDashboards.tsx * Search: Add mergeReducers * Search: Use mergeReducers * Search: remove default state from reducers * Search: Fix recent and starred icons * Search: Enable search * Search: Add markup * Search: Separate manageDashboardsReducer * Search: Add DashboardActions.tsx * Use new Select for TagFilter * Search: Use TagFilter for search filters * Search: Use TagList * Search: Add toggleSection * Search: Add more actions * Search add manageDashboards.test.ts * Search: Add getCheckedUids * Search: Add modify and toggle checked actions * Search: Update tests * Search: Update component template * Search: Enable section toggle * Search: Derive canMove and canDelete * Search: Handle delete items * Search: Fix tests * Search: Enable toggle items * Search: Add confirm modal subtitle * Search: Use theme vars * Search: Add getCheckedDashboardsUids * Search: Add MoveToFolderModal * Search: Enable moving dashboards * Search: Fix strict null checks errors * Search: Fix strict null checks errors[2] * Search: Enable filters * Search: Add useSearchQuery.ts * Search: Toggle items when toggling all * Search: Update useSearchQuery to accept custom params * Search: Add useSearchQuery to dashboard search * Search: use SearchField for manage dashboards * Search: Remove event param from query change * Search: Add base search hooks * Search: refactor useSearch to accept reducer * Search: use useDashboardSearch hook * Search: Fix useSearchQuery params * Search: Enable folder search * Search: Update tests * Search: Pass the props to manage-dashboards * Search: Add search filters margin * Search: Remove search-field-wrapper class and hide logic for it * Search: Adjust SearchField styles * Search: Move search-results-container inside SearchResults * Search: Fix type errors * Search: Add EmptyListCTA * Search: Update move message * Search: Cleanup * Search: Add todo * Search: Fix action type * Search: Use React wrapper vs FolderDashboardsCtrl and DashboardListCtrl * Search: DashboardList => DashboardListPage * Search: Remove ManageDashboards from angular_wrappers * Minor style tweaks * Search: Use LinkButton Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
2020-04-17 07:29:20 -05:00
};
render(<DashboardSearch {...props} />);
jest.runAllTimers();
Search: migrate manage dashboards (#23530) * Search: add search wrapper * Search: add DashboardSearch.tsx * Search: enable search * Search: update types * Search: useReducer for saving search results * Search: use default query * Search: add toggle custom action * Search: add onQueryChange * Search: debounce search * Search: pas dispatch as a prop * Search: add tag filter * Search: Fix types * Search: revert changes * Search: close overlay on esc * Search: enable tag filtering * Search: clear query * Search: add autofocus to search field * Search: Rename close to closeSearch * Search: Add no results message * Search: Add loading state * Search: Remove Select from Forms namespace * Remove Add selectedIndex * Remove Add getFlattenedSections * Remove Enable selecting items * Search: add hasId * Search: preselect first item * Search: Add utils tests * Search: Fix moving selection down * Search: Add findSelected * Search: Add type to section * Search: Handle Enter key press on item highlight * Search: Move reducer et al. to separate files * Search: Remove redundant render check * Search: Close overlay on Esc and ArrowLeft press * Search: Add close button * Search: Document utils * Search: use Icon for remove icon * Search: Add DashboardSearch.test.tsx * Search: Move test data to a separate file * Search: Finalise DashboardSearch.test.tsx * Add search reducer tests * Search: Add search results loading indicator * Search: Remove inline function * Search: Do not mutate item * Search: Tweak utils * Search: Do not clear query on tag clear * Search: Fix folder:current search * Search: Fix results scroll * Search: Update tests * Search: Close overlay on cog icon click * Add mobile styles for close button * Search: Use CustomScrollbar * Search: Memoize TagList.tsx * Search: Fix type errors * Search: More strictNullChecks fixes * Search: Add ManageDashboards.tsx * Search: Add mergeReducers * Search: Use mergeReducers * Search: remove default state from reducers * Search: Fix recent and starred icons * Search: Enable search * Search: Add markup * Search: Separate manageDashboardsReducer * Search: Add DashboardActions.tsx * Use new Select for TagFilter * Search: Use TagFilter for search filters * Search: Use TagList * Search: Add toggleSection * Search: Add more actions * Search add manageDashboards.test.ts * Search: Add getCheckedUids * Search: Add modify and toggle checked actions * Search: Update tests * Search: Update component template * Search: Enable section toggle * Search: Derive canMove and canDelete * Search: Handle delete items * Search: Fix tests * Search: Enable toggle items * Search: Add confirm modal subtitle * Search: Use theme vars * Search: Add getCheckedDashboardsUids * Search: Add MoveToFolderModal * Search: Enable moving dashboards * Search: Fix strict null checks errors * Search: Fix strict null checks errors[2] * Search: Enable filters * Search: Add useSearchQuery.ts * Search: Toggle items when toggling all * Search: Update useSearchQuery to accept custom params * Search: Add useSearchQuery to dashboard search * Search: use SearchField for manage dashboards * Search: Remove event param from query change * Search: Add base search hooks * Search: refactor useSearch to accept reducer * Search: use useDashboardSearch hook * Search: Fix useSearchQuery params * Search: Enable folder search * Search: Update tests * Search: Pass the props to manage-dashboards * Search: Add search filters margin * Search: Remove search-field-wrapper class and hide logic for it * Search: Adjust SearchField styles * Search: Move search-results-container inside SearchResults * Search: Fix type errors * Search: Add EmptyListCTA * Search: Update move message * Search: Cleanup * Search: Add todo * Search: Fix action type * Search: Use React wrapper vs FolderDashboardsCtrl and DashboardListCtrl * Search: DashboardList => DashboardListPage * Search: Remove ManageDashboards from angular_wrappers * Minor style tweaks * Search: Use LinkButton Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
2020-04-17 07:29:20 -05:00
};
Search/refactor dashboard search (#23274) * Search: add search wrapper * Search: add DashboardSearch.tsx * Search: enable search * Search: update types * Search: useReducer for saving search results * Search: use default query * Search: add toggle custom action * Search: add onQueryChange * Search: debounce search * Search: pas dispatch as a prop * Search: add tag filter * Search: Fix types * Search: revert changes * Search: close overlay on esc * Search: enable tag filtering * Search: clear query * Search: add autofocus to search field * Search: Rename close to closeSearch * Search: Add no results message * Search: Add loading state * Search: Remove Select from Forms namespace * Remove Add selectedIndex * Remove Add getFlattenedSections * Remove Enable selecting items * Search: add hasId * Search: preselect first item * Search: Add utils tests * Search: Fix moving selection down * Search: Add findSelected * Search: Add type to section * Search: Handle Enter key press on item highlight * Search: Move reducer et al. to separate files * Search: Remove redundant render check * Search: Close overlay on Esc and ArrowLeft press * Search: Add close button * Search: Document utils * Search: use Icon for remove icon * Search: Add DashboardSearch.test.tsx * Search: Move test data to a separate file * Search: Finalise DashboardSearch.test.tsx * Add search reducer tests * Search: Add search results loading indicator * Search: Remove inline function * Search: Do not mutate item * Search: Tweak utils * Search: Do not clear query on tag clear * Search: Fix folder:current search * Search: Fix results scroll * Search: Update tests * Search: Close overlay on cog icon click * Add mobile styles for close button * Search: Use CustomScrollbar * Search: Memoize TagList.tsx * Search: Fix type errors * Search: More strictNullChecks fixes * Search: Consistent handler names * Search: Fix search items types in test * Search: Fix merge conflicts * Search: Fix strictNullChecks errors
2020-04-08 10:14:03 -05:00
/**
* Need to wrap component render in async act and use jest.runAllTimers to test
* calls inside useDebounce hook
*/
describe('DashboardSearch', () => {
it('should call search api with default query when initialised', async () => {
setup();
await waitFor(() => screen.getByPlaceholderText('Search dashboards by name'));
Search/refactor dashboard search (#23274) * Search: add search wrapper * Search: add DashboardSearch.tsx * Search: enable search * Search: update types * Search: useReducer for saving search results * Search: use default query * Search: add toggle custom action * Search: add onQueryChange * Search: debounce search * Search: pas dispatch as a prop * Search: add tag filter * Search: Fix types * Search: revert changes * Search: close overlay on esc * Search: enable tag filtering * Search: clear query * Search: add autofocus to search field * Search: Rename close to closeSearch * Search: Add no results message * Search: Add loading state * Search: Remove Select from Forms namespace * Remove Add selectedIndex * Remove Add getFlattenedSections * Remove Enable selecting items * Search: add hasId * Search: preselect first item * Search: Add utils tests * Search: Fix moving selection down * Search: Add findSelected * Search: Add type to section * Search: Handle Enter key press on item highlight * Search: Move reducer et al. to separate files * Search: Remove redundant render check * Search: Close overlay on Esc and ArrowLeft press * Search: Add close button * Search: Document utils * Search: use Icon for remove icon * Search: Add DashboardSearch.test.tsx * Search: Move test data to a separate file * Search: Finalise DashboardSearch.test.tsx * Add search reducer tests * Search: Add search results loading indicator * Search: Remove inline function * Search: Do not mutate item * Search: Tweak utils * Search: Do not clear query on tag clear * Search: Fix folder:current search * Search: Fix results scroll * Search: Update tests * Search: Close overlay on cog icon click * Add mobile styles for close button * Search: Use CustomScrollbar * Search: Memoize TagList.tsx * Search: Fix type errors * Search: More strictNullChecks fixes * Search: Consistent handler names * Search: Fix search items types in test * Search: Fix merge conflicts * Search: Fix strictNullChecks errors
2020-04-08 10:14:03 -05:00
expect(mockSearch).toHaveBeenCalledTimes(1);
expect(mockSearch).toHaveBeenCalledWith({
query: '',
tag: [],
Search: migrate manage dashboards (#23530) * Search: add search wrapper * Search: add DashboardSearch.tsx * Search: enable search * Search: update types * Search: useReducer for saving search results * Search: use default query * Search: add toggle custom action * Search: add onQueryChange * Search: debounce search * Search: pas dispatch as a prop * Search: add tag filter * Search: Fix types * Search: revert changes * Search: close overlay on esc * Search: enable tag filtering * Search: clear query * Search: add autofocus to search field * Search: Rename close to closeSearch * Search: Add no results message * Search: Add loading state * Search: Remove Select from Forms namespace * Remove Add selectedIndex * Remove Add getFlattenedSections * Remove Enable selecting items * Search: add hasId * Search: preselect first item * Search: Add utils tests * Search: Fix moving selection down * Search: Add findSelected * Search: Add type to section * Search: Handle Enter key press on item highlight * Search: Move reducer et al. to separate files * Search: Remove redundant render check * Search: Close overlay on Esc and ArrowLeft press * Search: Add close button * Search: Document utils * Search: use Icon for remove icon * Search: Add DashboardSearch.test.tsx * Search: Move test data to a separate file * Search: Finalise DashboardSearch.test.tsx * Add search reducer tests * Search: Add search results loading indicator * Search: Remove inline function * Search: Do not mutate item * Search: Tweak utils * Search: Do not clear query on tag clear * Search: Fix folder:current search * Search: Fix results scroll * Search: Update tests * Search: Close overlay on cog icon click * Add mobile styles for close button * Search: Use CustomScrollbar * Search: Memoize TagList.tsx * Search: Fix type errors * Search: More strictNullChecks fixes * Search: Add ManageDashboards.tsx * Search: Add mergeReducers * Search: Use mergeReducers * Search: remove default state from reducers * Search: Fix recent and starred icons * Search: Enable search * Search: Add markup * Search: Separate manageDashboardsReducer * Search: Add DashboardActions.tsx * Use new Select for TagFilter * Search: Use TagFilter for search filters * Search: Use TagList * Search: Add toggleSection * Search: Add more actions * Search add manageDashboards.test.ts * Search: Add getCheckedUids * Search: Add modify and toggle checked actions * Search: Update tests * Search: Update component template * Search: Enable section toggle * Search: Derive canMove and canDelete * Search: Handle delete items * Search: Fix tests * Search: Enable toggle items * Search: Add confirm modal subtitle * Search: Use theme vars * Search: Add getCheckedDashboardsUids * Search: Add MoveToFolderModal * Search: Enable moving dashboards * Search: Fix strict null checks errors * Search: Fix strict null checks errors[2] * Search: Enable filters * Search: Add useSearchQuery.ts * Search: Toggle items when toggling all * Search: Update useSearchQuery to accept custom params * Search: Add useSearchQuery to dashboard search * Search: use SearchField for manage dashboards * Search: Remove event param from query change * Search: Add base search hooks * Search: refactor useSearch to accept reducer * Search: use useDashboardSearch hook * Search: Fix useSearchQuery params * Search: Enable folder search * Search: Update tests * Search: Pass the props to manage-dashboards * Search: Add search filters margin * Search: Remove search-field-wrapper class and hide logic for it * Search: Adjust SearchField styles * Search: Move search-results-container inside SearchResults * Search: Fix type errors * Search: Add EmptyListCTA * Search: Update move message * Search: Cleanup * Search: Add todo * Search: Fix action type * Search: Use React wrapper vs FolderDashboardsCtrl and DashboardListCtrl * Search: DashboardList => DashboardListPage * Search: Remove ManageDashboards from angular_wrappers * Minor style tweaks * Search: Use LinkButton Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
2020-04-17 07:29:20 -05:00
skipRecent: false,
skipStarred: false,
Search/refactor dashboard search (#23274) * Search: add search wrapper * Search: add DashboardSearch.tsx * Search: enable search * Search: update types * Search: useReducer for saving search results * Search: use default query * Search: add toggle custom action * Search: add onQueryChange * Search: debounce search * Search: pas dispatch as a prop * Search: add tag filter * Search: Fix types * Search: revert changes * Search: close overlay on esc * Search: enable tag filtering * Search: clear query * Search: add autofocus to search field * Search: Rename close to closeSearch * Search: Add no results message * Search: Add loading state * Search: Remove Select from Forms namespace * Remove Add selectedIndex * Remove Add getFlattenedSections * Remove Enable selecting items * Search: add hasId * Search: preselect first item * Search: Add utils tests * Search: Fix moving selection down * Search: Add findSelected * Search: Add type to section * Search: Handle Enter key press on item highlight * Search: Move reducer et al. to separate files * Search: Remove redundant render check * Search: Close overlay on Esc and ArrowLeft press * Search: Add close button * Search: Document utils * Search: use Icon for remove icon * Search: Add DashboardSearch.test.tsx * Search: Move test data to a separate file * Search: Finalise DashboardSearch.test.tsx * Add search reducer tests * Search: Add search results loading indicator * Search: Remove inline function * Search: Do not mutate item * Search: Tweak utils * Search: Do not clear query on tag clear * Search: Fix folder:current search * Search: Fix results scroll * Search: Update tests * Search: Close overlay on cog icon click * Add mobile styles for close button * Search: Use CustomScrollbar * Search: Memoize TagList.tsx * Search: Fix type errors * Search: More strictNullChecks fixes * Search: Consistent handler names * Search: Fix search items types in test * Search: Fix merge conflicts * Search: Fix strictNullChecks errors
2020-04-08 10:14:03 -05:00
starred: false,
folderIds: [],
layout: SearchLayout.Folders,
sort: undefined,
prevSort: null,
Search/refactor dashboard search (#23274) * Search: add search wrapper * Search: add DashboardSearch.tsx * Search: enable search * Search: update types * Search: useReducer for saving search results * Search: use default query * Search: add toggle custom action * Search: add onQueryChange * Search: debounce search * Search: pas dispatch as a prop * Search: add tag filter * Search: Fix types * Search: revert changes * Search: close overlay on esc * Search: enable tag filtering * Search: clear query * Search: add autofocus to search field * Search: Rename close to closeSearch * Search: Add no results message * Search: Add loading state * Search: Remove Select from Forms namespace * Remove Add selectedIndex * Remove Add getFlattenedSections * Remove Enable selecting items * Search: add hasId * Search: preselect first item * Search: Add utils tests * Search: Fix moving selection down * Search: Add findSelected * Search: Add type to section * Search: Handle Enter key press on item highlight * Search: Move reducer et al. to separate files * Search: Remove redundant render check * Search: Close overlay on Esc and ArrowLeft press * Search: Add close button * Search: Document utils * Search: use Icon for remove icon * Search: Add DashboardSearch.test.tsx * Search: Move test data to a separate file * Search: Finalise DashboardSearch.test.tsx * Add search reducer tests * Search: Add search results loading indicator * Search: Remove inline function * Search: Do not mutate item * Search: Tweak utils * Search: Do not clear query on tag clear * Search: Fix folder:current search * Search: Fix results scroll * Search: Update tests * Search: Close overlay on cog icon click * Add mobile styles for close button * Search: Use CustomScrollbar * Search: Memoize TagList.tsx * Search: Fix type errors * Search: More strictNullChecks fixes * Search: Consistent handler names * Search: Fix search items types in test * Search: Fix merge conflicts * Search: Fix strictNullChecks errors
2020-04-08 10:14:03 -05:00
});
});
it('should call api with updated query on query change', async () => {
setup();
Search: migrate manage dashboards (#23530) * Search: add search wrapper * Search: add DashboardSearch.tsx * Search: enable search * Search: update types * Search: useReducer for saving search results * Search: use default query * Search: add toggle custom action * Search: add onQueryChange * Search: debounce search * Search: pas dispatch as a prop * Search: add tag filter * Search: Fix types * Search: revert changes * Search: close overlay on esc * Search: enable tag filtering * Search: clear query * Search: add autofocus to search field * Search: Rename close to closeSearch * Search: Add no results message * Search: Add loading state * Search: Remove Select from Forms namespace * Remove Add selectedIndex * Remove Add getFlattenedSections * Remove Enable selecting items * Search: add hasId * Search: preselect first item * Search: Add utils tests * Search: Fix moving selection down * Search: Add findSelected * Search: Add type to section * Search: Handle Enter key press on item highlight * Search: Move reducer et al. to separate files * Search: Remove redundant render check * Search: Close overlay on Esc and ArrowLeft press * Search: Add close button * Search: Document utils * Search: use Icon for remove icon * Search: Add DashboardSearch.test.tsx * Search: Move test data to a separate file * Search: Finalise DashboardSearch.test.tsx * Add search reducer tests * Search: Add search results loading indicator * Search: Remove inline function * Search: Do not mutate item * Search: Tweak utils * Search: Do not clear query on tag clear * Search: Fix folder:current search * Search: Fix results scroll * Search: Update tests * Search: Close overlay on cog icon click * Add mobile styles for close button * Search: Use CustomScrollbar * Search: Memoize TagList.tsx * Search: Fix type errors * Search: More strictNullChecks fixes * Search: Add ManageDashboards.tsx * Search: Add mergeReducers * Search: Use mergeReducers * Search: remove default state from reducers * Search: Fix recent and starred icons * Search: Enable search * Search: Add markup * Search: Separate manageDashboardsReducer * Search: Add DashboardActions.tsx * Use new Select for TagFilter * Search: Use TagFilter for search filters * Search: Use TagList * Search: Add toggleSection * Search: Add more actions * Search add manageDashboards.test.ts * Search: Add getCheckedUids * Search: Add modify and toggle checked actions * Search: Update tests * Search: Update component template * Search: Enable section toggle * Search: Derive canMove and canDelete * Search: Handle delete items * Search: Fix tests * Search: Enable toggle items * Search: Add confirm modal subtitle * Search: Use theme vars * Search: Add getCheckedDashboardsUids * Search: Add MoveToFolderModal * Search: Enable moving dashboards * Search: Fix strict null checks errors * Search: Fix strict null checks errors[2] * Search: Enable filters * Search: Add useSearchQuery.ts * Search: Toggle items when toggling all * Search: Update useSearchQuery to accept custom params * Search: Add useSearchQuery to dashboard search * Search: use SearchField for manage dashboards * Search: Remove event param from query change * Search: Add base search hooks * Search: refactor useSearch to accept reducer * Search: use useDashboardSearch hook * Search: Fix useSearchQuery params * Search: Enable folder search * Search: Update tests * Search: Pass the props to manage-dashboards * Search: Add search filters margin * Search: Remove search-field-wrapper class and hide logic for it * Search: Adjust SearchField styles * Search: Move search-results-container inside SearchResults * Search: Fix type errors * Search: Add EmptyListCTA * Search: Update move message * Search: Cleanup * Search: Add todo * Search: Fix action type * Search: Use React wrapper vs FolderDashboardsCtrl and DashboardListCtrl * Search: DashboardList => DashboardListPage * Search: Remove ManageDashboards from angular_wrappers * Minor style tweaks * Search: Use LinkButton Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
2020-04-17 07:29:20 -05:00
const input = await screen.findByPlaceholderText('Search dashboards by name');
await act((async () => {
await fireEvent.input(input, { target: { value: 'Test' } });
Search/refactor dashboard search (#23274) * Search: add search wrapper * Search: add DashboardSearch.tsx * Search: enable search * Search: update types * Search: useReducer for saving search results * Search: use default query * Search: add toggle custom action * Search: add onQueryChange * Search: debounce search * Search: pas dispatch as a prop * Search: add tag filter * Search: Fix types * Search: revert changes * Search: close overlay on esc * Search: enable tag filtering * Search: clear query * Search: add autofocus to search field * Search: Rename close to closeSearch * Search: Add no results message * Search: Add loading state * Search: Remove Select from Forms namespace * Remove Add selectedIndex * Remove Add getFlattenedSections * Remove Enable selecting items * Search: add hasId * Search: preselect first item * Search: Add utils tests * Search: Fix moving selection down * Search: Add findSelected * Search: Add type to section * Search: Handle Enter key press on item highlight * Search: Move reducer et al. to separate files * Search: Remove redundant render check * Search: Close overlay on Esc and ArrowLeft press * Search: Add close button * Search: Document utils * Search: use Icon for remove icon * Search: Add DashboardSearch.test.tsx * Search: Move test data to a separate file * Search: Finalise DashboardSearch.test.tsx * Add search reducer tests * Search: Add search results loading indicator * Search: Remove inline function * Search: Do not mutate item * Search: Tweak utils * Search: Do not clear query on tag clear * Search: Fix folder:current search * Search: Fix results scroll * Search: Update tests * Search: Close overlay on cog icon click * Add mobile styles for close button * Search: Use CustomScrollbar * Search: Memoize TagList.tsx * Search: Fix type errors * Search: More strictNullChecks fixes * Search: Consistent handler names * Search: Fix search items types in test * Search: Fix merge conflicts * Search: Fix strictNullChecks errors
2020-04-08 10:14:03 -05:00
jest.runAllTimers();
}) as any);
Search/refactor dashboard search (#23274) * Search: add search wrapper * Search: add DashboardSearch.tsx * Search: enable search * Search: update types * Search: useReducer for saving search results * Search: use default query * Search: add toggle custom action * Search: add onQueryChange * Search: debounce search * Search: pas dispatch as a prop * Search: add tag filter * Search: Fix types * Search: revert changes * Search: close overlay on esc * Search: enable tag filtering * Search: clear query * Search: add autofocus to search field * Search: Rename close to closeSearch * Search: Add no results message * Search: Add loading state * Search: Remove Select from Forms namespace * Remove Add selectedIndex * Remove Add getFlattenedSections * Remove Enable selecting items * Search: add hasId * Search: preselect first item * Search: Add utils tests * Search: Fix moving selection down * Search: Add findSelected * Search: Add type to section * Search: Handle Enter key press on item highlight * Search: Move reducer et al. to separate files * Search: Remove redundant render check * Search: Close overlay on Esc and ArrowLeft press * Search: Add close button * Search: Document utils * Search: use Icon for remove icon * Search: Add DashboardSearch.test.tsx * Search: Move test data to a separate file * Search: Finalise DashboardSearch.test.tsx * Add search reducer tests * Search: Add search results loading indicator * Search: Remove inline function * Search: Do not mutate item * Search: Tweak utils * Search: Do not clear query on tag clear * Search: Fix folder:current search * Search: Fix results scroll * Search: Update tests * Search: Close overlay on cog icon click * Add mobile styles for close button * Search: Use CustomScrollbar * Search: Memoize TagList.tsx * Search: Fix type errors * Search: More strictNullChecks fixes * Search: Consistent handler names * Search: Fix search items types in test * Search: Fix merge conflicts * Search: Fix strictNullChecks errors
2020-04-08 10:14:03 -05:00
expect(mockSearch).toHaveBeenCalledWith({
query: 'Test',
Search: migrate manage dashboards (#23530) * Search: add search wrapper * Search: add DashboardSearch.tsx * Search: enable search * Search: update types * Search: useReducer for saving search results * Search: use default query * Search: add toggle custom action * Search: add onQueryChange * Search: debounce search * Search: pas dispatch as a prop * Search: add tag filter * Search: Fix types * Search: revert changes * Search: close overlay on esc * Search: enable tag filtering * Search: clear query * Search: add autofocus to search field * Search: Rename close to closeSearch * Search: Add no results message * Search: Add loading state * Search: Remove Select from Forms namespace * Remove Add selectedIndex * Remove Add getFlattenedSections * Remove Enable selecting items * Search: add hasId * Search: preselect first item * Search: Add utils tests * Search: Fix moving selection down * Search: Add findSelected * Search: Add type to section * Search: Handle Enter key press on item highlight * Search: Move reducer et al. to separate files * Search: Remove redundant render check * Search: Close overlay on Esc and ArrowLeft press * Search: Add close button * Search: Document utils * Search: use Icon for remove icon * Search: Add DashboardSearch.test.tsx * Search: Move test data to a separate file * Search: Finalise DashboardSearch.test.tsx * Add search reducer tests * Search: Add search results loading indicator * Search: Remove inline function * Search: Do not mutate item * Search: Tweak utils * Search: Do not clear query on tag clear * Search: Fix folder:current search * Search: Fix results scroll * Search: Update tests * Search: Close overlay on cog icon click * Add mobile styles for close button * Search: Use CustomScrollbar * Search: Memoize TagList.tsx * Search: Fix type errors * Search: More strictNullChecks fixes * Search: Add ManageDashboards.tsx * Search: Add mergeReducers * Search: Use mergeReducers * Search: remove default state from reducers * Search: Fix recent and starred icons * Search: Enable search * Search: Add markup * Search: Separate manageDashboardsReducer * Search: Add DashboardActions.tsx * Use new Select for TagFilter * Search: Use TagFilter for search filters * Search: Use TagList * Search: Add toggleSection * Search: Add more actions * Search add manageDashboards.test.ts * Search: Add getCheckedUids * Search: Add modify and toggle checked actions * Search: Update tests * Search: Update component template * Search: Enable section toggle * Search: Derive canMove and canDelete * Search: Handle delete items * Search: Fix tests * Search: Enable toggle items * Search: Add confirm modal subtitle * Search: Use theme vars * Search: Add getCheckedDashboardsUids * Search: Add MoveToFolderModal * Search: Enable moving dashboards * Search: Fix strict null checks errors * Search: Fix strict null checks errors[2] * Search: Enable filters * Search: Add useSearchQuery.ts * Search: Toggle items when toggling all * Search: Update useSearchQuery to accept custom params * Search: Add useSearchQuery to dashboard search * Search: use SearchField for manage dashboards * Search: Remove event param from query change * Search: Add base search hooks * Search: refactor useSearch to accept reducer * Search: use useDashboardSearch hook * Search: Fix useSearchQuery params * Search: Enable folder search * Search: Update tests * Search: Pass the props to manage-dashboards * Search: Add search filters margin * Search: Remove search-field-wrapper class and hide logic for it * Search: Adjust SearchField styles * Search: Move search-results-container inside SearchResults * Search: Fix type errors * Search: Add EmptyListCTA * Search: Update move message * Search: Cleanup * Search: Add todo * Search: Fix action type * Search: Use React wrapper vs FolderDashboardsCtrl and DashboardListCtrl * Search: DashboardList => DashboardListPage * Search: Remove ManageDashboards from angular_wrappers * Minor style tweaks * Search: Use LinkButton Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
2020-04-17 07:29:20 -05:00
skipRecent: false,
skipStarred: false,
Search/refactor dashboard search (#23274) * Search: add search wrapper * Search: add DashboardSearch.tsx * Search: enable search * Search: update types * Search: useReducer for saving search results * Search: use default query * Search: add toggle custom action * Search: add onQueryChange * Search: debounce search * Search: pas dispatch as a prop * Search: add tag filter * Search: Fix types * Search: revert changes * Search: close overlay on esc * Search: enable tag filtering * Search: clear query * Search: add autofocus to search field * Search: Rename close to closeSearch * Search: Add no results message * Search: Add loading state * Search: Remove Select from Forms namespace * Remove Add selectedIndex * Remove Add getFlattenedSections * Remove Enable selecting items * Search: add hasId * Search: preselect first item * Search: Add utils tests * Search: Fix moving selection down * Search: Add findSelected * Search: Add type to section * Search: Handle Enter key press on item highlight * Search: Move reducer et al. to separate files * Search: Remove redundant render check * Search: Close overlay on Esc and ArrowLeft press * Search: Add close button * Search: Document utils * Search: use Icon for remove icon * Search: Add DashboardSearch.test.tsx * Search: Move test data to a separate file * Search: Finalise DashboardSearch.test.tsx * Add search reducer tests * Search: Add search results loading indicator * Search: Remove inline function * Search: Do not mutate item * Search: Tweak utils * Search: Do not clear query on tag clear * Search: Fix folder:current search * Search: Fix results scroll * Search: Update tests * Search: Close overlay on cog icon click * Add mobile styles for close button * Search: Use CustomScrollbar * Search: Memoize TagList.tsx * Search: Fix type errors * Search: More strictNullChecks fixes * Search: Consistent handler names * Search: Fix search items types in test * Search: Fix merge conflicts * Search: Fix strictNullChecks errors
2020-04-08 10:14:03 -05:00
tag: [],
starred: false,
folderIds: [],
layout: SearchLayout.Folders,
sort: undefined,
prevSort: null,
Search/refactor dashboard search (#23274) * Search: add search wrapper * Search: add DashboardSearch.tsx * Search: enable search * Search: update types * Search: useReducer for saving search results * Search: use default query * Search: add toggle custom action * Search: add onQueryChange * Search: debounce search * Search: pas dispatch as a prop * Search: add tag filter * Search: Fix types * Search: revert changes * Search: close overlay on esc * Search: enable tag filtering * Search: clear query * Search: add autofocus to search field * Search: Rename close to closeSearch * Search: Add no results message * Search: Add loading state * Search: Remove Select from Forms namespace * Remove Add selectedIndex * Remove Add getFlattenedSections * Remove Enable selecting items * Search: add hasId * Search: preselect first item * Search: Add utils tests * Search: Fix moving selection down * Search: Add findSelected * Search: Add type to section * Search: Handle Enter key press on item highlight * Search: Move reducer et al. to separate files * Search: Remove redundant render check * Search: Close overlay on Esc and ArrowLeft press * Search: Add close button * Search: Document utils * Search: use Icon for remove icon * Search: Add DashboardSearch.test.tsx * Search: Move test data to a separate file * Search: Finalise DashboardSearch.test.tsx * Add search reducer tests * Search: Add search results loading indicator * Search: Remove inline function * Search: Do not mutate item * Search: Tweak utils * Search: Do not clear query on tag clear * Search: Fix folder:current search * Search: Fix results scroll * Search: Update tests * Search: Close overlay on cog icon click * Add mobile styles for close button * Search: Use CustomScrollbar * Search: Memoize TagList.tsx * Search: Fix type errors * Search: More strictNullChecks fixes * Search: Consistent handler names * Search: Fix search items types in test * Search: Fix merge conflicts * Search: Fix strictNullChecks errors
2020-04-08 10:14:03 -05:00
});
});
it("should render 'No results' message when there are no dashboards", async () => {
setup();
const message = await screen.findByText('No dashboards matching your query were found.');
expect(message).toBeInTheDocument();
Search/refactor dashboard search (#23274) * Search: add search wrapper * Search: add DashboardSearch.tsx * Search: enable search * Search: update types * Search: useReducer for saving search results * Search: use default query * Search: add toggle custom action * Search: add onQueryChange * Search: debounce search * Search: pas dispatch as a prop * Search: add tag filter * Search: Fix types * Search: revert changes * Search: close overlay on esc * Search: enable tag filtering * Search: clear query * Search: add autofocus to search field * Search: Rename close to closeSearch * Search: Add no results message * Search: Add loading state * Search: Remove Select from Forms namespace * Remove Add selectedIndex * Remove Add getFlattenedSections * Remove Enable selecting items * Search: add hasId * Search: preselect first item * Search: Add utils tests * Search: Fix moving selection down * Search: Add findSelected * Search: Add type to section * Search: Handle Enter key press on item highlight * Search: Move reducer et al. to separate files * Search: Remove redundant render check * Search: Close overlay on Esc and ArrowLeft press * Search: Add close button * Search: Document utils * Search: use Icon for remove icon * Search: Add DashboardSearch.test.tsx * Search: Move test data to a separate file * Search: Finalise DashboardSearch.test.tsx * Add search reducer tests * Search: Add search results loading indicator * Search: Remove inline function * Search: Do not mutate item * Search: Tweak utils * Search: Do not clear query on tag clear * Search: Fix folder:current search * Search: Fix results scroll * Search: Update tests * Search: Close overlay on cog icon click * Add mobile styles for close button * Search: Use CustomScrollbar * Search: Memoize TagList.tsx * Search: Fix type errors * Search: More strictNullChecks fixes * Search: Consistent handler names * Search: Fix search items types in test * Search: Fix merge conflicts * Search: Fix strictNullChecks errors
2020-04-08 10:14:03 -05:00
});
it('should render search results', async () => {
mockSearch.mockResolvedValueOnce(searchResults);
setup();
const section = await screen.findAllByLabelText('Search section');
expect(section).toHaveLength(2);
expect(screen.getAllByLabelText('Search items')).toHaveLength(1);
Search/refactor dashboard search (#23274) * Search: add search wrapper * Search: add DashboardSearch.tsx * Search: enable search * Search: update types * Search: useReducer for saving search results * Search: use default query * Search: add toggle custom action * Search: add onQueryChange * Search: debounce search * Search: pas dispatch as a prop * Search: add tag filter * Search: Fix types * Search: revert changes * Search: close overlay on esc * Search: enable tag filtering * Search: clear query * Search: add autofocus to search field * Search: Rename close to closeSearch * Search: Add no results message * Search: Add loading state * Search: Remove Select from Forms namespace * Remove Add selectedIndex * Remove Add getFlattenedSections * Remove Enable selecting items * Search: add hasId * Search: preselect first item * Search: Add utils tests * Search: Fix moving selection down * Search: Add findSelected * Search: Add type to section * Search: Handle Enter key press on item highlight * Search: Move reducer et al. to separate files * Search: Remove redundant render check * Search: Close overlay on Esc and ArrowLeft press * Search: Add close button * Search: Document utils * Search: use Icon for remove icon * Search: Add DashboardSearch.test.tsx * Search: Move test data to a separate file * Search: Finalise DashboardSearch.test.tsx * Add search reducer tests * Search: Add search results loading indicator * Search: Remove inline function * Search: Do not mutate item * Search: Tweak utils * Search: Do not clear query on tag clear * Search: Fix folder:current search * Search: Fix results scroll * Search: Update tests * Search: Close overlay on cog icon click * Add mobile styles for close button * Search: Use CustomScrollbar * Search: Memoize TagList.tsx * Search: Fix type errors * Search: More strictNullChecks fixes * Search: Consistent handler names * Search: Fix search items types in test * Search: Fix merge conflicts * Search: Fix strictNullChecks errors
2020-04-08 10:14:03 -05:00
});
it('should call search with selected tags', async () => {
setup();
Search/refactor dashboard search (#23274) * Search: add search wrapper * Search: add DashboardSearch.tsx * Search: enable search * Search: update types * Search: useReducer for saving search results * Search: use default query * Search: add toggle custom action * Search: add onQueryChange * Search: debounce search * Search: pas dispatch as a prop * Search: add tag filter * Search: Fix types * Search: revert changes * Search: close overlay on esc * Search: enable tag filtering * Search: clear query * Search: add autofocus to search field * Search: Rename close to closeSearch * Search: Add no results message * Search: Add loading state * Search: Remove Select from Forms namespace * Remove Add selectedIndex * Remove Add getFlattenedSections * Remove Enable selecting items * Search: add hasId * Search: preselect first item * Search: Add utils tests * Search: Fix moving selection down * Search: Add findSelected * Search: Add type to section * Search: Handle Enter key press on item highlight * Search: Move reducer et al. to separate files * Search: Remove redundant render check * Search: Close overlay on Esc and ArrowLeft press * Search: Add close button * Search: Document utils * Search: use Icon for remove icon * Search: Add DashboardSearch.test.tsx * Search: Move test data to a separate file * Search: Finalise DashboardSearch.test.tsx * Add search reducer tests * Search: Add search results loading indicator * Search: Remove inline function * Search: Do not mutate item * Search: Tweak utils * Search: Do not clear query on tag clear * Search: Fix folder:current search * Search: Fix results scroll * Search: Update tests * Search: Close overlay on cog icon click * Add mobile styles for close button * Search: Use CustomScrollbar * Search: Memoize TagList.tsx * Search: Fix type errors * Search: More strictNullChecks fixes * Search: Consistent handler names * Search: Fix search items types in test * Search: Fix merge conflicts * Search: Fix strictNullChecks errors
2020-04-08 10:14:03 -05:00
await waitFor(() => screen.getByLabelText('Tag filter'));
Search: migrate manage dashboards (#23530) * Search: add search wrapper * Search: add DashboardSearch.tsx * Search: enable search * Search: update types * Search: useReducer for saving search results * Search: use default query * Search: add toggle custom action * Search: add onQueryChange * Search: debounce search * Search: pas dispatch as a prop * Search: add tag filter * Search: Fix types * Search: revert changes * Search: close overlay on esc * Search: enable tag filtering * Search: clear query * Search: add autofocus to search field * Search: Rename close to closeSearch * Search: Add no results message * Search: Add loading state * Search: Remove Select from Forms namespace * Remove Add selectedIndex * Remove Add getFlattenedSections * Remove Enable selecting items * Search: add hasId * Search: preselect first item * Search: Add utils tests * Search: Fix moving selection down * Search: Add findSelected * Search: Add type to section * Search: Handle Enter key press on item highlight * Search: Move reducer et al. to separate files * Search: Remove redundant render check * Search: Close overlay on Esc and ArrowLeft press * Search: Add close button * Search: Document utils * Search: use Icon for remove icon * Search: Add DashboardSearch.test.tsx * Search: Move test data to a separate file * Search: Finalise DashboardSearch.test.tsx * Add search reducer tests * Search: Add search results loading indicator * Search: Remove inline function * Search: Do not mutate item * Search: Tweak utils * Search: Do not clear query on tag clear * Search: Fix folder:current search * Search: Fix results scroll * Search: Update tests * Search: Close overlay on cog icon click * Add mobile styles for close button * Search: Use CustomScrollbar * Search: Memoize TagList.tsx * Search: Fix type errors * Search: More strictNullChecks fixes * Search: Add ManageDashboards.tsx * Search: Add mergeReducers * Search: Use mergeReducers * Search: remove default state from reducers * Search: Fix recent and starred icons * Search: Enable search * Search: Add markup * Search: Separate manageDashboardsReducer * Search: Add DashboardActions.tsx * Use new Select for TagFilter * Search: Use TagFilter for search filters * Search: Use TagList * Search: Add toggleSection * Search: Add more actions * Search add manageDashboards.test.ts * Search: Add getCheckedUids * Search: Add modify and toggle checked actions * Search: Update tests * Search: Update component template * Search: Enable section toggle * Search: Derive canMove and canDelete * Search: Handle delete items * Search: Fix tests * Search: Enable toggle items * Search: Add confirm modal subtitle * Search: Use theme vars * Search: Add getCheckedDashboardsUids * Search: Add MoveToFolderModal * Search: Enable moving dashboards * Search: Fix strict null checks errors * Search: Fix strict null checks errors[2] * Search: Enable filters * Search: Add useSearchQuery.ts * Search: Toggle items when toggling all * Search: Update useSearchQuery to accept custom params * Search: Add useSearchQuery to dashboard search * Search: use SearchField for manage dashboards * Search: Remove event param from query change * Search: Add base search hooks * Search: refactor useSearch to accept reducer * Search: use useDashboardSearch hook * Search: Fix useSearchQuery params * Search: Enable folder search * Search: Update tests * Search: Pass the props to manage-dashboards * Search: Add search filters margin * Search: Remove search-field-wrapper class and hide logic for it * Search: Adjust SearchField styles * Search: Move search-results-container inside SearchResults * Search: Fix type errors * Search: Add EmptyListCTA * Search: Update move message * Search: Cleanup * Search: Add todo * Search: Fix action type * Search: Use React wrapper vs FolderDashboardsCtrl and DashboardListCtrl * Search: DashboardList => DashboardListPage * Search: Remove ManageDashboards from angular_wrappers * Minor style tweaks * Search: Use LinkButton Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
2020-04-17 07:29:20 -05:00
const tagComponent = screen.getByLabelText('Tag filter');
await selectEvent.select(tagComponent, 'tag1');
expect(tagComponent).toBeInTheDocument();
await waitFor(() =>
expect(mockSearch).toHaveBeenCalledWith({
query: '',
skipRecent: false,
skipStarred: false,
tag: ['tag1'],
starred: false,
folderIds: [],
layout: SearchLayout.Folders,
sort: undefined,
prevSort: null,
})
);
});
it('should call search api with provided search params', async () => {
const params = { query: 'test query', tag: ['tag1'], sort: { value: 'asc' } };
setup({ params });
await waitFor(() => {
expect(mockSearch).toHaveBeenCalledTimes(1);
expect(mockSearch).toHaveBeenCalledWith(
expect.objectContaining({
query: 'test query',
tag: ['tag1'],
sort: 'asc',
})
);
});
});
Search/refactor dashboard search (#23274) * Search: add search wrapper * Search: add DashboardSearch.tsx * Search: enable search * Search: update types * Search: useReducer for saving search results * Search: use default query * Search: add toggle custom action * Search: add onQueryChange * Search: debounce search * Search: pas dispatch as a prop * Search: add tag filter * Search: Fix types * Search: revert changes * Search: close overlay on esc * Search: enable tag filtering * Search: clear query * Search: add autofocus to search field * Search: Rename close to closeSearch * Search: Add no results message * Search: Add loading state * Search: Remove Select from Forms namespace * Remove Add selectedIndex * Remove Add getFlattenedSections * Remove Enable selecting items * Search: add hasId * Search: preselect first item * Search: Add utils tests * Search: Fix moving selection down * Search: Add findSelected * Search: Add type to section * Search: Handle Enter key press on item highlight * Search: Move reducer et al. to separate files * Search: Remove redundant render check * Search: Close overlay on Esc and ArrowLeft press * Search: Add close button * Search: Document utils * Search: use Icon for remove icon * Search: Add DashboardSearch.test.tsx * Search: Move test data to a separate file * Search: Finalise DashboardSearch.test.tsx * Add search reducer tests * Search: Add search results loading indicator * Search: Remove inline function * Search: Do not mutate item * Search: Tweak utils * Search: Do not clear query on tag clear * Search: Fix folder:current search * Search: Fix results scroll * Search: Update tests * Search: Close overlay on cog icon click * Add mobile styles for close button * Search: Use CustomScrollbar * Search: Memoize TagList.tsx * Search: Fix type errors * Search: More strictNullChecks fixes * Search: Consistent handler names * Search: Fix search items types in test * Search: Fix merge conflicts * Search: Fix strictNullChecks errors
2020-04-08 10:14:03 -05:00
});