fix(useEntityListProvider): sets arrayLimit to 10000 to solve problem parsing urls with more than 20 occurences of the same query parameter key
Signed-off-by: Jonathan Nagayoshi <jonathan@nagayoshi.com.br>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/plugin-catalog-react': patch
|
||||
---
|
||||
|
||||
fixes bug related to qs library upgrade. makes the EntityListProvider return the correct queryParameters even when there are more than 20 occurences of the same value
|
||||
@@ -222,6 +222,27 @@ describe('<EntityListProvider />', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('resolves query param filter values with large arrays', async () => {
|
||||
const largeArray = Array.from({ length: 50 }, (_, i) => `owner-${i}`);
|
||||
const query = qs.stringify({
|
||||
filters: { kind: 'component', owners: largeArray },
|
||||
});
|
||||
const { result } = renderHook(() => useEntityList(), {
|
||||
wrapper: createWrapper({
|
||||
location: `/catalog?${query}`,
|
||||
pagination,
|
||||
}),
|
||||
});
|
||||
|
||||
await waitFor(() => {
|
||||
expect(result.current.queryParameters).toBeTruthy();
|
||||
});
|
||||
expect(result.current.queryParameters).toEqual({
|
||||
kind: 'component',
|
||||
owners: largeArray,
|
||||
});
|
||||
});
|
||||
|
||||
it('does not fetch when only frontend filters change', async () => {
|
||||
const { result } = renderHook(() => useEntityList(), {
|
||||
wrapper: createWrapper({ pagination }),
|
||||
|
||||
@@ -199,6 +199,7 @@ export const EntityListProvider = <EntityFilters extends DefaultEntityFilters>(
|
||||
} = useMemo(() => {
|
||||
const parsed = qs.parse(location.search, {
|
||||
ignoreQueryPrefix: true,
|
||||
arrayLimit: 10000,
|
||||
});
|
||||
|
||||
let limit = paginationLimit;
|
||||
@@ -398,6 +399,7 @@ export const EntityListProvider = <EntityFilters extends DefaultEntityFilters>(
|
||||
|
||||
const oldParams = qs.parse(location.search, {
|
||||
ignoreQueryPrefix: true,
|
||||
arrayLimit: 10000,
|
||||
});
|
||||
const newParams = qs.stringify(
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user