This commit is contained in:
yevanmore 2026-03-24 12:08:03 +08:00 committed by GitHub
commit 1067233f4d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 6 deletions

View File

@ -81,9 +81,10 @@ describe('useAvailableBlocks', () => {
expect(result.current.availableNextBlocks).toEqual([])
})
it('should return empty array for End node', () => {
it('should return available blocks for End node (same as regular nodes)', () => {
const { result } = renderWorkflowHook(() => useAvailableBlocks(BlockEnum.End), { hooksStoreProps })
expect(result.current.availableNextBlocks).toEqual([])
expect(result.current.availableNextBlocks.length).toBeGreaterThan(0)
expect(result.current.availableNextBlocks).toContain(BlockEnum.LLM)
})
it('should return empty array for LoopEnd node', () => {
@ -143,14 +144,21 @@ describe('useAvailableBlocks', () => {
expect(blocks.availablePrevBlocks).toEqual([])
})
it('should return empty nextBlocks for End/LoopEnd/KnowledgeBase', () => {
it('should return empty nextBlocks for LoopEnd/KnowledgeBase', () => {
const { result } = renderWorkflowHook(() => useAvailableBlocks(BlockEnum.LLM), { hooksStoreProps })
expect(result.current.getAvailableBlocks(BlockEnum.End).availableNextBlocks).toEqual([])
expect(result.current.getAvailableBlocks(BlockEnum.LoopEnd).availableNextBlocks).toEqual([])
expect(result.current.getAvailableBlocks(BlockEnum.KnowledgeBase).availableNextBlocks).toEqual([])
})
it('should return available nextBlocks for End node (same as regular nodes)', () => {
const { result } = renderWorkflowHook(() => useAvailableBlocks(BlockEnum.LLM), { hooksStoreProps })
const blocks = result.current.getAvailableBlocks(BlockEnum.End)
expect(blocks.availableNextBlocks.length).toBeGreaterThan(0)
expect(blocks.availableNextBlocks).toContain(BlockEnum.LLM)
})
it('should filter by inContainer when provided', () => {
const { result } = renderWorkflowHook(() => useAvailableBlocks(BlockEnum.LLM), { hooksStoreProps })
const blocks = result.current.getAvailableBlocks(BlockEnum.Code, true)

View File

@ -30,7 +30,7 @@ export const useAvailableBlocks = (nodeType?: BlockEnum, inContainer?: boolean)
return availableNodesType
}, [availableNodesType, nodeType])
const availableNextBlocks = useMemo(() => {
if (!nodeType || nodeType === BlockEnum.End || nodeType === BlockEnum.LoopEnd || nodeType === BlockEnum.KnowledgeBase)
if (!nodeType || nodeType === BlockEnum.LoopEnd || nodeType === BlockEnum.KnowledgeBase)
return []
return availableNodesType
@ -42,7 +42,7 @@ export const useAvailableBlocks = (nodeType?: BlockEnum, inContainer?: boolean)
availablePrevBlocks = []
let availableNextBlocks = availableNodesType
if (!nodeType || nodeType === BlockEnum.End || nodeType === BlockEnum.LoopEnd || nodeType === BlockEnum.KnowledgeBase)
if (!nodeType || nodeType === BlockEnum.LoopEnd || nodeType === BlockEnum.KnowledgeBase)
availableNextBlocks = []
return {