Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat: context field search and filter improvements (#6732)
Adds highlighting to search values Search also looks in `description` behind a flag - it could possibly degrade performance when too many items. Tested with 200 and it's ok but anything above might degrade: Adds a Select/Unselect all button Shows the selected values above the search Closes # [1-2232](https://linear.app/unleash/issue/1-2232/context-field-ui-filter-and-search) https://github.com/Unleash/unleash/assets/104830839/ba2fe56f-c5db-4ce7-bc3c-1e7988682984 --------- Signed-off-by: andreas-unleash <andreas@getunleash.ai>
- Loading branch information
1 parent
11f4155
commit c868b5a
Showing
11 changed files
with
240 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
...aintAccordionEdit/ConstraintAccordionEditBody/LegalValueLabel/filter-legal-values.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import { filterLegalValues } from './LegalValueLabel'; | ||
|
||
describe('filterLegalValues function tests', () => { | ||
const mockLegalValues = [ | ||
{ value: 'Apple', description: 'A fruit' }, | ||
{ value: 'Banana', description: 'Yellow fruit' }, | ||
{ value: 'Carrot', description: 'A vegetable' }, | ||
{ value: 'SE', description: 'Sweden' }, | ||
{ value: 'Eggplant', description: undefined }, | ||
]; | ||
|
||
test('Basic functionality with value property', () => { | ||
const filter = 'apple'; | ||
const expected = [{ value: 'Apple', description: 'A fruit' }]; | ||
expect(filterLegalValues(mockLegalValues, filter)).toEqual(expected); | ||
}); | ||
|
||
test('Filters based on description property', () => { | ||
const filter = 'vegetable'; | ||
const expected = [{ value: 'Carrot', description: 'A vegetable' }]; | ||
expect(filterLegalValues(mockLegalValues, filter)).toEqual(expected); | ||
}); | ||
|
||
test('Case insensitivity', () => { | ||
const filter = 'BANANA'; | ||
const expected = [{ value: 'Banana', description: 'Yellow fruit' }]; | ||
expect(filterLegalValues(mockLegalValues, filter)).toEqual(expected); | ||
}); | ||
|
||
test('No matches found', () => { | ||
const filter = 'Zucchini'; | ||
expect(filterLegalValues(mockLegalValues, filter)).toEqual([]); | ||
}); | ||
|
||
test('Empty filter string', () => { | ||
const filter = ''; | ||
expect(filterLegalValues(mockLegalValues, filter)).toEqual( | ||
mockLegalValues, | ||
); | ||
}); | ||
|
||
test('Special characters in filter', () => { | ||
const filter = 'a fruit'; | ||
const expected = [{ value: 'Apple', description: 'A fruit' }]; | ||
expect(filterLegalValues(mockLegalValues, filter)).toEqual(expected); | ||
}); | ||
|
||
test('Empty input array', () => { | ||
const filter = 'anything'; | ||
expect(filterLegalValues([], filter)).toEqual([]); | ||
}); | ||
|
||
test('Exact match', () => { | ||
const filter = 'Carrot'; | ||
const expected = [{ value: 'Carrot', description: 'A vegetable' }]; | ||
expect(filterLegalValues(mockLegalValues, filter)).toEqual(expected); | ||
}); | ||
|
||
test('Partial match', () => { | ||
const filter = 'sw'; | ||
const expected = [{ value: 'SE', description: 'Sweden' }]; | ||
expect(filterLegalValues(mockLegalValues, filter)).toEqual(expected); | ||
}); | ||
|
||
test('Combination of match and no match', () => { | ||
const filter = 'a'; | ||
const expected = [ | ||
{ value: 'Apple', description: 'A fruit' }, | ||
{ value: 'Banana', description: 'Yellow fruit' }, | ||
{ value: 'Carrot', description: 'A vegetable' }, | ||
{ value: 'Eggplant', description: undefined }, | ||
]; | ||
expect(filterLegalValues(mockLegalValues, filter)).toEqual(expected); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.