Repository navigation
feat(ui): add search input clear buttons and unit test coverage #119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
jonesbusy
merged 9 commits into
jenkins-infra:main
from
hrithik577:feature/search-bar-clear-button
Oct 25, 2026
Merged
Changes from 4 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
d50d073
feat(ui): add search input clear buttons and unit test coverage
hrithik577 5db0d44
Prevent default action on mouse down for search bar
hrithik577 26a8834
Merge branch 'main' into feature/search-bar-clear-button
hrithik577 e937798
fix(ui): prevent default on mousedown for search clear button
hrithik577 1de4a5c
Merge branch 'main' into feature/search-bar-clear-button
krisstern ebe0c6b
Merge branch 'main' into feature/search-bar-clear-button
krisstern 91f2442
Merge branch 'main' into feature/search-bar-clear-button
jonesbusy 394bd4a
fix(ui): consolidate search-bar imports and restore input focus on clear
hrithik577 cfbd313
Merge branch 'main' into feature/search-bar-clear-button
krisstern File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,111 @@ | ||
| import React from 'react'; | ||
| import { describe, it, expect, vi } from 'vitest'; | ||
| import { render, screen, fireEvent } from '@testing-library/react'; | ||
| import PluginSearchBar from '../../../src/components/pluginList/PluginSearchBar'; | ||
|
|
||
| describe('PluginSearchBar', () => { | ||
| it('renders search input with placeholder', () => { | ||
| render( | ||
| <PluginSearchBar | ||
| search="" | ||
| onSearchChange={() => {}} | ||
| statusFilter="all" | ||
| onClearFilter={() => {}} | ||
| resultCount={42} | ||
| /> | ||
| ); | ||
| expect(screen.getByPlaceholderText('Search a plugin…')).toBeDefined(); | ||
| console.log(` PluginSearchBar : search input with placeholder rendered`); | ||
| }); | ||
|
|
||
| it('displays result count correctly', () => { | ||
| render( | ||
| <PluginSearchBar | ||
| search="" | ||
| onSearchChange={() => {}} | ||
| statusFilter="all" | ||
| onClearFilter={() => {}} | ||
| resultCount={42} | ||
| /> | ||
| ); | ||
| expect(screen.getByText('42 results')).toBeDefined(); | ||
| console.log(` PluginSearchBar : "42 results" displayed`); | ||
| }); | ||
|
|
||
| it('displays singular "result" when count is 1', () => { | ||
| render( | ||
| <PluginSearchBar | ||
| search="" | ||
| onSearchChange={() => {}} | ||
| statusFilter="all" | ||
| onClearFilter={() => {}} | ||
| resultCount={1} | ||
| /> | ||
| ); | ||
| expect(screen.getByText('1 result')).toBeDefined(); | ||
| console.log(` PluginSearchBar : "1 result" (singular) displayed`); | ||
| }); | ||
|
|
||
| it('calls onSearchChange when typing in search input', () => { | ||
| const onChange = vi.fn(); | ||
| render( | ||
| <PluginSearchBar | ||
| search="" | ||
| onSearchChange={onChange} | ||
| statusFilter="all" | ||
| onClearFilter={() => {}} | ||
| resultCount={0} | ||
| /> | ||
| ); | ||
| fireEvent.change(screen.getByPlaceholderText('Search a plugin…'), { | ||
| target: { value: 'git' }, | ||
| }); | ||
| expect(onChange).toHaveBeenCalledWith('git'); | ||
| console.log(` PluginSearchBar : typing "git" triggers onSearchChange`); | ||
| }); | ||
|
|
||
| it('shows status filter chip when statusFilter is not "all"', () => { | ||
| render( | ||
| <PluginSearchBar | ||
| search="" | ||
| onSearchChange={() => {}} | ||
| statusFilter="green" | ||
| onClearFilter={() => {}} | ||
| resultCount={10} | ||
| /> | ||
| ); | ||
| expect(screen.getByText('All Passed')).toBeDefined(); | ||
| expect(screen.getByText('✕')).toBeDefined(); | ||
| console.log(` PluginSearchBar : "All Passed" status chip rendered`); | ||
| }); | ||
|
|
||
| it('calls onClearFilter when status filter chip dismiss is clicked', () => { | ||
| const onClear = vi.fn(); | ||
| render( | ||
| <PluginSearchBar search="" onSearchChange={() => {}} statusFilter="red" onClearFilter={onClear} resultCount={5} /> | ||
| ); | ||
| fireEvent.click(screen.getByText('✕').closest('button')!); | ||
| expect(onClear).toHaveBeenCalled(); | ||
| console.log(` PluginSearchBar : clicking status filter dismiss calls onClearFilter`); | ||
| }); | ||
|
|
||
| it('renders search clear button when search is non-empty and triggers onSearchChange("") when clicked', () => { | ||
| const onSearchChange = vi.fn(); | ||
| render( | ||
| <PluginSearchBar | ||
| search="git" | ||
| onSearchChange={onSearchChange} | ||
| statusFilter="all" | ||
| onClearFilter={() => {}} | ||
| resultCount={5} | ||
| /> | ||
| ); | ||
|
|
||
| const clearButton = screen.getByRole('button', { name: 'Clear search input' }); | ||
| expect(clearButton).toBeDefined(); | ||
|
|
||
| fireEvent.click(clearButton); | ||
| expect(onSearchChange).toHaveBeenCalledWith(''); | ||
| console.log(` PluginSearchBar : clicking clear input button triggers onSearchChange("")`); | ||
| }); | ||
| }); |
This file contains hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.