|
|
|
@ -1,6 +1,12 @@ |
|
|
|
import { describe, expect, it, beforeEach } from "vitest"; |
|
|
|
import { useGenerationPreferenceStore, createInitialGenerationPreferences } from "@/store/generationPreferenceStore"; |
|
|
|
import { buildDefaultGenerationNodeCreation, buildDefaultGenerationNodeData } from "@/utils/defaultGenerationNodeModel"; |
|
|
|
import { |
|
|
|
DEFAULT_IMAGE_GENERATION_ASPECT_RATIO, |
|
|
|
DEFAULT_IMAGE_GENERATION_MODEL_ID, |
|
|
|
DEFAULT_VIDEO_GENERATION_ASPECT_RATIO, |
|
|
|
DEFAULT_VIDEO_GENERATION_MODEL_ID, |
|
|
|
} from "@/constants/generationPreferenceDefaults"; |
|
|
|
import type { SelectedModel } from "@/types"; |
|
|
|
|
|
|
|
const selectedModel: SelectedModel = { |
|
|
|
@ -18,6 +24,15 @@ describe("generationPreferenceStore", () => { |
|
|
|
useGenerationPreferenceStore.setState(createInitialGenerationPreferences()); |
|
|
|
}); |
|
|
|
|
|
|
|
it("initializes image and video preferences from default generation config", async () => { |
|
|
|
const { image, video } = useGenerationPreferenceStore.getState(); |
|
|
|
expect(image.model.modelId).toBe(DEFAULT_IMAGE_GENERATION_MODEL_ID); |
|
|
|
expect(image.aspectRatio).toBe(DEFAULT_IMAGE_GENERATION_ASPECT_RATIO); |
|
|
|
expect(image.parameters).toEqual({ ratio: DEFAULT_IMAGE_GENERATION_ASPECT_RATIO }); |
|
|
|
expect(video.model.modelId).toBe(DEFAULT_VIDEO_GENERATION_MODEL_ID); |
|
|
|
expect(video.parameters).toEqual({ ratio: DEFAULT_VIDEO_GENERATION_ASPECT_RATIO }); |
|
|
|
}); |
|
|
|
|
|
|
|
it("keeps only model configuration fields when remembering image preferences", async () => { |
|
|
|
useGenerationPreferenceStore.getState().updateImagePreference({ |
|
|
|
selectedModel, |
|
|
|
@ -83,7 +98,7 @@ describe("generationPreferenceStore", () => { |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
it("does not use remembered node size when creating generation nodes without ratio", async () => { |
|
|
|
it("uses configured video ratio when creating generation nodes from default preferences", async () => { |
|
|
|
useGenerationPreferenceStore.getState().updateVideoPreference({ |
|
|
|
selectedModel: { |
|
|
|
provider: "popiserver", |
|
|
|
@ -91,12 +106,12 @@ describe("generationPreferenceStore", () => { |
|
|
|
displayName: "Video Model", |
|
|
|
capabilities: ["text-to-video"], |
|
|
|
}, |
|
|
|
parameters: { duration: 5 }, |
|
|
|
parameters: { ratio: DEFAULT_VIDEO_GENERATION_ASPECT_RATIO }, |
|
|
|
}); |
|
|
|
|
|
|
|
await expect(buildDefaultGenerationNodeCreation("generateVideo")).resolves.toEqual({ |
|
|
|
data: expect.any(Object), |
|
|
|
size: undefined, |
|
|
|
size: { width: 360, height: 203 }, |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|