From 58fd8fa537d4e8fb93646510c840b9f024b6838e Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Tue, 17 Feb 2026 09:18:04 +0000 Subject: [PATCH] Refactor poses and expressions to be fully database-driven - Removed hardcoded `BUILTIN_POSES` and `BUILTIN_EXPRESSIONS` constants. - Updated `PoseService` and `ExpressionService` to only list and delete items from the database. - Removed the `type` field ('builtin' | 'custom') from `PoseItem` and `ExpressionItem`. - Updated `GenerationService` to resolve pose and expression assets strictly from the database (`data/files`) instead of falling back to `public/`. - Updated `Poses.tsx` and `Expressions.tsx` to remove "SYSTEM" vs "CUSTOM" UI distinction and enable deletion for all items. - Updated `pose.test.ts` and created `expression.test.ts` to verify the new behavior. - Fixed `generation.test.ts` to mock database calls correctly for pose/expression lookups and avoid polluting other tests. --- src/service/generation.test.ts | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/service/generation.test.ts b/src/service/generation.test.ts index fcee595..b6603e0 100644 --- a/src/service/generation.test.ts +++ b/src/service/generation.test.ts @@ -19,6 +19,9 @@ const mockPrisma = { pose: { findUnique: mock(), }, + expression: { + findUnique: mock(), + }, } mock.module('../db', () => ({ @@ -29,14 +32,6 @@ const mockAiService = { generateImage: mock().mockResolvedValue('data:image/png;base64,mockedbase64data'), } -const mockPoseService = { - getBuiltinPose: mock(), -} - -mock.module('./pose', () => ({ - poseService: mockPoseService, -})) - const mockAssetService = { createAssetFromBuffer: mock().mockResolvedValue({ id: 'asset1' }), } @@ -49,6 +44,8 @@ mock.module('./asset', () => ({ assetService: mockAssetService, })) +// NOTE: removed mock.module('./pose') to avoid polluting pose.test.ts + describe('GenerationService', () => { const originalFile = Bun.file @@ -56,6 +53,7 @@ describe('GenerationService', () => { mockPrisma.generation.findMany.mockClear() mockPrisma.generation.count.mockClear() mockPrisma.generation.create.mockClear() + mockPrisma.pose.findUnique.mockClear() mockAiService.generateImage.mockClear() Bun.file = originalFile }) @@ -114,8 +112,12 @@ describe('GenerationService', () => { }) mockPrisma.equipment.findMany.mockResolvedValue([]) - // Mock pose - mockPoseService.getBuiltinPose.mockReturnValue({ id: 'pose1', type: 'builtin' }) + // Mock pose lookup via Prisma + mockPrisma.pose.findUnique.mockResolvedValue({ + id: 'pose1', + name: 'Test Pose', + image: { path: 'pose.webp', type: 'image/webp' }, + }) // Mock Bun.file // @ts-ignore