mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-07 08:30:06 +00:00
## Summary Tested these changes and confirmed that: 1. Feedback button shows. 2. You can run workflows and switch out models. 3. You can use the mask editor. (thank you @ric-yu for helping me verify). ## Changes A lot, please see commits. Gets us up to date with `main` as of 10-11-2025. --------- Co-authored-by: Simula_r <18093452+simula-r@users.noreply.github.com> Co-authored-by: github-actions <github-actions@github.com> Co-authored-by: snomiao <snomiao@gmail.com> Co-authored-by: Christian Byrne <cbyrne@comfy.org> Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: DrJKL <DrJKL@users.noreply.github.com> Co-authored-by: Alexander Brown <drjkl@comfy.org> Co-authored-by: Marwan Ahmed <155799754+marawan206@users.noreply.github.com> Co-authored-by: DrJKL <DrJKL0424@gmail.com> Co-authored-by: Rizumu Ayaka <rizumu@ayaka.moe> Co-authored-by: Comfy Org PR Bot <snomiao+comfy-pr@gmail.com> Co-authored-by: AustinMroz <4284322+AustinMroz@users.noreply.github.com> Co-authored-by: Austin Mroz <austin@comfy.org> Co-authored-by: Johnpaul Chiwetelu <49923152+Myestery@users.noreply.github.com> Co-authored-by: GitHub Action <action@github.com> Co-authored-by: filtered <176114999+webfiltered@users.noreply.github.com> Co-authored-by: Benjamin Lu <benceruleanlu@proton.me> Co-authored-by: Jin Yi <jin12cc@gmail.com> Co-authored-by: Robin Huang <robin.j.huang@gmail.com>
193 lines
5.3 KiB
TypeScript
193 lines
5.3 KiB
TypeScript
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
|
import { computed, shallowRef } from 'vue'
|
|
|
|
import {
|
|
type GraphNodeManager,
|
|
type VueNodeData,
|
|
useGraphNodeManager
|
|
} from '@/composables/graph/useGraphNodeManager'
|
|
import { useVueNodeLifecycle } from '@/composables/graph/useVueNodeLifecycle'
|
|
import type {
|
|
LGraph,
|
|
LGraphCanvas,
|
|
LGraphNode
|
|
} from '@/lib/litegraph/src/litegraph'
|
|
import { useCanvasStore } from '@/renderer/core/canvas/canvasStore'
|
|
import { useLayoutMutations } from '@/renderer/core/layout/operations/layoutMutations'
|
|
import { useNodeEventHandlers } from '@/renderer/extensions/vueNodes/composables/useNodeEventHandlers'
|
|
|
|
vi.mock('@/renderer/core/canvas/canvasStore', () => {
|
|
const canvas: Partial<LGraphCanvas> = {
|
|
select: vi.fn(),
|
|
deselect: vi.fn(),
|
|
deselectAll: vi.fn()
|
|
}
|
|
const updateSelectedItems = vi.fn()
|
|
return {
|
|
useCanvasStore: vi.fn(() => ({
|
|
canvas: canvas as LGraphCanvas,
|
|
updateSelectedItems,
|
|
selectedItems: []
|
|
}))
|
|
}
|
|
})
|
|
|
|
vi.mock('@/renderer/core/canvas/useCanvasInteractions', () => ({
|
|
useCanvasInteractions: vi.fn(() => ({
|
|
shouldHandleNodePointerEvents: computed(() => true) // Default to allowing pointer events
|
|
}))
|
|
}))
|
|
|
|
vi.mock('@/renderer/core/layout/operations/layoutMutations', () => {
|
|
const setSource = vi.fn()
|
|
const bringNodeToFront = vi.fn()
|
|
return {
|
|
useLayoutMutations: vi.fn(() => ({
|
|
setSource,
|
|
bringNodeToFront
|
|
}))
|
|
}
|
|
})
|
|
|
|
vi.mock('@/composables/graph/useGraphNodeManager', () => {
|
|
const mockNode = {
|
|
id: 'node-1',
|
|
selected: false,
|
|
flags: { pinned: false }
|
|
}
|
|
const nodeManager = shallowRef({
|
|
getNode: vi.fn(() => mockNode as Partial<LGraphNode> as LGraphNode)
|
|
} as Partial<GraphNodeManager> as GraphNodeManager)
|
|
return {
|
|
useGraphNodeManager: vi.fn(() => nodeManager)
|
|
}
|
|
})
|
|
|
|
vi.mock('@/composables/graph/useVueNodeLifecycle', () => {
|
|
const nodeManager = useGraphNodeManager(undefined as unknown as LGraph)
|
|
return {
|
|
useVueNodeLifecycle: vi.fn(() => ({
|
|
nodeManager
|
|
}))
|
|
}
|
|
})
|
|
|
|
describe('useNodeEventHandlers', () => {
|
|
const { nodeManager: mockNodeManager } = useVueNodeLifecycle()
|
|
|
|
const mockNode = mockNodeManager.value!.getNode('fake_id')
|
|
const mockLayoutMutations = useLayoutMutations()
|
|
|
|
const testNodeData: VueNodeData = {
|
|
id: 'node-1',
|
|
title: 'Test Node',
|
|
type: 'test',
|
|
mode: 0,
|
|
selected: false,
|
|
executing: false
|
|
}
|
|
|
|
beforeEach(async () => {
|
|
vi.restoreAllMocks()
|
|
})
|
|
|
|
describe('handleNodeSelect', () => {
|
|
it('should select single node on regular click', () => {
|
|
const { handleNodeSelect } = useNodeEventHandlers()
|
|
const { canvas, updateSelectedItems } = useCanvasStore()
|
|
|
|
const event = new PointerEvent('pointerdown', {
|
|
bubbles: true,
|
|
ctrlKey: false,
|
|
metaKey: false
|
|
})
|
|
|
|
handleNodeSelect(event, testNodeData)
|
|
|
|
expect(canvas?.deselectAll).toHaveBeenCalledOnce()
|
|
expect(canvas?.select).toHaveBeenCalledWith(mockNode)
|
|
expect(updateSelectedItems).toHaveBeenCalledOnce()
|
|
})
|
|
|
|
it('should toggle selection on ctrl+click', () => {
|
|
const { handleNodeSelect } = useNodeEventHandlers()
|
|
const { canvas } = useCanvasStore()
|
|
|
|
// Test selecting unselected node with ctrl
|
|
mockNode!.selected = false
|
|
|
|
const ctrlClickEvent = new PointerEvent('pointerdown', {
|
|
bubbles: true,
|
|
ctrlKey: true,
|
|
metaKey: false
|
|
})
|
|
|
|
handleNodeSelect(ctrlClickEvent, testNodeData)
|
|
|
|
expect(canvas?.deselectAll).not.toHaveBeenCalled()
|
|
expect(canvas?.select).toHaveBeenCalledWith(mockNode)
|
|
})
|
|
|
|
it('should deselect on ctrl+click of selected node', () => {
|
|
const { handleNodeSelect } = useNodeEventHandlers()
|
|
const { canvas } = useCanvasStore()
|
|
|
|
// Test deselecting selected node with ctrl
|
|
mockNode!.selected = true
|
|
|
|
const ctrlClickEvent = new PointerEvent('pointerdown', {
|
|
bubbles: true,
|
|
ctrlKey: true,
|
|
metaKey: false
|
|
})
|
|
|
|
handleNodeSelect(ctrlClickEvent, testNodeData)
|
|
|
|
expect(canvas?.deselect).toHaveBeenCalledWith(mockNode)
|
|
expect(canvas?.select).not.toHaveBeenCalled()
|
|
})
|
|
|
|
it('should handle meta key (Cmd) on Mac', () => {
|
|
const { handleNodeSelect } = useNodeEventHandlers()
|
|
const { canvas } = useCanvasStore()
|
|
|
|
mockNode!.selected = false
|
|
|
|
const metaClickEvent = new PointerEvent('pointerdown', {
|
|
bubbles: true,
|
|
ctrlKey: false,
|
|
metaKey: true
|
|
})
|
|
|
|
handleNodeSelect(metaClickEvent, testNodeData)
|
|
|
|
expect(canvas?.select).toHaveBeenCalledWith(mockNode)
|
|
expect(canvas?.deselectAll).not.toHaveBeenCalled()
|
|
})
|
|
|
|
it('should bring node to front when not pinned', () => {
|
|
const { handleNodeSelect } = useNodeEventHandlers()
|
|
|
|
mockNode!.flags.pinned = false
|
|
|
|
const event = new PointerEvent('pointerdown')
|
|
handleNodeSelect(event, testNodeData)
|
|
|
|
expect(mockLayoutMutations.bringNodeToFront).toHaveBeenCalledWith(
|
|
'node-1'
|
|
)
|
|
})
|
|
|
|
it('should not bring pinned node to front', () => {
|
|
const { handleNodeSelect } = useNodeEventHandlers()
|
|
|
|
mockNode!.flags.pinned = true
|
|
|
|
const event = new PointerEvent('pointerdown')
|
|
handleNodeSelect(event, testNodeData)
|
|
|
|
expect(mockLayoutMutations.bringNodeToFront).not.toHaveBeenCalled()
|
|
})
|
|
})
|
|
})
|