mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-05 15:40:10 +00:00
This completes the integration of ComfyUI Manager migration features with enhanced conflict detection system. Key changes include: ## Manager Migration & Conflict Detection - Integrated PR #4637 (4-state manager restart workflow) with PR #4654 (comprehensive conflict detection) - Fixed conflict detection to properly check `latest_version` fields for registry API compatibility - Added conflict detection to PackCardFooter and InfoPanelHeader for comprehensive warning coverage - Merged missing English locale translations from main branch with proper conflict resolution ## Bug Fixes - Fixed double API path issue (`/api/v2/v2/`) in manager service routes - Corrected PackUpdateButton payload structure and service method calls - Enhanced conflict detection system to handle both installed and registry package structures ## Technical Improvements - Updated conflict detection composable to handle both installed and registry package structures - Enhanced manager service with proper error handling and route corrections - Improved type safety across manager components with proper TypeScript definitions
166 lines
4.1 KiB
TypeScript
166 lines
4.1 KiB
TypeScript
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
|
import { ref } from 'vue'
|
|
|
|
import { useManagerQueue } from '@/composables/useManagerQueue'
|
|
import { components } from '@/types/generatedManagerTypes'
|
|
|
|
// Mock dialog service
|
|
vi.mock('@/services/dialogService', () => ({
|
|
useDialogService: () => ({
|
|
showManagerProgressDialog: vi.fn()
|
|
})
|
|
}))
|
|
|
|
// Mock the app API
|
|
vi.mock('@/scripts/app', () => ({
|
|
app: {
|
|
api: {
|
|
addEventListener: vi.fn(),
|
|
removeEventListener: vi.fn(),
|
|
clientId: 'test-client-id'
|
|
}
|
|
}
|
|
}))
|
|
|
|
type ManagerTaskHistory = Record<
|
|
string,
|
|
components['schemas']['TaskHistoryItem']
|
|
>
|
|
type ManagerTaskQueue = components['schemas']['TaskStateMessage']
|
|
|
|
describe('useManagerQueue', () => {
|
|
let taskHistory: any
|
|
let taskQueue: any
|
|
let installedPacks: any
|
|
|
|
const createManagerQueue = () => {
|
|
taskHistory = ref<ManagerTaskHistory>({})
|
|
taskQueue = ref<ManagerTaskQueue>({
|
|
history: {},
|
|
running_queue: [],
|
|
pending_queue: [],
|
|
installed_packs: {}
|
|
})
|
|
installedPacks = ref({})
|
|
|
|
return useManagerQueue(taskHistory, taskQueue, installedPacks)
|
|
}
|
|
|
|
beforeEach(() => {
|
|
vi.clearAllMocks()
|
|
})
|
|
|
|
afterEach(() => {
|
|
vi.clearAllMocks()
|
|
})
|
|
|
|
describe('initialization', () => {
|
|
it('should initialize with empty state', () => {
|
|
const queue = createManagerQueue()
|
|
|
|
expect(queue.currentQueueLength.value).toBe(0)
|
|
expect(queue.allTasksDone.value).toBe(true)
|
|
expect(queue.isProcessing.value).toBe(false)
|
|
expect(queue.historyCount.value).toBe(0)
|
|
})
|
|
})
|
|
|
|
describe('task state management', () => {
|
|
it('should track task queue length', () => {
|
|
const queue = createManagerQueue()
|
|
|
|
// Add tasks to queue
|
|
taskQueue.value.running_queue = [
|
|
{
|
|
ui_id: 'task1',
|
|
client_id: 'test-client-id',
|
|
task_name: 'Installing pack1'
|
|
}
|
|
]
|
|
taskQueue.value.pending_queue = [
|
|
{
|
|
ui_id: 'task2',
|
|
client_id: 'test-client-id',
|
|
task_name: 'Installing pack2'
|
|
}
|
|
]
|
|
|
|
expect(queue.currentQueueLength.value).toBe(2)
|
|
expect(queue.allTasksDone.value).toBe(false)
|
|
})
|
|
|
|
it('should handle empty queues', () => {
|
|
const queue = createManagerQueue()
|
|
|
|
taskQueue.value.running_queue = []
|
|
taskQueue.value.pending_queue = []
|
|
|
|
expect(queue.currentQueueLength.value).toBe(0)
|
|
expect(queue.allTasksDone.value).toBe(true)
|
|
})
|
|
})
|
|
|
|
describe('task history management', () => {
|
|
it('should track task history count', () => {
|
|
const queue = createManagerQueue()
|
|
|
|
taskHistory.value = {
|
|
task1: {
|
|
ui_id: 'task1',
|
|
client_id: 'test-client-id',
|
|
status: { status_str: 'success', completed: true }
|
|
},
|
|
task2: {
|
|
ui_id: 'task2',
|
|
client_id: 'test-client-id',
|
|
status: { status_str: 'success', completed: true }
|
|
}
|
|
}
|
|
|
|
expect(queue.historyCount.value).toBe(2)
|
|
})
|
|
|
|
it('should filter tasks by client ID', () => {
|
|
const queue = createManagerQueue()
|
|
|
|
const mockState = {
|
|
history: {
|
|
task1: {
|
|
ui_id: 'task1',
|
|
client_id: 'test-client-id', // This client
|
|
kind: 'install',
|
|
timestamp: '2024-01-01T00:00:00Z',
|
|
result: 'success',
|
|
status: {
|
|
status_str: 'success' as const,
|
|
completed: true,
|
|
messages: []
|
|
}
|
|
},
|
|
task2: {
|
|
ui_id: 'task2',
|
|
client_id: 'other-client-id', // Different client
|
|
kind: 'install',
|
|
timestamp: '2024-01-01T00:00:00Z',
|
|
result: 'success',
|
|
status: {
|
|
status_str: 'success' as const,
|
|
completed: true,
|
|
messages: []
|
|
}
|
|
}
|
|
},
|
|
running_queue: [],
|
|
pending_queue: [],
|
|
installed_packs: {}
|
|
}
|
|
|
|
queue.updateTaskState(mockState)
|
|
|
|
// Should only include task from this client
|
|
expect(taskHistory.value).toHaveProperty('task1')
|
|
expect(taskHistory.value).not.toHaveProperty('task2')
|
|
})
|
|
})
|
|
})
|