Skip to content

Commit

Permalink
fix(search-filter): clear button not working all search filter
Browse files Browse the repository at this point in the history
  • Loading branch information
saithsab877 committed Aug 2, 2024
1 parent e9da16c commit 3b14331
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/components/App/SideBar/FilterSearch/__tests__/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -176,4 +176,31 @@ describe('FilterSearch Component', () => {

expect(screen.queryByText('Type')).not.toBeInTheDocument()
})

it('should reset Source Nodes, Hops, and Max Results to default values when "Clear" button is clicked', async () => {
renderComponent()

const type1Pill = screen.getByText('Type1')
fireEvent.click(type1Pill)

const hopsCheckbox = screen.getByLabelText('2 hops away')
fireEvent.click(hopsCheckbox)

const maxResultsSlider = screen.getByTestId('max-results-slider')
fireEvent.mouseDown(maxResultsSlider)
fireEvent.mouseUp(maxResultsSlider, { clientX: 50 })

const sourceNodesSlider = screen.getByTestId('source-nodes-slider')
fireEvent.mouseDown(sourceNodesSlider)
fireEvent.mouseUp(sourceNodesSlider, { clientX: 20 })

const clearButton = screen.getByText('Clear')
fireEvent.click(clearButton)

waitFor(() => {
expect(screen.getByLabelText('Direct relationship')).toBeChecked()
expect(screen.getByTestId('max-results-slider')).toHaveValue(30)
expect(screen.getByTestId('source-nodes-slider')).toHaveValue(10)
})
})
})
3 changes: 3 additions & 0 deletions src/components/App/SideBar/FilterSearch/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ export const FilterSearch = ({ showAllSchemas, setShowAllSchemas, schemaAll, anc

const handleClear = async () => {
setSelectedTypes([])
setHops(1)
setSourceNodes(10)
setMaxResults(30)
}

const handleViewMoreClick = () => {
Expand Down

0 comments on commit 3b14331

Please sign in to comment.