[fix] cleanup

This commit is contained in:
Arjan Singh
2025-09-17 16:35:18 -07:00
parent ecc3aaa0d1
commit 13c82c72da
5 changed files with 33 additions and 27 deletions

View File

@@ -6,7 +6,6 @@ import { nextTick } from 'vue'
import AssetBrowserModal from '@/platform/assets/components/AssetBrowserModal.vue'
import type { AssetDisplayItem } from '@/platform/assets/composables/useAssetBrowser'
import type { AssetItem } from '@/platform/assets/schemas/assetSchema'
import { assetService } from '@/platform/assets/services/assetService'
// Mock assetService
vi.mock('@/platform/assets/services/assetService', () => ({
@@ -106,12 +105,9 @@ vi.mock('vue-i18n', () => ({
vi.mock('@/i18n', () => ({
t: (key: string) => key,
d: (date: Date, options?: any) => date.toLocaleDateString()
d: (date: Date) => date.toLocaleDateString()
}))
// Mock console.error for error handling tests
const consoleErrorSpy = vi.spyOn(console, 'error').mockImplementation(() => {})
describe('AssetBrowserModal', () => {
const createTestAsset = (
id: string,
@@ -271,10 +267,8 @@ describe('AssetBrowserModal', () => {
const emittedAsset = emitted![0][0] as AssetDisplayItem
expect(emittedAsset.id).toBe('asset1')
})
})
describe('Left Panel Conditional Logic', () => {
it('hides left panel by default when showLeftPanel prop is undefined', () => {
const singleCategoryAssets = [

View File

@@ -1,4 +1,4 @@
import { describe, expect, it, vi, beforeEach } from 'vitest'
import { beforeEach, describe, expect, it, vi } from 'vitest'
import { nextTick } from 'vue'
import { useAssetBrowser } from '@/platform/assets/composables/useAssetBrowser'
@@ -20,7 +20,7 @@ vi.mock('@/i18n', () => ({
}
return translations[key] || key
},
d: (date: Date, options?: any) => date.toLocaleDateString()
d: (date: Date) => date.toLocaleDateString()
}))
describe('useAssetBrowser', () => {
@@ -258,7 +258,6 @@ describe('useAssetBrowser', () => {
})
})
describe('Async Asset Selection with Detail Fetching', () => {
it('should fetch asset details and call onSelect with filename when provided', async () => {
const onSelectSpy = vi.fn()
@@ -279,11 +278,15 @@ describe('useAssetBrowser', () => {
await selectAssetWithCallback(asset.id, onSelectSpy)
expect(assetService.getAssetDetails).toHaveBeenCalledWith('asset-123')
expect(onSelectSpy).toHaveBeenCalledWith('checkpoints/test-model.safetensors')
expect(onSelectSpy).toHaveBeenCalledWith(
'checkpoints/test-model.safetensors'
)
})
it('should handle missing user_metadata.filename as error', async () => {
const consoleErrorSpy = vi.spyOn(console, 'error').mockImplementation(() => {})
const consoleErrorSpy = vi
.spyOn(console, 'error')
.mockImplementation(() => {})
const onSelectSpy = vi.fn()
const asset = createApiAsset({ id: 'asset-456' })
@@ -310,7 +313,9 @@ describe('useAssetBrowser', () => {
})
it('should handle API errors gracefully', async () => {
const consoleErrorSpy = vi.spyOn(console, 'error').mockImplementation(() => {})
const consoleErrorSpy = vi
.spyOn(console, 'error')
.mockImplementation(() => {})
const onSelectSpy = vi.fn()
const asset = createApiAsset({ id: 'asset-789' })