mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-24 16:29:45 +00:00
fix: onNodeRemoved not called when loading new graph (and tearing down previous) (#5407)
* standardize graph cleanup * test: fix useCoreCommands tests and add regression test - Fix mocking to properly simulate app.clean() calling graph.clear() - Add intelligent subgraph detection in mock to match real implementation - Add regression test for Vue node cleanup bug to prevent future regressions - Ensures app.clean() properly triggers onNodeRemoved events through graph.clear() 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * fix unit tests * move beforeLoadNewGraph to before graph is cleaned --------- Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -6,17 +6,25 @@ import { api } from '@/scripts/api'
|
||||
import { app } from '@/scripts/app'
|
||||
import { useSettingStore } from '@/stores/settingStore'
|
||||
|
||||
vi.mock('@/scripts/app', () => ({
|
||||
app: {
|
||||
clean: vi.fn(),
|
||||
canvas: {
|
||||
subgraph: null
|
||||
},
|
||||
graph: {
|
||||
clear: vi.fn()
|
||||
vi.mock('@/scripts/app', () => {
|
||||
const mockGraphClear = vi.fn()
|
||||
const mockCanvas = { subgraph: undefined }
|
||||
|
||||
return {
|
||||
app: {
|
||||
clean: vi.fn(() => {
|
||||
// Simulate app.clean() calling graph.clear() only when not in subgraph
|
||||
if (!mockCanvas.subgraph) {
|
||||
mockGraphClear()
|
||||
}
|
||||
}),
|
||||
canvas: mockCanvas,
|
||||
graph: {
|
||||
clear: mockGraphClear
|
||||
}
|
||||
}
|
||||
}
|
||||
}))
|
||||
})
|
||||
|
||||
vi.mock('@/scripts/api', () => ({
|
||||
api: {
|
||||
|
||||
Reference in New Issue
Block a user