mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-01-26 19:09:52 +00:00
fix: update for reviews
This commit is contained in:
@@ -233,23 +233,21 @@ test.describe('Node Color Adjustments', () => {
|
||||
await comfyPage.setSetting('Comfy.Node.Opacity', 0.5)
|
||||
await comfyPage.setSetting('Comfy.ColorPalette', 'light')
|
||||
await comfyPage.nextFrame()
|
||||
await comfyPage.page.waitForFunction(
|
||||
() => {
|
||||
const workflow = localStorage.getItem('workflow')
|
||||
if (!workflow) return false
|
||||
try {
|
||||
const parsed = JSON.parse(workflow)
|
||||
return parsed?.nodes && Array.isArray(parsed.nodes)
|
||||
} catch {
|
||||
return false
|
||||
}
|
||||
},
|
||||
{ timeout: 3000 }
|
||||
)
|
||||
const workflow = await comfyPage.page.evaluate(() => {
|
||||
return localStorage.getItem('workflow')
|
||||
})
|
||||
const parsed = JSON.parse(workflow ?? '{}')
|
||||
const parsed = await (
|
||||
await comfyPage.page.waitForFunction(
|
||||
() => {
|
||||
const workflow = localStorage.getItem('workflow')
|
||||
if (!workflow) return null
|
||||
try {
|
||||
const data = JSON.parse(workflow)
|
||||
return Array.isArray(data?.nodes) ? data : null
|
||||
} catch {
|
||||
return null
|
||||
}
|
||||
},
|
||||
{ timeout: 3000 }
|
||||
)
|
||||
).jsonValue()
|
||||
expect(parsed.nodes).toBeDefined()
|
||||
expect(Array.isArray(parsed.nodes)).toBe(true)
|
||||
for (const node of parsed.nodes) {
|
||||
|
||||
@@ -1,14 +1,24 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
|
||||
import { MAX_DRAFTS, createDraftCacheState, mostRecentDraftPath, moveDraft, removeDraft, touchEntry, upsertDraft } from '@/platform/workflow/persistence/base/draftCache';
|
||||
import type { WorkflowDraftSnapshot } from '@/platform/workflow/persistence/base/draftCache';
|
||||
import {
|
||||
MAX_DRAFTS,
|
||||
createDraftCacheState,
|
||||
mostRecentDraftPath,
|
||||
moveDraft,
|
||||
removeDraft,
|
||||
touchEntry,
|
||||
upsertDraft
|
||||
} from './draftCache'
|
||||
import type { WorkflowDraftSnapshot } from './draftCache'
|
||||
|
||||
const createSnapshot = (name: string): WorkflowDraftSnapshot => ({
|
||||
data: JSON.stringify({ name }),
|
||||
updatedAt: Date.now(),
|
||||
name,
|
||||
isTemporary: true
|
||||
})
|
||||
function createSnapshot(name: string): WorkflowDraftSnapshot {
|
||||
return {
|
||||
data: JSON.stringify({ name }),
|
||||
updatedAt: Date.now(),
|
||||
name,
|
||||
isTemporary: true
|
||||
}
|
||||
}
|
||||
|
||||
describe('draftCache helpers', () => {
|
||||
it('touchEntry moves path to end', () => {
|
||||
@@ -163,7 +163,7 @@ describe('useWorkflowPersistence', () => {
|
||||
|
||||
const drafts = JSON.parse(
|
||||
localStorage.getItem('Comfy.Workflow.Drafts') ?? '{}'
|
||||
) as Record<string, any>
|
||||
) as Record<string, { data: string; isTemporary: boolean }>
|
||||
|
||||
expect(Object.keys(drafts)).toEqual(
|
||||
expect.arrayContaining(['workflows/DraftA.json', 'workflows/DraftB.json'])
|
||||
|
||||
@@ -201,11 +201,18 @@ export function useWorkflowPersistence() {
|
||||
const parsedWorkflows = JSON.parse(
|
||||
getStorageValue('Comfy.OpenWorkflowsPaths') || '[]'
|
||||
)
|
||||
const storedWorkflows = Array.isArray(parsedWorkflows) ? parsedWorkflows : []
|
||||
const storedWorkflows = Array.isArray(parsedWorkflows)
|
||||
? parsedWorkflows.filter(
|
||||
(entry): entry is string => typeof entry === 'string'
|
||||
)
|
||||
: []
|
||||
const parsedIndex = JSON.parse(
|
||||
getStorageValue('Comfy.ActiveWorkflowIndex') || '-1'
|
||||
)
|
||||
const storedActiveIndex = typeof parsedIndex === 'number' ? parsedIndex : -1
|
||||
const storedActiveIndex =
|
||||
typeof parsedIndex === 'number' && Number.isFinite(parsedIndex)
|
||||
? parsedIndex
|
||||
: -1
|
||||
watch(restoreState, ({ paths, activeIndex }) => {
|
||||
if (workflowPersistenceEnabled.value) {
|
||||
setStorageValue('Comfy.OpenWorkflowsPaths', JSON.stringify(paths))
|
||||
|
||||
@@ -57,6 +57,8 @@ export const useWorkflowDraftStore = defineStore('workflowDraft', () => {
|
||||
const oldestPath = state.order[0]
|
||||
updateState(removeDraftEntry(state, oldestPath))
|
||||
updateState(upsertDraft(currentState(), path, snapshot, MAX_DRAFTS))
|
||||
} else {
|
||||
throw error
|
||||
}
|
||||
} else {
|
||||
throw error
|
||||
|
||||
Reference in New Issue
Block a user