mirror of
https://github.com/Graylog2/graylog2-server.git
synced 2026-03-13 09:32:21 +08:00
Render DefaultQueryParamProvider by default in component unit tests. (#25145)
* Render DefaultQueryParamProvider by default in wrappedTestingLibrary and remove redundant test wrappers. * Fix `WidgetFocusProvider.test`. * Fixing linter hints * Fixing test
This commit is contained in:
@@ -20,7 +20,6 @@ import * as React from 'react';
|
||||
import { MemoryRouter } from 'react-router-dom';
|
||||
|
||||
import { useQueryParam } from 'routing/QueryParams';
|
||||
import DefaultQueryParamProvider from 'routing/DefaultQueryParamProvider';
|
||||
import { asMock } from 'helpers/mocking';
|
||||
|
||||
import useUrlQueryFilters from './useUrlQueryFilters';
|
||||
@@ -31,11 +30,7 @@ jest.mock('routing/QueryParams', () => ({
|
||||
}));
|
||||
|
||||
describe('useUrlQueryFilters', () => {
|
||||
const wrapper = ({ children }: { children: React.ReactNode }) => (
|
||||
<MemoryRouter>
|
||||
<DefaultQueryParamProvider>{children}</DefaultQueryParamProvider>
|
||||
</MemoryRouter>
|
||||
);
|
||||
const wrapper = ({ children }: { children: React.ReactNode }) => <MemoryRouter>{children}</MemoryRouter>;
|
||||
|
||||
beforeEach(() => {
|
||||
asMock(useQueryParam).mockReturnValue([['index_set_id=index_set_id_1', 'index_set_id=index_set_id_2'], () => {}]);
|
||||
|
||||
@@ -20,7 +20,6 @@ import userEvent from '@testing-library/user-event';
|
||||
|
||||
import type { SearchParams } from 'stores/PaginationTypes';
|
||||
import TableFetchContext, { type ContextValue } from 'components/common/PaginatedEntityTable/TableFetchContext';
|
||||
import DefaultQueryParamProvider from 'routing/DefaultQueryParamProvider';
|
||||
|
||||
import Slicing from './index';
|
||||
|
||||
@@ -56,17 +55,15 @@ describe('Slicing', () => {
|
||||
};
|
||||
|
||||
return render(
|
||||
<DefaultQueryParamProvider>
|
||||
<TableFetchContext.Provider value={contextValue}>
|
||||
<Slicing
|
||||
appSection="test-app-section"
|
||||
columnSchemas={columnSchemas}
|
||||
onChangeSlicing={() => {}}
|
||||
fetchSlices={() => Promise.resolve({ slices: [] })}
|
||||
{...props}
|
||||
/>
|
||||
</TableFetchContext.Provider>
|
||||
</DefaultQueryParamProvider>,
|
||||
<TableFetchContext.Provider value={contextValue}>
|
||||
<Slicing
|
||||
appSection="test-app-section"
|
||||
columnSchemas={columnSchemas}
|
||||
onChangeSlicing={() => {}}
|
||||
fetchSlices={() => Promise.resolve({ slices: [] })}
|
||||
{...props}
|
||||
/>
|
||||
</TableFetchContext.Provider>,
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@ import { render, screen, waitFor } from 'wrappedTestingLibrary';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
|
||||
import { useQueryParams } from 'routing/QueryParams';
|
||||
import DefaultQueryParamProvider from 'routing/DefaultQueryParamProvider';
|
||||
import InteractiveContext from 'views/components/contexts/InteractiveContext';
|
||||
import { asMock } from 'helpers/mocking';
|
||||
|
||||
@@ -33,15 +32,12 @@ jest.mock('routing/QueryParams', () => ({
|
||||
}));
|
||||
|
||||
describe('PaginatedList', () => {
|
||||
const renderSUT = (component: React.ReactElement) =>
|
||||
render(<DefaultQueryParamProvider>{component}</DefaultQueryParamProvider>);
|
||||
|
||||
beforeEach(() => {
|
||||
asMock(useQueryParams).mockImplementation(() => [{}, jest.fn()]);
|
||||
});
|
||||
|
||||
it('should display Pagination', () => {
|
||||
renderSUT(
|
||||
render(
|
||||
<PaginatedList totalItems={100} onChange={() => {}}>
|
||||
<div>The list</div>
|
||||
</PaginatedList>,
|
||||
@@ -52,7 +48,7 @@ describe('PaginatedList', () => {
|
||||
});
|
||||
|
||||
it('should not dived by 0 if pageSize is 0 Pagination', () => {
|
||||
renderSUT(
|
||||
render(
|
||||
<PaginatedList totalItems={100} pageSize={0} onChange={() => {}}>
|
||||
<div>The list</div>
|
||||
</PaginatedList>,
|
||||
@@ -62,7 +58,7 @@ describe('PaginatedList', () => {
|
||||
});
|
||||
|
||||
it('should not display Pagination, when context is not interactive', () => {
|
||||
const { queryByText } = renderSUT(
|
||||
const { queryByText } = render(
|
||||
<InteractiveContext.Provider value={false}>
|
||||
<PaginatedList totalItems={100} onChange={() => {}}>
|
||||
<div>The list</div>
|
||||
@@ -76,7 +72,7 @@ describe('PaginatedList', () => {
|
||||
|
||||
it('should reset current page on page size change', async () => {
|
||||
const onChangeStub = jest.fn();
|
||||
const { getByRole } = renderSUT(
|
||||
const { getByRole } = render(
|
||||
<PaginatedList totalItems={200} onChange={onChangeStub} activePage={3}>
|
||||
<div>The list</div>
|
||||
</PaginatedList>,
|
||||
@@ -102,7 +98,7 @@ describe('PaginatedList', () => {
|
||||
const currentPage = 4;
|
||||
asMock(useQueryParams).mockImplementation(() => [{ page: currentPage }, setQueryParams]);
|
||||
|
||||
const { findByTestId } = renderSUT(
|
||||
const { findByTestId } = render(
|
||||
<PaginatedList totalItems={200} onChange={() => {}} activePage={3}>
|
||||
<div>The list</div>
|
||||
</PaginatedList>,
|
||||
@@ -118,7 +114,7 @@ describe('PaginatedList', () => {
|
||||
|
||||
describe('with internal state', () => {
|
||||
it('should update active page, when prop changes', async () => {
|
||||
const { findByTestId, rerender } = renderSUT(
|
||||
const { findByTestId, rerender } = render(
|
||||
<PaginatedList totalItems={200} onChange={() => {}} activePage={3} useQueryParameter={false}>
|
||||
<div>The list</div>
|
||||
</PaginatedList>,
|
||||
@@ -130,11 +126,9 @@ describe('PaginatedList', () => {
|
||||
expect(activePageElement[0].textContent).toContain('3');
|
||||
|
||||
rerender(
|
||||
<DefaultQueryParamProvider>
|
||||
<PaginatedList totalItems={200} onChange={() => {}} activePage={1} useQueryParameter={false}>
|
||||
<div>The list</div>
|
||||
</PaginatedList>
|
||||
</DefaultQueryParamProvider>,
|
||||
<PaginatedList totalItems={200} onChange={() => {}} activePage={1} useQueryParameter={false}>
|
||||
<div>The list</div>
|
||||
</PaginatedList>,
|
||||
);
|
||||
|
||||
await findByTestId('graylog-pagination');
|
||||
|
||||
@@ -27,7 +27,6 @@ import useFieldTypesForMappings from 'views/logic/fieldactions/ChangeFieldType/h
|
||||
import { profile1, attributes, profile2 } from 'fixtures/indexSetFieldTypeProfiles';
|
||||
import ProfilesList from 'components/indices/IndexSetFieldTypeProfiles/ProfilesList';
|
||||
import useFetchEntities from 'components/common/PaginatedEntityTable/useFetchEntities';
|
||||
import DefaultQueryParamProvider from 'routing/DefaultQueryParamProvider';
|
||||
|
||||
const getData = (list = [profile1]) => ({
|
||||
list,
|
||||
@@ -39,12 +38,9 @@ const getData = (list = [profile1]) => ({
|
||||
|
||||
const renderIndexSetFieldTypeProfilesList = () =>
|
||||
render(
|
||||
<DefaultQueryParamProvider>
|
||||
<TestStoreProvider>
|
||||
<ProfilesList />
|
||||
</TestStoreProvider>
|
||||
,
|
||||
</DefaultQueryParamProvider>,
|
||||
<TestStoreProvider>
|
||||
<ProfilesList />
|
||||
</TestStoreProvider>,
|
||||
);
|
||||
|
||||
jest.mock('routing/useParams', () => jest.fn());
|
||||
|
||||
@@ -40,7 +40,6 @@ import {
|
||||
import useProfile from 'components/indices/IndexSetFieldTypeProfiles/hooks/useProfile';
|
||||
import useIndexProfileWithMappingsByField from 'components/indices/IndexSetFieldTypes/hooks/useIndexProfileWithMappingsByField';
|
||||
import useProfileOptions from 'components/indices/IndexSetFieldTypeProfiles/hooks/useProfileOptions';
|
||||
import DefaultQueryParamProvider from 'routing/DefaultQueryParamProvider';
|
||||
|
||||
const getData = (list = [defaultField]) => ({
|
||||
list,
|
||||
@@ -52,12 +51,9 @@ const getData = (list = [defaultField]) => ({
|
||||
|
||||
const renderIndexSetFieldTypesList = () =>
|
||||
render(
|
||||
<DefaultQueryParamProvider>
|
||||
<TestStoreProvider>
|
||||
<IndexSetFieldTypesList />
|
||||
</TestStoreProvider>
|
||||
,
|
||||
</DefaultQueryParamProvider>,
|
||||
<TestStoreProvider>
|
||||
<IndexSetFieldTypesList />
|
||||
</TestStoreProvider>,
|
||||
);
|
||||
|
||||
jest.mock('stores/indices/IndexSetsStore', () => ({
|
||||
|
||||
@@ -25,14 +25,9 @@ import asMock from 'helpers/mocking/AsMock';
|
||||
import SetProfileModal from 'components/indices/IndexSetFieldTypes/SetProfileModal';
|
||||
import useProfileOptions from 'components/indices/IndexSetFieldTypeProfiles/hooks/useProfileOptions';
|
||||
import useRemoveProfileFromIndexMutation from 'components/indices/IndexSetFieldTypes/hooks/useRemoveProfileFromIndexMutation';
|
||||
import DefaultQueryParamProvider from 'routing/DefaultQueryParamProvider';
|
||||
|
||||
const renderModal = (currentProfile = 'profile-id-111') =>
|
||||
render(
|
||||
<DefaultQueryParamProvider>
|
||||
<SetProfileModal currentProfile={currentProfile} onClose={() => {}} show />
|
||||
</DefaultQueryParamProvider>,
|
||||
);
|
||||
render(<SetProfileModal currentProfile={currentProfile} onClose={() => {}} show />);
|
||||
|
||||
jest.mock('routing/useParams', () => jest.fn());
|
||||
jest.mock('components/indices/IndexSetFieldTypes/hooks/useSetIndexSetProfileMutation', () => jest.fn());
|
||||
|
||||
@@ -21,7 +21,6 @@ import userEvent from '@testing-library/user-event';
|
||||
import type { SearchParams } from 'stores/PaginationTypes';
|
||||
import type { GenericEntityType } from 'logic/lookup-tables/types';
|
||||
import { DATA_ADAPTERS, ERROR_STATE } from 'components/lookup-tables/fixtures';
|
||||
import DefaultQueryParamProvider from 'routing/DefaultQueryParamProvider';
|
||||
|
||||
import { attributes } from './constants';
|
||||
import DataAdapterList from './index';
|
||||
@@ -78,14 +77,10 @@ jest.mock('components/lookup-tables/hooks/useLookupTablesAPI', () => ({
|
||||
}));
|
||||
|
||||
const moreActionsName = { name: new RegExp(`More Actions for ${DATA_ADAPTERS[0].name}`, 'i') };
|
||||
const renderSUT = () =>
|
||||
render(
|
||||
<DefaultQueryParamProvider>
|
||||
<DataAdapterList />
|
||||
</DefaultQueryParamProvider>,
|
||||
);
|
||||
|
||||
describe('Data Adapter List', () => {
|
||||
const renderSUT = () => render(<DataAdapterList />);
|
||||
|
||||
it('should render a list of data adapters', async () => {
|
||||
renderSUT();
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@ import userEvent from '@testing-library/user-event';
|
||||
import type { SearchParams } from 'stores/PaginationTypes';
|
||||
import type { GenericEntityType } from 'logic/lookup-tables/types';
|
||||
import { CACHES } from 'components/lookup-tables/fixtures';
|
||||
import DefaultQueryParamProvider from 'routing/DefaultQueryParamProvider';
|
||||
|
||||
import { attributes } from './constants';
|
||||
import CacheList from './index';
|
||||
@@ -74,14 +73,10 @@ jest.mock('components/lookup-tables/hooks/useLookupTablesAPI', () => ({
|
||||
}));
|
||||
|
||||
const moreActionsName = { name: new RegExp(`More Actions for ${CACHES[0].name}`, 'i') };
|
||||
const renderSUT = () =>
|
||||
render(
|
||||
<DefaultQueryParamProvider>
|
||||
<CacheList />
|
||||
</DefaultQueryParamProvider>,
|
||||
);
|
||||
|
||||
describe('Cache List', () => {
|
||||
const renderSUT = () => render(<CacheList />);
|
||||
|
||||
it('should render a list of caches', async () => {
|
||||
renderSUT();
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@ import userEvent from '@testing-library/user-event';
|
||||
import type { SearchParams } from 'stores/PaginationTypes';
|
||||
import type { GenericEntityType, LookupTable } from 'logic/lookup-tables/types';
|
||||
import { LOOKUP_TABLES, CACHES_MAP, ADAPTERS_MAP, ERROR_STATE } from 'components/lookup-tables/fixtures';
|
||||
import DefaultQueryParamProvider from 'routing/DefaultQueryParamProvider';
|
||||
|
||||
import { attributes } from './constants';
|
||||
import LookupTableList from './index';
|
||||
@@ -82,14 +81,10 @@ jest.mock('components/lookup-tables/hooks/useLookupTablesAPI', () => ({
|
||||
}));
|
||||
|
||||
const moreActionsName = { name: new RegExp(`More Actions for ${LOOKUP_TABLES[0].name}`, 'i') };
|
||||
const renderSUT = () =>
|
||||
render(
|
||||
<DefaultQueryParamProvider>
|
||||
<LookupTableList />
|
||||
</DefaultQueryParamProvider>,
|
||||
);
|
||||
|
||||
describe('Lookup Table List', () => {
|
||||
const renderSUT = () => render(<LookupTableList />);
|
||||
|
||||
it('should render a list of lookup tables', async () => {
|
||||
renderSUT();
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@ import { render, waitFor, screen } from 'wrappedTestingLibrary';
|
||||
import mockAction from 'helpers/mocking/MockAction';
|
||||
import { rolesList as mockRoles } from 'fixtures/roles';
|
||||
import { AuthzRolesActions } from 'stores/roles/AuthzRolesStore';
|
||||
import DefaultQueryParamProvider from 'routing/DefaultQueryParamProvider';
|
||||
|
||||
import RolesOverview from './RolesOverview';
|
||||
|
||||
@@ -56,12 +55,7 @@ jest.mock('stores/roles/AuthzRolesStore', () => ({
|
||||
}));
|
||||
|
||||
describe('RolesOverview', () => {
|
||||
const renderSUT = () =>
|
||||
render(
|
||||
<DefaultQueryParamProvider>
|
||||
<RolesOverview />
|
||||
</DefaultQueryParamProvider>,
|
||||
);
|
||||
const renderSUT = () => render(<RolesOverview />);
|
||||
|
||||
afterEach(() => {
|
||||
jest.clearAllMocks();
|
||||
|
||||
@@ -18,8 +18,6 @@ import userEvent from '@testing-library/user-event';
|
||||
import * as React from 'react';
|
||||
import { screen, render, waitFor } from 'wrappedTestingLibrary';
|
||||
|
||||
import DefaultQueryParamProvider from 'routing/DefaultQueryParamProvider';
|
||||
|
||||
import SidecarFailureTrackingList from './SidecarFailureTrackingList';
|
||||
|
||||
import type { Collector, SidecarSummary } from '../types';
|
||||
@@ -75,20 +73,18 @@ const toggleShowInactive = jest.fn();
|
||||
|
||||
const renderSUT = (sidecarsList: Array<SidecarSummary> = [], collectorsList: Array<Collector> = []) =>
|
||||
render(
|
||||
<DefaultQueryParamProvider>
|
||||
<SidecarFailureTrackingList
|
||||
sidecars={sidecarsList}
|
||||
collectors={collectorsList}
|
||||
pagination={pagination}
|
||||
query={query}
|
||||
onlyActive={onlyActive}
|
||||
sort={sort}
|
||||
onPageChange={handlePageChange}
|
||||
onQueryChange={handleQueryChange}
|
||||
onSortChange={handleSortChange}
|
||||
toggleShowInactive={toggleShowInactive}
|
||||
/>
|
||||
</DefaultQueryParamProvider>,
|
||||
<SidecarFailureTrackingList
|
||||
sidecars={sidecarsList}
|
||||
collectors={collectorsList}
|
||||
pagination={pagination}
|
||||
query={query}
|
||||
onlyActive={onlyActive}
|
||||
sort={sort}
|
||||
onPageChange={handlePageChange}
|
||||
onQueryChange={handleQueryChange}
|
||||
onSortChange={handleSortChange}
|
||||
toggleShowInactive={toggleShowInactive}
|
||||
/>,
|
||||
);
|
||||
|
||||
describe('SidecarFailureTrackingList', () => {
|
||||
|
||||
@@ -20,7 +20,6 @@ import { render, screen, within } from 'wrappedTestingLibrary';
|
||||
import { StreamRoutingRules } from '@graylog/server-api';
|
||||
|
||||
import type { Attribute } from 'stores/PaginationTypes';
|
||||
import DefaultQueryParamProvider from 'routing/DefaultQueryParamProvider';
|
||||
import { createStreamFixture } from 'components/streams/fixtures';
|
||||
import { asMock } from 'helpers/mocking';
|
||||
import StreamConnectedPipelines from 'components/streams/StreamDetails/StreamDataRoutingIntake/StreamConnectedPipelines';
|
||||
@@ -161,12 +160,7 @@ const listResponse = {
|
||||
},
|
||||
};
|
||||
|
||||
const renderList = () =>
|
||||
render(
|
||||
<DefaultQueryParamProvider>
|
||||
<StreamConnectedPipelines stream={createStreamFixture('1')} />
|
||||
</DefaultQueryParamProvider>,
|
||||
);
|
||||
const renderList = () => render(<StreamConnectedPipelines stream={createStreamFixture('1')} />);
|
||||
|
||||
describe('<StreamConnectedPipelines />', () => {
|
||||
beforeEach(() => {
|
||||
|
||||
@@ -26,7 +26,6 @@ import useUserLayoutPreferences from 'components/common/EntityDataTable/hooks/us
|
||||
import { layoutPreferences } from 'fixtures/entityListLayoutPreferences';
|
||||
import useStreamRuleTypes from 'components/streams/hooks/useStreamRuleTypes';
|
||||
import { streamRuleTypes } from 'fixtures/streamRuleTypes';
|
||||
import DefaultQueryParamProvider from 'routing/DefaultQueryParamProvider';
|
||||
|
||||
import StreamsOverview from './StreamsOverview';
|
||||
|
||||
@@ -76,12 +75,7 @@ const paginatedStreams = (exampleStream = stream) => ({
|
||||
});
|
||||
|
||||
describe('StreamsOverview', () => {
|
||||
const renderSut = () =>
|
||||
render(
|
||||
<DefaultQueryParamProvider>
|
||||
<StreamsOverview indexSets={indexSets} />
|
||||
</DefaultQueryParamProvider>,
|
||||
);
|
||||
const renderSut = () => render(<StreamsOverview indexSets={indexSets} />);
|
||||
|
||||
beforeEach(() => {
|
||||
asMock(useUserLayoutPreferences).mockReturnValue({
|
||||
|
||||
@@ -25,7 +25,6 @@ import asMock from 'helpers/mocking/AsMock';
|
||||
import mockAction from 'helpers/mocking/MockAction';
|
||||
import { UsersActions } from 'stores/users/UsersStore';
|
||||
import useWindowConfirmMock from 'helpers/mocking/useWindowConfirmMock';
|
||||
import DefaultQueryParamProvider from 'routing/DefaultQueryParamProvider';
|
||||
|
||||
import UsersOverview from './UsersOverview';
|
||||
|
||||
@@ -55,12 +54,7 @@ const clickMoreActions = async (username: string) => {
|
||||
const extendedTimeout = applyTimeoutMultiplier(30000);
|
||||
|
||||
describe('UsersOverview', () => {
|
||||
const renderSUT = () =>
|
||||
render(
|
||||
<DefaultQueryParamProvider>
|
||||
<UsersOverview />
|
||||
</DefaultQueryParamProvider>,
|
||||
);
|
||||
const renderSUT = () => render(<UsersOverview />);
|
||||
|
||||
afterEach(() => {
|
||||
jest.clearAllMocks();
|
||||
|
||||
@@ -29,7 +29,6 @@ import useViewsPlugin from 'views/test/testViewsPlugin';
|
||||
import IndexSetFieldTypesPage from 'pages/IndexSetFieldTypesPage';
|
||||
import useFieldTypesForMappings from 'views/logic/fieldactions/ChangeFieldType/hooks/useFieldTypesForMappings';
|
||||
import { overriddenIndexField, defaultField, attributes } from 'fixtures/indexSetFieldTypes';
|
||||
import DefaultQueryParamProvider from 'routing/DefaultQueryParamProvider';
|
||||
|
||||
const getData = (list = [defaultField]) => ({
|
||||
list,
|
||||
@@ -41,12 +40,9 @@ const getData = (list = [defaultField]) => ({
|
||||
|
||||
const renderIndexSetFieldTypesPage = () =>
|
||||
render(
|
||||
<DefaultQueryParamProvider>
|
||||
<TestStoreProvider>
|
||||
<IndexSetFieldTypesPage />
|
||||
</TestStoreProvider>
|
||||
,
|
||||
</DefaultQueryParamProvider>,
|
||||
<TestStoreProvider>
|
||||
<IndexSetFieldTypesPage />
|
||||
</TestStoreProvider>,
|
||||
);
|
||||
|
||||
jest.mock('views/logic/fieldactions/ChangeFieldType/hooks/useFieldTypesForMappings', () => jest.fn());
|
||||
|
||||
@@ -19,7 +19,6 @@ import { render, screen } from 'wrappedTestingLibrary';
|
||||
|
||||
import { usePluginExports } from 'views/test/testPlugins';
|
||||
import { prefixUrl } from 'routing/Routes';
|
||||
import DefaultQueryParamProvider from 'routing/DefaultQueryParamProvider';
|
||||
|
||||
import RulesPage from './RulesPage';
|
||||
|
||||
@@ -34,13 +33,9 @@ const rulesPlugin = {
|
||||
],
|
||||
};
|
||||
describe('RulesPage', () => {
|
||||
const renderSUT = () => render(<RulesPage />);
|
||||
|
||||
usePluginExports(rulesPlugin);
|
||||
const renderSUT = () =>
|
||||
render(
|
||||
<DefaultQueryParamProvider>
|
||||
<RulesPage />
|
||||
</DefaultQueryParamProvider>,
|
||||
);
|
||||
|
||||
it('should show create rule button', async () => {
|
||||
renderSUT();
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
*/
|
||||
import * as React from 'react';
|
||||
import { render, screen } from 'wrappedTestingLibrary';
|
||||
import { useLocation } from 'react-router-dom';
|
||||
import Immutable from 'immutable';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
|
||||
@@ -34,16 +33,15 @@ import useView from 'views/hooks/useView';
|
||||
import View from 'views/logic/views/View';
|
||||
import ViewState from 'views/logic/views/ViewState';
|
||||
import { setNewWidget } from 'views/logic/slices/widgetsSlice';
|
||||
import useLocation from 'routing/useLocation';
|
||||
|
||||
jest.mock('routing/useLocation');
|
||||
|
||||
const mockNavigate = jest.fn();
|
||||
|
||||
jest.mock('react-router-dom', () => ({
|
||||
...jest.requireActual('react-router-dom'),
|
||||
useNavigate: () => mockNavigate,
|
||||
useLocation: jest.fn(() => ({
|
||||
pathname: '',
|
||||
search: '',
|
||||
})),
|
||||
}));
|
||||
|
||||
jest.mock('views/stores/useViewsDispatch');
|
||||
@@ -118,7 +116,7 @@ describe('WidgetFocusProvider', () => {
|
||||
});
|
||||
|
||||
it('should update url on widget focus close', async () => {
|
||||
asMock(useLocation).mockReturnValueOnce({
|
||||
asMock(useLocation).mockReturnValue({
|
||||
...emptyLocation,
|
||||
search: '?focusedId=widget-id&focusing=true',
|
||||
});
|
||||
|
||||
@@ -32,7 +32,6 @@ import type { ContextValue } from 'components/common/PaginatedEntityTable/TableF
|
||||
import TableFetchContext from 'components/common/PaginatedEntityTable/TableFetchContext';
|
||||
import useWindowConfirmMock from 'helpers/mocking/useWindowConfirmMock';
|
||||
import { deleteView } from 'views/api/views';
|
||||
import DefaultQueryParamProvider from 'routing/DefaultQueryParamProvider';
|
||||
|
||||
jest.mock('hooks/useCurrentUser');
|
||||
jest.mock('components/common/EntityDataTable/hooks/useSelectedEntities');
|
||||
@@ -71,11 +70,7 @@ describe('DashboardActions', () => {
|
||||
const simpleDashboard = simpleView();
|
||||
const menuIsHidden = () => expect(screen.queryByRole('menu')).not.toBeInTheDocument();
|
||||
const renderSUT = (props: React.ComponentProps<typeof DashboardActions> = { dashboard: simpleDashboard }) =>
|
||||
render(
|
||||
<DefaultQueryParamProvider>
|
||||
<DashboardActions {...props} />
|
||||
</DefaultQueryParamProvider>,
|
||||
);
|
||||
render(<DashboardActions {...props} />);
|
||||
|
||||
const clickDashboardAction = async (action: string) => {
|
||||
userEvent.click(await screen.findByRole('button', { name: /more/i }));
|
||||
|
||||
@@ -22,7 +22,6 @@ import View from 'views/logic/views/View';
|
||||
import Search from 'views/logic/search/Search';
|
||||
import { asMock } from 'helpers/mocking';
|
||||
import useFetchEntities from 'components/common/PaginatedEntityTable/useFetchEntities';
|
||||
import DefaultQueryParamProvider from 'routing/DefaultQueryParamProvider';
|
||||
|
||||
import DashboardsOverview from './DashboardsOverview';
|
||||
|
||||
@@ -88,11 +87,7 @@ const loadDashboardsResponse = (count = 1) => {
|
||||
};
|
||||
|
||||
describe('DashboardsOverview', () => {
|
||||
const SUT = () => (
|
||||
<DefaultQueryParamProvider>
|
||||
<DashboardsOverview />
|
||||
</DefaultQueryParamProvider>
|
||||
);
|
||||
const SUT = () => <DashboardsOverview />;
|
||||
|
||||
beforeEach(() => {
|
||||
asMock(useFetchEntities).mockReturnValue(loadDashboardsResponse(0));
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
import * as React from 'react';
|
||||
import { render, screen } from 'wrappedTestingLibrary';
|
||||
|
||||
import DefaultQueryParamProvider from 'routing/DefaultQueryParamProvider';
|
||||
import { usePluginExports } from 'views/test/testPlugins';
|
||||
import { prefixUrl } from 'routing/Routes';
|
||||
|
||||
@@ -49,11 +48,7 @@ const pluginExports = {
|
||||
describe('DashboardsPage', () => {
|
||||
usePluginExports(pluginExports);
|
||||
it('should render header and list', async () => {
|
||||
render(
|
||||
<DefaultQueryParamProvider>
|
||||
<DashboardsPage />
|
||||
</DefaultQueryParamProvider>,
|
||||
);
|
||||
render(<DashboardsPage />);
|
||||
|
||||
await screen.findByRole('heading', { name: /dashboards/i });
|
||||
await screen.findByText('No dashboards have been found.');
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
import React from 'react';
|
||||
import { MemoryRouter } from 'react-router-dom';
|
||||
|
||||
import DefaultQueryParamProvider from 'routing/DefaultQueryParamProvider';
|
||||
|
||||
import DefaultQueryClientProvider from './DefaultQueryClientProvider';
|
||||
import DefaultProviders from './DefaultProviders';
|
||||
|
||||
@@ -27,7 +29,9 @@ type Props = {
|
||||
const WrappingContainer = ({ children }: Props) => (
|
||||
<DefaultQueryClientProvider>
|
||||
<MemoryRouter>
|
||||
<DefaultProviders env="test">{children}</DefaultProviders>
|
||||
<DefaultQueryParamProvider>
|
||||
<DefaultProviders env="test">{children}</DefaultProviders>
|
||||
</DefaultQueryParamProvider>
|
||||
</MemoryRouter>
|
||||
</DefaultQueryClientProvider>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user