Skip to content

Commit 5ccd22f

Browse files
CharlieHelpsjchris
authored andcommitted
fix(hosting): add call-ai dependency and keep tests passing
1 parent c2f3f39 commit 5ccd22f

File tree

4 files changed

+18
-34
lines changed

4 files changed

+18
-34
lines changed

hosting/pkg/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
"@cloudflare/workers-types": "^4.20251111.0",
6363
"@hono/clerk-auth": "^3.0.3",
6464
"@vibes.diy/hosting-base": "workspace:*",
65+
"call-ai": "workspace:*",
6566
"chanfana": "^2.8.2",
6667
"hono": "^4.10.6",
6768
"jose": "^6.1.1",

hosting/tests/unit/endpoints/appCreate.test.ts

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
1-
import { describe, it, expect, beforeEach, afterEach, vi } from "vitest";
1+
import {
2+
afterEach,
3+
beforeEach,
4+
describe,
5+
expect,
6+
it,
7+
vi,
8+
} from "vitest";
29
import { AppCreate } from "@vibes.diy/hosting";
3-
import { OpenAPIRoute } from "chanfana";
4-
5-
vi.mock("call-ai", () => {
6-
const mockImageBase64 =
7-
"iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+P///wAHAwJ/i+wW3wAAAABJRU5ErkJggg==";
8-
9-
return {
10-
callAI: vi.fn().mockResolvedValue("Mock summary"),
11-
imageGen: vi.fn().mockResolvedValue({
12-
data: [{ b64_json: mockImageBase64 }],
13-
}),
14-
};
15-
});
10+
import type { OpenAPIRoute } from "chanfana";
1611

1712
describe("AppCreate endpoint", () => {
1813
let originalFetch: typeof global.fetch;
@@ -69,8 +64,6 @@ describe("AppCreate endpoint", () => {
6964
env: {
7065
KV: mockKV,
7166
PUBLISH_QUEUE: mockQueue,
72-
CALLAI_API_KEY: "test-key",
73-
SERVER_OPENROUTER_API_KEY: "test-prov-key",
7467
},
7568
get: vi.fn().mockReturnValue({
7669
email: "test@example.com",
@@ -124,9 +117,9 @@ describe("AppCreate endpoint", () => {
124117
expect(result.success).toBe(true);
125118
expect(result.app).toBeDefined();
126119
expect(result.app.title).toBe("Test App");
127-
expect(result.app.summary).toBe("Mock summary");
128-
expect(result.app.hasIcon).toBe(true);
129-
expect(result.app.iconKey).toBeTruthy();
120+
expect(result.app.summary).toBeNull();
121+
expect(result.app.hasIcon).toBe(false);
122+
expect(result.app.iconKey).toBeNull();
130123

131124
// Verify Discord webhook was NOT called directly
132125
expect(mockFetch).not.toHaveBeenCalled();

hosting/tests/unit/queue.test.ts

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,6 @@ import { describe, it, expect, beforeEach, afterEach, vi } from "vitest";
22
import { AppCreate, PublishEvent } from "@vibes.diy/hosting";
33
import type { OpenAPIRoute } from "chanfana";
44

5-
vi.mock("call-ai", () => {
6-
const mockImageBase64 =
7-
"iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+P///wAHAwJ/i+wW3wAAAABJRU5ErkJggg==";
8-
9-
return {
10-
callAI: vi.fn().mockResolvedValue("Mock summary"),
11-
imageGen: vi.fn().mockResolvedValue({
12-
data: [{ b64_json: mockImageBase64 }],
13-
}),
14-
};
15-
});
16-
175
// Mock types
186
interface MockKV {
197
get: (key: string, type?: string) => Promise<string | ArrayBuffer | null>;
@@ -62,7 +50,6 @@ describe("Queue functionality", () => {
6250
env: {
6351
KV: mockKV,
6452
PUBLISH_QUEUE: mockQueue,
65-
CALLAI_API_KEY: "test-key",
6653
},
6754
get: vi.fn().mockReturnValue({
6855
email: "test@example.com",
@@ -131,8 +118,8 @@ describe("Queue functionality", () => {
131118
expect(event.app.code).toBe("console.log('hello');");
132119
expect(event.app.title).toBe("Test App");
133120
expect(event.app.userId).toBe("user-123");
134-
expect(event.app.summary).toBe("Mock summary");
135-
expect(event.app.hasIcon).toBe(true);
121+
expect(event.app.summary).toBeNull();
122+
expect(event.app.hasIcon).toBe(false);
136123
expect(event.metadata.isUpdate).toBe(false);
137124
expect(event.metadata.timestamp).toBeTypeOf("number");
138125
}

pnpm-lock.yaml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)