Skip to content

Commit

Permalink
fix(sanity): allow global search "contains" filter to match inside wo…
Browse files Browse the repository at this point in the history
…rds (#7572)
  • Loading branch information
juice49 authored Oct 2, 2024
1 parent b8dc3c7 commit e7e7185
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ describe('stringOperators', () => {

it('should create a valid filter for stringMatches', () => {
const filter = stringOperators.stringMatches.groqFilter({fieldPath, value})
expect(filter).toEqual(`${fieldPath} match "${value}"`)
expect(filter).toEqual(`${fieldPath} match "*${value}*"`)
})

it('should create a valid filter for stringNotMatches', () => {
const filter = stringOperators.stringNotMatches.groqFilter({fieldPath, value})
expect(filter).toEqual(`!(${fieldPath} match "*${value}*")`)
})

it('should create a valid filter for stringNotEqual', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const stringOperators = {
nameKey: 'search.operator.string-contains.name',
descriptionKey: 'search.operator.string-contains.description',
groqFilter: ({fieldPath, value}) =>
value && fieldPath ? `${fieldPath} match ${toJSON(value)}` : null,
value && fieldPath ? `${fieldPath} match "*${value}*"` : null,
initialValue: null,
inputComponent: SearchFilterStringInput as SearchOperatorInput<string | number>,
type: 'stringMatches',
Expand All @@ -55,7 +55,7 @@ export const stringOperators = {
nameKey: 'search.operator.string-not-contains.name',
descriptionKey: 'search.operator.string-not-contains.description',
groqFilter: ({fieldPath, value}) =>
value && fieldPath ? `!(${fieldPath} match ${toJSON(value)})` : null,
value && fieldPath ? `!(${fieldPath} match "*${value}*")` : null,
initialValue: null,
inputComponent: SearchFilterStringInput as SearchOperatorInput<string | number>,
type: 'stringNotMatches',
Expand Down

0 comments on commit e7e7185

Please sign in to comment.