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