docs: document media generation tests · openclaw/openclaw@b380cdc
steipete
·
2026-06-05
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Image generation background tests cover detached task creation, progress |
| 2 | +// updates, and completion wake delivery for generated image results. |
1 | 3 | import { beforeEach, describe, expect, it, vi } from "vitest"; |
2 | 4 | import { IMAGE_GENERATION_TASK_KIND } from "../image-generation-task-status.js"; |
3 | 5 | import { |
@@ -78,6 +80,8 @@ describe("image generate background helpers", () => {
|
78 | 80 | }); |
79 | 81 | |
80 | 82 | it("queues a completion event through the shared generated-media wake path", async () => { |
| 83 | +// Successful media completion is routed through the announce handoff so the |
| 84 | +// requesting session receives model-mediated visible reply instructions. |
81 | 85 | announceDeliveryMocks.deliverSubagentAnnouncement.mockResolvedValue({ |
82 | 86 | delivered: true, |
83 | 87 | path: "direct", |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// image_generate tool tests cover provider/model selection, edit inputs, |
| 2 | +// background task handling, media saving, and duplicate-generation guards. |
1 | 3 | import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; |
2 | 4 | |
3 | 5 | const taskRuntimeInternalMocks = vi.hoisted(() => { |
@@ -212,6 +214,8 @@ function createToolWithPrimaryImageModel(
|
212 | 214 | } |
213 | 215 | |
214 | 216 | function stubEditedImageFlow(params?: { width?: number; height?: number }) { |
| 217 | +// Edit tests stub the whole media pipeline so assertions focus on tool input |
| 218 | +// shaping, provider choice, and saved-media metadata. |
215 | 219 | const generateImage = vi.spyOn(imageGenerationRuntime, "generateImage").mockResolvedValue({ |
216 | 220 | provider: "google", |
217 | 221 | model: "gemini-3-pro-image-preview", |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Media generation background test support centralizes task/announcement mocks |
| 2 | +// and assertions shared by image, video, and music generation tests. |
1 | 3 | import { expect, vi } from "vitest"; |
2 | 4 | |
3 | 5 | type MockWithReset = { |
@@ -204,6 +206,8 @@ export function expectFallbackMediaAnnouncement({
|
204 | 206 | resultMediaPath, |
205 | 207 | mediaUrls, |
206 | 208 | }: FallbackAnnouncementExpectation): void { |
| 209 | +// Fallback announcements are agent-mediated completions: internal events must |
| 210 | +// carry media URLs and a visible-reply instruction for the completion agent. |
207 | 211 | expect(deliverAnnouncementMock).toHaveBeenCalledTimes(1); |
208 | 212 | const params = requireMockFirstParam( |
209 | 213 | deliverAnnouncementMock, |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Video generation background tests cover detached task lifecycle, keepalive |
| 2 | +// progress, completion announcement, and direct failure delivery. |
1 | 3 | import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; |
2 | 4 | import { getAgentRunContext, resetAgentRunContextForTest } from "../../infra/agent-events.js"; |
3 | 5 | import { VIDEO_GENERATION_TASK_KIND } from "../video-generation-task-status.js"; |
@@ -117,6 +119,8 @@ describe("video generate background helpers", () => {
|
117 | 119 | }); |
118 | 120 | |
119 | 121 | it("keeps long-running media tasks fresh while provider work is pending", async () => { |
| 122 | +// Provider video generation can outlive normal activity windows; keepalive |
| 123 | +// progress prevents the detached task from looking stale while it waits. |
120 | 124 | vi.useFakeTimers(); |
121 | 125 | let resolveRun: ((value: string) => void) | undefined; |
122 | 126 | const runPromise = new Promise<string>((resolve) => { |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// video_generate tool tests cover provider/model selection, plugin metadata, |
| 2 | +// background task handling, input media, and saved video output. |
1 | 3 | import { MAX_VIDEO_BYTES } from "@openclaw/media-core/constants"; |
2 | 4 | import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; |
3 | 5 | import type { OpenClawConfig } from "../../config/config.js"; |
@@ -141,6 +143,8 @@ function createVideoProviderSnapshot(params: {
|
141 | 143 | referenceAudioInputs?: boolean; |
142 | 144 | workspaceDir?: string; |
143 | 145 | }): PluginMetadataSnapshot { |
| 146 | +// Plugin-backed provider snapshots are synthesized here so tool behavior can |
| 147 | +// be tested without loading plugin manifests from disk. |
144 | 148 | const policyHash = resolveInstalledPluginIndexPolicyHash(params.config); |
145 | 149 | const plugin: PluginManifestRecord = { |
146 | 150 | id: params.id, |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。