From 8abeb1b9e817149d82dc597b88c23b20b31f9a08 Mon Sep 17 00:00:00 2001 From: daniele-mng Date: Wed, 4 Sep 2024 18:14:28 +0200 Subject: [PATCH 1/7] fix: default filter in details page --- src/web/entities/filterprovider.jsx | 3 +- src/web/hooks/__tests__/usePageFilter.jsx | 229 ++++++++-------------- src/web/hooks/usePageFilter.js | 14 +- src/web/utils/testing.jsx | 31 +-- 4 files changed, 107 insertions(+), 170 deletions(-) diff --git a/src/web/entities/filterprovider.jsx b/src/web/entities/filterprovider.jsx index 689fdbf4bc..13a80ccacb 100644 --- a/src/web/entities/filterprovider.jsx +++ b/src/web/entities/filterprovider.jsx @@ -3,7 +3,6 @@ * SPDX-License-Identifier: AGPL-3.0-or-later */ - import React from 'react'; import Loading from 'web/components/loading/loading'; @@ -18,7 +17,7 @@ const FilterProvider = ({ pageName = gmpname, locationQuery = {}, }) => { - const [returnedFilter, isLoadingFilter] = usePageFilter(pageName, { + const [returnedFilter, isLoadingFilter] = usePageFilter(pageName, gmpname, { fallbackFilter, locationQueryFilterString: locationQuery?.filter, }); diff --git a/src/web/hooks/__tests__/usePageFilter.jsx b/src/web/hooks/__tests__/usePageFilter.jsx index 6f12833aa5..7d4d008b57 100644 --- a/src/web/hooks/__tests__/usePageFilter.jsx +++ b/src/web/hooks/__tests__/usePageFilter.jsx @@ -9,37 +9,25 @@ import {describe, test, expect, testing} from '@gsa/testing'; import Filter, {DEFAULT_FALLBACK_FILTER} from 'gmp/models/filter'; -import {fireEvent, rendererWith, screen} from 'web/utils/testing'; +import {rendererWith, waitFor} from 'web/utils/testing'; import {loadingActions} from 'web/store/usersettings/defaults/actions'; import {defaultFilterLoadingActions} from 'web/store/usersettings/defaultfilters/actions'; import usePageFilter from '../usePageFilter'; import {pageFilter} from 'web/store/pages/actions'; +import {vi} from 'vitest'; -const TestComponent = ({fallbackFilter}) => { - const [filter, isLoadingFilter, changeFilter, removeFilter, resetFilter] = - usePageFilter('somePage', {fallbackFilter}); - return ( - <> - {isLoadingFilter ? ( -
Loading...
- ) : ( - <> -
{filter.toFilterString()}
-