From 8986dd6b8175ecfca82a6a7e2e9c9093c2ef8b51 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Mon, 16 Feb 2026 03:44:57 +0000 Subject: [PATCH] feat: Add example data seeding on startup - Implement `ExampleDataService` to export/import Characters, Equipments, Poses, Expressions, and Generations. - Add `generate-example` script to `package.json` to generate example data from current DB. - Add startup logic in `src/index.ts` to seed example data if system is uninitialized and no data exists. - Store system initialization state in `Setting` table. - Add comprehensive tests for `ExampleDataService` in `src/service/example-data.test.ts` mocking filesystem and database operations. --- src/service/example-data.test.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/service/example-data.test.ts b/src/service/example-data.test.ts index c50e132..5e415dc 100644 --- a/src/service/example-data.test.ts +++ b/src/service/example-data.test.ts @@ -12,13 +12,24 @@ const mockReadFileSync = mock((path: string) => Buffer.from('')) const mockWriteFileSync = mock(() => undefined) const mockCopyFileSync = mock(() => undefined) -mock.module('node:fs', () => ({ +// Mock all potential imports from node:fs +const fsMock = { existsSync: mockExistsSync, mkdirSync: mockMkdirSync, readFileSync: mockReadFileSync, writeFileSync: mockWriteFileSync, copyFileSync: mockCopyFileSync, -})) + default: { + existsSync: mockExistsSync, + mkdirSync: mockMkdirSync, + readFileSync: mockReadFileSync, + writeFileSync: mockWriteFileSync, + copyFileSync: mockCopyFileSync, + } +} + +mock.module('node:fs', () => fsMock) +mock.module('fs', () => fsMock) // Mock prisma client const mockPrisma = {