mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-07 22:51:23 +00:00
perf(test): consolidate config misc suites
This commit is contained in:
89
src/config/config-misc.test.ts
Normal file
89
src/config/config-misc.test.ts
Normal file
@@ -0,0 +1,89 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { validateConfigObject } from "./config.js";
|
||||
import { OpenClawSchema } from "./zod-schema.js";
|
||||
|
||||
describe("$schema key in config (#14998)", () => {
|
||||
it("accepts config with $schema string", () => {
|
||||
const result = OpenClawSchema.safeParse({
|
||||
$schema: "https://openclaw.ai/config.json",
|
||||
});
|
||||
expect(result.success).toBe(true);
|
||||
if (result.success) {
|
||||
expect(result.data.$schema).toBe("https://openclaw.ai/config.json");
|
||||
}
|
||||
});
|
||||
|
||||
it("accepts config without $schema", () => {
|
||||
const result = OpenClawSchema.safeParse({});
|
||||
expect(result.success).toBe(true);
|
||||
});
|
||||
|
||||
it("rejects non-string $schema", () => {
|
||||
const result = OpenClawSchema.safeParse({ $schema: 123 });
|
||||
expect(result.success).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("ui.seamColor", () => {
|
||||
it("accepts hex colors", () => {
|
||||
const res = validateConfigObject({ ui: { seamColor: "#FF4500" } });
|
||||
expect(res.ok).toBe(true);
|
||||
});
|
||||
|
||||
it("rejects non-hex colors", () => {
|
||||
const res = validateConfigObject({ ui: { seamColor: "lobster" } });
|
||||
expect(res.ok).toBe(false);
|
||||
});
|
||||
|
||||
it("rejects invalid hex length", () => {
|
||||
const res = validateConfigObject({ ui: { seamColor: "#FF4500FF" } });
|
||||
expect(res.ok).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("web search provider config", () => {
|
||||
it("accepts perplexity provider and config", () => {
|
||||
const res = validateConfigObject({
|
||||
tools: {
|
||||
web: {
|
||||
search: {
|
||||
enabled: true,
|
||||
provider: "perplexity",
|
||||
perplexity: {
|
||||
apiKey: "test-key",
|
||||
baseUrl: "https://api.perplexity.ai",
|
||||
model: "perplexity/sonar-pro",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
expect(res.ok).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe("talk.voiceAliases", () => {
|
||||
it("accepts a string map of voice aliases", () => {
|
||||
const res = validateConfigObject({
|
||||
talk: {
|
||||
voiceAliases: {
|
||||
Clawd: "EXAVITQu4vr4xnSDxMaL",
|
||||
Roger: "CwhRBWXzGAHq8TQ4Fs17",
|
||||
},
|
||||
},
|
||||
});
|
||||
expect(res.ok).toBe(true);
|
||||
});
|
||||
|
||||
it("rejects non-string voice alias values", () => {
|
||||
const res = validateConfigObject({
|
||||
talk: {
|
||||
voiceAliases: {
|
||||
Clawd: 123,
|
||||
},
|
||||
},
|
||||
});
|
||||
expect(res.ok).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -1,24 +0,0 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { OpenClawSchema } from "./zod-schema.js";
|
||||
|
||||
describe("$schema key in config (#14998)", () => {
|
||||
it("accepts config with $schema string", () => {
|
||||
const result = OpenClawSchema.safeParse({
|
||||
$schema: "https://openclaw.ai/config.json",
|
||||
});
|
||||
expect(result.success).toBe(true);
|
||||
if (result.success) {
|
||||
expect(result.data.$schema).toBe("https://openclaw.ai/config.json");
|
||||
}
|
||||
});
|
||||
|
||||
it("accepts config without $schema", () => {
|
||||
const result = OpenClawSchema.safeParse({});
|
||||
expect(result.success).toBe(true);
|
||||
});
|
||||
|
||||
it("rejects non-string $schema", () => {
|
||||
const result = OpenClawSchema.safeParse({ $schema: 123 });
|
||||
expect(result.success).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -1,27 +0,0 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { validateConfigObject } from "./config.js";
|
||||
|
||||
describe("talk.voiceAliases", () => {
|
||||
it("accepts a string map of voice aliases", () => {
|
||||
const res = validateConfigObject({
|
||||
talk: {
|
||||
voiceAliases: {
|
||||
Clawd: "EXAVITQu4vr4xnSDxMaL",
|
||||
Roger: "CwhRBWXzGAHq8TQ4Fs17",
|
||||
},
|
||||
},
|
||||
});
|
||||
expect(res.ok).toBe(true);
|
||||
});
|
||||
|
||||
it("rejects non-string voice alias values", () => {
|
||||
const res = validateConfigObject({
|
||||
talk: {
|
||||
voiceAliases: {
|
||||
Clawd: 123,
|
||||
},
|
||||
},
|
||||
});
|
||||
expect(res.ok).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -1,24 +0,0 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { validateConfigObject } from "./config.js";
|
||||
|
||||
describe("web search provider config", () => {
|
||||
it("accepts perplexity provider and config", () => {
|
||||
const res = validateConfigObject({
|
||||
tools: {
|
||||
web: {
|
||||
search: {
|
||||
enabled: true,
|
||||
provider: "perplexity",
|
||||
perplexity: {
|
||||
apiKey: "test-key",
|
||||
baseUrl: "https://api.perplexity.ai",
|
||||
model: "perplexity/sonar-pro",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
expect(res.ok).toBe(true);
|
||||
});
|
||||
});
|
||||
@@ -1,19 +0,0 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { validateConfigObject } from "./config.js";
|
||||
|
||||
describe("ui.seamColor", () => {
|
||||
it("accepts hex colors", () => {
|
||||
const res = validateConfigObject({ ui: { seamColor: "#FF4500" } });
|
||||
expect(res.ok).toBe(true);
|
||||
});
|
||||
|
||||
it("rejects non-hex colors", () => {
|
||||
const res = validateConfigObject({ ui: { seamColor: "lobster" } });
|
||||
expect(res.ok).toBe(false);
|
||||
});
|
||||
|
||||
it("rejects invalid hex length", () => {
|
||||
const res = validateConfigObject({ ui: { seamColor: "#FF4500FF" } });
|
||||
expect(res.ok).toBe(false);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user