fix: workflow log search input controlled state (#29930)

This commit is contained in:
yyh
2025-12-19 15:52:21 +08:00
committed by GitHub
parent d7b8db2afc
commit 2efdb7b887
2 changed files with 17 additions and 7 deletions

View File

@@ -7,6 +7,7 @@
* - Keyword search
*/
import { useState } from 'react'
import { fireEvent, render, screen, waitFor } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import Filter, { TIME_PERIOD_MAPPING } from './filter'
@@ -293,12 +294,21 @@ describe('Filter', () => {
const user = userEvent.setup()
const setQueryParams = jest.fn()
render(
<Filter
queryParams={createDefaultQueryParams()}
setQueryParams={setQueryParams}
/>,
)
const Wrapper = () => {
const [queryParams, updateQueryParams] = useState<QueryParam>(createDefaultQueryParams())
const handleSetQueryParams = (next: QueryParam) => {
updateQueryParams(next)
setQueryParams(next)
}
return (
<Filter
queryParams={queryParams}
setQueryParams={handleSetQueryParams}
/>
)
}
render(<Wrapper />)
const input = screen.getByPlaceholderText('common.operation.search')
await user.type(input, 'workflow')

View File

@@ -65,7 +65,7 @@ const Filter: FC<IFilterProps> = ({ queryParams, setQueryParams }: IFilterProps)
wrapperClassName='w-[200px]'
showLeftIcon
showClearIcon
value={queryParams.keyword}
value={queryParams.keyword ?? ''}
placeholder={t('common.operation.search')!}
onChange={(e) => {
setQueryParams({ ...queryParams, keyword: e.target.value })