mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-04 04:40:25 +00:00
test: dedupe media provider tests
This commit is contained in:
@@ -1,13 +1,24 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
loadBundledMusicGenerationProviders,
|
||||
loadBundledVideoGenerationProviders,
|
||||
} from "../../test/helpers/media-generation/bundled-provider-builders.js";
|
||||
import { listSupportedMusicGenerationModes } from "../music-generation/capabilities.js";
|
||||
import { BUNDLED_PLUGIN_CONTRACT_SNAPSHOTS } from "../plugins/contracts/inventory/bundled-capability-metadata.js";
|
||||
import { listSupportedVideoGenerationModes } from "../video-generation/capabilities.js";
|
||||
|
||||
function expectedBundledVideoProviderPluginIds(): string[] {
|
||||
const EXPECTED_BUNDLED_VIDEO_PROVIDER_PLUGIN_IDS = [
|
||||
"alibaba",
|
||||
"byteplus",
|
||||
"comfy",
|
||||
"fal",
|
||||
"google",
|
||||
"minimax",
|
||||
"openai",
|
||||
"qwen",
|
||||
"runway",
|
||||
"together",
|
||||
"vydra",
|
||||
"xai",
|
||||
] as const;
|
||||
|
||||
const EXPECTED_BUNDLED_MUSIC_PROVIDER_PLUGIN_IDS = ["comfy", "google", "minimax"] as const;
|
||||
|
||||
function bundledVideoProviderPluginIds(): string[] {
|
||||
return BUNDLED_PLUGIN_CONTRACT_SNAPSHOTS.filter(
|
||||
(entry) => entry.videoGenerationProviderIds.length > 0,
|
||||
)
|
||||
@@ -15,7 +26,7 @@ function expectedBundledVideoProviderPluginIds(): string[] {
|
||||
.toSorted((left, right) => left.localeCompare(right));
|
||||
}
|
||||
|
||||
function expectedBundledMusicProviderPluginIds(): string[] {
|
||||
function bundledMusicProviderPluginIds(): string[] {
|
||||
return BUNDLED_PLUGIN_CONTRACT_SNAPSHOTS.filter(
|
||||
(entry) => entry.musicGenerationProviderIds.length > 0,
|
||||
)
|
||||
@@ -24,76 +35,21 @@ function expectedBundledMusicProviderPluginIds(): string[] {
|
||||
}
|
||||
|
||||
describe("bundled media-generation provider capabilities", () => {
|
||||
it("declares explicit mode support for every bundled video-generation provider", async () => {
|
||||
const entries = await loadBundledVideoGenerationProviders();
|
||||
expect(entries.map((entry) => entry.pluginId).toSorted()).toEqual(
|
||||
expectedBundledVideoProviderPluginIds(),
|
||||
);
|
||||
|
||||
for (const entry of entries) {
|
||||
const { provider } = entry;
|
||||
expect(
|
||||
provider.capabilities.generate,
|
||||
`${provider.id} missing generate capabilities`,
|
||||
).toBeDefined();
|
||||
expect(
|
||||
provider.capabilities.imageToVideo,
|
||||
`${provider.id} missing imageToVideo capabilities`,
|
||||
).toBeDefined();
|
||||
expect(
|
||||
provider.capabilities.videoToVideo,
|
||||
`${provider.id} missing videoToVideo capabilities`,
|
||||
).toBeDefined();
|
||||
|
||||
const supportedModes = listSupportedVideoGenerationModes(provider);
|
||||
const imageToVideo = provider.capabilities.imageToVideo;
|
||||
const videoToVideo = provider.capabilities.videoToVideo;
|
||||
|
||||
if (imageToVideo?.enabled) {
|
||||
expect(
|
||||
imageToVideo.maxInputImages ?? 0,
|
||||
`${provider.id} imageToVideo.enabled requires maxInputImages`,
|
||||
).toBeGreaterThan(0);
|
||||
expect(supportedModes).toContain("imageToVideo");
|
||||
}
|
||||
if (videoToVideo?.enabled) {
|
||||
expect(
|
||||
videoToVideo.maxInputVideos ?? 0,
|
||||
`${provider.id} videoToVideo.enabled requires maxInputVideos`,
|
||||
).toBeGreaterThan(0);
|
||||
expect(supportedModes).toContain("videoToVideo");
|
||||
}
|
||||
it("tracks every bundled video-generation provider manifest", () => {
|
||||
expect(bundledVideoProviderPluginIds()).toEqual(EXPECTED_BUNDLED_VIDEO_PROVIDER_PLUGIN_IDS);
|
||||
for (const entry of BUNDLED_PLUGIN_CONTRACT_SNAPSHOTS.filter(
|
||||
(snapshot) => snapshot.videoGenerationProviderIds.length > 0,
|
||||
)) {
|
||||
expect(entry.videoGenerationProviderIds, entry.pluginId).toEqual([entry.pluginId]);
|
||||
}
|
||||
});
|
||||
|
||||
it("declares explicit generate/edit support for every bundled music-generation provider", async () => {
|
||||
const entries = await loadBundledMusicGenerationProviders();
|
||||
expect(entries.map((entry) => entry.pluginId).toSorted()).toEqual(
|
||||
expectedBundledMusicProviderPluginIds(),
|
||||
);
|
||||
|
||||
for (const entry of entries) {
|
||||
const { provider } = entry;
|
||||
expect(
|
||||
provider.capabilities.generate,
|
||||
`${provider.id} missing generate capabilities`,
|
||||
).toBeDefined();
|
||||
expect(provider.capabilities.edit, `${provider.id} missing edit capabilities`).toBeDefined();
|
||||
|
||||
const edit = provider.capabilities.edit;
|
||||
if (!edit) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (edit.enabled) {
|
||||
expect(
|
||||
edit.maxInputImages ?? 0,
|
||||
`${provider.id} edit.enabled requires maxInputImages`,
|
||||
).toBeGreaterThan(0);
|
||||
expect(listSupportedMusicGenerationModes(provider)).toContain("edit");
|
||||
} else {
|
||||
expect(listSupportedMusicGenerationModes(provider)).toEqual(["generate"]);
|
||||
}
|
||||
it("tracks every bundled music-generation provider manifest", () => {
|
||||
expect(bundledMusicProviderPluginIds()).toEqual(EXPECTED_BUNDLED_MUSIC_PROVIDER_PLUGIN_IDS);
|
||||
for (const entry of BUNDLED_PLUGIN_CONTRACT_SNAPSHOTS.filter(
|
||||
(snapshot) => snapshot.musicGenerationProviderIds.length > 0,
|
||||
)) {
|
||||
expect(entry.musicGenerationProviderIds, entry.pluginId).toEqual([entry.pluginId]);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user