mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-13 06:20:35 +00:00
test: migrate suites to e2e coverage layout
This commit is contained in:
67
src/commands/doctor-config-flow.e2e.test.ts
Normal file
67
src/commands/doctor-config-flow.e2e.test.ts
Normal file
@@ -0,0 +1,67 @@
|
||||
import fs from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { withTempHome } from "../../test/helpers/temp-home.js";
|
||||
import { loadAndMaybeMigrateDoctorConfig } from "./doctor-config-flow.js";
|
||||
|
||||
describe("doctor config flow", () => {
|
||||
it("preserves invalid config for doctor repairs", async () => {
|
||||
await withTempHome(async (home) => {
|
||||
const configDir = path.join(home, ".openclaw");
|
||||
await fs.mkdir(configDir, { recursive: true });
|
||||
await fs.writeFile(
|
||||
path.join(configDir, "openclaw.json"),
|
||||
JSON.stringify(
|
||||
{
|
||||
gateway: { auth: { mode: "token", token: 123 } },
|
||||
agents: { list: [{ id: "pi" }] },
|
||||
},
|
||||
null,
|
||||
2,
|
||||
),
|
||||
"utf-8",
|
||||
);
|
||||
|
||||
const result = await loadAndMaybeMigrateDoctorConfig({
|
||||
options: { nonInteractive: true },
|
||||
confirm: async () => false,
|
||||
});
|
||||
|
||||
expect((result.cfg as Record<string, unknown>).gateway).toEqual({
|
||||
auth: { mode: "token", token: 123 },
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it("drops unknown keys on repair", async () => {
|
||||
await withTempHome(async (home) => {
|
||||
const configDir = path.join(home, ".openclaw");
|
||||
await fs.mkdir(configDir, { recursive: true });
|
||||
await fs.writeFile(
|
||||
path.join(configDir, "openclaw.json"),
|
||||
JSON.stringify(
|
||||
{
|
||||
bridge: { bind: "auto" },
|
||||
gateway: { auth: { mode: "token", token: "ok", extra: true } },
|
||||
agents: { list: [{ id: "pi" }] },
|
||||
},
|
||||
null,
|
||||
2,
|
||||
),
|
||||
"utf-8",
|
||||
);
|
||||
|
||||
const result = await loadAndMaybeMigrateDoctorConfig({
|
||||
options: { nonInteractive: true, repair: true },
|
||||
confirm: async () => false,
|
||||
});
|
||||
|
||||
const cfg = result.cfg as Record<string, unknown>;
|
||||
expect(cfg.bridge).toBeUndefined();
|
||||
expect((cfg.gateway as Record<string, unknown>)?.auth).toEqual({
|
||||
mode: "token",
|
||||
token: "ok",
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user