perf(test): speed up hot test files

This commit is contained in:
Peter Steinberger
2026-02-14 02:55:39 +00:00
parent dd08ca97bb
commit 72e9364bac
3 changed files with 64 additions and 38 deletions

View File

@@ -4,15 +4,60 @@ import path from "node:path";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import type { ChannelPlugin } from "../channels/plugins/types.js";
import type { OpenClawConfig } from "../config/config.js";
import { discordPlugin } from "../../extensions/discord/src/channel.js";
import { slackPlugin } from "../../extensions/slack/src/channel.js";
import { telegramPlugin } from "../../extensions/telegram/src/channel.js";
import { collectPluginsCodeSafetyFindings } from "./audit-extra.js";
import { runSecurityAudit } from "./audit.js";
import * as skillScanner from "./skill-scanner.js";
const isWindows = process.platform === "win32";
function stubChannelPlugin(params: {
id: "discord" | "slack" | "telegram";
label: string;
resolveAccount: (cfg: OpenClawConfig) => unknown;
}): ChannelPlugin {
return {
id: params.id,
meta: {
id: params.id,
label: params.label,
selectionLabel: params.label,
docsPath: "/docs/testing",
blurb: "test stub",
},
capabilities: {
chatTypes: ["dm", "group"],
},
security: {},
config: {
listAccountIds: (cfg) => {
const enabled = Boolean((cfg.channels as Record<string, unknown> | undefined)?.[params.id]);
return enabled ? ["default"] : [];
},
resolveAccount: (cfg) => params.resolveAccount(cfg),
isEnabled: () => true,
isConfigured: () => true,
},
};
}
const discordPlugin = stubChannelPlugin({
id: "discord",
label: "Discord",
resolveAccount: (cfg) => ({ config: cfg.channels?.discord ?? {} }),
});
const slackPlugin = stubChannelPlugin({
id: "slack",
label: "Slack",
resolveAccount: (cfg) => ({ config: cfg.channels?.slack ?? {} }),
});
const telegramPlugin = stubChannelPlugin({
id: "telegram",
label: "Telegram",
resolveAccount: (cfg) => ({ config: cfg.channels?.telegram ?? {} }),
});
function successfulProbeResult(url: string) {
return {
ok: true,