fix: resolve current ci regressions

This commit is contained in:
Peter Steinberger 2026-03-14 00:51:01 +00:00
parent 17eaa59a7a
commit e794417623
10 changed files with 30 additions and 25 deletions

View File

@ -372,7 +372,7 @@ function wrappedCompactionArgs(overrides: Record<string, unknown> = {}) {
sessionFile: TEST_SESSION_FILE,
workspaceDir: TEST_WORKSPACE_DIR,
customInstructions: TEST_CUSTOM_INSTRUCTIONS,
enqueue: (task: () => unknown) => task(),
enqueue: async <T>(task: () => Promise<T> | T) => await task(),
...overrides,
};
}

View File

@ -431,6 +431,7 @@ async function probeTarget(params: {
error: "No model available for probe",
};
}
const model = target.model;
const sessionId = `probe-${target.provider}-${crypto.randomUUID()}`;
const sessionFile = resolveSessionTranscriptPath(sessionId, agentId);
@ -439,7 +440,7 @@ async function probeTarget(params: {
const start = Date.now();
const buildResult = (status: AuthProbeResult["status"], error?: string): AuthProbeResult => ({
provider: target.provider,
model: `${target.model.provider}/${target.model.model}`,
model: `${model.provider}/${model.model}`,
profileId: target.profileId,
label: target.label,
source: target.source,

View File

@ -22,7 +22,7 @@ function createGatewayAudit({
expectedGatewayToken?: string;
path?: string;
serviceToken?: string;
environmentValueSources?: Record<string, string>;
environmentValueSources?: Record<string, "file" | "inline">;
} = {}) {
return auditGatewayServiceConfig({
env: { HOME: "/tmp" },

View File

@ -179,6 +179,7 @@ function makeFallbackSummaryPlugin(params: {
id: "fallback-plugin",
meta: {
id: "fallback-plugin",
label: "Fallback",
selectionLabel: "Fallback",
docsPath: "/channels/fallback",
blurb: "test",
@ -289,7 +290,7 @@ describe("buildChannelSummary", () => {
]);
});
it("falls back to plugin id and default account id when no label or accounts exist", async () => {
it("uses the channel label and default account id when no accounts exist", async () => {
vi.mocked(listChannelPlugins).mockReturnValue([
makeFallbackSummaryPlugin({
enabled: true,
@ -304,7 +305,7 @@ describe("buildChannelSummary", () => {
includeAllowFrom: false,
});
expect(lines).toEqual(["fallback-plugin: configured", " - fallback-account"]);
expect(lines).toEqual(["Fallback: configured", " - fallback-account"]);
});
it("shows not-configured status when enabled accounts exist without configured ones", async () => {
@ -321,6 +322,6 @@ describe("buildChannelSummary", () => {
includeAllowFrom: false,
});
expect(lines).toEqual(["fallback-plugin: not configured"]);
expect(lines).toEqual(["Fallback: not configured"]);
});
});

View File

@ -4,12 +4,14 @@ import { startHeartbeatRunner } from "./heartbeat-runner.js";
import { requestHeartbeatNow, resetHeartbeatWakeStateForTests } from "./heartbeat-wake.js";
describe("startHeartbeatRunner", () => {
type RunOnce = Parameters<typeof startHeartbeatRunner>[0]["runOnce"];
function useFakeHeartbeatTime() {
vi.useFakeTimers();
vi.setSystemTime(new Date(0));
}
function startDefaultRunner(runOnce: Parameters<typeof startHeartbeatRunner>[0]["runOnce"]) {
function startDefaultRunner(runOnce: RunOnce) {
return startHeartbeatRunner({
cfg: heartbeatConfig(),
runOnce,
@ -40,7 +42,7 @@ describe("startHeartbeatRunner", () => {
async function expectWakeDispatch(params: {
cfg: OpenClawConfig;
runSpy: ReturnType<typeof vi.fn>;
runSpy: RunOnce;
wake: { reason: string; agentId?: string; sessionKey?: string; coalesceMs: number };
expectedCall: Record<string, unknown>;
}) {

View File

@ -3,6 +3,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { signalOutbound } from "../../channels/plugins/outbound/signal.js";
import { telegramOutbound } from "../../channels/plugins/outbound/telegram.js";
import { whatsappOutbound } from "../../channels/plugins/outbound/whatsapp.js";
import type { ChannelOutboundAdapter } from "../../channels/plugins/types.adapters.js";
import type { OpenClawConfig } from "../../config/config.js";
import { STATE_DIR } from "../../config/paths.js";
import { setActivePluginRegistry } from "../../plugins/runtime.js";
@ -83,7 +84,7 @@ type DeliverOutboundArgs = Parameters<typeof deliverOutboundPayloads>[0];
type DeliverOutboundPayload = DeliverOutboundArgs["payloads"][number];
type DeliverSession = DeliverOutboundArgs["session"];
function setMatrixTextOnlyPlugin(sendText: ReturnType<typeof vi.fn>) {
function setMatrixTextOnlyPlugin(sendText: NonNullable<ChannelOutboundAdapter["sendText"]>) {
setActivePluginRegistry(
createTestRegistry([
{

View File

@ -1,5 +1,6 @@
import type { MessageEvent, PostbackEvent } from "@line/bot-sdk";
import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
import type { LineAccountConfig } from "./types.js";
// Avoid pulling in globals/pairing/media dependencies; this suite only asserts
// allowlist/groupPolicy gating and message-context wiring.
@ -79,7 +80,7 @@ function createReplayMessageEvent(params: {
}) {
return {
type: "message",
message: { id: params.messageId, type: "text", text: "hello" },
message: { id: params.messageId, type: "text", text: "hello", quoteToken: "quote-token" },
replyToken: "reply-token",
timestamp: Date.now(),
source: { type: "group", groupId: params.groupId, userId: params.userId },
@ -111,8 +112,8 @@ function createTestMessageEvent(params: {
function createLineWebhookTestContext(params: {
processMessage: LineWebhookContext["processMessage"];
groupPolicy?: "open";
dmPolicy?: "open";
groupPolicy?: LineAccountConfig["groupPolicy"];
dmPolicy?: LineAccountConfig["dmPolicy"];
requireMention?: boolean;
groupHistories?: Map<string, import("../auto-reply/reply/history.js").HistoryEntry[]>;
replayCache?: ReturnType<typeof createLineWebhookReplayCache>;
@ -157,7 +158,7 @@ function createOpenGroupReplayContext(
}
async function expectGroupMessageBlocked(params: {
processMessage: ReturnType<typeof vi.fn>;
processMessage: LineWebhookContext["processMessage"];
event: MessageEvent;
context: Parameters<typeof handleLineWebhookEvents>[1];
}) {
@ -182,7 +183,7 @@ async function expectRequireMentionGroupMessageProcessed(event: MessageEvent) {
async function startInflightReplayDuplicate(params: {
event: MessageEvent;
processMessage: ReturnType<typeof vi.fn>;
processMessage: LineWebhookContext["processMessage"];
}) {
const context = createOpenGroupReplayContext(
params.processMessage,
@ -248,7 +249,7 @@ describe("handleLineWebhookEvents", () => {
await expectGroupMessageBlocked({
processMessage,
event: createTestMessageEvent({
message: { id: "m2", type: "text", text: "hi" },
message: { id: "m2", type: "text", text: "hi", quoteToken: "quote-token" },
source: { type: "group", groupId: "group-1", userId: "user-2" },
webhookEventId: "evt-2",
}),
@ -373,7 +374,7 @@ describe("handleLineWebhookEvents", () => {
await expectGroupMessageBlocked({
processMessage,
event: createTestMessageEvent({
message: { id: "m5b", type: "text", text: "hi" },
message: { id: "m5b", type: "text", text: "hi", quoteToken: "quote-token" },
source: { type: "group", groupId: "group-1", userId: "user-5" },
webhookEventId: "evt-5b",
}),

View File

@ -139,7 +139,7 @@ describe("fetchRemoteMedia telegram network policy", () => {
{ address: "149.154.167.220", family: 4 },
{ address: "2001:67c:4e8:f004::9", family: 6 },
]) as unknown as LookupFn;
undiciFetch
undiciMocks.fetch
.mockRejectedValueOnce(createTelegramFetchFailedError("EHOSTUNREACH"))
.mockResolvedValueOnce(
new Response(new Uint8Array([0xff, 0xd8, 0xff, 0x00]), {
@ -169,7 +169,7 @@ describe("fetchRemoteMedia telegram network policy", () => {
},
});
const firstInit = undiciFetch.mock.calls[0]?.[1] as
const firstInit = undiciMocks.fetch.mock.calls[0]?.[1] as
| (RequestInit & {
dispatcher?: {
options?: {
@ -178,7 +178,7 @@ describe("fetchRemoteMedia telegram network policy", () => {
};
})
| undefined;
const secondInit = undiciFetch.mock.calls[1]?.[1] as
const secondInit = undiciMocks.fetch.mock.calls[1]?.[1] as
| (RequestInit & {
dispatcher?: {
options?: {
@ -188,7 +188,7 @@ describe("fetchRemoteMedia telegram network policy", () => {
})
| undefined;
expect(undiciFetch).toHaveBeenCalledTimes(2);
expect(undiciMocks.fetch).toHaveBeenCalledTimes(2);
expect(firstInit?.dispatcher?.options?.connect).toEqual(
expect.objectContaining({
autoSelectFamily: true,
@ -212,7 +212,7 @@ describe("fetchRemoteMedia telegram network policy", () => {
]) as unknown as LookupFn;
const primaryError = createTelegramFetchFailedError("EHOSTUNREACH");
const fallbackError = createTelegramFetchFailedError("ETIMEDOUT");
undiciFetch.mockRejectedValueOnce(primaryError).mockRejectedValueOnce(fallbackError);
undiciMocks.fetch.mockRejectedValueOnce(primaryError).mockRejectedValueOnce(fallbackError);
const telegramTransport = resolveTelegramTransport(undefined, {
network: {

View File

@ -1,4 +1,3 @@
import { randomUUID } from "node:crypto";
import fs from "node:fs";
import os from "node:os";
import path from "node:path";
@ -16,8 +15,8 @@ export function mkdirSafeDir(dir: string) {
}
export function makeTrackedTempDir(prefix: string, trackedDirs: string[]) {
const dir = path.join(os.tmpdir(), `${prefix}-${randomUUID()}`);
mkdirSafeDir(dir);
const dir = fs.mkdtempSync(path.join(os.tmpdir(), String(prefix) + "-"));
chmodSafeDir(dir);
trackedDirs.push(dir);
return dir;
}

View File

@ -56,7 +56,7 @@ function expectDmMessagePreviewViaSendMessage(
async function createDmDraftTransportStream(params: {
api?: ReturnType<typeof createMockDraftApi>;
previewTransport?: "draft" | "message";
warn?: ReturnType<typeof vi.fn>;
warn?: (message: string) => void;
}) {
const api = params.api ?? createMockDraftApi();
const stream = createDraftStream(api, {