diff --git a/libs/feature/search/src/lib/state/effects.spec.ts b/libs/feature/search/src/lib/state/effects.spec.ts index 218190d26a..d7c49215bc 100644 --- a/libs/feature/search/src/lib/state/effects.spec.ts +++ b/libs/feature/search/src/lib/state/effects.spec.ts @@ -483,6 +483,21 @@ describe('Effects', () => { ) }) }) + describe('when geometry is undefined', () => { + beforeEach(() => { + effects['filterGeometry$'] = of(undefined) as any + effects = TestBed.inject(SearchEffects) + actions$ = of(new RequestMoreResults('main')) + }) + it('skips the geometry in the search', async () => { + await firstValueFrom(effects.loadResults$) + expect(repository.search).toHaveBeenCalledWith( + expect.objectContaining({ + filterGeometry: undefined, + }) + ) + }) + }) }) describe('when useSpatialFilter is disabled', () => { beforeEach(() => { diff --git a/libs/feature/search/src/lib/state/effects.ts b/libs/feature/search/src/lib/state/effects.ts index 5c411efce4..4cc5cda439 100644 --- a/libs/feature/search/src/lib/state/effects.ts +++ b/libs/feature/search/src/lib/state/effects.ts @@ -126,10 +126,11 @@ export class SearchEffects { ), switchMap(([state, favorites]) => { if (!state.params.useSpatialFilter || !this.filterGeometry$) { - return of([state, favorites, null]) + return of([state, favorites, undefined]) } return this.filterGeometry$.pipe( tap((geom) => { + if (!geom) return try { const trace = validGeoJson(geom, true) as string[] if (trace?.length > 0) { @@ -145,7 +146,7 @@ export class SearchEffects { }), map((geom) => [state, favorites, geom]), catchError((e) => { - return of([state, favorites, null]) + return of([state, favorites, undefined]) }) ) }), @@ -153,7 +154,7 @@ export class SearchEffects { ([state, favorites, geometry]: [ SearchStateSearch, string[], - Geometry | null + Geometry | undefined ]) => { const { currentPage, pageSize, sort } = state.params const filters = {