mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-05-02 20:22:08 +00:00
Migrate legacy reroute to litegraph native reroute (#3151)
Co-authored-by: github-actions <github-actions@github.com>
This commit is contained in:
35
tests-ui/tests/utils/migration/migrateReroute.test.ts
Normal file
35
tests-ui/tests/utils/migration/migrateReroute.test.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import fs from 'node:fs'
|
||||
import path from 'node:path'
|
||||
import { describe, expect, it } from 'vitest'
|
||||
|
||||
import type { WorkflowJSON04 } from '@/schemas/comfyWorkflowSchema'
|
||||
import { migrateLegacyRerouteNodes } from '@/utils/migration/migrateReroute'
|
||||
|
||||
describe('migrateReroute', () => {
|
||||
describe('migrateReroute snapshots', () => {
|
||||
// Helper function to load workflow JSON files
|
||||
const loadWorkflow = (filePath: string): WorkflowJSON04 => {
|
||||
const fullPath = path.resolve(__dirname, filePath)
|
||||
const fileContent = fs.readFileSync(fullPath, 'utf-8')
|
||||
return JSON.parse(fileContent) as WorkflowJSON04
|
||||
}
|
||||
|
||||
it.each(['branching.json', 'single_connected.json'])(
|
||||
'should correctly migrate %s',
|
||||
(fileName) => {
|
||||
// Load the legacy workflow
|
||||
const legacyWorkflow = loadWorkflow(
|
||||
`workflows/reroute/legacy/${fileName}`
|
||||
)
|
||||
|
||||
// Migrate the workflow
|
||||
const migratedWorkflow = migrateLegacyRerouteNodes(legacyWorkflow)
|
||||
|
||||
// Compare with snapshot
|
||||
expect(JSON.stringify(migratedWorkflow, null, 2)).toMatchFileSnapshot(
|
||||
`workflows/reroute/native/${fileName}`
|
||||
)
|
||||
}
|
||||
)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user