* 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
60 lines
1.6 KiB
TypeScript
60 lines
1.6 KiB
TypeScript
import { ChannelType, type Client } from "@buape/carbon";
|
|
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
import {
|
|
__resetDiscordThreadStarterCacheForTest,
|
|
resolveDiscordThreadStarter,
|
|
} from "./threading.js";
|
|
|
|
async function resolveStarter(
|
|
message: Partial<Awaited<ReturnType<Client["rest"]["get"]>>>,
|
|
resolveTimestampMs: () => number | undefined,
|
|
) {
|
|
const get = vi.fn().mockResolvedValue(message);
|
|
const client = { rest: { get } } as unknown as Client;
|
|
|
|
return resolveDiscordThreadStarter({
|
|
channel: { id: "thread-1" },
|
|
client,
|
|
parentId: "parent-1",
|
|
parentType: ChannelType.GuildText,
|
|
resolveTimestampMs,
|
|
});
|
|
}
|
|
|
|
describe("resolveDiscordThreadStarter", () => {
|
|
beforeEach(() => {
|
|
__resetDiscordThreadStarterCacheForTest();
|
|
});
|
|
|
|
it("falls back to joined embed title and description when content is empty", async () => {
|
|
const result = await resolveStarter(
|
|
{
|
|
content: " ",
|
|
embeds: [{ title: "Alert", description: "Details" }],
|
|
author: { username: "Alice", discriminator: "0" },
|
|
timestamp: "2026-02-24T12:00:00.000Z",
|
|
},
|
|
() => 123,
|
|
);
|
|
|
|
expect(result).toEqual({
|
|
text: "Alert\nDetails",
|
|
author: "Alice",
|
|
timestamp: 123,
|
|
});
|
|
});
|
|
|
|
it("prefers starter content over embed fallback text", async () => {
|
|
const result = await resolveStarter(
|
|
{
|
|
content: "starter content",
|
|
embeds: [{ title: "Alert", description: "Details" }],
|
|
author: { username: "Alice", discriminator: "0" },
|
|
},
|
|
() => undefined,
|
|
);
|
|
|
|
expect(result?.text).toBe("starter content");
|
|
});
|
|
});
|