mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-01-26 19:09:52 +00:00
* [feat] add Comfy.Assets.UseAssetAPI to CORE_SETTINGS * [feat] create AssetService 1. Add service for accessing new Asset API 2. Add fallback model paths logic so empty model directories appear for the user. 3. Copious tests for them all. Co-Authored-By: Claude <noreply@anthropic.com> * [feat] switch between assets and file paths for model data * [feat] ignore assets with "missing" tag * [fix] formatting and style * [fix] call assets API with the correct filters * [feat] elminate unused modelPath code * [fix] remove stray comment * [fix] model manager api was not parsed correctly --------- Co-authored-by: Claude <noreply@anthropic.com>
31 lines
851 B
TypeScript
31 lines
851 B
TypeScript
import axios from 'axios'
|
|
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
|
|
|
import { api } from '@/scripts/api'
|
|
|
|
vi.mock('axios')
|
|
|
|
describe('getFolderPaths', () => {
|
|
beforeEach(() => {
|
|
vi.resetAllMocks()
|
|
})
|
|
|
|
it('returns legacy API response when available', async () => {
|
|
const mockResponse = { checkpoints: ['/test/checkpoints'] }
|
|
vi.mocked(axios.get).mockResolvedValueOnce({ data: mockResponse })
|
|
|
|
const result = await api.getFolderPaths()
|
|
|
|
expect(result).toEqual(mockResponse)
|
|
})
|
|
|
|
it('returns empty object when legacy API unavailable (dynamic discovery)', async () => {
|
|
vi.mocked(axios.get).mockRejectedValueOnce(new Error())
|
|
|
|
const result = await api.getFolderPaths()
|
|
|
|
// With dynamic discovery, we don't pre-generate directories when API is unavailable
|
|
expect(result).toEqual({})
|
|
})
|
|
})
|