mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 05:21:23 +00:00
perf(test): speed up hot test files
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user