mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-29 20:34:28 +00:00
feat(agent): store preset avatars as real files in s3 storage (#381)
* feat(agent): store preset avatars as real files in s3 storage * fix(agent): use inline base64 previews in dialog and remove static avatar files * feat(agent): add 4 avatar presets and track avatarPreset in agent config * refactor(agent): consolidate preset avatar base64 data in dtos
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import {
|
||||
getPresetAvatarBuffer,
|
||||
isPresetAvatarId,
|
||||
PRESET_AVATAR_IDS,
|
||||
type PresetAvatarId,
|
||||
} from './presets'
|
||||
|
||||
describe('agent presets', () => {
|
||||
it('identifies preset avatar IDs correctly', () => {
|
||||
expect(PRESET_AVATAR_IDS).toHaveLength(8)
|
||||
for (const id of PRESET_AVATAR_IDS) {
|
||||
expect(isPresetAvatarId(id)).toBe(true)
|
||||
}
|
||||
expect(isPresetAvatarId('avatar-999')).toBe(false)
|
||||
expect(isPresetAvatarId('')).toBe(false)
|
||||
expect(isPresetAvatarId(null)).toBe(false)
|
||||
expect(isPresetAvatarId(undefined)).toBe(false)
|
||||
})
|
||||
|
||||
it('returns valid buffer for all preset avatars', () => {
|
||||
for (const id of PRESET_AVATAR_IDS) {
|
||||
const buf = getPresetAvatarBuffer(id)
|
||||
expect(buf).toBeInstanceOf(Buffer)
|
||||
expect(buf?.length).toBeGreaterThan(5000)
|
||||
}
|
||||
expect(getPresetAvatarBuffer('unknown' as PresetAvatarId)).toBeNull()
|
||||
})
|
||||
|
||||
it('provides AVAILABLE_AVATARS with 8 previews via dtos', async () => {
|
||||
const { AVAILABLE_AVATARS } = await import('@shumai/dtos')
|
||||
expect(AVAILABLE_AVATARS).toHaveLength(8)
|
||||
for (const avatar of AVAILABLE_AVATARS) {
|
||||
expect(avatar.id).toMatch(/^avatar-[1-8]$/)
|
||||
expect(avatar.preview).toMatch(/^data:image\/webp;base64,/)
|
||||
}
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user