refactor(test-utils): share direct channel plugin test fixture
This commit is contained in:
@@ -1,32 +1,10 @@
|
||||
import { afterEach, describe, expect, it } from "vitest";
|
||||
import type { ChannelPlugin } from "../channels/plugins/types.js";
|
||||
import { setActivePluginRegistry } from "../plugins/runtime.js";
|
||||
import { makeDirectPlugin } from "../test-utils/channel-plugin-test-fixtures.js";
|
||||
import { createTestRegistry } from "../test-utils/channel-plugins.js";
|
||||
import { formatConfigChannelsStatusLines } from "./channels/status.js";
|
||||
|
||||
function makeDirectPlugin(params: {
|
||||
id: string;
|
||||
label: string;
|
||||
docsPath: string;
|
||||
config: ChannelPlugin["config"];
|
||||
}): ChannelPlugin {
|
||||
return {
|
||||
id: params.id,
|
||||
meta: {
|
||||
id: params.id,
|
||||
label: params.label,
|
||||
selectionLabel: params.label,
|
||||
docsPath: params.docsPath,
|
||||
blurb: "test",
|
||||
},
|
||||
capabilities: { chatTypes: ["direct"] },
|
||||
config: params.config,
|
||||
actions: {
|
||||
listActions: () => ["send"],
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
function makeUnavailableTokenPlugin(): ChannelPlugin {
|
||||
return makeDirectPlugin({
|
||||
id: "token-only",
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import { listChannelPlugins } from "../../channels/plugins/index.js";
|
||||
import type { ChannelPlugin } from "../../channels/plugins/types.js";
|
||||
import { makeDirectPlugin } from "../../test-utils/channel-plugin-test-fixtures.js";
|
||||
import { buildChannelsTable } from "./channels.js";
|
||||
|
||||
vi.mock("../../channels/plugins/index.js", () => ({
|
||||
@@ -116,29 +117,6 @@ function makeUnavailableSlackPlugin(): ChannelPlugin {
|
||||
};
|
||||
}
|
||||
|
||||
function makeDirectPlugin(params: {
|
||||
id: string;
|
||||
label: string;
|
||||
docsPath: string;
|
||||
config: ChannelPlugin["config"];
|
||||
}): ChannelPlugin {
|
||||
return {
|
||||
id: params.id,
|
||||
meta: {
|
||||
id: params.id,
|
||||
label: params.label,
|
||||
selectionLabel: params.label,
|
||||
docsPath: params.docsPath,
|
||||
blurb: "test",
|
||||
},
|
||||
capabilities: { chatTypes: ["direct"] },
|
||||
config: params.config,
|
||||
actions: {
|
||||
listActions: () => ["send"],
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
function makeSourceAwareUnavailablePlugin(): ChannelPlugin {
|
||||
return makeDirectPlugin({
|
||||
id: "slack",
|
||||
|
||||
24
src/test-utils/channel-plugin-test-fixtures.ts
Normal file
24
src/test-utils/channel-plugin-test-fixtures.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import type { ChannelPlugin } from "../channels/plugins/types.js";
|
||||
|
||||
export function makeDirectPlugin(params: {
|
||||
id: string;
|
||||
label: string;
|
||||
docsPath: string;
|
||||
config: ChannelPlugin["config"];
|
||||
}): ChannelPlugin {
|
||||
return {
|
||||
id: params.id,
|
||||
meta: {
|
||||
id: params.id,
|
||||
label: params.label,
|
||||
selectionLabel: params.label,
|
||||
docsPath: params.docsPath,
|
||||
blurb: "test",
|
||||
},
|
||||
capabilities: { chatTypes: ["direct"] },
|
||||
config: params.config,
|
||||
actions: {
|
||||
listActions: () => ["send"],
|
||||
},
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user