evOo-local/packages/adapters/src/media/comfyui-settings.test.ts
Claude 9b4b9c8465
fix(media): GPU guard for smaller cards, top-level type imports
- The GPU guard waited for free VRAM at the operation's floor even on a card
  whose total memory is below it (an 8 GB card and a 12 GB video floor), so
  such jobs deferred until their budget ran out. The requirement is now capped
  at 90% of the card's total; a card with less than half the floor fails at
  once with "The GPU does not have enough memory for this job."
- Tests pin that media tools reach a run only through the space's
  capabilities and within the bot's allowlist now that the image tool
  definitions exist.
- Type-only imports are top-level `import type` in the media runtime, tools,
  RPCs and tests (AGENTS.md).
- The ComfyUI settings test gives saveMediaSettings a store with nothing saved,
  since the save reads the previous settings before validating.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MRtGG9ARfqqhma3t85Ro2u
2026-10-03 14:01:14 +00:00

32 lines
1.1 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { saveMediaSettings } from "../media-settings.js";
const comfyui = (workflows: { imageWorkflow?: string; videoWorkflow?: string }) => ({
comfyui: { baseUrl: "http://127.0.0.1:8188", ...workflows },
transcription: null,
});
describe("ComfyUI settings", () => {
it("refuses custom workflows the provider could not fill", async () => {
// Nothing saved yet; validation fails before anything is stored.
const deps = {
prisma: { integrationProviderConfig: { findUnique: async () => null } },
} as unknown as Parameters<typeof saveMediaSettings>[0];
await expect(
saveMediaSettings(
deps,
comfyui({ imageWorkflow: '{"1": {"class_type": "X", "inputs": {}}}' }),
),
).rejects.toThrow("Image workflow: Workflow needs a {{prompt}} placeholder");
await expect(
saveMediaSettings(
deps,
comfyui({
videoWorkflow:
'{"1": {"class_type": "X", "inputs": {"t": "{{prompt}}", "c": "{{cfg}}"}}}',
}),
),
).rejects.toThrow("Video workflow: Unknown workflow placeholders: {{cfg}}");
});
});