mirror of
https://github.com/langgenius/dify.git
synced 2026-09-05 00:31:19 +08:00
fix: preserve agent task editor focus when inserting commands (#41166)
This commit is contained in:
parent
3de20e0ba8
commit
fef28097cc
@ -3,6 +3,7 @@ import type { AgentV2NodeType } from '../types'
|
||||
import type { PromptEditorProps } from '@/app/components/base/prompt-editor'
|
||||
import type { NodePanelProps } from '@/app/components/workflow/types'
|
||||
import { act, fireEvent, render, screen, within } from '@testing-library/react'
|
||||
import userEvent from '@testing-library/user-event'
|
||||
import { BlockEnum } from '@/app/components/workflow/types'
|
||||
import { FlowType } from '@/types/common'
|
||||
import { AgentV2Panel } from '../panel'
|
||||
@ -1230,7 +1231,8 @@ describe('agent/panel', () => {
|
||||
expect(screen.queryByText('Clarification Drafter')).not.toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('updates agent task and opens prompt insertion shortcuts', () => {
|
||||
it('updates agent task and opens prompt insertion shortcuts', async () => {
|
||||
const user = userEvent.setup()
|
||||
render(
|
||||
<AgentV2Panel
|
||||
id="agent-node"
|
||||
@ -1267,9 +1269,9 @@ describe('agent/panel', () => {
|
||||
screen.queryByRole('button', { name: 'workflow.nodes.agent.task.mention' }),
|
||||
).not.toBeInTheDocument()
|
||||
|
||||
fireEvent.focus(editor)
|
||||
await user.click(editor)
|
||||
|
||||
fireEvent.click(screen.getByRole('button', { name: 'workflow.nodes.agent.task.insert' }))
|
||||
await user.click(screen.getByRole('button', { name: 'workflow.nodes.agent.task.insert' }))
|
||||
expect(mockEditorFocus).toHaveBeenCalled()
|
||||
expect(mockInsertNodes.mock.calls[0]?.[0]?.[0]?.getTextContent()).toBe('/')
|
||||
expect(
|
||||
|
||||
@ -36,6 +36,7 @@ function AgentTaskToolbar({ taskLength, onInsert }: { taskLength: number; onInse
|
||||
<button
|
||||
type="button"
|
||||
className="flex items-center gap-1 system-xs-medium hover:text-text-secondary focus-visible:ring-2 focus-visible:ring-state-accent-solid focus-visible:outline-hidden"
|
||||
onMouseDown={(event) => event.preventDefault()}
|
||||
onClick={handleInsert}
|
||||
>
|
||||
<span aria-hidden className="i-ri-slash-commands-2 size-3.5" />
|
||||
|
||||
Loading…
Reference in New Issue
Block a user