mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-03 06:10:22 +00:00
Merged via squash.
Prepared head SHA: 9b29023c68
Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com>
Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com>
Reviewed-by: @gumadeiras
59 lines
1.9 KiB
TypeScript
59 lines
1.9 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import type { ChannelSetupPlugin } from "../../channels/plugins/setup-wizard-types.js";
|
|
import type { ChannelSetupWizard } from "../../channels/plugins/setup-wizard.js";
|
|
import type { OpenClawConfig } from "../../config/config.js";
|
|
import { createChannelTestPluginBase } from "../../test-utils/channel-plugins.js";
|
|
import { resolveChannelSetupWizardAdapterForPlugin } from "./registry.js";
|
|
|
|
function createSetupPlugin(params: {
|
|
setupWizard: ChannelSetupPlugin["setupWizard"];
|
|
}): ChannelSetupPlugin {
|
|
return {
|
|
...createChannelTestPluginBase({
|
|
id: "demo",
|
|
label: "Demo",
|
|
}),
|
|
setup: {
|
|
applyAccountConfig: ({ cfg }: { cfg: OpenClawConfig }) => cfg,
|
|
},
|
|
setupWizard: params.setupWizard,
|
|
};
|
|
}
|
|
|
|
describe("resolveChannelSetupWizardAdapterForPlugin", () => {
|
|
it("builds and caches adapters from the plugin setupWizard surface", () => {
|
|
const setupWizard: ChannelSetupWizard = {
|
|
channel: "demo",
|
|
status: {
|
|
configuredLabel: "Configured",
|
|
unconfiguredLabel: "Not configured",
|
|
resolveConfigured: () => false,
|
|
},
|
|
credentials: [],
|
|
};
|
|
const plugin = createSetupPlugin({ setupWizard });
|
|
|
|
const adapter = resolveChannelSetupWizardAdapterForPlugin(plugin);
|
|
|
|
expect(adapter?.channel).toBe("demo");
|
|
expect(typeof adapter?.getStatus).toBe("function");
|
|
expect(typeof adapter?.configure).toBe("function");
|
|
expect(resolveChannelSetupWizardAdapterForPlugin(plugin)).toBe(adapter);
|
|
});
|
|
|
|
it("passes through adapter-shaped setupWizard surfaces", () => {
|
|
const setupWizard = {
|
|
channel: "demo",
|
|
getStatus: async () => ({
|
|
channel: "demo",
|
|
configured: false,
|
|
statusLines: [],
|
|
}),
|
|
configure: async ({ cfg }: { cfg: OpenClawConfig }) => ({ cfg }),
|
|
};
|
|
const plugin = createSetupPlugin({ setupWizard });
|
|
|
|
expect(resolveChannelSetupWizardAdapterForPlugin(plugin)).toBe(setupWizard);
|
|
});
|
|
});
|