This repository was archived by the owner on Apr 18, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +48
-2
lines changed Expand file tree Collapse file tree 4 files changed +48
-2
lines changed Original file line number Diff line number Diff line change 55 margin-bottom 10px
66 font-size 14px
77 color #58 58 58
8- width 220px
8+ width 220px
9+
10+
11+ .button__filter-length
12+ font-size 11px
13+ font-weight 500
14+ text-align center
15+ color #03 08 52
16+ width 15px
17+ height 20px
18+ line-height 21px
19+ border-radius 2px
20+ background #d6 e4 ff
21+ margin-left 3px
Original file line number Diff line number Diff line change @@ -112,6 +112,7 @@ export const Filter: FC<FilterInterface> = ({
112112 < IconFilter />
113113 </ Elem >
114114 < Elem name = { 'text' } > Filter</ Elem >
115+ { filterList . length > 0 && < Elem name = { 'filter-length' } data-testid = { 'filter-length' } > { filterList . length } </ Elem > }
115116 </ Button >
116117 </ Dropdown . Trigger >
117118 ) ;
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ export interface FilterListInterface {
1414 operation ?: string | string [ ] | undefined ;
1515 value ?: any ;
1616 path ?: string ;
17- logic ?: Logic ;
17+ logic ?: 'and' | 'or' ;
1818}
1919
2020export interface AvailableFiltersInterface {
Original file line number Diff line number Diff line change @@ -124,4 +124,36 @@ describe('Filter', () => {
124124
125125 expect ( filteredContent ) . toStrictEqual ( [ { labelName : 'Car' } , { labelName : 'AirCar' } ] ) ;
126126 } ) ;
127+
128+ test ( 'Should show filter length badge' , ( ) => {
129+ const filter = render ( < Filter
130+ onChange = { mockOnChange }
131+ filterData = { filterData }
132+ availableFilters = { [ {
133+ label : 'Annotation results' ,
134+ path : 'labelName' ,
135+ type : 'String' ,
136+ } ,
137+ {
138+ label : 'Confidence score' ,
139+ path : 'score' ,
140+ type : 'Number' ,
141+ } ] }
142+ /> ) ;
143+
144+ const FilterButton = filter . getByText ( 'Filter' ) ;
145+
146+ fireEvent . click ( FilterButton ) ;
147+
148+ expect ( screen . getByText ( 'No filters applied' ) ) . toBeDefined ( ) ;
149+
150+ const AddButton = filter . getByText ( 'Add Filter' ) ;
151+
152+ fireEvent . click ( AddButton ) ;
153+ fireEvent . click ( AddButton ) ;
154+
155+ const filterLength = filter . getByTestId ( 'filter-length' ) ;
156+
157+ expect ( filterLength . textContent ) . toBe ( '2' ) ;
158+ } ) ;
127159} ) ;
You can’t perform that action at this time.
0 commit comments