import { describe, expect, it } from 'vitest'

import { appearanceApiToSnapshot } from '../../lib/appearance-api.js'
import type { AppearanceApiResponse } from '../../lib/appearance-api.js'

describe('appearanceApiToSnapshot', () => {
  it('maps admin logo URLs from GET /appearance into ThemeProvider adminBrand', () => {
    const data: AppearanceApiResponse = {
      appearance: {
        adminColorModeDefault: 'system',
        adminAccentColor: 'teal',
        sidebarDensity: 'compact',
        contentFont: 'Inter',
        reduceMotion: true,
      },
      brand: {
        mode: 'customAdminBrand',
        adminPrimaryLogoAssetId: 'admin-logo',
      },
      resolved: { admin: { initials: 'UC' } },
      assets: [
        {
          id: 'admin-logo',
          publicUrl: 'https://cdn.example.com/upchat-admin.svg',
          mimeType: 'image/svg+xml',
          width: 320,
          height: 80,
        },
      ],
      siteTitle: 'UpChat',
    }

    const snapshot = appearanceApiToSnapshot(data)

    expect(snapshot.adminBrand?.primaryUrl).toBe('https://cdn.example.com/upchat-admin.svg')
    expect(snapshot.adminBrand?.initials).toBe('UP')
    expect(snapshot.accent).toBe('teal')
    expect(snapshot.density).toBe('compact')
    expect(snapshot.reduceMotion).toBe(true)
  })
})
