mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-19 05:01:15 +00:00
* refactor: move Discord channel implementation to extensions/discord/src/ Move all Discord source files from src/discord/ to extensions/discord/src/, following the extension migration pattern. Source files in src/discord/ are replaced with re-export shims. Channel-plugin files from src/channels/plugins/*/discord* are similarly moved and shimmed. - Copy all .ts source files preserving subdirectory structure (monitor/, voice/) - Move channel-plugin files (actions, normalize, onboarding, outbound, status-issues) - Fix all relative imports to use correct paths from new location - Create re-export shims at original locations for backward compatibility - Delete test files from shim locations (tests live in extension now) - Update tsconfig.plugin-sdk.dts.json rootDir from "src" to "." to accommodate extension files outside src/ - Update write-plugin-sdk-entry-dts.ts to match new declaration output paths * fix: add importOriginal to thread-bindings session-meta mock for extensions test * style: fix formatting in thread-bindings lifecycle test
37 lines
1.2 KiB
TypeScript
37 lines
1.2 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import {
|
|
buildDiscordUnresolvedResults,
|
|
filterDiscordGuilds,
|
|
findDiscordGuildByName,
|
|
resolveDiscordAllowlistToken,
|
|
} from "./resolve-allowlist-common.js";
|
|
|
|
describe("resolve-allowlist-common", () => {
|
|
const guilds = [
|
|
{ id: "1", name: "Main Guild", slug: "main-guild" },
|
|
{ id: "2", name: "Ops Guild", slug: "ops-guild" },
|
|
];
|
|
|
|
it("resolves and filters guilds by id or name", () => {
|
|
expect(findDiscordGuildByName(guilds, "Main Guild")?.id).toBe("1");
|
|
expect(filterDiscordGuilds(guilds, { guildId: "2" })).toEqual([guilds[1]]);
|
|
expect(filterDiscordGuilds(guilds, { guildName: "main-guild" })).toEqual([guilds[0]]);
|
|
});
|
|
|
|
it("builds unresolved result rows in input order", () => {
|
|
const unresolved = buildDiscordUnresolvedResults(["a", "b"], (input) => ({
|
|
input,
|
|
resolved: false,
|
|
}));
|
|
expect(unresolved).toEqual([
|
|
{ input: "a", resolved: false },
|
|
{ input: "b", resolved: false },
|
|
]);
|
|
});
|
|
|
|
it("normalizes allowlist token values", () => {
|
|
expect(resolveDiscordAllowlistToken(" discord-token ")).toBe("discord-token");
|
|
expect(resolveDiscordAllowlistToken("")).toBeUndefined();
|
|
});
|
|
});
|