mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 11:07:41 +00:00
chore(tsgo/format): fix CI errors
This commit is contained in:
@@ -24,6 +24,7 @@ import {
|
||||
resolveExecApprovalsSocketPath,
|
||||
resolveSafeBins,
|
||||
type ExecAllowlistEntry,
|
||||
type ExecApprovalsAgent,
|
||||
type ExecApprovalsFile,
|
||||
} from "./exec-approvals.js";
|
||||
import { SAFE_BIN_PROFILE_FIXTURES, SAFE_BIN_PROFILES } from "./exec-safe-bin-policy.js";
|
||||
@@ -204,7 +205,7 @@ describe("exec approvals command resolution", () => {
|
||||
return {
|
||||
command: "./scripts/run.sh --flag",
|
||||
cwd,
|
||||
envPath: undefined as string | undefined,
|
||||
envPath: undefined as NodeJS.ProcessEnv | undefined,
|
||||
expectedPath: script,
|
||||
expectedExecutableName: undefined,
|
||||
};
|
||||
@@ -222,7 +223,7 @@ describe("exec approvals command resolution", () => {
|
||||
return {
|
||||
command: '"./bin/tool" --version',
|
||||
cwd,
|
||||
envPath: undefined as string | undefined,
|
||||
envPath: undefined as NodeJS.ProcessEnv | undefined,
|
||||
expectedPath: script,
|
||||
expectedExecutableName: undefined,
|
||||
};
|
||||
@@ -258,7 +259,7 @@ describe("exec approvals shell parsing", () => {
|
||||
for (const testCase of cases) {
|
||||
const res = analyzeShellCommand({ command: testCase.command });
|
||||
expect(res.ok, testCase.name).toBe(true);
|
||||
if (testCase.expectedSegments) {
|
||||
if ("expectedSegments" in testCase) {
|
||||
expect(
|
||||
res.segments.map((seg) => seg.argv[0]),
|
||||
testCase.name,
|
||||
@@ -1197,7 +1198,7 @@ describe("normalizeExecApprovals handles string allowlist entries (#9790)", () =
|
||||
const patterns = getMainAllowlistPatterns({
|
||||
version: 1,
|
||||
agents: {
|
||||
main: { allowlist: testCase.allowlist } as ExecApprovalsFile["agents"]["main"],
|
||||
main: { allowlist: testCase.allowlist } as ExecApprovalsAgent,
|
||||
},
|
||||
});
|
||||
expect(patterns, testCase.name).toEqual(testCase.expectedPatterns);
|
||||
@@ -1205,7 +1206,7 @@ describe("normalizeExecApprovals handles string allowlist entries (#9790)", () =
|
||||
const entries = normalizeExecApprovals({
|
||||
version: 1,
|
||||
agents: {
|
||||
main: { allowlist: testCase.allowlist } as ExecApprovalsFile["agents"]["main"],
|
||||
main: { allowlist: testCase.allowlist } as ExecApprovalsAgent,
|
||||
},
|
||||
}).agents?.main?.allowlist;
|
||||
expectNoSpreadStringArtifacts(entries ?? []);
|
||||
|
||||
@@ -17,6 +17,7 @@ import { buildAgentPeerSessionKey } from "../routing/session-key.js";
|
||||
import { createOutboundTestPlugin, createTestRegistry } from "../test-utils/channel-plugins.js";
|
||||
import {
|
||||
isHeartbeatEnabledForAgent,
|
||||
type HeartbeatDeps,
|
||||
resolveHeartbeatIntervalMs,
|
||||
resolveHeartbeatPrompt,
|
||||
runHeartbeatOnce,
|
||||
@@ -439,7 +440,10 @@ describe("resolveHeartbeatSenderContext", () => {
|
||||
});
|
||||
|
||||
describe("runHeartbeatOnce", () => {
|
||||
const createHeartbeatDeps = (sendWhatsApp: ReturnType<typeof vi.fn>, nowMs = 0) => ({
|
||||
const createHeartbeatDeps = (
|
||||
sendWhatsApp: NonNullable<HeartbeatDeps["sendWhatsApp"]>,
|
||||
nowMs = 0,
|
||||
): HeartbeatDeps => ({
|
||||
sendWhatsApp,
|
||||
getQueueSize: () => 0,
|
||||
nowMs: () => nowMs,
|
||||
@@ -516,7 +520,7 @@ describe("runHeartbeatOnce", () => {
|
||||
);
|
||||
|
||||
replySpy.mockResolvedValue([{ text: "Let me check..." }, { text: "Final alert" }]);
|
||||
const sendWhatsApp = vi.fn().mockResolvedValue({
|
||||
const sendWhatsApp = vi.fn<NonNullable<HeartbeatDeps["sendWhatsApp"]>>().mockResolvedValue({
|
||||
messageId: "m1",
|
||||
toJid: "jid",
|
||||
});
|
||||
@@ -569,7 +573,7 @@ describe("runHeartbeatOnce", () => {
|
||||
}),
|
||||
);
|
||||
replySpy.mockResolvedValue([{ text: "Final alert" }]);
|
||||
const sendWhatsApp = vi.fn().mockResolvedValue({
|
||||
const sendWhatsApp = vi.fn<NonNullable<HeartbeatDeps["sendWhatsApp"]>>().mockResolvedValue({
|
||||
messageId: "m1",
|
||||
toJid: "jid",
|
||||
});
|
||||
@@ -645,7 +649,7 @@ describe("runHeartbeatOnce", () => {
|
||||
);
|
||||
|
||||
replySpy.mockResolvedValue([{ text: "Final alert" }]);
|
||||
const sendWhatsApp = vi.fn().mockResolvedValue({
|
||||
const sendWhatsApp = vi.fn<NonNullable<HeartbeatDeps["sendWhatsApp"]>>().mockResolvedValue({
|
||||
messageId: "m1",
|
||||
toJid: "jid",
|
||||
});
|
||||
@@ -749,7 +753,9 @@ describe("runHeartbeatOnce", () => {
|
||||
|
||||
replySpy.mockReset();
|
||||
replySpy.mockResolvedValue([{ text: testCase.message }]);
|
||||
const sendWhatsApp = vi.fn().mockResolvedValue({ messageId: "m1", toJid: "jid" });
|
||||
const sendWhatsApp = vi
|
||||
.fn<NonNullable<HeartbeatDeps["sendWhatsApp"]>>()
|
||||
.mockResolvedValue({ messageId: "m1", toJid: "jid" });
|
||||
|
||||
await runHeartbeatOnce({
|
||||
cfg,
|
||||
@@ -811,7 +817,9 @@ describe("runHeartbeatOnce", () => {
|
||||
);
|
||||
|
||||
replySpy.mockResolvedValue([{ text: "Final alert" }]);
|
||||
const sendWhatsApp = vi.fn().mockResolvedValue({ messageId: "m1", toJid: "jid" });
|
||||
const sendWhatsApp = vi
|
||||
.fn<NonNullable<HeartbeatDeps["sendWhatsApp"]>>()
|
||||
.mockResolvedValue({ messageId: "m1", toJid: "jid" });
|
||||
|
||||
await runHeartbeatOnce({
|
||||
cfg,
|
||||
@@ -827,7 +835,12 @@ describe("runHeartbeatOnce", () => {
|
||||
it("handles reasoning payload delivery variants", async () => {
|
||||
const replySpy = vi.spyOn(replyModule, "getReplyFromConfig");
|
||||
try {
|
||||
const cases = [
|
||||
const cases: Array<{
|
||||
name: string;
|
||||
caseDir: string;
|
||||
replies: Array<{ text: string }>;
|
||||
expectedTexts: string[];
|
||||
}> = [
|
||||
{
|
||||
name: "reasoning + final payload",
|
||||
caseDir: "hb-reasoning",
|
||||
@@ -840,7 +853,7 @@ describe("runHeartbeatOnce", () => {
|
||||
replies: [{ text: "Reasoning:\n_Because it helps_" }, { text: "HEARTBEAT_OK" }],
|
||||
expectedTexts: ["Reasoning:\n_Because it helps_"],
|
||||
},
|
||||
] as const;
|
||||
];
|
||||
|
||||
for (const testCase of cases) {
|
||||
const tmpDir = await createCaseDir(testCase.caseDir);
|
||||
@@ -876,7 +889,9 @@ describe("runHeartbeatOnce", () => {
|
||||
|
||||
replySpy.mockReset();
|
||||
replySpy.mockResolvedValue(testCase.replies);
|
||||
const sendWhatsApp = vi.fn().mockResolvedValue({ messageId: "m1", toJid: "jid" });
|
||||
const sendWhatsApp = vi
|
||||
.fn<NonNullable<HeartbeatDeps["sendWhatsApp"]>>()
|
||||
.mockResolvedValue({ messageId: "m1", toJid: "jid" });
|
||||
|
||||
await runHeartbeatOnce({
|
||||
cfg,
|
||||
@@ -934,7 +949,7 @@ describe("runHeartbeatOnce", () => {
|
||||
);
|
||||
|
||||
replySpy.mockResolvedValue({ text: "Hello from heartbeat" });
|
||||
const sendWhatsApp = vi.fn().mockResolvedValue({
|
||||
const sendWhatsApp = vi.fn<NonNullable<HeartbeatDeps["sendWhatsApp"]>>().mockResolvedValue({
|
||||
messageId: "m1",
|
||||
toJid: "jid",
|
||||
});
|
||||
@@ -1020,7 +1035,9 @@ describe("runHeartbeatOnce", () => {
|
||||
|
||||
const replySpy = vi.spyOn(replyModule, "getReplyFromConfig");
|
||||
replySpy.mockResolvedValue({ text: params.replyText ?? "Checked logs and PRs" });
|
||||
const sendWhatsApp = vi.fn().mockResolvedValue({ messageId: "m1", toJid: "jid" });
|
||||
const sendWhatsApp = vi
|
||||
.fn<NonNullable<HeartbeatDeps["sendWhatsApp"]>>()
|
||||
.mockResolvedValue({ messageId: "m1", toJid: "jid" });
|
||||
const res = await runHeartbeatOnce({
|
||||
cfg,
|
||||
reason: params.reason,
|
||||
|
||||
@@ -407,7 +407,7 @@ describe("DirectoryCache", () => {
|
||||
] as const,
|
||||
expected: { a: "value-a2", b: undefined, c: "value-c" },
|
||||
},
|
||||
] as const;
|
||||
];
|
||||
|
||||
for (const testCase of cases) {
|
||||
const cache = new DirectoryCache<string>(60_000, 2);
|
||||
@@ -477,7 +477,7 @@ describe("buildOutboundResultEnvelope", () => {
|
||||
input: { delivery: discordDelivery, flattenDelivery: false },
|
||||
expected: { delivery: discordDelivery },
|
||||
},
|
||||
] as const;
|
||||
];
|
||||
for (const testCase of cases) {
|
||||
expect(buildOutboundResultEnvelope(testCase.input), testCase.name).toEqual(testCase.expected);
|
||||
}
|
||||
@@ -519,7 +519,7 @@ describe("formatOutboundDeliverySummary", () => {
|
||||
},
|
||||
expected: "✅ Sent via Discord. Message ID: d1 (channel chan)",
|
||||
},
|
||||
] as const;
|
||||
];
|
||||
|
||||
for (const testCase of cases) {
|
||||
expect(formatOutboundDeliverySummary(testCase.channel, testCase.result), testCase.name).toBe(
|
||||
@@ -581,7 +581,7 @@ describe("buildOutboundDeliveryJson", () => {
|
||||
timestamp: 123,
|
||||
},
|
||||
},
|
||||
] as const;
|
||||
];
|
||||
|
||||
for (const testCase of cases) {
|
||||
expect(buildOutboundDeliveryJson(testCase.input), testCase.name).toEqual(testCase.expected);
|
||||
@@ -602,7 +602,7 @@ describe("formatGatewaySummary", () => {
|
||||
input: { action: "Poll sent", channel: "discord", messageId: "p1" },
|
||||
expected: "✅ Poll sent via gateway (discord). Message ID: p1",
|
||||
},
|
||||
] as const;
|
||||
];
|
||||
|
||||
for (const testCase of cases) {
|
||||
expect(formatGatewaySummary(testCase.input), testCase.name).toBe(testCase.expected);
|
||||
@@ -844,7 +844,7 @@ describe("normalizeOutboundPayloadsForJson", () => {
|
||||
},
|
||||
],
|
||||
},
|
||||
] as const;
|
||||
];
|
||||
|
||||
for (const testCase of cases) {
|
||||
expect(normalizeOutboundPayloadsForJson(testCase.input)).toEqual(testCase.expected);
|
||||
@@ -879,7 +879,7 @@ describe("formatOutboundPayloadLog", () => {
|
||||
},
|
||||
expected: "MEDIA:https://x.test/a.png",
|
||||
},
|
||||
] as const;
|
||||
];
|
||||
|
||||
for (const testCase of cases) {
|
||||
expect(formatOutboundPayloadLog(testCase.input), testCase.name).toBe(testCase.expected);
|
||||
|
||||
Reference in New Issue
Block a user