diff --git a/client/src/features/achievements/__tests__/resolveLucideIcon.spec.ts b/client/src/features/achievements/__tests__/resolveLucideIcon.spec.ts index 51117ec0a..e4ba0d715 100644 --- a/client/src/features/achievements/__tests__/resolveLucideIcon.spec.ts +++ b/client/src/features/achievements/__tests__/resolveLucideIcon.spec.ts @@ -1,8 +1,11 @@ +import { readFileSync } from 'node:fs' +import { resolve } from 'node:path' import { describe, it, expect } from 'vitest' import { resolveLucideIcon } from '../utils/resolveLucideIcon' import { ArrowLeftRight, BookHeart, + BookMarked, BookOpen, BookX, Flame, @@ -56,4 +59,16 @@ describe('resolveLucideIcon', () => { expect(resolveLucideIcon('orbit')).toBe(Orbit) expect(resolveLucideIcon('arrow-left-right')).toBe(ArrowLeftRight) }) + + it('resolves book-marked, which lucide ships only as an alias', () => { + expect(resolveLucideIcon('book-marked')).toBe(BookMarked) + }) + + it('resolves every icon the server seeds, so no achievement draws the fallback', () => { + const seed = readFileSync(resolve(process.cwd(), '../server/src/modules/achievement/seed/achievement-seed.ts'), 'utf8') + const names = [...new Set([...seed.matchAll(/iconName: '([^']+)'/g)].map((match) => match[1]!))] + + expect(names.length).toBeGreaterThan(0) + expect(names.filter((name) => resolveLucideIcon(name) === HelpCircle)).toEqual([]) + }) }) diff --git a/client/src/features/achievements/utils/resolveLucideIcon.ts b/client/src/features/achievements/utils/resolveLucideIcon.ts index bd56017b0..0d26ad202 100644 --- a/client/src/features/achievements/utils/resolveLucideIcon.ts +++ b/client/src/features/achievements/utils/resolveLucideIcon.ts @@ -4,6 +4,7 @@ import { ArrowUpDown, Award, BookHeart, + BookMarked, BookmarkCheck, BookOpen, BookX, @@ -64,6 +65,8 @@ const ICON_MAP: Record = { 'arrow-up-down': ArrowUpDown, award: Award, 'book-heart': BookHeart, + // Epic Voyager's seed name. Lucide ships it only as an alias of book-bookmark. + 'book-marked': BookMarked, 'bookmark-check': BookmarkCheck, 'book-open': BookOpen, 'book-x': BookX,