test(gateway): fix config.patch baseHash fixtures

This commit is contained in:
Peter Steinberger
2026-01-15 04:49:33 +00:00
parent eb3e865f15
commit 0a7f5bf6a5
2 changed files with 12 additions and 2 deletions

View File

@@ -1,6 +1,8 @@
import { describe, expect, it } from "vitest";
import { connectOk, onceMessage, startServerWithClient } from "./test-helpers.js";
import { connectOk, installGatewayTestHooks, onceMessage, startServerWithClient } from "./test-helpers.js";
installGatewayTestHooks();
describe("gateway config.patch", () => {
it("merges patches without clobbering unrelated config", async () => {

View File

@@ -1,3 +1,4 @@
import crypto from "node:crypto";
import fs from "node:fs/promises";
import os from "node:os";
import path from "node:path";
@@ -157,16 +158,20 @@ vi.mock("../config/sessions.js", async () => {
vi.mock("../config/config.js", async () => {
const actual = await vi.importActual<typeof import("../config/config.js")>("../config/config.js");
const resolveConfigPath = () => path.join(os.homedir(), ".clawdbot", "clawdbot.json");
const hashConfigRaw = (raw: string | null) =>
crypto.createHash("sha256").update(raw ?? "").digest("hex");
const readConfigFileSnapshot = async () => {
if (testState.legacyIssues.length > 0) {
const raw = JSON.stringify(testState.legacyParsed ?? {});
return {
path: resolveConfigPath(),
exists: true,
raw: JSON.stringify(testState.legacyParsed ?? {}),
raw,
parsed: testState.legacyParsed ?? {},
valid: false,
config: {},
hash: hashConfigRaw(raw),
issues: testState.legacyIssues.map((issue) => ({
path: issue.path,
message: issue.message,
@@ -185,6 +190,7 @@ vi.mock("../config/config.js", async () => {
parsed: {},
valid: true,
config: {},
hash: hashConfigRaw(null),
issues: [],
legacyIssues: [],
};
@@ -199,6 +205,7 @@ vi.mock("../config/config.js", async () => {
parsed,
valid: true,
config: parsed,
hash: hashConfigRaw(raw),
issues: [],
legacyIssues: [],
};
@@ -210,6 +217,7 @@ vi.mock("../config/config.js", async () => {
parsed: {},
valid: false,
config: {},
hash: hashConfigRaw(null),
issues: [{ path: "", message: `read failed: ${String(err)}` }],
legacyIssues: [],
};