Skip to content

The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.

1.3 KB
Raw Blame
/**
 * normalizeModelBase — shared identity for the installed-visibility check and
 * the fuzzy variant fallback (a user: bundle "installed" on disk must not
 * survive when the running ComfyUI cannot see the file).
 * Run: npx vitest run src/api/__tests__/discover-visibility.test.ts
 */
import { describe, it, expect } from 'vitest'
import { normalizeModelBase } from '../discover'

describe('normalizeModelBase', () => {
  it('strips extension and lowercases', () => {
    expect(normalizeModelBase('JuggernautXL_v9.safetensors')).toBe('juggernautxl_v9')
  })

  it('drops nested subdir prefixes ComfyUI enums can carry', () => {
    expect(normalizeModelBase('SDXL/juggernautXL_v9.safetensors')).toBe('juggernautxl_v9')
    expect(normalizeModelBase('SDXL\\juggernautXL_v9.safetensors')).toBe('juggernautxl_v9')
  })

  it('strips common quant suffixes so variants match', () => {
    expect(normalizeModelBase('z_image_turbo_fp8.safetensors')).toBe('z_image_turbo')
    expect(normalizeModelBase('z_image_turbo_bf16.safetensors')).toBe('z_image_turbo')
  })

  it('does NOT substring-match different models (strict base identity)', () => {
    expect(normalizeModelBase('z_image_turbo.safetensors')).not.toBe(
      normalizeModelBase('z_image_base.safetensors'),
    )
  })
})