mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-04 23:20:07 +00:00
[fix] Restore conflict notification work and fix tests
- Fix missing footerProps property in DialogInstance interface - Add missing InstalledPacksResponse type import in tests - Add missing getImportFailInfoBulk method to test mock - Remove unused ManagerComponents import causing type error - All unit and component tests now pass successfully
This commit is contained in:
@@ -43,6 +43,7 @@ interface DialogInstance {
|
||||
component: Component
|
||||
contentProps: Record<string, any>
|
||||
footerComponent?: Component
|
||||
footerProps?: Record<string, any>
|
||||
dialogComponentProps: DialogComponentProps
|
||||
priority: number
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ vi.mock('@/stores/comfyManagerStore', () => ({
|
||||
useComfyManagerStore: vi.fn(() => ({
|
||||
isPackInstalled: vi.fn(() => false),
|
||||
isPackEnabled: vi.fn(() => true),
|
||||
isPackInstalling: vi.fn(() => false),
|
||||
installedPacksIds: []
|
||||
}))
|
||||
}))
|
||||
|
||||
@@ -3,8 +3,8 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import { nextTick } from 'vue'
|
||||
|
||||
import { useConflictDetection } from '@/composables/useConflictDetection'
|
||||
import type { InstalledPacksResponse } from '@/types/comfyManagerTypes'
|
||||
import type { components } from '@/types/comfyRegistryTypes'
|
||||
import type { components as ManagerComponents } from '@/types/generatedManagerTypes'
|
||||
|
||||
// Mock dependencies
|
||||
vi.mock('@/scripts/api', () => ({
|
||||
@@ -199,21 +199,20 @@ describe.skip('useConflictDetection with Registry Store', () => {
|
||||
describe('package requirements detection with Registry Store', () => {
|
||||
it('should fetch and combine local + Registry data successfully', async () => {
|
||||
// Mock installed packages
|
||||
const mockInstalledPacks: ManagerComponents['schemas']['InstalledPacksResponse'] =
|
||||
{
|
||||
'ComfyUI-Manager': {
|
||||
ver: 'cb0fa5829d5378e5dddb8e8515b30a3ff20e1471',
|
||||
cnr_id: '',
|
||||
aux_id: 'viva-jinyi/ComfyUI-Manager',
|
||||
enabled: true
|
||||
},
|
||||
'ComfyUI-TestNode': {
|
||||
ver: '1.0.0',
|
||||
cnr_id: 'test-node',
|
||||
aux_id: null,
|
||||
enabled: false
|
||||
}
|
||||
const mockInstalledPacks: InstalledPacksResponse = {
|
||||
'ComfyUI-Manager': {
|
||||
ver: 'cb0fa5829d5378e5dddb8e8515b30a3ff20e1471',
|
||||
cnr_id: '',
|
||||
aux_id: 'viva-jinyi/ComfyUI-Manager',
|
||||
enabled: true
|
||||
},
|
||||
'ComfyUI-TestNode': {
|
||||
ver: '1.0.0',
|
||||
cnr_id: 'test-node',
|
||||
aux_id: null,
|
||||
enabled: false
|
||||
}
|
||||
}
|
||||
|
||||
// Mock Registry data
|
||||
const mockRegistryPacks: components['schemas']['Node'][] = [
|
||||
@@ -291,15 +290,14 @@ describe.skip('useConflictDetection with Registry Store', () => {
|
||||
|
||||
it('should handle Registry Store failures gracefully', async () => {
|
||||
// Mock installed packages
|
||||
const mockInstalledPacks: ManagerComponents['schemas']['InstalledPacksResponse'] =
|
||||
{
|
||||
'Unknown-Package': {
|
||||
ver: '1.0.0',
|
||||
cnr_id: 'unknown',
|
||||
aux_id: null,
|
||||
enabled: true
|
||||
}
|
||||
const mockInstalledPacks: InstalledPacksResponse = {
|
||||
'Unknown-Package': {
|
||||
ver: '1.0.0',
|
||||
cnr_id: 'unknown',
|
||||
aux_id: null,
|
||||
enabled: true
|
||||
}
|
||||
}
|
||||
|
||||
mockComfyManagerService.listInstalledPacks.mockResolvedValue(
|
||||
mockInstalledPacks
|
||||
@@ -343,15 +341,14 @@ describe.skip('useConflictDetection with Registry Store', () => {
|
||||
describe('conflict detection logic with Registry Store', () => {
|
||||
it('should detect no conflicts for fully compatible packages', async () => {
|
||||
// Mock compatible package
|
||||
const mockInstalledPacks: ManagerComponents['schemas']['InstalledPacksResponse'] =
|
||||
{
|
||||
CompatibleNode: {
|
||||
ver: '1.0.0',
|
||||
cnr_id: 'compatible-node',
|
||||
aux_id: null,
|
||||
enabled: true
|
||||
}
|
||||
const mockInstalledPacks: InstalledPacksResponse = {
|
||||
CompatibleNode: {
|
||||
ver: '1.0.0',
|
||||
cnr_id: 'compatible-node',
|
||||
aux_id: null,
|
||||
enabled: true
|
||||
}
|
||||
}
|
||||
|
||||
const mockCompatibleRegistryPacks: components['schemas']['Node'][] = [
|
||||
{
|
||||
@@ -388,15 +385,14 @@ describe.skip('useConflictDetection with Registry Store', () => {
|
||||
|
||||
it('should detect OS incompatibility conflicts', async () => {
|
||||
// Mock OS-incompatible package
|
||||
const mockInstalledPacks: ManagerComponents['schemas']['InstalledPacksResponse'] =
|
||||
{
|
||||
WindowsOnlyNode: {
|
||||
ver: '1.0.0',
|
||||
cnr_id: 'windows-only',
|
||||
aux_id: null,
|
||||
enabled: true
|
||||
}
|
||||
const mockInstalledPacks: InstalledPacksResponse = {
|
||||
WindowsOnlyNode: {
|
||||
ver: '1.0.0',
|
||||
cnr_id: 'windows-only',
|
||||
aux_id: null,
|
||||
enabled: true
|
||||
}
|
||||
}
|
||||
|
||||
const mockWindowsOnlyRegistryPacks: components['schemas']['Node'][] = [
|
||||
{
|
||||
@@ -441,15 +437,14 @@ describe.skip('useConflictDetection with Registry Store', () => {
|
||||
|
||||
it('should detect accelerator incompatibility conflicts', async () => {
|
||||
// Mock CUDA-only package
|
||||
const mockInstalledPacks: ManagerComponents['schemas']['InstalledPacksResponse'] =
|
||||
{
|
||||
CudaOnlyNode: {
|
||||
ver: '1.0.0',
|
||||
cnr_id: 'cuda-only',
|
||||
aux_id: null,
|
||||
enabled: true
|
||||
}
|
||||
const mockInstalledPacks: InstalledPacksResponse = {
|
||||
CudaOnlyNode: {
|
||||
ver: '1.0.0',
|
||||
cnr_id: 'cuda-only',
|
||||
aux_id: null,
|
||||
enabled: true
|
||||
}
|
||||
}
|
||||
|
||||
const mockCudaOnlyRegistryPacks: components['schemas']['Node'][] = [
|
||||
{
|
||||
@@ -494,15 +489,14 @@ describe.skip('useConflictDetection with Registry Store', () => {
|
||||
|
||||
it('should treat Registry-banned packages as conflicts', async () => {
|
||||
// Mock Registry-banned package
|
||||
const mockInstalledPacks: ManagerComponents['schemas']['InstalledPacksResponse'] =
|
||||
{
|
||||
BannedNode: {
|
||||
ver: '1.0.0',
|
||||
cnr_id: 'banned-node',
|
||||
aux_id: null,
|
||||
enabled: true
|
||||
}
|
||||
const mockInstalledPacks: InstalledPacksResponse = {
|
||||
BannedNode: {
|
||||
ver: '1.0.0',
|
||||
cnr_id: 'banned-node',
|
||||
aux_id: null,
|
||||
enabled: true
|
||||
}
|
||||
}
|
||||
|
||||
const mockBannedRegistryPacks: components['schemas']['NodeVersion'][] = [
|
||||
{
|
||||
@@ -548,15 +542,14 @@ describe.skip('useConflictDetection with Registry Store', () => {
|
||||
|
||||
it('should treat locally disabled packages as banned', async () => {
|
||||
// Mock locally disabled package
|
||||
const mockInstalledPacks: ManagerComponents['schemas']['InstalledPacksResponse'] =
|
||||
{
|
||||
DisabledNode: {
|
||||
ver: '1.0.0',
|
||||
cnr_id: 'disabled-node',
|
||||
aux_id: null,
|
||||
enabled: false
|
||||
}
|
||||
const mockInstalledPacks: InstalledPacksResponse = {
|
||||
DisabledNode: {
|
||||
ver: '1.0.0',
|
||||
cnr_id: 'disabled-node',
|
||||
aux_id: null,
|
||||
enabled: false
|
||||
}
|
||||
}
|
||||
|
||||
const mockActiveRegistryPacks: components['schemas']['Node'][] = [
|
||||
{
|
||||
@@ -605,15 +598,14 @@ describe.skip('useConflictDetection with Registry Store', () => {
|
||||
describe('computed properties with Registry Store', () => {
|
||||
it('should return true for hasConflicts when Registry conflicts exist', async () => {
|
||||
// Mock package with OS incompatibility
|
||||
const mockInstalledPacks: ManagerComponents['schemas']['InstalledPacksResponse'] =
|
||||
{
|
||||
ConflictedNode: {
|
||||
ver: '1.0.0',
|
||||
cnr_id: 'conflicted-node',
|
||||
aux_id: null,
|
||||
enabled: true
|
||||
}
|
||||
const mockInstalledPacks: InstalledPacksResponse = {
|
||||
ConflictedNode: {
|
||||
ver: '1.0.0',
|
||||
cnr_id: 'conflicted-node',
|
||||
aux_id: null,
|
||||
enabled: true
|
||||
}
|
||||
}
|
||||
|
||||
const mockConflictedRegistryPacks: components['schemas']['Node'][] = [
|
||||
{
|
||||
@@ -653,15 +645,14 @@ describe.skip('useConflictDetection with Registry Store', () => {
|
||||
|
||||
it('should return packages with conflicts', async () => {
|
||||
// Mock package with conflicts
|
||||
const mockInstalledPacks: ManagerComponents['schemas']['InstalledPacksResponse'] =
|
||||
{
|
||||
ErrorNode: {
|
||||
ver: '1.0.0',
|
||||
cnr_id: 'error-node',
|
||||
aux_id: null,
|
||||
enabled: true
|
||||
}
|
||||
const mockInstalledPacks: InstalledPacksResponse = {
|
||||
ErrorNode: {
|
||||
ver: '1.0.0',
|
||||
cnr_id: 'error-node',
|
||||
aux_id: null,
|
||||
enabled: true
|
||||
}
|
||||
}
|
||||
|
||||
const mockErrorRegistryPacks: components['schemas']['Node'][] = [
|
||||
{
|
||||
@@ -700,21 +691,20 @@ describe.skip('useConflictDetection with Registry Store', () => {
|
||||
|
||||
it('should return only banned packages for bannedPackages', async () => {
|
||||
// Mock one banned and one normal package
|
||||
const mockInstalledPacks: ManagerComponents['schemas']['InstalledPacksResponse'] =
|
||||
{
|
||||
BannedNode: {
|
||||
ver: '1.0.0',
|
||||
cnr_id: 'banned-node',
|
||||
aux_id: null,
|
||||
enabled: false
|
||||
},
|
||||
NormalNode: {
|
||||
ver: '1.0.0',
|
||||
cnr_id: 'normal-node',
|
||||
aux_id: null,
|
||||
enabled: true
|
||||
}
|
||||
const mockInstalledPacks: InstalledPacksResponse = {
|
||||
BannedNode: {
|
||||
ver: '1.0.0',
|
||||
cnr_id: 'banned-node',
|
||||
aux_id: null,
|
||||
enabled: false
|
||||
},
|
||||
NormalNode: {
|
||||
ver: '1.0.0',
|
||||
cnr_id: 'normal-node',
|
||||
aux_id: null,
|
||||
enabled: true
|
||||
}
|
||||
}
|
||||
|
||||
const mockRegistryPacks: components['schemas']['Node'][] = [
|
||||
{
|
||||
@@ -797,21 +787,20 @@ describe.skip('useConflictDetection with Registry Store', () => {
|
||||
|
||||
it('should handle Registry Store partial data gracefully', async () => {
|
||||
// Mock successful local data but partial Registry data
|
||||
const mockInstalledPacks: ManagerComponents['schemas']['InstalledPacksResponse'] =
|
||||
{
|
||||
'Package-A': {
|
||||
ver: '1.0.0',
|
||||
cnr_id: 'a',
|
||||
aux_id: null,
|
||||
enabled: true
|
||||
},
|
||||
'Package-B': {
|
||||
ver: '2.0.0',
|
||||
cnr_id: 'b',
|
||||
aux_id: null,
|
||||
enabled: true
|
||||
}
|
||||
const mockInstalledPacks: InstalledPacksResponse = {
|
||||
'Package-A': {
|
||||
ver: '1.0.0',
|
||||
cnr_id: 'a',
|
||||
aux_id: null,
|
||||
enabled: true
|
||||
},
|
||||
'Package-B': {
|
||||
ver: '2.0.0',
|
||||
cnr_id: 'b',
|
||||
aux_id: null,
|
||||
enabled: true
|
||||
}
|
||||
}
|
||||
|
||||
mockComfyManagerService.listInstalledPacks.mockResolvedValue(
|
||||
mockInstalledPacks
|
||||
@@ -921,15 +910,14 @@ describe.skip('useConflictDetection with Registry Store', () => {
|
||||
|
||||
it('should show conflict modal after update when conflicts exist', async () => {
|
||||
// Mock package with conflicts
|
||||
const mockInstalledPacks: ManagerComponents['schemas']['InstalledPacksResponse'] =
|
||||
{
|
||||
ConflictedNode: {
|
||||
ver: '1.0.0',
|
||||
cnr_id: 'conflicted-node',
|
||||
aux_id: null,
|
||||
enabled: true
|
||||
}
|
||||
const mockInstalledPacks: InstalledPacksResponse = {
|
||||
ConflictedNode: {
|
||||
ver: '1.0.0',
|
||||
cnr_id: 'conflicted-node',
|
||||
aux_id: null,
|
||||
enabled: true
|
||||
}
|
||||
}
|
||||
|
||||
const mockConflictedRegistryPacks: components['schemas']['Node'][] = [
|
||||
{
|
||||
|
||||
@@ -86,6 +86,7 @@ describe('useComfyManagerStore', () => {
|
||||
getQueueStatus: vi.fn().mockResolvedValue(null),
|
||||
listInstalledPacks: vi.fn().mockResolvedValue({}),
|
||||
getImportFailInfo: vi.fn().mockResolvedValue(null),
|
||||
getImportFailInfoBulk: vi.fn().mockResolvedValue({}),
|
||||
installPack: vi.fn().mockResolvedValue(null),
|
||||
uninstallPack: vi.fn().mockResolvedValue(null),
|
||||
enablePack: vi.fn().mockResolvedValue(null),
|
||||
|
||||
@@ -1,129 +0,0 @@
|
||||
import { createPinia, setActivePinia } from 'pinia'
|
||||
import { beforeEach, describe, expect, it } from 'vitest'
|
||||
|
||||
import { useNodeCompatibilityStore } from '@/stores/nodeCompatibilityStore'
|
||||
|
||||
describe('useNodeCompatibilityStore', () => {
|
||||
beforeEach(() => {
|
||||
setActivePinia(createPinia())
|
||||
})
|
||||
|
||||
it('should initialize with empty state', () => {
|
||||
const store = useNodeCompatibilityStore()
|
||||
|
||||
expect(store.isChecking).toBe(false)
|
||||
expect(store.lastCheckTime).toBeNull()
|
||||
expect(store.checkError).toBeNull()
|
||||
expect(store.hasIncompatibleNodes).toBe(false)
|
||||
expect(store.totalIncompatibleCount).toBe(0)
|
||||
expect(store.shouldShowNotification).toBe(false)
|
||||
})
|
||||
|
||||
it('should add incompatible nodes correctly', () => {
|
||||
const store = useNodeCompatibilityStore()
|
||||
|
||||
store.addIncompatibleNode(
|
||||
'test-node',
|
||||
'Test Node',
|
||||
'banned',
|
||||
'Node is banned for testing'
|
||||
)
|
||||
|
||||
expect(store.hasIncompatibleNodes).toBe(true)
|
||||
expect(store.totalIncompatibleCount).toBe(1)
|
||||
expect(store.hasNodeCompatibilityIssues('test-node')).toBe(true)
|
||||
|
||||
const compatibilityInfo = store.getNodeCompatibilityInfo('test-node')
|
||||
expect(compatibilityInfo).toBeDefined()
|
||||
expect(compatibilityInfo?.disableReason).toBe('banned')
|
||||
})
|
||||
|
||||
it('should remove incompatible nodes correctly', () => {
|
||||
const store = useNodeCompatibilityStore()
|
||||
|
||||
store.addIncompatibleNode(
|
||||
'test-node',
|
||||
'Test Node',
|
||||
'banned',
|
||||
'Node is banned for testing'
|
||||
)
|
||||
|
||||
expect(store.hasIncompatibleNodes).toBe(true)
|
||||
|
||||
store.removeIncompatibleNode('test-node')
|
||||
|
||||
expect(store.hasIncompatibleNodes).toBe(false)
|
||||
expect(store.hasNodeCompatibilityIssues('test-node')).toBe(false)
|
||||
})
|
||||
|
||||
it('should handle notification modal state correctly', () => {
|
||||
const store = useNodeCompatibilityStore()
|
||||
|
||||
// Add an incompatible node
|
||||
store.addIncompatibleNode(
|
||||
'test-node',
|
||||
'Test Node',
|
||||
'banned',
|
||||
'Node is banned for testing'
|
||||
)
|
||||
|
||||
expect(store.shouldShowNotification).toBe(true)
|
||||
expect(store.pendingNotificationNodes).toHaveLength(1)
|
||||
|
||||
store.markNotificationModalShown()
|
||||
|
||||
expect(store.shouldShowNotification).toBe(false)
|
||||
expect(store.pendingNotificationNodes).toHaveLength(0)
|
||||
})
|
||||
|
||||
it('should clear all results correctly', () => {
|
||||
const store = useNodeCompatibilityStore()
|
||||
|
||||
store.addIncompatibleNode(
|
||||
'test-node',
|
||||
'Test Node',
|
||||
'banned',
|
||||
'Node is banned for testing'
|
||||
)
|
||||
store.recordCheckError('Test error')
|
||||
|
||||
expect(store.hasIncompatibleNodes).toBe(true)
|
||||
expect(store.checkError).toBe('Test error')
|
||||
|
||||
store.clearResults()
|
||||
|
||||
expect(store.hasIncompatibleNodes).toBe(false)
|
||||
expect(store.checkError).toBeNull()
|
||||
})
|
||||
|
||||
it('should track checking state correctly', () => {
|
||||
const store = useNodeCompatibilityStore()
|
||||
|
||||
expect(store.isChecking).toBe(false)
|
||||
|
||||
store.setCheckingState(true)
|
||||
expect(store.isChecking).toBe(true)
|
||||
|
||||
store.recordCheckCompletion()
|
||||
expect(store.isChecking).toBe(false)
|
||||
expect(store.lastCheckTime).toBeDefined()
|
||||
})
|
||||
|
||||
it('should provide compatibility summary', () => {
|
||||
const store = useNodeCompatibilityStore()
|
||||
|
||||
store.addIncompatibleNode(
|
||||
'banned-node',
|
||||
'Banned Node',
|
||||
'banned',
|
||||
'Node is banned'
|
||||
)
|
||||
|
||||
const summary = store.getCompatibilitySummary()
|
||||
|
||||
expect(summary.incompatibleCount).toBe(1)
|
||||
expect(summary.bannedCount).toBe(0) // bannedNodes is separate from incompatibleNodes
|
||||
expect(summary.totalIssues).toBe(1)
|
||||
expect(summary.hasError).toBe(false)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user