-
Notifications
You must be signed in to change notification settings - Fork 4.5k
fix:retained input reference on x icon click #36268
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
Closed
saiprabhu-dandanayak
wants to merge
11
commits into
appsmithorg:release
from
saiprabhu-dandanayak:fix/retaining-input-reference
Closed
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
ba04252
fix:retained input reference on x icon click
saiprabhu-dandanayak b70c450
Merge branch 'release' of https://github.com/saiprabhu-dandanayak/app…
saiprabhu-dandanayak c0904e8
fix: removed debugging statements
saiprabhu-dandanayak 2839a9d
Merge branch 'release' of https://github.com/saiprabhu-dandanayak/app…
saiprabhu-dandanayak 087206f
feat:added unit tests
saiprabhu-dandanayak cc78dd7
Merge branch 'release' of https://github.com/saiprabhu-dandanayak/app…
saiprabhu-dandanayak 5a0c59e
fix:linting issues
saiprabhu-dandanayak 9b2e84c
Merge branch 'release' of https://github.com/saiprabhu-dandanayak/app…
saiprabhu-dandanayak 4121d20
Merge branch 'release' of https://github.com/saiprabhu-dandanayak/app…
saiprabhu-dandanayak c223bf7
fix:renamed test file
saiprabhu-dandanayak 67434fb
fix:merge conflicts
saiprabhu-dandanayak 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
66 changes: 66 additions & 0 deletions
66
app/client/packages/design-system/widgets-old/src/SearchComponent/SearchComponent.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,66 @@ | ||
| import React from "react"; | ||
| import { render, fireEvent, screen } from "@testing-library/react"; | ||
| import SearchComponent from "."; | ||
| import "@testing-library/jest-dom"; | ||
|
|
||
| jest.mock("lodash", () => ({ | ||
| debounce: (fn: any) => fn, | ||
| })); | ||
|
|
||
| jest.mock("../utils/icon-loadables", () => ({ | ||
| importSvg: jest.fn().mockReturnValue(() => <svg data-testid="cross-icon" />), | ||
| })); | ||
|
|
||
| describe("SearchComponent", () => { | ||
| const onSearchMock = jest.fn(); | ||
|
|
||
| const renderComponent = (props = {}) => { | ||
| return render( | ||
| <SearchComponent | ||
| onSearch={onSearchMock} | ||
| placeholder="Search..." | ||
| value="" | ||
| {...props} | ||
| />, | ||
| ); | ||
| }; | ||
|
|
||
| it("1.should clear the search value and trigger onSearch with an empty value when the cross icon is clicked anh have focused", () => { | ||
| renderComponent({ | ||
| enableClientSideSearch: true, | ||
| value: "test", | ||
| }); | ||
| const inputElement = screen.getByPlaceholderText( | ||
| "Search...", | ||
| ) as HTMLInputElement; | ||
| const clearButton = screen.getByTestId("cross-icon"); | ||
|
|
||
| fireEvent.click(clearButton); | ||
|
|
||
| expect(inputElement).toHaveFocus(); | ||
| expect(inputElement.value).toBe(""); | ||
| expect(onSearchMock).toHaveBeenCalledWith(""); | ||
| }); | ||
|
|
||
| it("2.should reset localValue when component receives a new value prop", () => { | ||
| const { rerender } = renderComponent({ | ||
| value: "initial", | ||
| }); | ||
|
|
||
| const inputElement = screen.getByPlaceholderText( | ||
| "Search...", | ||
| ) as HTMLInputElement; | ||
|
|
||
| expect(inputElement.value).toBe("initial"); | ||
|
|
||
| rerender( | ||
| <SearchComponent | ||
| onSearch={onSearchMock} | ||
| placeholder="Search..." | ||
| value="updated" | ||
| />, | ||
| ); | ||
|
|
||
| expect(inputElement.value).toBe("updated"); | ||
| }); | ||
| }); |
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
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
Oops, something went wrong.
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.