Move all Slack channel implementation files from src/slack/ to extensions/slack/src/ and replace originals with shim re-exports. This follows the extension migration pattern for channel plugins. - Copy all .ts files to extensions/slack/src/ (preserving directory structure: monitor/, http/, monitor/events/, monitor/message-handler/) - Transform import paths: external src/ imports use relative paths back to src/, internal slack imports stay relative within extension - Replace all src/slack/ files with shim re-exports pointing to the extension copies - Update tsconfig.plugin-sdk.dts.json rootDir from "src" to "." so the DTS build can follow shim chains into extensions/ - Update write-plugin-sdk-entry-dts.ts re-export path accordingly - Preserve extensions/slack/index.ts, package.json, openclaw.plugin.json, src/channel.ts, src/runtime.ts, src/channel.test.ts (untouched)
52 lines
1.1 KiB
TypeScript
52 lines
1.1 KiB
TypeScript
import type { WebClient } from "@slack/web-api";
|
|
import { vi } from "vitest";
|
|
|
|
export type SlackEditTestClient = WebClient & {
|
|
chat: {
|
|
update: ReturnType<typeof vi.fn>;
|
|
};
|
|
};
|
|
|
|
export type SlackSendTestClient = WebClient & {
|
|
conversations: {
|
|
open: ReturnType<typeof vi.fn>;
|
|
};
|
|
chat: {
|
|
postMessage: ReturnType<typeof vi.fn>;
|
|
};
|
|
};
|
|
|
|
export function installSlackBlockTestMocks() {
|
|
vi.mock("../../../src/config/config.js", () => ({
|
|
loadConfig: () => ({}),
|
|
}));
|
|
|
|
vi.mock("./accounts.js", () => ({
|
|
resolveSlackAccount: () => ({
|
|
accountId: "default",
|
|
botToken: "xoxb-test",
|
|
botTokenSource: "config",
|
|
config: {},
|
|
}),
|
|
}));
|
|
}
|
|
|
|
export function createSlackEditTestClient(): SlackEditTestClient {
|
|
return {
|
|
chat: {
|
|
update: vi.fn(async () => ({ ok: true })),
|
|
},
|
|
} as unknown as SlackEditTestClient;
|
|
}
|
|
|
|
export function createSlackSendTestClient(): SlackSendTestClient {
|
|
return {
|
|
conversations: {
|
|
open: vi.fn(async () => ({ channel: { id: "D123" } })),
|
|
},
|
|
chat: {
|
|
postMessage: vi.fn(async () => ({ ts: "171234.567" })),
|
|
},
|
|
} as unknown as SlackSendTestClient;
|
|
}
|