-
Notifications
You must be signed in to change notification settings - Fork 899
add debounced search on type to the search bar #2703
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
Merged
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
702a654
debounced search on type
Kira-Pilot db3c5fe
Merge remote-tracking branch 'origin/main' into search-bar-improvemen…
Kira-Pilot 4f3202d
loading workspaces on page entry
Kira-Pilot 766f03e
fixing e2e test
Kira-Pilot 0b66269
resolve merge conflicts
Kira-Pilot 5637ca5
removing boilerplate
Kira-Pilot 610b3f2
Merge remote-tracking branch 'origin/main' into search-bar-improvemen…
Kira-Pilot 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,9 +42,10 @@ | |
"formik": "2.2.9", | ||
"front-matter": "4.0.2", | ||
"history": "5.3.0", | ||
"just-debounce-it": "3.0.1", | ||
"react": "17.0.2", | ||
"react-dom": "17.0.2", | ||
"react-helmet": "^6.1.0", | ||
"react-helmet": "6.1.0", | ||
"react-markdown": "8.0.3", | ||
"react-router-dom": "6.3.0", | ||
"sourcemapped-stacktrace": "1.1.11", | ||
|
@@ -74,7 +75,7 @@ | |
"@types/node": "14.18.16", | ||
"@types/react": "17.0.44", | ||
"@types/react-dom": "17.0.16", | ||
"@types/react-helmet": "^6.1.5", | ||
"@types/react-helmet": "6.1.5", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❓ Was this intentional? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto |
||
"@types/superagent": "4.1.15", | ||
"@types/uuid": "8.3.4", | ||
"@typescript-eslint/eslint-plugin": "5.27.0", | ||
|
38 changes: 38 additions & 0 deletions
38
site/src/components/SearchBarWithFilter/SearchBarWithFilter.test.tsx
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,38 @@ | ||
import { fireEvent, screen } from "@testing-library/react" | ||
import userEvent from "@testing-library/user-event" | ||
import { render } from "../../testHelpers/renderHelpers" | ||
import { SearchBarWithFilter } from "./SearchBarWithFilter" | ||
|
||
// mock the debounce utility | ||
jest.mock("just-debounce-it", () => | ||
jest.fn((fn) => { | ||
fn.cancel = jest.fn() | ||
return fn | ||
}), | ||
) | ||
|
||
describe("SearchBarWithFilter", () => { | ||
it("calls the onFilter handler on keystroke", async () => { | ||
// When | ||
const onFilter = jest.fn() | ||
render(<SearchBarWithFilter onFilter={onFilter} />) | ||
|
||
const searchInput = screen.getByRole("textbox") | ||
await userEvent.type(searchInput, "workspace") // 9 characters | ||
|
||
// Then | ||
expect(onFilter).toBeCalledTimes(10) // 9 characters + 1 on component mount | ||
}) | ||
|
||
it("calls the onFilter handler on submit", async () => { | ||
// When | ||
const onFilter = jest.fn() | ||
render(<SearchBarWithFilter onFilter={onFilter} />) | ||
|
||
const searchInput = screen.getByRole("textbox") | ||
await fireEvent.keyDown(searchInput, { key: "Enter", code: "Enter", charCode: 13 }) | ||
|
||
// Then | ||
expect(onFilter).toBeCalledTimes(1) | ||
}) | ||
}) |
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❓ Was this intentional?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jsjoeio Yeah, Grey requested that I always pin dependencies. I'm down to revisit this rule in the future, but figured I'd clean up while I was in there.