Skip to content

Commit

Permalink
don't expose facet path; add a test
Browse files Browse the repository at this point in the history
  • Loading branch information
nl0 committed Nov 29, 2023
1 parent 027b6fa commit 098bb5d
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
33 changes: 33 additions & 0 deletions catalog/app/containers/Search/model.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import * as KTree from 'utils/KeyedTree'

import * as model from './model'

describe('containers/Search/model', () => {
describe('groupFacets', () => {
it('should group the facets without exceeding recursion limit', () => {
const f1: model.PackageUserMetaFacet = {
__typename: 'KeywordPackageUserMetaFacet',
path: '/a/b',
extents: {
__typename: 'KeywordExtents',
values: ['first'],
},
}
const f2: model.PackageUserMetaFacet = {
__typename: 'KeywordPackageUserMetaFacet',
path: '/a/b',
extents: {
__typename: 'KeywordExtents',
values: ['second'],
},
}
const facets = [f1, f2]
const [grouped] = model.groupFacets(facets)
expect(grouped).toEqual(
KTree.Tree([
KTree.Pair('path:a', KTree.Tree([KTree.Pair('path:b', KTree.Leaf(f1))])),
]),
)
})
})
})
4 changes: 3 additions & 1 deletion catalog/app/containers/Search/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,9 @@ function resolveFacetConflict(existing: FacetNode, conflict: FacetNode): FacetNo
// this would cause an infinite recursion if not handled
if (existingId === conflictId) {
Sentry.withScope((scope) => {
scope.setExtras({ existingId, conflictId })
const depth = JSONPointer.parse(existing.value.path).length
const type = PackageUserMetaFacetTypeDisplay[existing.value.__typename]
scope.setExtras({ depth, type })
Sentry.captureMessage('Duplicate facet', 'warning')
})
// keep the facet encountered first
Expand Down

0 comments on commit 098bb5d

Please sign in to comment.