[Manager] "Restarting" state after clicking restart button (#4637)

This commit is contained in:
Jin Yi
2025-08-02 04:04:58 +09:00
committed by GitHub
parent 5abe2d0822
commit 211eeff143
8 changed files with 859 additions and 71 deletions

View File

@@ -6,6 +6,8 @@ import { useComfyManagerService } from '@/services/comfyManagerService'
import { useComfyManagerStore } from '@/stores/comfyManagerStore'
import {
InstalledPacksResponse,
ManagerChannel,
ManagerDatabaseSource,
ManagerPackInstalled
} from '@/types/comfyManagerTypes'
@@ -13,6 +15,34 @@ vi.mock('@/services/comfyManagerService', () => ({
useComfyManagerService: vi.fn()
}))
vi.mock('@/services/dialogService', () => ({
useDialogService: () => ({
showManagerProgressDialog: vi.fn()
})
}))
vi.mock('@/composables/useManagerQueue', () => {
const enqueueTaskMock = vi.fn()
return {
useManagerQueue: () => ({
statusMessage: ref(''),
allTasksDone: ref(false),
enqueueTask: enqueueTaskMock,
uncompletedCount: ref(0)
}),
enqueueTask: enqueueTaskMock
}
})
vi.mock('@/composables/useServerLogs', () => ({
useServerLogs: () => ({
startListening: vi.fn(),
stopListening: vi.fn(),
logs: ref([])
})
}))
vi.mock('vue-i18n', () => ({
useI18n: () => ({
t: vi.fn((key) => key)
@@ -33,11 +63,7 @@ interface EnabledDisabledTestCase {
}
describe('useComfyManagerStore', () => {
let mockManagerService: {
isLoading: ReturnType<typeof ref<boolean>>
error: ReturnType<typeof ref<string | null>>
listInstalledPacks: ReturnType<typeof vi.fn>
}
let mockManagerService: ReturnType<typeof useComfyManagerService>
const triggerPacksChange = async (
installedPacks: InstalledPacksResponse,
@@ -55,10 +81,21 @@ describe('useComfyManagerStore', () => {
mockManagerService = {
isLoading: ref(false),
error: ref(null),
listInstalledPacks: vi.fn().mockResolvedValue({})
startQueue: vi.fn().mockResolvedValue(null),
resetQueue: vi.fn().mockResolvedValue(null),
getQueueStatus: vi.fn().mockResolvedValue(null),
listInstalledPacks: vi.fn().mockResolvedValue({}),
getImportFailInfo: vi.fn().mockResolvedValue(null),
installPack: vi.fn().mockResolvedValue(null),
uninstallPack: vi.fn().mockResolvedValue(null),
enablePack: vi.fn().mockResolvedValue(null),
disablePack: vi.fn().mockResolvedValue(null),
updatePack: vi.fn().mockResolvedValue(null),
updateAllPacks: vi.fn().mockResolvedValue(null),
rebootComfyUI: vi.fn().mockResolvedValue(null),
isLegacyManagerUI: vi.fn().mockResolvedValue(false)
}
// @ts-expect-error Mocking the return type of useComfyManagerService
vi.mocked(useComfyManagerService).mockReturnValue(mockManagerService)
})
@@ -313,4 +350,90 @@ describe('useComfyManagerStore', () => {
}
)
})
describe('isPackInstalling', () => {
it('should return false for packs not being installed', () => {
const store = useComfyManagerStore()
expect(store.isPackInstalling('test-pack')).toBe(false)
expect(store.isPackInstalling(undefined)).toBe(false)
expect(store.isPackInstalling('')).toBe(false)
})
it('should track pack as installing when installPack is called', async () => {
const store = useComfyManagerStore()
// Call installPack
await store.installPack.call({
id: 'test-pack',
repository: 'https://github.com/test/test-pack',
channel: ManagerChannel.DEV,
mode: ManagerDatabaseSource.CACHE,
selected_version: 'latest',
version: 'latest'
})
// Check that the pack is marked as installing
expect(store.isPackInstalling('test-pack')).toBe(true)
})
it('should remove pack from installing list when explicitly removed', async () => {
const store = useComfyManagerStore()
// Call installPack
await store.installPack.call({
id: 'test-pack',
repository: 'https://github.com/test/test-pack',
channel: ManagerChannel.DEV,
mode: ManagerDatabaseSource.CACHE,
selected_version: 'latest',
version: 'latest'
})
// Verify pack is installing
expect(store.isPackInstalling('test-pack')).toBe(true)
// Call installPack again for another pack to demonstrate multiple installs
await store.installPack.call({
id: 'another-pack',
repository: 'https://github.com/test/another-pack',
channel: ManagerChannel.DEV,
mode: ManagerDatabaseSource.CACHE,
selected_version: 'latest',
version: 'latest'
})
// Both should be installing
expect(store.isPackInstalling('test-pack')).toBe(true)
expect(store.isPackInstalling('another-pack')).toBe(true)
})
it('should track multiple packs installing independently', async () => {
const store = useComfyManagerStore()
// Install pack 1
await store.installPack.call({
id: 'pack-1',
repository: 'https://github.com/test/pack-1',
channel: ManagerChannel.DEV,
mode: ManagerDatabaseSource.CACHE,
selected_version: 'latest',
version: 'latest'
})
// Install pack 2
await store.installPack.call({
id: 'pack-2',
repository: 'https://github.com/test/pack-2',
channel: ManagerChannel.DEV,
mode: ManagerDatabaseSource.CACHE,
selected_version: 'latest',
version: 'latest'
})
// Both should be installing
expect(store.isPackInstalling('pack-1')).toBe(true)
expect(store.isPackInstalling('pack-2')).toBe(true)
expect(store.isPackInstalling('pack-3')).toBe(false)
})
})
})