mirror of
https://github.com/langgenius/dify.git
synced 2025-12-19 17:27:16 -05:00
fix: workflow log search input controlled state (#29930)
This commit is contained in:
@@ -7,6 +7,7 @@
|
|||||||
* - Keyword search
|
* - Keyword search
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { useState } from 'react'
|
||||||
import { fireEvent, render, screen, waitFor } from '@testing-library/react'
|
import { fireEvent, render, screen, waitFor } from '@testing-library/react'
|
||||||
import userEvent from '@testing-library/user-event'
|
import userEvent from '@testing-library/user-event'
|
||||||
import Filter, { TIME_PERIOD_MAPPING } from './filter'
|
import Filter, { TIME_PERIOD_MAPPING } from './filter'
|
||||||
@@ -293,12 +294,21 @@ describe('Filter', () => {
|
|||||||
const user = userEvent.setup()
|
const user = userEvent.setup()
|
||||||
const setQueryParams = jest.fn()
|
const setQueryParams = jest.fn()
|
||||||
|
|
||||||
render(
|
const Wrapper = () => {
|
||||||
<Filter
|
const [queryParams, updateQueryParams] = useState<QueryParam>(createDefaultQueryParams())
|
||||||
queryParams={createDefaultQueryParams()}
|
const handleSetQueryParams = (next: QueryParam) => {
|
||||||
setQueryParams={setQueryParams}
|
updateQueryParams(next)
|
||||||
/>,
|
setQueryParams(next)
|
||||||
)
|
}
|
||||||
|
return (
|
||||||
|
<Filter
|
||||||
|
queryParams={queryParams}
|
||||||
|
setQueryParams={handleSetQueryParams}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
render(<Wrapper />)
|
||||||
|
|
||||||
const input = screen.getByPlaceholderText('common.operation.search')
|
const input = screen.getByPlaceholderText('common.operation.search')
|
||||||
await user.type(input, 'workflow')
|
await user.type(input, 'workflow')
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ const Filter: FC<IFilterProps> = ({ queryParams, setQueryParams }: IFilterProps)
|
|||||||
wrapperClassName='w-[200px]'
|
wrapperClassName='w-[200px]'
|
||||||
showLeftIcon
|
showLeftIcon
|
||||||
showClearIcon
|
showClearIcon
|
||||||
value={queryParams.keyword}
|
value={queryParams.keyword ?? ''}
|
||||||
placeholder={t('common.operation.search')!}
|
placeholder={t('common.operation.search')!}
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
setQueryParams({ ...queryParams, keyword: e.target.value })
|
setQueryParams({ ...queryParams, keyword: e.target.value })
|
||||||
|
|||||||
Reference in New Issue
Block a user