Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"test:integration": "vitest run --include 'tests/integration/**/*.test.ts'",
"test:stress": "vitest run --config tests/vitest.config.ts",
"test:real": "vitest run --config tests/real/vitest.config.ts",
"test:local-chat": "vitest run tests/local-chat/chat-completions.test.ts",
"dev": "tsx watch src/index.ts",
"dev:web": "cd web && npx vite",
"build:web": "cd web && npx vite build",
Expand Down
105 changes: 105 additions & 0 deletions tests/local-chat/chat-completions.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
import { describe, it, expect } from "vitest";
import { execFile } from "node:child_process";
import { promisify } from "node:util";

const execFileAsync = promisify(execFile);
const baseUrl = "http://localhost:8080/v1/chat/completions";
const apiKey = "sk-ssujojoqwer1234aaaa";

async function runCurl(payload: Record<string, unknown>) {
const { stdout } = await execFileAsync(
"curl",
[
"-sS",
"-w",
"\n%{http_code}",
baseUrl,
"-H",
"Content-Type: application/json",
"-H",
`Authorization: Bearer ${apiKey}`,
"-d",
JSON.stringify(payload),
],
{ timeout: 30000 }
);

const lines = stdout.split("\n");
const statusLine = lines.pop() ?? "";
const body = lines.join("\n");
const status = Number(statusLine.trim());

return { status, body };
}

describe("local chat completions (curl)", () => {
it("gpt-5.4 returns OK", async () => {
const { status, body } = await runCurl({
model: "gpt-5.4",
messages: [{ role: "user", content: "Directly reply OK." }],
});

expect(status).toBe(200);
expect(body).toContain("OK");
});

it("gpt-5.4-mini returns OK", async () => {
const { status, body } = await runCurl({
model: "gpt-5.4-mini",
messages: [{ role: "user", content: "Directly reply OK." }],
});

expect(status).toBe(200);
expect(body).toContain("OK");
});

it("gpt-5.4-mini-fast returns OK", async () => {
const { status, body } = await runCurl({
model: "gpt-5.4-mini-fast",
messages: [{ role: "user", content: "Directly reply OK." }],
});

expect(status).toBe(200);
expect(body).toContain("OK");
});

it("gpt-5.4-xhigh-fast returns OK", async () => {
const { status, body } = await runCurl({
model: "gpt-5.4-xhigh-fast",
messages: [{ role: "user", content: "Directly reply OK." }],
});

expect(status).toBe(200);
expect(body).toContain("OK");
});

it("gpt-5.4-xhigh returns OK", async () => {
const { status, body } = await runCurl({
model: "gpt-5.4-xhigh",
messages: [{ role: "user", content: "Directly reply OK." }],
});

expect(status).toBe(200);
expect(body).toContain("OK");
});

it("openrouter/free returns OK", async () => {
const { status, body } = await runCurl({
model: "openrouter/free",
messages: [{ role: "user", content: "Directly reply OK." }],
});

expect(status).toBe(200);
expect(body).toContain("OK");
});

it("minimaxai/minimax-m2.7 returns OK", async () => {
const { status, body } = await runCurl({
model: "minimaxai/minimax-m2.7",
messages: [{ role: "user", content: "Directly reply OK." }],
});

expect(status).toBe(200);
expect(body).toContain("OK");
});
});
1 change: 1 addition & 0 deletions vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export default defineConfig({
"tests/unit/**/*.{test,spec}.ts",
"tests/integration/**/*.{test,spec}.ts",
"tests/e2e/**/*.{test,spec}.ts",
"tests/local-chat/**/*.{test,spec}.ts",
"packages/electron/__tests__/**/*.{test,spec}.ts",
],
},
Expand Down
Loading