Skip to content

Commit af605c8

Browse files
authored
Merge branch 'main' into fix/codex-context-engine-projection-budget
2 parents dec5a37 + 0ed551e commit af605c8

3 files changed

Lines changed: 63 additions & 25 deletions

File tree

extensions/runway/video-generation-provider.test.ts

Lines changed: 49 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,41 @@ beforeAll(async () => {
1515

1616
installProviderHttpMockCleanup();
1717

18+
function firstPostJsonRequest() {
19+
const [call] = postJsonRequestMock.mock.calls;
20+
if (!call) {
21+
throw new Error("expected Runway create request");
22+
}
23+
const [request] = call;
24+
if (!request || typeof request !== "object") {
25+
throw new Error("expected Runway create request options");
26+
}
27+
return request as { url?: string; body?: Record<string, unknown> };
28+
}
29+
30+
function firstFetchWithTimeoutCall() {
31+
const [call] = fetchWithTimeoutMock.mock.calls;
32+
if (!call) {
33+
throw new Error("expected Runway poll request");
34+
}
35+
const [url, init, timeoutMs, requestFetch] = call;
36+
if (typeof url !== "string") {
37+
throw new Error("expected Runway poll request URL");
38+
}
39+
if (!init || typeof init !== "object" || Array.isArray(init)) {
40+
throw new Error("expected Runway poll request init");
41+
}
42+
if (typeof timeoutMs !== "number") {
43+
throw new Error("expected Runway poll request timeout");
44+
}
45+
return {
46+
init: init as { method?: string; headers?: unknown },
47+
requestFetch,
48+
timeoutMs,
49+
url,
50+
};
51+
}
52+
1853
describe("runway video generation provider", () => {
1954
it("declares explicit mode capabilities", () => {
2055
expectExplicitVideoGenerationCapabilities(buildRunwayVideoGenerationProvider());
@@ -54,23 +89,20 @@ describe("runway video generation provider", () => {
5489
});
5590

5691
expect(postJsonRequestMock).toHaveBeenCalledTimes(1);
57-
const createRequest = postJsonRequestMock.mock.calls[0]?.[0] as
58-
| { url?: string; body?: unknown }
59-
| undefined;
60-
expect(createRequest?.url).toBe("https://api.dev.runwayml.com/v1/text_to_video");
61-
expect(createRequest?.body).toEqual({
92+
const createRequest = firstPostJsonRequest();
93+
expect(createRequest.url).toBe("https://api.dev.runwayml.com/v1/text_to_video");
94+
expect(createRequest.body).toEqual({
6295
model: "gen4.5",
6396
promptText: "a tiny lobster DJ under neon lights",
6497
ratio: "1280:720",
6598
duration: 4,
6699
});
67-
const pollCall = fetchWithTimeoutMock.mock.calls[0];
68-
expect(pollCall?.[0]).toBe("https://api.dev.runwayml.com/v1/tasks/task-1");
69-
const pollInit = pollCall?.[1] as { method?: string; headers?: unknown } | undefined;
70-
expect(pollInit?.method).toBe("GET");
71-
expect(pollInit?.headers).toBeInstanceOf(Headers);
72-
expect(pollCall?.[2]).toBe(120000);
73-
expect(pollCall?.[3]).toBe(fetch);
100+
const pollCall = firstFetchWithTimeoutCall();
101+
expect(pollCall.url).toBe("https://api.dev.runwayml.com/v1/tasks/task-1");
102+
expect(pollCall.init.method).toBe("GET");
103+
expect(pollCall.init.headers).toBeInstanceOf(Headers);
104+
expect(pollCall.timeoutMs).toBe(120000);
105+
expect(pollCall.requestFetch).toBe(fetch);
74106
expect(result.videos).toHaveLength(1);
75107
const video = result.videos[0];
76108
if (!video) {
@@ -116,13 +148,11 @@ describe("runway video generation provider", () => {
116148
});
117149

118150
expect(postJsonRequestMock).toHaveBeenCalledTimes(1);
119-
const request = postJsonRequestMock.mock.calls[0]?.[0] as
120-
| { url?: string; body?: Record<string, unknown> }
121-
| undefined;
122-
expect(request?.url).toBe("https://api.dev.runwayml.com/v1/image_to_video");
123-
expect(request?.body?.promptImage).toMatch(/^data:image\/png;base64,/u);
124-
expect(request?.body?.ratio).toBe("960:960");
125-
expect(request?.body?.duration).toBe(6);
151+
const request = firstPostJsonRequest();
152+
expect(request.url).toBe("https://api.dev.runwayml.com/v1/image_to_video");
153+
expect(request.body?.promptImage).toMatch(/^data:image\/png;base64,/u);
154+
expect(request.body?.ratio).toBe("960:960");
155+
expect(request.body?.duration).toBe(6);
126156
});
127157

128158
it("requires gen4_aleph for video-to-video", async () => {

src/hooks/llm-slug-generator.test.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,15 @@ vi.mock("../agents/pi-embedded.js", () => ({
2323
import { generateSlugViaLLM } from "./llm-slug-generator.js";
2424

2525
function requireFirstRunOptions(): Record<string, unknown> {
26-
const options = runEmbeddedPiAgentMock.mock.calls[0]?.[0] as Record<string, unknown> | undefined;
27-
if (!options) {
26+
const [call] = runEmbeddedPiAgentMock.mock.calls;
27+
if (!call) {
28+
throw new Error("expected embedded Pi agent run");
29+
}
30+
const [options] = call;
31+
if (!options || typeof options !== "object") {
2832
throw new Error("expected embedded Pi agent run options");
2933
}
30-
return options;
34+
return options as Record<string, unknown>;
3135
}
3236

3337
describe("generateSlugViaLLM", () => {

src/tts/openai-compatible-speech-provider.test.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,15 @@ vi.mock("openclaw/plugin-sdk/provider-http", () => ({
2020
}));
2121

2222
function requireFirstMockArg(mock: ReturnType<typeof vi.fn>): Record<string, unknown> {
23-
const arg = mock.mock.calls[0]?.[0] as Record<string, unknown> | undefined;
24-
if (!arg) {
23+
const [call] = mock.mock.calls;
24+
if (!call) {
25+
throw new Error("missing first mock call");
26+
}
27+
const [arg] = call;
28+
if (!arg || typeof arg !== "object") {
2529
throw new Error("missing first mock argument");
2630
}
27-
return arg;
31+
return arg as Record<string, unknown>;
2832
}
2933

3034
describe("createOpenAiCompatibleSpeechProvider", () => {

0 commit comments

Comments
 (0)