mirror of
https://github.com/langgenius/dify.git
synced 2026-05-03 00:48:04 +08:00
test: improve coverage for some files (#33218)
This commit is contained in:
@ -151,6 +151,43 @@ describe('BlockInput', () => {
|
||||
|
||||
expect(screen.queryByRole('textbox')).not.toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('should handle change when onConfirm is not provided', async () => {
|
||||
render(<BlockInput value="Hello" />)
|
||||
|
||||
const contentArea = screen.getByText('Hello')
|
||||
fireEvent.click(contentArea)
|
||||
|
||||
const textarea = await screen.findByRole('textbox')
|
||||
fireEvent.change(textarea, { target: { value: 'Hello World' } })
|
||||
|
||||
expect(textarea).toHaveValue('Hello World')
|
||||
})
|
||||
|
||||
it('should enter edit mode when clicked with empty value', async () => {
|
||||
render(<BlockInput value="" />)
|
||||
const contentArea = screen.getByTestId('block-input').firstChild as Element
|
||||
fireEvent.click(contentArea)
|
||||
|
||||
const textarea = await screen.findByRole('textbox')
|
||||
expect(textarea).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('should exit edit mode on blur', async () => {
|
||||
render(<BlockInput value="Hello" />)
|
||||
|
||||
const contentArea = screen.getByText('Hello')
|
||||
fireEvent.click(contentArea)
|
||||
|
||||
const textarea = await screen.findByRole('textbox')
|
||||
expect(textarea).toBeInTheDocument()
|
||||
|
||||
fireEvent.blur(textarea)
|
||||
|
||||
await waitFor(() => {
|
||||
expect(screen.queryByRole('textbox')).not.toBeInTheDocument()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('Edge Cases', () => {
|
||||
@ -168,8 +205,9 @@ describe('BlockInput', () => {
|
||||
})
|
||||
|
||||
it('should handle newlines in value', () => {
|
||||
render(<BlockInput value="line1\nline2" />)
|
||||
const { container } = render(<BlockInput value={`line1\nline2`} />)
|
||||
expect(screen.getByText(/line1/)).toBeInTheDocument()
|
||||
expect(container.querySelector('br')).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('should handle multiple same variables', () => {
|
||||
|
||||
Reference in New Issue
Block a user