Skip to content

Commit 50b030f

Browse files
committed
test: cover AetherAPI provider wiring
1 parent 387c212 commit 50b030f

2 files changed

Lines changed: 103 additions & 4 deletions

File tree

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
// npx vitest run src/api/providers/__tests__/aetherapi.spec.ts
2+
3+
import OpenAI from "openai"
4+
5+
import { type AetherapiModelId, type ProviderSettings, aetherapiDefaultModelId, aetherapiModels } from "@roo-code/types"
6+
7+
import { buildApiHandler } from "../../index"
8+
import { AetherapiHandler } from "../aetherapi"
9+
10+
const mockCreate = vi.fn()
11+
12+
vi.mock("openai", () => ({
13+
default: vi.fn(() => ({
14+
chat: {
15+
completions: {
16+
create: mockCreate,
17+
},
18+
},
19+
})),
20+
}))
21+
22+
describe("AetherapiHandler", () => {
23+
beforeEach(() => {
24+
vi.clearAllMocks()
25+
})
26+
27+
it("uses the default AetherAPI base URL", () => {
28+
new AetherapiHandler({ aetherapiApiKey: "test-aetherapi-api-key" })
29+
30+
expect(OpenAI).toHaveBeenCalledWith(
31+
expect.objectContaining({
32+
baseURL: "https://api.aetherapi.dev/v1",
33+
}),
34+
)
35+
})
36+
37+
it("uses a configured AetherAPI base URL", () => {
38+
new AetherapiHandler({
39+
aetherapiApiKey: "test-aetherapi-api-key",
40+
aetherapiBaseUrl: "https://gateway.example.test/v1",
41+
})
42+
43+
expect(OpenAI).toHaveBeenCalledWith(
44+
expect.objectContaining({
45+
baseURL: "https://gateway.example.test/v1",
46+
}),
47+
)
48+
})
49+
50+
it("uses the AetherAPI API key", () => {
51+
new AetherapiHandler({ aetherapiApiKey: "test-aetherapi-api-key" })
52+
53+
expect(OpenAI).toHaveBeenCalledWith(
54+
expect.objectContaining({
55+
apiKey: "test-aetherapi-api-key",
56+
}),
57+
)
58+
})
59+
60+
it("throws when the AetherAPI API key is missing", () => {
61+
expect(() => new AetherapiHandler({})).toThrow("API key is required")
62+
})
63+
64+
it("returns the default AetherAPI model when no model is specified", () => {
65+
const handler = new AetherapiHandler({ aetherapiApiKey: "test-aetherapi-api-key" })
66+
67+
expect(handler.getModel()).toEqual({
68+
id: aetherapiDefaultModelId,
69+
info: aetherapiModels[aetherapiDefaultModelId],
70+
})
71+
})
72+
73+
it("returns a configured AetherAPI model", () => {
74+
const modelId: AetherapiModelId = "gpt-5.4"
75+
const handler = new AetherapiHandler({
76+
apiModelId: modelId,
77+
aetherapiApiKey: "test-aetherapi-api-key",
78+
})
79+
80+
expect(handler.getModel()).toEqual({
81+
id: modelId,
82+
info: aetherapiModels[modelId],
83+
})
84+
})
85+
})
86+
87+
describe("buildApiHandler AetherAPI routing", () => {
88+
it("builds an AetherAPI handler for the aetherapi provider", () => {
89+
const handler = buildApiHandler({
90+
apiProvider: "aetherapi",
91+
aetherapiApiKey: "test-aetherapi-api-key",
92+
apiModelId: "gpt-5.4",
93+
} as ProviderSettings)
94+
95+
expect(handler).toBeInstanceOf(AetherapiHandler)
96+
expect(handler.getModel()).toEqual({
97+
id: "gpt-5.4",
98+
info: aetherapiModels["gpt-5.4"],
99+
})
100+
})
101+
})

webview-ui/src/components/settings/__tests__/ApiOptions.spec.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,8 @@ vi.mock("@vscode/webview-ui-toolkit/react", () => ({
2525
type={type ?? "text"}
2626
value={value}
2727
placeholder={placeholder}
28-
onChange={(event) => {
29-
onInput?.(event)
30-
onBlur?.(event)
31-
}}
28+
onChange={(event) => onInput?.(event)}
29+
onBlur={(event) => onBlur?.(event)}
3230
/>
3331
</div>
3432
),

0 commit comments

Comments
 (0)