chore: format sources and update protocol outputs
This commit is contained in:
@@ -227,7 +227,11 @@ export const configHandlers: GatewayRequestHandlers = {
|
||||
respond(false, undefined, errorShape(ErrorCodes.INVALID_REQUEST, parsedRes.error));
|
||||
return;
|
||||
}
|
||||
if (!parsedRes.parsed || typeof parsedRes.parsed !== "object" || Array.isArray(parsedRes.parsed)) {
|
||||
if (
|
||||
!parsedRes.parsed ||
|
||||
typeof parsedRes.parsed !== "object" ||
|
||||
Array.isArray(parsedRes.parsed)
|
||||
) {
|
||||
respond(
|
||||
false,
|
||||
undefined,
|
||||
|
||||
@@ -28,7 +28,10 @@ describe("gateway config.patch", () => {
|
||||
},
|
||||
}),
|
||||
);
|
||||
const setRes = await onceMessage<{ ok: boolean }>(ws, (o) => o.type === "res" && o.id === setId);
|
||||
const setRes = await onceMessage<{ ok: boolean }>(
|
||||
ws,
|
||||
(o) => o.type === "res" && o.id === setId,
|
||||
);
|
||||
expect(setRes.ok).toBe(true);
|
||||
|
||||
const getId = "req-get";
|
||||
@@ -85,7 +88,9 @@ describe("gateway config.patch", () => {
|
||||
);
|
||||
const get2Res = await onceMessage<{
|
||||
ok: boolean;
|
||||
payload?: { config?: { gateway?: { mode?: string }; channels?: { telegram?: { botToken?: string } } } };
|
||||
payload?: {
|
||||
config?: { gateway?: { mode?: string }; channels?: { telegram?: { botToken?: string } } };
|
||||
};
|
||||
}>(ws, (o) => o.type === "res" && o.id === get2Id);
|
||||
expect(get2Res.ok).toBe(true);
|
||||
expect(get2Res.payload?.config?.gateway?.mode).toBe("local");
|
||||
@@ -112,7 +117,10 @@ describe("gateway config.patch", () => {
|
||||
},
|
||||
}),
|
||||
);
|
||||
const setRes = await onceMessage<{ ok: boolean }>(ws, (o) => o.type === "res" && o.id === setId);
|
||||
const setRes = await onceMessage<{ ok: boolean }>(
|
||||
ws,
|
||||
(o) => o.type === "res" && o.id === setId,
|
||||
);
|
||||
expect(setRes.ok).toBe(true);
|
||||
|
||||
const patchId = "req-patch-2";
|
||||
@@ -154,7 +162,10 @@ describe("gateway config.patch", () => {
|
||||
},
|
||||
}),
|
||||
);
|
||||
const setRes = await onceMessage<{ ok: boolean }>(ws, (o) => o.type === "res" && o.id === setId);
|
||||
const setRes = await onceMessage<{ ok: boolean }>(
|
||||
ws,
|
||||
(o) => o.type === "res" && o.id === setId,
|
||||
);
|
||||
expect(setRes.ok).toBe(true);
|
||||
|
||||
const set2Id = "req-set-4";
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import type { PluginRegistry } from "../../../plugins/registry.js";
|
||||
|
||||
export const createTestRegistry = (
|
||||
overrides: Partial<PluginRegistry> = {},
|
||||
): PluginRegistry => {
|
||||
export const createTestRegistry = (overrides: Partial<PluginRegistry> = {}): PluginRegistry => {
|
||||
const base: PluginRegistry = {
|
||||
plugins: [],
|
||||
tools: [],
|
||||
|
||||
@@ -44,7 +44,9 @@ describe("createGatewayPluginRequestHandler", () => {
|
||||
{ pluginId: "second", handler: second, source: "second" },
|
||||
],
|
||||
}),
|
||||
log: { warn: vi.fn() } as unknown as Parameters<typeof createGatewayPluginRequestHandler>[0]["log"],
|
||||
log: { warn: vi.fn() } as unknown as Parameters<
|
||||
typeof createGatewayPluginRequestHandler
|
||||
>[0]["log"],
|
||||
});
|
||||
|
||||
const { res } = makeResponse();
|
||||
@@ -78,10 +80,7 @@ describe("createGatewayPluginRequestHandler", () => {
|
||||
expect(handled).toBe(true);
|
||||
expect(log.warn).toHaveBeenCalledWith(expect.stringContaining("boom"));
|
||||
expect(res.statusCode).toBe(500);
|
||||
expect(setHeader).toHaveBeenCalledWith(
|
||||
"Content-Type",
|
||||
"text/plain; charset=utf-8",
|
||||
);
|
||||
expect(setHeader).toHaveBeenCalledWith("Content-Type", "text/plain; charset=utf-8");
|
||||
expect(end).toHaveBeenCalledWith("Internal Server Error");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -170,7 +170,10 @@ vi.mock("../config/config.js", async () => {
|
||||
const actual = await vi.importActual<typeof import("../config/config.js")>("../config/config.js");
|
||||
const resolveConfigPath = () => path.join(testConfigRoot.value, "clawdbot.json");
|
||||
const hashConfigRaw = (raw: string | null) =>
|
||||
crypto.createHash("sha256").update(raw ?? "").digest("hex");
|
||||
crypto
|
||||
.createHash("sha256")
|
||||
.update(raw ?? "")
|
||||
.digest("hex");
|
||||
|
||||
const readConfigFileSnapshot = async () => {
|
||||
if (testState.legacyIssues.length > 0) {
|
||||
|
||||
Reference in New Issue
Block a user