Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Datahub: Remove warning from console if filter geometry undefined #798

Merged
merged 2 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions libs/feature/search/src/lib/state/effects.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.not.objectContaining({
tkohr marked this conversation as resolved.
Show resolved Hide resolved
filterGeometry: { type: 'Polygon', coordinates: [[]] },
})
)
})
})
})
describe('when useSpatialFilter is disabled', () => {
beforeEach(() => {
Expand Down
22 changes: 12 additions & 10 deletions libs/feature/search/src/lib/state/effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,17 +130,19 @@ export class SearchEffects {
}
return this.filterGeometry$.pipe(
tap((geom) => {
try {
const trace = validGeoJson(geom, true) as string[]
if (trace?.length > 0) {
throw new Error(trace.join('\n'))
if (geom) {
tkohr marked this conversation as resolved.
Show resolved Hide resolved
try {
const trace = validGeoJson(geom, true) as string[]
if (trace?.length > 0) {
throw new Error(trace.join('\n'))
}
} catch (error) {
console.warn(
'Error while parsing the geometry filter\n',
error
)
throw new Error()
}
} catch (error) {
console.warn(
'Error while parsing the geometry filter\n',
error
)
throw new Error()
}
}),
map((geom) => [state, favorites, geom]),
tkohr marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
Loading