Skip to content

Commit a01c4c3

Browse files
committed
test: split provider-shaped core test coverage
1 parent 3181112 commit a01c4c3

7 files changed

Lines changed: 559 additions & 506 deletions

src/commands/doctor-config-flow.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2020,6 +2020,7 @@ describe("doctor config flow", () => {
20202020

20212021
it("does not report repeat talk provider normalization on consecutive repair runs", async () => {
20222022
await withTempHome(async (home) => {
2023+
const providerId = "acme-speech";
20232024
const configDir = path.join(home, ".openclaw");
20242025
await fs.mkdir(configDir, { recursive: true });
20252026
await fs.writeFile(
@@ -2029,9 +2030,9 @@ describe("doctor config flow", () => {
20292030
talk: {
20302031
interruptOnSpeech: true,
20312032
silenceTimeoutMs: 1500,
2032-
provider: "elevenlabs",
2033+
provider: providerId,
20332034
providers: {
2034-
elevenlabs: {
2035+
[providerId]: {
20352036
apiKey: "secret-key",
20362037
voiceId: "voice-123",
20372038
modelId: "eleven_v3",
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
import { describe, expect, it } from "vitest";
2+
import { migrateLegacyConfig } from "./legacy-config-migrate.js";
3+
4+
describe("legacy migrate provider-shaped config", () => {
5+
it("moves messages.tts.<provider> keys into messages.tts.providers", () => {
6+
const res = migrateLegacyConfig({
7+
messages: {
8+
tts: {
9+
provider: "elevenlabs",
10+
elevenlabs: {
11+
apiKey: "test-key",
12+
voiceId: "voice-1",
13+
},
14+
},
15+
},
16+
});
17+
18+
expect(res.changes).toContain(
19+
"Moved messages.tts.elevenlabs → messages.tts.providers.elevenlabs.",
20+
);
21+
expect(res.config?.messages?.tts).toEqual({
22+
provider: "elevenlabs",
23+
providers: {
24+
elevenlabs: {
25+
apiKey: "test-key",
26+
voiceId: "voice-1",
27+
},
28+
},
29+
});
30+
});
31+
32+
it("moves channels.discord.accounts.<id>.voice.tts.edge into providers.microsoft", () => {
33+
const res = migrateLegacyConfig({
34+
channels: {
35+
discord: {
36+
accounts: {
37+
main: {
38+
voice: {
39+
tts: {
40+
edge: {
41+
voice: "en-US-JennyNeural",
42+
},
43+
},
44+
},
45+
},
46+
},
47+
},
48+
},
49+
});
50+
51+
expect(res.changes).toContain(
52+
"Moved channels.discord.accounts.main.voice.tts.edge → channels.discord.accounts.main.voice.tts.providers.microsoft.",
53+
);
54+
const mainTts = (
55+
res.config?.channels?.discord?.accounts as
56+
| Record<string, { voice?: { tts?: Record<string, unknown> } }>
57+
| undefined
58+
)?.main?.voice?.tts;
59+
expect(mainTts?.providers).toEqual({
60+
microsoft: {
61+
voice: "en-US-JennyNeural",
62+
},
63+
});
64+
expect(mainTts?.edge).toBeUndefined();
65+
});
66+
67+
it("moves plugins.entries.voice-call.config.tts.<provider> keys into providers", () => {
68+
const res = migrateLegacyConfig({
69+
plugins: {
70+
entries: {
71+
"voice-call": {
72+
config: {
73+
tts: {
74+
provider: "openai",
75+
openai: {
76+
model: "gpt-4o-mini-tts",
77+
voice: "alloy",
78+
},
79+
},
80+
},
81+
},
82+
},
83+
},
84+
});
85+
86+
expect(res.changes).toContain(
87+
"Moved plugins.entries.voice-call.config.tts.openai → plugins.entries.voice-call.config.tts.providers.openai.",
88+
);
89+
const voiceCallTts = (
90+
res.config?.plugins?.entries as
91+
| Record<string, { config?: { tts?: Record<string, unknown> } }>
92+
| undefined
93+
)?.["voice-call"]?.config?.tts;
94+
expect(voiceCallTts).toEqual({
95+
provider: "openai",
96+
providers: {
97+
openai: {
98+
model: "gpt-4o-mini-tts",
99+
voice: "alloy",
100+
},
101+
},
102+
});
103+
});
104+
105+
it("does not migrate legacy tts provider keys for unknown plugin ids", () => {
106+
const res = migrateLegacyConfig({
107+
plugins: {
108+
entries: {
109+
"third-party-plugin": {
110+
config: {
111+
tts: {
112+
provider: "openai",
113+
openai: {
114+
model: "custom-tts",
115+
},
116+
},
117+
},
118+
},
119+
},
120+
},
121+
});
122+
123+
expect(res.changes).toEqual([]);
124+
expect(res.config).toBeNull();
125+
});
126+
127+
it("does not migrate extension-owned talk legacy fields during config-load migration", () => {
128+
const res = migrateLegacyConfig({
129+
talk: {
130+
voiceId: "voice-1",
131+
modelId: "eleven_v3",
132+
outputFormat: "pcm_44100",
133+
apiKey: "test-key",
134+
},
135+
});
136+
137+
expect(res.config).toBeNull();
138+
expect(res.changes).toEqual([]);
139+
});
140+
});

src/commands/doctor/shared/legacy-config-migrate.test.ts

Lines changed: 0 additions & 140 deletions
Original file line numberDiff line numberDiff line change
@@ -156,146 +156,6 @@ describe("legacy migrate mention routing", () => {
156156
});
157157
});
158158

159-
describe("legacy migrate tts provider shape", () => {
160-
it("moves messages.tts.<provider> keys into messages.tts.providers", () => {
161-
const res = migrateLegacyConfig({
162-
messages: {
163-
tts: {
164-
provider: "elevenlabs",
165-
elevenlabs: {
166-
apiKey: "test-key",
167-
voiceId: "voice-1",
168-
},
169-
},
170-
},
171-
});
172-
173-
expect(res.changes).toContain(
174-
"Moved messages.tts.elevenlabs → messages.tts.providers.elevenlabs.",
175-
);
176-
expect(res.config?.messages?.tts).toEqual({
177-
provider: "elevenlabs",
178-
providers: {
179-
elevenlabs: {
180-
apiKey: "test-key",
181-
voiceId: "voice-1",
182-
},
183-
},
184-
});
185-
});
186-
187-
it("moves channels.discord.accounts.<id>.voice.tts.edge into providers.microsoft", () => {
188-
const res = migrateLegacyConfig({
189-
channels: {
190-
discord: {
191-
accounts: {
192-
main: {
193-
voice: {
194-
tts: {
195-
edge: {
196-
voice: "en-US-JennyNeural",
197-
},
198-
},
199-
},
200-
},
201-
},
202-
},
203-
},
204-
});
205-
206-
expect(res.changes).toContain(
207-
"Moved channels.discord.accounts.main.voice.tts.edge → channels.discord.accounts.main.voice.tts.providers.microsoft.",
208-
);
209-
const mainTts = (
210-
res.config?.channels?.discord?.accounts as
211-
| Record<string, { voice?: { tts?: Record<string, unknown> } }>
212-
| undefined
213-
)?.main?.voice?.tts;
214-
expect(mainTts?.providers).toEqual({
215-
microsoft: {
216-
voice: "en-US-JennyNeural",
217-
},
218-
});
219-
expect(mainTts?.edge).toBeUndefined();
220-
});
221-
222-
it("moves plugins.entries.voice-call.config.tts.<provider> keys into providers", () => {
223-
const res = migrateLegacyConfig({
224-
plugins: {
225-
entries: {
226-
"voice-call": {
227-
config: {
228-
tts: {
229-
provider: "openai",
230-
openai: {
231-
model: "gpt-4o-mini-tts",
232-
voice: "alloy",
233-
},
234-
},
235-
},
236-
},
237-
},
238-
},
239-
});
240-
241-
expect(res.changes).toContain(
242-
"Moved plugins.entries.voice-call.config.tts.openai → plugins.entries.voice-call.config.tts.providers.openai.",
243-
);
244-
const voiceCallTts = (
245-
res.config?.plugins?.entries as
246-
| Record<string, { config?: { tts?: Record<string, unknown> } }>
247-
| undefined
248-
)?.["voice-call"]?.config?.tts;
249-
expect(voiceCallTts).toEqual({
250-
provider: "openai",
251-
providers: {
252-
openai: {
253-
model: "gpt-4o-mini-tts",
254-
voice: "alloy",
255-
},
256-
},
257-
});
258-
});
259-
260-
it("does not migrate legacy tts provider keys for unknown plugin ids", () => {
261-
const res = migrateLegacyConfig({
262-
plugins: {
263-
entries: {
264-
"third-party-plugin": {
265-
config: {
266-
tts: {
267-
provider: "openai",
268-
openai: {
269-
model: "custom-tts",
270-
},
271-
},
272-
},
273-
},
274-
},
275-
},
276-
});
277-
278-
expect(res.changes).toEqual([]);
279-
expect(res.config).toBeNull();
280-
});
281-
});
282-
283-
describe("legacy migrate talk provider shape", () => {
284-
it("does not migrate extension-owned talk legacy fields during config-load migration", () => {
285-
const res = migrateLegacyConfig({
286-
talk: {
287-
voiceId: "voice-1",
288-
modelId: "eleven_v3",
289-
outputFormat: "pcm_44100",
290-
apiKey: "test-key",
291-
},
292-
});
293-
294-
expect(res.config).toBeNull();
295-
expect(res.changes).toEqual([]);
296-
});
297-
});
298-
299159
describe("legacy migrate sandbox scope aliases", () => {
300160
it("moves agents.defaults.sandbox.perSession into scope", () => {
301161
const res = migrateLegacyConfig({

0 commit comments

Comments
 (0)